using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; using Core.Mes.Client.Common; namespace Core.LgMes.Client.LgIntegrationQuery { public partial class frmStoresMaterielSelect : Core.Mes.Client.Common.frmStyleBase { public string strMslocation = ""; //料仓位置 public string strMsnumId = ""; //料仓号 public string strMaterielCode = ""; //物料代码 public string strMaterielName = ""; //物料名称 public string strBatchNo = ""; //批次号 public string strSetSurPlus = ""; //加入量 public frmStoresMaterielSelect() { InitializeComponent(); } private void frmStoresMaterielSelect_Load(object sender, EventArgs e) { lblMslocationText.Text = strMslocation; lblMsnumIDText.Text = strMsnumId; InitialMateriel();//初始化物料名Combox QueryData(); SetExistMaintenanceColor(); } /// /// 初始化物料Combox /// private void InitialMateriel() { string strErr = ""; object obj =null;//hengxing ClientCommon._RemotingHelp.ExecuteMethod( // "lgIntegrationQuery", // "Core.LgMes.Server.lgIntegrationQuery.LgGeneralInfo", // "InitialMateriel", new object[] { "" }, out strErr); if (strErr == "") { DataSet ds = obj as DataSet; Globals.FillUltraComboItems(cboMaterielName, ds); } } private void QueryData() { dataTable1.Clear(); string szWhere = " and t.MATERIELCODE='" + strMaterielCode + "'"; GetDataSource(szWhere); JJBStaticFunction.SetRowEdit(ultraGrid1); ultraGrid1.DisplayLayout.Bands[0].Columns["ERPITEMCODE"].Header.VisiblePosition = 1; } /// /// 获取物料库出库物料 /// /// private void GetDataSource(string szWhere) { string szOut = ""; dataSet1.Tables[0].Clear(); object obj =null;//hengxing ClientCommon._RemotingHelp.ExecuteMethod( // "lgIntegrationQuery", // "Core.LgMes.Server.lgIntegrationQuery.LgGeneralInfo", // "GetMaterielOutData", new object[] { szWhere }, out szOut); if (szOut == "" && obj != null) { DataTable dw = ((DataSet)obj).Tables[0]; int i; for (i = 0; i < dw.Rows.Count; i++)//dataTable1.Rows.Count; i++) { DataRow dr = dataTable1.NewRow(); dr["Flag"] = false; dr["MaterielCode"] = dw.Rows[i]["MaterielCode"]; dr["MaterielName"] = dw.Rows[i]["MaterielName"]; dr["MaterielforShort"] = dw.Rows[i]["MaterielName"]; dr["MaterielType"] = dw.Rows[i]["SORTCODE"]; dr["MaterielUnits"] = dw.Rows[i]["unit"]; dr["BATCHNO"] = dw.Rows[i]["BATCHNO"]; dr["WEIGHT"] = dw.Rows[i]["WEIGHT"]; dr["C"] = dw.Rows[i]["C"]; dr["SI"] = dw.Rows[i]["SI"]; dr["MN"] = dw.Rows[i]["MN"]; dr["P"] = dw.Rows[i]["P"]; dr["S"] = dw.Rows[i]["S"]; dr["Asn"] = dw.Rows[i]["Asn"]; dr["SURPLUSWGT"] = dw.Rows[i]["SURPLUSWGT"]; dataTable1.Rows.Add(dr); } JJBStaticFunction.SetRowEdit(ultraGrid1); } } /// /// 标识已经配置的物料 /// private void SetExistMaintenanceColor() { for (int j = 0; j < ultraGrid1.Rows.Count; j++) { ultraGrid1.DisplayLayout.Rows[j].CellAppearance.ForeColor = Color.Black; } for (int i = 0; i < ultraGrid1.Rows.Count; i++) { if (ultraGrid1.Rows[i].Cells["SURPLUSWGT"].Value.ToString() == "0") { ultraGrid1.DisplayLayout.Rows[i].CellAppearance.ForeColor = Color.Red; } } } private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "See": string strWhere = ""; if (ckbBatchNo.Checked == true) strWhere = " and t.BATCHNO='" + txtBatchNo.Text.Trim() + "'"; if (ckbMaterielName.Checked == true) strWhere += " and t.MATERIELCODE='" + cboMaterielName.Value.ToString() + "'"; GetDataSource(strWhere); SetExistMaintenanceColor(); break; case "Close": this.Close(); break; default: break; } } private void ckbBatchNo_CheckedChanged(object sender, EventArgs e) { txtBatchNo.Enabled = ckbBatchNo.Checked; } private void ckbMaterielName_CheckedChanged(object sender, EventArgs e) { cboMaterielName.Enabled = ckbMaterielName.Checked; } private void ultraGrid1_Click(object sender, EventArgs e) { if (ultraGrid1.ActiveRow != null) { if (ultraGrid1.ActiveRow.Cells["SURPLUSWGT"].Value.ToString() == "0") { MessageBox.Show("所选物料已经消耗完!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (Convert.ToBoolean(ultraGrid1.ActiveRow.Cells["Flag"].Value) == true) { ultraGrid1.ActiveRow.Cells["Flag"].Value = false; lblBatchNoText.Text = ""; } else { ultraGrid1.ActiveRow.Cells["Flag"].Value = true; lblBatchNoText.Text = ultraGrid1.ActiveRow.Cells["BATCHNO"].Value.ToString(); } for (int j = 0; j < ultraGrid1.Rows.Count; j++) { if (j != ultraGrid1.ActiveRow.Index) ultraGrid1.DisplayLayout.Rows[j].Cells["Flag"].Value = false; } } } private void txtWgt_KeyPress(object sender, KeyPressEventArgs e) { if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '.' || e.KeyChar == '\b' || e.KeyChar == '-')) { e.Handled = true; } } private void butOK_Click(object sender, EventArgs e) { UltraGridRow UltraRow = null; foreach (UltraGridRow ugr in ultraGrid1.Rows) { if (Convert.ToBoolean(ugr.Cells["Flag"].Value) == true) { UltraRow = ugr; break; } } if (UltraRow != null && txtWgt.Text.Trim().Length > 0) { if (Convert.ToDouble(txtWgt.Text.Trim()) > Convert.ToDouble(UltraRow.Cells["SURPLUSWGT"].Value)) MessageBox.Show("输入的加入重量大于库存出库总重,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); else { strBatchNo = UltraRow.Cells["BatchNo"].Value.ToString(); strSetSurPlus = txtWgt.Text.Trim(); this.Close(); } } else MessageBox.Show("请选择要加入【" + strMslocation + "】岗位【" + strMsnumId + "】料仓的物料批次信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } }