ba1d10f622739c974f2f6fe4caad00ba2cc42d53.svn-base 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 CoreFS.CA06;
  10. using Infragistics.Win.UltraWinGrid;
  11. using System.Collections;
  12. namespace Core.LZMes.Client.UIB
  13. {
  14. public partial class CUIB030240 : FrmBase
  15. {
  16. public string ORG_SMP_NO = "";
  17. public string ORG_SMP_NO_LOT = "";
  18. public string QLTY_CD_GP = ""; //被替换项目代码
  19. public string QLTY_CD_GPN = ""; //被替换项目名称
  20. public CUIB030240()
  21. {
  22. InitializeComponent();
  23. }
  24. public void DoQuery()
  25. {
  26. }
  27. public SortedList al = null;//存入选择的替换项目
  28. private void button1_Click(object sender, EventArgs e)
  29. {
  30. try
  31. {
  32. if (MessageBox.Show("确定替换?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  33. return;
  34. al = new SortedList();
  35. string QLTYCD = "";
  36. string QLTY_VAL = "";
  37. string QLTY_VAL_TH = "";
  38. foreach (UltraGridRow ugr in this.ultraGrid4.Rows)
  39. {
  40. if (ugr.Cells["CHK"].Text.ToLower() == "true")
  41. {
  42. QLTYCD = ugr.Cells["QLTY_CD"].Text;
  43. QLTY_VAL = ugr.Cells["QLTY_VAL_WK"].Text;
  44. QLTY_VAL_TH = ugr.Cells["ZH_VALUE"].Text;
  45. if (QLTY_VAL_TH != "")
  46. QLTY_VAL = QLTY_VAL_TH;
  47. if (QLTYCD != "" && QLTY_VAL != "")
  48. {
  49. al.Add(QLTYCD, QLTY_VAL);
  50. }
  51. }
  52. }
  53. if (al.Count == 0)
  54. {
  55. System.Windows.Forms.MessageBox.Show("请选择材质项目,并设定值!");
  56. return;
  57. }
  58. }
  59. catch (Exception ex)
  60. {
  61. System.Diagnostics.Debug.WriteLine(ex.ToString());
  62. }
  63. this.DialogResult = DialogResult.OK;
  64. }
  65. private void button2_Click(object sender, EventArgs e)
  66. {
  67. this.Close();
  68. }
  69. private void CUIB030240_Load(object sender, EventArgs e)
  70. {
  71. try
  72. {
  73. if (QLTY_CD_GP.IndexOf("EL") > -1 && QLTY_CD_GPN.IndexOf("50") > -1)
  74. {
  75. this.button3_50.Visible = true;
  76. }
  77. if (QLTY_CD_GP.IndexOf("EL") > -1 && QLTY_CD_GPN.IndexOf("80") > -1)
  78. {
  79. this.button4_80.Visible = true;
  80. }
  81. //钢卷原始检验信息
  82. ArrayList al = new ArrayList();
  83. al.Add("UIB030230_04.SELECT");
  84. al.Add(ORG_SMP_NO);
  85. al.Add(ORG_SMP_NO_LOT);
  86. this.dataSet3.Tables[0].Clear();
  87. CoreClientParam ccp = new CoreClientParam();
  88. ccp.ServerName = "UIB.COM.ComDBQuery";
  89. ccp.MethodName = "doSimpleQuery";
  90. ccp.ServerParams = new object[] { al };
  91. ccp.SourceDataTable = this.dataSet3.Tables[0];
  92. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  93. int isCheck = 0;
  94. foreach (UltraGridRow ugr in this.ultraGrid4.Rows)
  95. {
  96. string QLTYCD = ugr.Cells["QLTY_CD"].Text;
  97. //找到与替换项目相同的材质默认勾选
  98. if (QLTY_CD_GP.Equals(QLTYCD))
  99. {
  100. ugr.Cells["CHK"].Value = "True";
  101. isCheck = 1;
  102. break;
  103. }
  104. }
  105. if (isCheck == 0) //若不存在相同的项目则默认勾选类似的
  106. {
  107. foreach (UltraGridRow ugr in this.ultraGrid4.Rows)
  108. {
  109. string QLTYCD = ugr.Cells["QLTY_CD"].Text;
  110. //找到与替换项目类似的伸长率默认勾选,否则不勾选
  111. if (QLTY_CD_GP.Substring(0, 2).Equals(QLTYCD.Substring(0, 2)) && isCheck == 0 &&
  112. (QLTYCD.IndexOf("EL") > -1 || QLTYCD.IndexOf("YS") > -1 || QLTYCD.IndexOf("TE") > -1
  113. || QLTYCD.IndexOf("YR") > -1 || QLTYCD.IndexOf("RP") > -1))
  114. {
  115. ugr.Cells["CHK"].Value = "True";
  116. isCheck = 1;
  117. break;
  118. }
  119. }
  120. }
  121. }
  122. catch (Exception ex)
  123. {
  124. }
  125. }
  126. private void ultraGrid4_CellChange(object sender, CellEventArgs e)
  127. {
  128. try
  129. {
  130. if (this.ultraGrid4.ActiveRow == null) return;
  131. string clickColumnID = this.ultraGrid4.ActiveCell.Column.Key;
  132. if (clickColumnID.Equals("CHK"))
  133. {
  134. string QLTYCD = this.ultraGrid4.ActiveRow.Cells["QLTY_CD"].Value.ToString();
  135. string CHK_VAL = this.ultraGrid4.ActiveRow.Cells["CHK"].Text.ToString();
  136. //找到与替换项目类似的材质默认勾选
  137. if (!QLTY_CD_GP.Substring(0, 2).Equals(QLTYCD.Substring(0, 2)))
  138. {
  139. this.ultraGrid4.ActiveRow.Cells["CHK"].Value = "False";
  140. System.Windows.Forms.MessageBox.Show("请选择相同材质项目!");
  141. return;
  142. }
  143. foreach (UltraGridRow ugr in this.ultraGrid4.Rows)
  144. {
  145. if (!QLTYCD.Equals(ugr.Cells["QLTY_CD"].Text.ToString()))
  146. {
  147. if (CHK_VAL == "True")
  148. {
  149. ugr.Cells["CHK"].Value = "False";
  150. }
  151. }
  152. }
  153. }
  154. //只允许编辑伸长率
  155. if (clickColumnID.Equals("ZH_VALUE"))
  156. {
  157. string QLTYCD = this.ultraGrid4.ActiveRow.Cells["QLTY_CD"].Value.ToString();
  158. if (QLTYCD.IndexOf("EL") > -1 && QLTY_CD_GP.IndexOf("EL") > -1 && !QLTY_CD_GP.Equals(QLTYCD))
  159. {
  160. }
  161. else
  162. {
  163. this.ultraGrid4.ActiveRow.Cells["ZH_VALUE"].Value = "";
  164. System.Windows.Forms.MessageBox.Show("只能修改伸长率不相同的值!");
  165. }
  166. }
  167. }
  168. catch (Exception ex)
  169. {
  170. System.Diagnostics.Debug.WriteLine(ex.ToString());
  171. }
  172. }
  173. private void button4_80_Click(object sender, EventArgs e)
  174. {
  175. try
  176. {
  177. foreach (UltraGridRow ugr in this.ultraGrid4.Rows)
  178. {
  179. string QLTYCD = ugr.Cells["QLTY_CD"].Text;
  180. string QLTYCD_NM = ugr.Cells["QLTY_CD_CFNM"].Text;
  181. string QLTY_VAL = ugr.Cells["QLTY_VAL_WK"].Text;
  182. if (QLTY_VAL != "")
  183. {
  184. double val_d = Double.Parse(QLTY_VAL);
  185. //伸长率值由A50转换成A80
  186. if (QLTYCD.IndexOf("EL") > -1 && QLTY_CD_GP.IndexOf("EL") > -1 && QLTYCD_NM.IndexOf("50") > -1 && QLTY_CD_GPN.IndexOf("80") > -1)
  187. {
  188. ugr.Cells["ZH_VALUE"].Value = Math.Round(val_d * 0.829, 3).ToString();
  189. //ugr.Cells["ZH_VALUE"].Activation = Activation.AllowEdit;
  190. }
  191. }
  192. }
  193. }
  194. catch (Exception ex)
  195. {
  196. System.Diagnostics.Debug.WriteLine(ex.ToString());
  197. }
  198. }
  199. private void button3_50_Click(object sender, EventArgs e)
  200. {
  201. try
  202. {
  203. foreach (UltraGridRow ugr in this.ultraGrid4.Rows)
  204. {
  205. string QLTYCD = ugr.Cells["QLTY_CD"].Text;
  206. string QLTYCD_NM = ugr.Cells["QLTY_CD_CFNM"].Text;
  207. string QLTY_VAL = ugr.Cells["QLTY_VAL_WK"].Text;
  208. if (QLTY_VAL != "")
  209. {
  210. double val_d = Double.Parse(QLTY_VAL);
  211. if (QLTYCD.IndexOf("EL") > -1 && QLTY_CD_GP.IndexOf("EL") > -1 && QLTYCD_NM.IndexOf("80") > -1 && QLTY_CD_GPN.IndexOf("50") > -1)
  212. {
  213. ugr.Cells["ZH_VALUE"].Value = Math.Round(val_d * 1.207, 3).ToString();
  214. }
  215. }
  216. }
  217. }
  218. catch (Exception ex)
  219. {
  220. System.Diagnostics.Debug.WriteLine(ex.ToString());
  221. }
  222. }
  223. private void ultraGrid4_ClickCell(object sender, ClickCellEventArgs e)
  224. {
  225. }
  226. }
  227. }