frmSteelConfiger.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Collections;
  10. using CoreFS.CA06;
  11. using Core.StlMes.Client.LgCommon;
  12. namespace Core.StlMes.Client.LgResMgt
  13. {
  14. public partial class frmSteelConfiger : frmStyleBase
  15. {
  16. public string WorkShopNo = "";
  17. private ArrayList BeforeCode; //初始物料编码
  18. private ArrayList BeforeName; //初始物料名称
  19. public frmSteelConfiger(OpeBase oba)
  20. {
  21. InitializeComponent();
  22. this.ob = oba;
  23. BeforeCode = new ArrayList();
  24. BeforeName = new ArrayList();
  25. }
  26. private void frmSteelConfiger_Load(object sender, EventArgs e)
  27. {
  28. GetMater();
  29. GetConfigMater();
  30. }
  31. // 获得钢铁物料
  32. /// <summary>
  33. /// 获得钢铁物料
  34. /// </summary>
  35. private void GetMater()
  36. {
  37. try
  38. {
  39. string strErr = "";
  40. ArrayList arry = new ArrayList();
  41. arry.Add("ScrapSteelConfig.Query");
  42. CommonClientToServer ccs = new CommonClientToServer();
  43. ccs.ob = this.ob;
  44. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  45. try
  46. {
  47. if (ultraGrid2.Rows.Count > 0)
  48. {
  49. ((DataSet)ultraGrid2.DataSource).Tables[0].Rows.Clear();
  50. }
  51. }
  52. catch (Exception)
  53. {
  54. }
  55. if (ds.Tables[0].Rows.Count > 0)
  56. {
  57. this.ultraGrid2.DataSource = ds;
  58. }
  59. PublicMethod.RefreshAndAutoSize(ultraGrid2);
  60. }
  61. catch { }
  62. }
  63. // 获得已经配置的物料
  64. /// <summary>
  65. /// 获得已经配置的物料
  66. /// </summary>
  67. private void GetConfigMater()
  68. {
  69. try
  70. {
  71. string strErr = "";
  72. ArrayList arry = new ArrayList();
  73. arry.Add("ScrapSteel.Config");
  74. arry.Add(WorkShopNo);
  75. CommonClientToServer ccs = new CommonClientToServer();
  76. ccs.ob = this.ob;
  77. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  78. if (ds != null && ds.Tables[0].Rows.Count > 0)
  79. {
  80. string matercode = "";
  81. string matername = "";
  82. for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  83. {
  84. matercode = ds.Tables[0].Rows[i]["SCRAPSTEELCODE"].ToString();
  85. matername = ds.Tables[0].Rows[i]["SCRAPSTEELNAME"].ToString();
  86. for (int j = 0; j < ultraGrid2.Rows.Count; j++)
  87. {
  88. if (matercode == ultraGrid2.Rows[j].Cells["MATERIELCODE"].Value.ToString())
  89. {
  90. ultraGrid2.Rows[j].Cells["FLAG"].Value = "True";
  91. string code = ultraGrid2.Rows[j].Cells["MATERIELCODE"].Value.ToString();
  92. string name = ultraGrid2.Rows[j].Cells["MATERIELNAME"].Value.ToString();
  93. BeforeCode.Add(code);
  94. BeforeName.Add(name);
  95. SetMater(code, name);
  96. }
  97. }
  98. }
  99. }
  100. }
  101. catch { }
  102. }
  103. private void SetMater(string matercode, string matername)
  104. {
  105. try
  106. {
  107. if (Mater1.Text.ToString() == "")
  108. {
  109. // Mater1.Tag = matercode;
  110. Mater1.Text = matername;
  111. return;
  112. }
  113. if (Mater2.Text.ToString() == "")
  114. {
  115. // Mater2.Tag = matercode;
  116. Mater2.Text = matername;
  117. return;
  118. }
  119. if ( Mater3.Text.ToString() == "")
  120. {
  121. // Mater3.Tag = matercode;
  122. Mater3.Text = matername;
  123. return;
  124. }
  125. if (Mater3.Text.ToString() == "")
  126. {
  127. // Mater3.Tag = matercode;
  128. Mater3.Text = matername;
  129. return;
  130. }
  131. if (Mater4.Text.ToString() == "")
  132. {
  133. // Mater4.Tag = matercode;
  134. Mater4.Text = matername;
  135. return;
  136. }
  137. if ( Mater5.Text.ToString() == "")
  138. {
  139. // Mater5.Tag = matercode;
  140. Mater5.Text = matername;
  141. return;
  142. }
  143. if ( Mater6.Text.ToString() == "")
  144. {
  145. // Mater6.Tag = matercode;
  146. Mater6.Text = matername;
  147. return;
  148. }
  149. else
  150. {
  151. // MessageBox.Show("最多只能配置6个物料!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  152. return;
  153. }
  154. }
  155. catch { }
  156. }
  157. private void CancelMater(string matercode, string matername)
  158. {
  159. try
  160. {
  161. if (Mater1.Text.ToString() == matername)
  162. {
  163. // Mater1.Tag = "";
  164. Mater1.Text = "";
  165. return;
  166. }
  167. if (Mater2.Text.ToString() == matername)
  168. {
  169. // Mater2.Tag = "";
  170. Mater2.Text = "";
  171. return;
  172. }
  173. if (Mater3.Text.ToString() == matername)
  174. {
  175. // Mater3.Tag = "";
  176. Mater3.Text = "";
  177. return;
  178. }
  179. if (Mater3.Text.ToString() == matername)
  180. {
  181. // Mater3.Tag = "";
  182. Mater3.Text = "";
  183. return;
  184. }
  185. if (Mater4.Text.ToString() == matername)
  186. {
  187. // Mater4.Tag = "";
  188. Mater4.Text = "";
  189. return;
  190. }
  191. if ( Mater5.Text.ToString() == matername)
  192. {
  193. // Mater5.Tag = "";
  194. Mater5.Text = "";
  195. return;
  196. }
  197. if (Mater6.Text.ToString() == matername)
  198. {
  199. // Mater6.Tag = "";
  200. Mater6.Text = "";
  201. return;
  202. }
  203. }
  204. catch { }
  205. }
  206. private void ultraGrid2_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  207. {
  208. try
  209. {
  210. ultraGrid2.UpdateData();
  211. string code = "";
  212. string name = "";
  213. int nvl = 0;
  214. int index = e.Cell.Row.Index;
  215. if (e.Cell.Column.Key.ToString() == "FLAG")
  216. {
  217. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  218. {
  219. if (ultraGrid2.Rows[i].Cells["FLAG"].Value.ToString() == "True")
  220. {
  221. nvl++;
  222. }
  223. }
  224. if (nvl > 6)
  225. {
  226. e.Cell.Value = "False";
  227. MessageBox.Show("最多只能配置6个物料!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  228. return;
  229. }
  230. if (e.Cell.Value.ToString() == "True")
  231. {
  232. code = ultraGrid2.Rows[index].Cells["MATERIELCODE"].Value.ToString();
  233. name = ultraGrid2.Rows[index].Cells["MATERIELNAME"].Value.ToString();
  234. SetMater(code,name);
  235. }
  236. else
  237. {
  238. code = ultraGrid2.Rows[index].Cells["MATERIELCODE"].Value.ToString();
  239. name = ultraGrid2.Rows[index].Cells["MATERIELNAME"].Value.ToString();
  240. CancelMater(code, name);
  241. }
  242. }
  243. }
  244. catch { }
  245. }
  246. // 保存物料配置
  247. /// <summary>
  248. /// 保存物料配置
  249. /// </summary>
  250. /// <param name="sender"></param>
  251. /// <param name="e"></param>
  252. private void button1_Click(object sender, EventArgs e)
  253. {
  254. try
  255. {
  256. if (ultraGrid2.Rows.Count == 0)
  257. {
  258. MessageBox.Show("没有可选的物料!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  259. return;
  260. }
  261. ArrayList listMcode = new ArrayList(); //物料编码
  262. ArrayList listMname = new ArrayList(); //物料名称
  263. string flag = "0";
  264. bool blValue = false;
  265. if (ultraGrid2.Rows.Count > 0)
  266. {
  267. ultraGrid2.UpdateData();
  268. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  269. {
  270. if (Convert.ToBoolean(ultraGrid2.Rows[i].Cells["FLAG"].Value) == true)
  271. {
  272. listMcode.Add(ultraGrid2.Rows[i].Cells["MATERIELCODE"].Value.ToString().Trim());
  273. listMname.Add(ultraGrid2.Rows[i].Cells["MATERIELNAME"].Value.ToString().Trim());
  274. blValue = true;
  275. }
  276. }
  277. if (blValue == false)
  278. {
  279. if (MessageBox.Show("你当前没有选择任何物料!你确定保存?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  280. return;
  281. listMcode = BeforeCode;
  282. listMname = BeforeName;
  283. flag = "1";
  284. }
  285. }
  286. if (listMcode.Count > 0)
  287. {
  288. //定义一个ArrayList集合存储变量[参数]值
  289. string strErr = "";
  290. string strSqlID = "frmScrapMater.Config";
  291. object[] sArgs = new object[5];
  292. sArgs[0] = listMcode;
  293. sArgs[1] = listMname; //炉号
  294. sArgs[2] =this.UserInfo.GetUserName();
  295. sArgs[3] = flag;
  296. sArgs[4] = WorkShopNo;
  297. CommonClientToServer ccTs = new CommonClientToServer();
  298. ccTs.ob = ob;
  299. string strRCode = ccTs.ExecuteProcedureFunctions("Core.LgMes.Server.Common.ComDBProcedure",
  300. "ExecProcWithCollParam", strSqlID, sArgs, out strErr);
  301. if (strErr == "")
  302. {
  303. frmScrapSteel frm = (frmScrapSteel)this.Tag;
  304. frm.GetConfigMater();
  305. MessageBox.Show("物料保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  306. System.Threading.Thread.Sleep(500);
  307. this.Close();
  308. }
  309. else
  310. {
  311. MessageBox.Show("物料保存失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  312. }
  313. }
  314. else
  315. {
  316. MessageBox.Show("物料保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  317. this.Close();
  318. }
  319. }
  320. catch { }
  321. }
  322. /// <summary>
  323. /// 取消
  324. /// </summary>
  325. /// <param name="sender"></param>
  326. /// <param name="e"></param>
  327. private void button2_Click(object sender, EventArgs e)
  328. {
  329. this.Close();
  330. }
  331. }
  332. }