JGCodeManage.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. using Core.Mes.Client.Comm.Server;
  2. using Core.Mes.Client.Comm.Tool;
  3. using CoreFS.CA06;
  4. using Infragistics.Win.UltraWinGrid;
  5. using System;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Linq;
  10. using System.Windows.Forms;
  11. namespace Core.StlMes.Client.Qcm
  12. {
  13. public partial class JGCodeManage : FrmBase
  14. {
  15. private FrmJGCodeManage frm;
  16. public JGCodeManage(OpeBase ob, string mscB, string msc_descB, string alpha,
  17. string stdName, string stdCode, string stdType, string steel, string dimaterCp,
  18. string heightCp, string custAlphaNo, string specialDesc, string ordLnPk, string steelCode)
  19. {
  20. InitializeComponent();
  21. //base.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
  22. //base.UpdateStyles();
  23. this.StartPosition = FormStartPosition.CenterScreen;
  24. this.IsLoadUserView = true;
  25. _ob = ob;
  26. msc = mscB;
  27. msc_desc = msc_descB;
  28. _stdName = stdName;
  29. _stdCode = stdCode;
  30. _stdType = stdType;
  31. _alpha = alpha;
  32. _steel = steel;
  33. _dimaterCp = dimaterCp;
  34. _heightCp = heightCp;
  35. _custAlphaNo = custAlphaNo == "" ? "/" : custAlphaNo;
  36. _specialDesc = specialDesc == "" ? "/" : specialDesc;
  37. _ordLnPk = ordLnPk;
  38. _steelCode = steelCode;
  39. frm = new FrmJGCodeManage();
  40. frm.PopupLoad("", _ob);
  41. this.panel1.Controls.Add(frm.UltraPanel1);
  42. this.panel1.Controls.Add(frm.UltraExpandableGroupBox1);
  43. this.panel1.Controls.Add(frm.UltraGrid1);
  44. frm.UltraGrid1.BringToFront();
  45. frm.UltraGrid1.DisplayLayout.Bands[0].Columns["CHK"].Hidden = false;
  46. frm.UltraGrid1.DisplayLayout.Bands[0].Columns["CHK"].CellActivation = Activation.AllowEdit;
  47. frm.UltraGrid1.CellChange += new CellEventHandler(UltraGrid1_CellChange);
  48. SetDefaultCondition();
  49. this.DoubleBuffered = true;
  50. SetStyle(ControlStyles.AllPaintingInWmPaint |
  51. ControlStyles.OptimizedDoubleBuffer, true);
  52. }
  53. private OpeBase _ob;
  54. private string msc;
  55. private string msc_desc;
  56. private string _stdName;
  57. private string _stdCode;
  58. private string _stdType;
  59. private string _alpha;
  60. private string _steel;
  61. private string _steelCode;
  62. private string _dimaterCp;
  63. private string _heightCp;
  64. private string _custAlphaNo;
  65. private string _model;
  66. private string _psc;
  67. private string _specialDesc;
  68. private string _ordLnPk;
  69. //选择的接箍
  70. private List<string> _choiceJgCodes = new List<string>();
  71. private void doQuery()
  72. {
  73. frm.ToolBar_Click(null, "Query");
  74. RefreshMscJG();
  75. }
  76. private void SetDefaultCondition()
  77. {
  78. if (_stdType == "" && _stdName == "") return;
  79. //frm.StdName = _stdName;
  80. frm.UltraCheckEditor3.Checked = true;
  81. //frm.UltraCheckEditor3.Enabled = false;
  82. frm.UltraTextEditor4.Text = _steel;
  83. //frm.UltraTextEditor4.Enabled = false;
  84. //DataTable dt = (DataTable)frm.UltraComboEditor7.DataSource;
  85. //dt.DefaultView.RowFilter = "STD_NAME = '"+ _stdName +"'";
  86. //if (frm.UltraComboEditor7.Items.Count > 0)
  87. //{
  88. // frm.UltraComboEditor7.SelectedIndex = 0;
  89. //}
  90. //frm.UltraComboEditor7.Enabled = false;
  91. DataTable dt2 = (DataTable)frm.UltraComboEditor3.DataSource;
  92. dt2.DefaultView.RowFilter = "STEELNAME = '" + _steel + "'";
  93. if (frm.UltraComboEditor3.Items.Count > 0)
  94. {
  95. frm.UltraComboEditor3.SelectedIndex = 0;
  96. }
  97. //frm.UltraComboEditor3.Enabled = false;
  98. if (_dimaterCp != "")
  99. {
  100. frm.NumDimaterCp.Checked = true;
  101. frm.NumDimaterCp.Value = double.Parse(_dimaterCp);
  102. }
  103. if (_heightCp != "")
  104. {
  105. frm.NumHeightCp.Checked = true;
  106. frm.NumHeightCp.Value = double.Parse(_heightCp);
  107. }
  108. }
  109. private void RefreshMscJG()
  110. {
  111. //_choiceJgCodes.Clear();
  112. //DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGAndMSC.doQuery",
  113. // new object[]{msc, "A"}, _ob);
  114. //IQueryable<UltraGridRow> iqueryable = frm.UltraGrid1.Rows.AsQueryable();
  115. //foreach (DataRow dr in dt.Rows)
  116. //{
  117. // _choiceJgCodes.Add(dr["CODE_JG"].ToString());
  118. // UltraGridRow[] rows = iqueryable.Where("CODE_JG = '" + dr["CODE_JG"].ToString() + "'").ToArray();
  119. // if (rows.Length > 0)
  120. // {
  121. // rows[0].Cells["CHK"].Value = true;
  122. // }
  123. //}
  124. //frm.UltraGrid1.UpdateData();
  125. }
  126. private void JGCodeManage_Load(object sender, EventArgs e)
  127. {
  128. doQuery();
  129. }
  130. //选择JG码,并将JG码的相应信息写到关联表中。
  131. private void ultraButton1_Click(object sender, EventArgs e)
  132. {
  133. try
  134. {
  135. this.ob = this._ob;
  136. frm.UltraGrid1.UpdateData();
  137. IQueryable<UltraGridRow> queryableRows = frm.UltraGrid1.Rows.AsQueryable().Where(
  138. a => a.GetValue("CHK") == "True");
  139. if (queryableRows.Count() == 0)
  140. {
  141. MessageUtil.ShowWarning("请选择一条数据后,再进行操作!");
  142. return;
  143. }
  144. //暂时不对接箍的标准做限制。
  145. //UltraGridRow[] rows = queryableRows.Where(a=> a.GetValue("STD_NAME") != _stdName).ToArray();
  146. //if (rows.Length > 0)
  147. //{
  148. // MessageUtil.ShowWarning("该冶金规范只能关联标准名称为["+ _stdName +"]的接箍!");
  149. // rows[0].Activate();
  150. // return;
  151. //}
  152. //DataRow orderLineRow = GetSlmOrderLineByPk(_ordLnPk);
  153. //if (orderLineRow != null)
  154. //{
  155. // foreach (UltraGridRow row in queryableRows)
  156. // {
  157. // if (row.GetValue("MODEL_CODE") != orderLineRow["MODEL_CODE"].ToString())
  158. // {
  159. // MessageUtil.ShowWarning("只能关联扣型为" + orderLineRow["MODEL_DESC"].ToString() + "的接箍");
  160. // row.Activate();
  161. // return;
  162. // }
  163. // }
  164. //}
  165. foreach (UltraGridRow row in queryableRows)
  166. {
  167. if (row.GetValue("REP_STEELCODE") != "" && !row.GetValue("REP_STEELCODE").Contains(_steelCode))
  168. {
  169. MessageUtil.ShowWarning("只能关联替代钢级包含" + _steel + "的接箍");
  170. row.Activate();
  171. return;
  172. }
  173. if (row.GetValue("REP_STEELCODE") == "" && row.GetValue("STEELCODE_JG") != _steelCode)
  174. {
  175. MessageUtil.ShowWarning("只能关联钢级为" + _steel + "的接箍");
  176. row.Activate();
  177. return;
  178. }
  179. }
  180. ArrayList parm = new ArrayList();
  181. int flag = 0;
  182. foreach (UltraGridRow row in queryableRows)
  183. {
  184. if (IsRepeat(msc, _specialDesc, row.GetValue("CODE_JG")))
  185. {
  186. MessageUtil.ShowWarning(msc + "下已存在重复的接箍数据!");
  187. row.Activate();
  188. return;
  189. }
  190. ArrayList list = new ArrayList();
  191. flag += 1;
  192. list.Add(msc);
  193. list.Add(msc_desc);
  194. list.Add(row.GetValue("CODE_JG"));
  195. list.Add("A");
  196. list.Add(this.UserInfo.GetUserName());
  197. list.Add(_custAlphaNo);
  198. list.Add(_specialDesc);
  199. parm.Add(list);
  200. }
  201. ServerHelper.SetData("com.steering.pss.qcm.JGAndMSC.AndJG",
  202. new object[] { parm }, ob);
  203. if (flag != 0)
  204. {
  205. MessageUtil.ShowTips("操作成功!");
  206. }
  207. this.DialogResult = DialogResult.OK;
  208. }
  209. catch (Exception ex) { }
  210. }
  211. /// <summary>
  212. /// 是否重复
  213. /// </summary>
  214. /// <param name="msc"></param>
  215. /// <param name="custAlpha"></param>
  216. /// <param name="codeJg"></param>
  217. /// <returns></returns>
  218. private bool IsRepeat(string msc, string orderSpecialDesc, string codeJg)
  219. {
  220. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.JGAndMSC.IsRepeat",
  221. new object[] { msc, orderSpecialDesc, codeJg }, ob);
  222. if (dt.Rows[0][0].ToString() == "0")
  223. {
  224. return false;
  225. }
  226. else
  227. {
  228. return true;
  229. }
  230. }
  231. private DataRow GetSlmOrderLineByPk(string orderLnPk)
  232. {
  233. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreFrmProPSCMSC2.getSlmOrderLineByPk",
  234. new object[] { orderLnPk }, _ob);
  235. if (dt.Rows.Count > 0)
  236. {
  237. return dt.Rows[0];
  238. }
  239. else
  240. {
  241. return null;
  242. }
  243. }
  244. private void ultraButton2_Click(object sender, EventArgs e)
  245. {
  246. this.Close();
  247. }
  248. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  249. {
  250. #if !DEBUG
  251. try
  252. {
  253. #endif
  254. switch (e.Tool.Key)
  255. {
  256. case "查询":
  257. doQuery();
  258. break;
  259. case "新增":
  260. frm.ToolBar_Click(null, "Add");
  261. RefreshMscJG();
  262. break;
  263. case "修改":
  264. frm.ToolBar_Click(null, "Update");
  265. RefreshMscJG();
  266. break;
  267. case "作废":
  268. frm.ToolBar_Click(null, "Delete");
  269. RefreshMscJG();
  270. break;
  271. case "恢复":
  272. frm.ToolBar_Click(null, "Resume");
  273. RefreshMscJG();
  274. break;
  275. case "刷新":
  276. frm.ToolBar_Click(null, "Refresh");
  277. RefreshMscJG();
  278. break;
  279. }
  280. #if !DEBUG
  281. }
  282. catch (Exception ex) { }
  283. #endif
  284. }
  285. private void UltraGrid1_CellChange(object sender, CellEventArgs e)
  286. {
  287. //frm.UltraGrid1.UpdateData();
  288. //if (e.Cell.Row.Cells["CHK"].Value.ToString() == "True")
  289. //{
  290. // //REP_STEELCODE
  291. // string[] repSteelCodes = e.Cell.Row.Cells["REP_STEELCODE"].Value.ToString().Split(';');
  292. // string[] steels = new string[repSteelCodes.Length + 1];
  293. // for(int i = 0; i < repSteelCodes.Length; i++)
  294. // {
  295. // steels[i] = repSteelCodes[i];
  296. // }
  297. // steels[steels.Length - 1] = e.Cell.Row.Cells["STEELCODE_JG"].Value.ToString();
  298. // ShowBLForm(steels);
  299. //}
  300. //frm.UltraGrid1.UpdateData();
  301. //if (e.Cell.Column.Key == "CHK")
  302. //{
  303. // if (e.Cell.Value.ToString() == "True")
  304. // {
  305. // if (_choiceJgCodes.Contains(e.Cell.Row.GetValue("CODE_JG")) == false)
  306. // {
  307. // _choiceJgCodes.Add(e.Cell.Row.GetValue("CODE_JG"));
  308. // }
  309. // }
  310. // else
  311. // {
  312. // _choiceJgCodes.Remove(e.Cell.Row.GetValue("CODE_JG"));
  313. // }
  314. //}
  315. }
  316. }
  317. }