frmStoresMaterielSelect.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using CoreFS.CA06;
  9. using Infragistics.Win.UltraWinGrid;
  10. using Core.Mes.Client.Common;
  11. namespace Core.LgMes.Client.LgIntegrationQuery
  12. {
  13. public partial class frmStoresMaterielSelect : Core.Mes.Client.Common.frmStyleBase
  14. {
  15. public string strMslocation = ""; //料仓位置
  16. public string strMsnumId = ""; //料仓号
  17. public string strMaterielCode = ""; //物料代码
  18. public string strMaterielName = ""; //物料名称
  19. public string strBatchNo = ""; //批次号
  20. public string strSetSurPlus = ""; //加入量
  21. public frmStoresMaterielSelect()
  22. {
  23. InitializeComponent();
  24. }
  25. private void frmStoresMaterielSelect_Load(object sender, EventArgs e)
  26. {
  27. lblMslocationText.Text = strMslocation;
  28. lblMsnumIDText.Text = strMsnumId;
  29. InitialMateriel();//初始化物料名Combox
  30. QueryData();
  31. SetExistMaintenanceColor();
  32. }
  33. /// <summary>
  34. /// 初始化物料Combox
  35. /// </summary>
  36. private void InitialMateriel()
  37. {
  38. string strErr = "";
  39. object obj =null;//hengxing ClientCommon._RemotingHelp.ExecuteMethod(
  40. // "lgIntegrationQuery",
  41. // "Core.LgMes.Server.lgIntegrationQuery.LgGeneralInfo",
  42. // "InitialMateriel", new object[] { "" }, out strErr);
  43. if (strErr == "")
  44. {
  45. DataSet ds = obj as DataSet;
  46. Globals.FillUltraComboItems(cboMaterielName, ds);
  47. }
  48. }
  49. private void QueryData()
  50. {
  51. dataTable1.Clear();
  52. string szWhere = " and t.MATERIELCODE='" + strMaterielCode + "'";
  53. GetDataSource(szWhere);
  54. JJBStaticFunction.SetRowEdit(ultraGrid1);
  55. ultraGrid1.DisplayLayout.Bands[0].Columns["ERPITEMCODE"].Header.VisiblePosition = 1;
  56. }
  57. /// <summary>
  58. /// 获取物料库出库物料
  59. /// </summary>
  60. /// <param name="szWhere"></param>
  61. private void GetDataSource(string szWhere)
  62. {
  63. string szOut = "";
  64. dataSet1.Tables[0].Clear();
  65. object obj =null;//hengxing ClientCommon._RemotingHelp.ExecuteMethod(
  66. // "lgIntegrationQuery",
  67. // "Core.LgMes.Server.lgIntegrationQuery.LgGeneralInfo",
  68. // "GetMaterielOutData", new object[] { szWhere }, out szOut);
  69. if (szOut == "" && obj != null)
  70. {
  71. DataTable dw = ((DataSet)obj).Tables[0];
  72. int i;
  73. for (i = 0; i < dw.Rows.Count; i++)//dataTable1.Rows.Count; i++)
  74. {
  75. DataRow dr = dataTable1.NewRow();
  76. dr["Flag"] = false;
  77. dr["MaterielCode"] = dw.Rows[i]["MaterielCode"];
  78. dr["MaterielName"] = dw.Rows[i]["MaterielName"];
  79. dr["MaterielforShort"] = dw.Rows[i]["MaterielName"];
  80. dr["MaterielType"] = dw.Rows[i]["SORTCODE"];
  81. dr["MaterielUnits"] = dw.Rows[i]["unit"];
  82. dr["BATCHNO"] = dw.Rows[i]["BATCHNO"];
  83. dr["WEIGHT"] = dw.Rows[i]["WEIGHT"];
  84. dr["C"] = dw.Rows[i]["C"];
  85. dr["SI"] = dw.Rows[i]["SI"];
  86. dr["MN"] = dw.Rows[i]["MN"];
  87. dr["P"] = dw.Rows[i]["P"];
  88. dr["S"] = dw.Rows[i]["S"];
  89. dr["Asn"] = dw.Rows[i]["Asn"];
  90. dr["SURPLUSWGT"] = dw.Rows[i]["SURPLUSWGT"];
  91. dataTable1.Rows.Add(dr);
  92. }
  93. JJBStaticFunction.SetRowEdit(ultraGrid1);
  94. }
  95. }
  96. /// <summary>
  97. /// 标识已经配置的物料
  98. /// </summary>
  99. private void SetExistMaintenanceColor()
  100. {
  101. for (int j = 0; j < ultraGrid1.Rows.Count; j++)
  102. {
  103. ultraGrid1.DisplayLayout.Rows[j].CellAppearance.ForeColor = Color.Black;
  104. }
  105. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  106. {
  107. if (ultraGrid1.Rows[i].Cells["SURPLUSWGT"].Value.ToString() == "0")
  108. {
  109. ultraGrid1.DisplayLayout.Rows[i].CellAppearance.ForeColor = Color.Red;
  110. }
  111. }
  112. }
  113. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  114. {
  115. switch (e.Tool.Key)
  116. {
  117. case "See":
  118. string strWhere = "";
  119. if (ckbBatchNo.Checked == true)
  120. strWhere = " and t.BATCHNO='" + txtBatchNo.Text.Trim() + "'";
  121. if (ckbMaterielName.Checked == true)
  122. strWhere += " and t.MATERIELCODE='" + cboMaterielName.Value.ToString() + "'";
  123. GetDataSource(strWhere);
  124. SetExistMaintenanceColor();
  125. break;
  126. case "Close":
  127. this.Close();
  128. break;
  129. default:
  130. break;
  131. }
  132. }
  133. private void ckbBatchNo_CheckedChanged(object sender, EventArgs e)
  134. {
  135. txtBatchNo.Enabled = ckbBatchNo.Checked;
  136. }
  137. private void ckbMaterielName_CheckedChanged(object sender, EventArgs e)
  138. {
  139. cboMaterielName.Enabled = ckbMaterielName.Checked;
  140. }
  141. private void ultraGrid1_Click(object sender, EventArgs e)
  142. {
  143. if (ultraGrid1.ActiveRow != null)
  144. {
  145. if (ultraGrid1.ActiveRow.Cells["SURPLUSWGT"].Value.ToString() == "0")
  146. {
  147. MessageBox.Show("所选物料已经消耗完!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  148. return;
  149. }
  150. if (Convert.ToBoolean(ultraGrid1.ActiveRow.Cells["Flag"].Value) == true)
  151. {
  152. ultraGrid1.ActiveRow.Cells["Flag"].Value = false;
  153. lblBatchNoText.Text = "";
  154. }
  155. else
  156. {
  157. ultraGrid1.ActiveRow.Cells["Flag"].Value = true;
  158. lblBatchNoText.Text = ultraGrid1.ActiveRow.Cells["BATCHNO"].Value.ToString();
  159. }
  160. for (int j = 0; j < ultraGrid1.Rows.Count; j++)
  161. {
  162. if (j != ultraGrid1.ActiveRow.Index)
  163. ultraGrid1.DisplayLayout.Rows[j].Cells["Flag"].Value = false;
  164. }
  165. }
  166. }
  167. private void txtWgt_KeyPress(object sender, KeyPressEventArgs e)
  168. {
  169. if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '.' || e.KeyChar == '\b' || e.KeyChar == '-'))
  170. {
  171. e.Handled = true;
  172. }
  173. }
  174. private void butOK_Click(object sender, EventArgs e)
  175. {
  176. UltraGridRow UltraRow = null;
  177. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  178. {
  179. if (Convert.ToBoolean(ugr.Cells["Flag"].Value) == true)
  180. {
  181. UltraRow = ugr;
  182. break;
  183. }
  184. }
  185. if (UltraRow != null && txtWgt.Text.Trim().Length > 0)
  186. {
  187. if (Convert.ToDouble(txtWgt.Text.Trim()) > Convert.ToDouble(UltraRow.Cells["SURPLUSWGT"].Value))
  188. MessageBox.Show("输入的加入重量大于库存出库总重,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  189. else
  190. {
  191. strBatchNo = UltraRow.Cells["BatchNo"].Value.ToString();
  192. strSetSurPlus = txtWgt.Text.Trim();
  193. this.Close();
  194. }
  195. }
  196. else
  197. MessageBox.Show("请选择要加入【" + strMslocation + "】岗位【" + strMsnumId + "】料仓的物料批次信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  198. }
  199. }
  200. }