using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Pub_Class; namespace SCM { public partial class Gy_SourceBillList_Touch : Form { public Gy_SourceBillList_Touch() { InitializeComponent(); } //定义 public const Int16 HTagCol = 0; public const Int16 HSnoCol = 1; public const Int16 HMainIDCol = 2; public const Int16 HSubIDCol = 3; public const Int16 HSourceBillTypeCol = 4; public const Int16 HSourceBillNoCol = 5; public const Int16 HMaterNumberCol = 6; public const Int16 HMaterNameCol = 7; public const Int16 HMaterModelCol = 8; public const Int16 HUnitNameCol = 9; public const Int16 HBatchNoCol = 10; public const Int16 HQtyCol = 11; public const Int16 HRelationQtyCol = 12; public const Int16 HNotBarCode = 13; public const Int16 HSourceBillTypeIDCol = 14; public frmBillQueryCondition_Base frmCondition; public string HSourceBillNo=""; public string HSourceBillType = ""; public string HSourceBillTypeID = ""; public Int64 HSelInterID = 0; public Int64 HSelEntryID = 0; public int OKTag = 0; const string ModCaption = "源单列表"; ClsGridViewSum oSumGrid = new ClsGridViewSum(); public Int32 iTopRow = 0;//画横线 SCM.WMSWeb.WebService1 oWeb = new SCM.WMSWeb.WebService1(); // #region 固定代码 //清空界面 public void Sub_ClearBill() { cmbHSourceBillType.Items.Clear(); // cmbHSourceBillType.Items.Add("生产订单"); cmbHSourceBillType.Items.Add("生产汇报单"); cmbHSourceBillType.Items.Add("收料通知单"); cmbHSourceBillType.SelectedIndex = 0; cmbHSourceBillType.Text = HSourceBillType; // txtHSourceBillNo.Text = ""; initGrid(); txtHSourceBillNo.Focus(); txtHSourceBillNo.SelectAll(); if (HSourceBillType == "生产订单") { txtHBarCode.Enabled = true; } else { txtHBarCode.Enabled = false; } } private void Gy_SourceBillList_Touch_Load(object sender, EventArgs e) { //设置动态URL oWeb.Url = SCM.ClsPub1.WEBSURL; // //frmCondition = new frmBillQueryCondition_Base(); this.Text = ModCaption; //lblCaption.Text = ModCaption; //oSumGrid.ogrdMain = grdMain; //初始化 new //oSumGrid.oGridsum = grdSum; initGrid(); } //时间控件 private void timer1_Tick(object sender, EventArgs e) { timer1.Enabled=false; Sub_ClearBill(); } private void timer2_Tick(object sender, EventArgs e) { timer2.Enabled = false; //cmbHSourceBillType.Text = HSourceBillType; //txtHSourceBillNo.Focus(); //txtHSourceBillNo.SelectAll(); } private void grdMain_Paint(object sender, PaintEventArgs e) { GraphicsGrid(); } private void GraphicsGrid() { //画底线 DBUtility.Xt_BaseBillFun.GraphicsGrid(grdMain); //画横线 //DBUtility.Xt_BaseBillFun.GraphicsRowGrid(grdMain, iTopRow, iTopRow + 50, Fun_GetCol("hmainid")); } private Int32 Fun_GetCol(string sCol) { return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain); } //保存列宽 private void bclk_Click(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); } //默认列宽 private void mrlk_Click(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name); } #endregion #region 窗体处理方法 //初始化GRID private void initGrid() { grdMain.RowCount = 0; grdMain.ColumnCount = 15; //总列数 ClsPub1.initGridFst(grdMain, this.Name); grdMain.RowCount = 0; // grdMain.Columns[HSnoCol].HeaderText = "序号"; grdMain.Columns[HSourceBillTypeCol].HeaderText = "源单类型"; grdMain.Columns[HSourceBillNoCol].HeaderText = "源单单号"; grdMain.Columns[HMaterNumberCol].HeaderText = "物料代码"; grdMain.Columns[HMaterNameCol].HeaderText = "物料名称"; grdMain.Columns[HMaterModelCol].HeaderText = "规格型号"; grdMain.Columns[HUnitNameCol].HeaderText = "计量单位"; grdMain.Columns[HBatchNoCol].HeaderText = "批次"; grdMain.Columns[HQtyCol].HeaderText = "数量"; grdMain.Columns[HRelationQtyCol].HeaderText = "未关联数量"; grdMain.Columns[HNotBarCode].HeaderText = "未生成条码数量"; // grdMain.Columns[HTagCol].Visible = false; grdMain.Columns[HMainIDCol].Visible = false; grdMain.Columns[HSubIDCol].Visible = false; // //string sAllowCol = HTagCol.ToString(); //string sTotalCol = HTagCol.ToString(); //格式化网格 //ClsPub1.initGridLast(sAllowCol, sTotalCol, oSumGrid); grdMain.RowTemplate.Height = 60; grdMain.RowTemplate.MinimumHeight = 60; grdMain.RowsDefaultCellStyle.Font = new Font("宋体", 22); grdMain.ReadOnly = true; } #endregion #region 返回源单信息 //返回源单信息 private void txtHSourceBillNo_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Return) { if (HSourceBillType == "生产订单") { initGrid(); txtHBarCode.Focus(); txtHBarCode.SelectAll(); } else { initGrid(); Display(); txtHSourceBillNo.Focus(); txtHSourceBillNo.SelectAll(); } } } private void Display() { string HSourceBillNo = ""; //源单单号 string HSourceBillType = ""; //源单类型 HSourceBillNo = txtHSourceBillNo.Text.Trim(); HSourceBillType = cmbHSourceBillType.Text; if (HSourceBillNo == "") { MessageBox.Show("源单单号不能为空!"); return; } //得到信息 DataSet DS = oWeb.getDataSetBySQL("exec h_p_SourceBillList_Touch '" + HSourceBillType + "','" + HSourceBillNo + "','" + DBUtility.ClsPub.isStrNull(txtHBarCode.Text) + "'" , "h_p_SourceBillList_Touch", ref DBUtility.ClsPub.sExeReturnInfo); if (DS==null || DS.Tables[0].Rows.Count == 0) { MessageBox.Show("没有找到相关源单信息!" + DBUtility.ClsPub.sExeReturnInfo); return; } //写入信息 for (int i = 0; i < DS.Tables[0].Rows.Count; i++) { Sub_WriteInForm(DS.Tables[0], i); } } //根据TABLE写入界面 private void Sub_WriteInForm(DataTable oTable, int i) { if (i >= grdMain.RowCount - 1) grdMain.Rows.Add(); grdMain.Rows[i].Cells[HSnoCol].Value = ClsPub.isStrNull(i + 1); grdMain.Rows[i].Cells[HMainIDCol].Value = oTable.Rows[i]["hmainid"].ToString(); grdMain.Rows[i].Cells[HSubIDCol].Value = oTable.Rows[i]["hsubid"].ToString(); grdMain.Rows[i].Cells[HMaterNumberCol].Value = oTable.Rows[i]["物料代码"].ToString(); grdMain.Rows[i].Cells[HSourceBillTypeCol].Value = oTable.Rows[i]["源单类型"].ToString(); grdMain.Rows[i].Cells[HSourceBillNoCol].Value = oTable.Rows[i]["源单单号"].ToString(); grdMain.Rows[i].Cells[HMaterNameCol].Value = oTable.Rows[i]["物料名称"].ToString(); grdMain.Rows[i].Cells[HMaterModelCol].Value = oTable.Rows[i]["规格型号"].ToString(); grdMain.Rows[i].Cells[HUnitNameCol].Value = oTable.Rows[i]["计量单位"].ToString(); grdMain.Rows[i].Cells[HBatchNoCol].Value = oTable.Rows[i]["批次"].ToString(); grdMain.Rows[i].Cells[HQtyCol].Value = oTable.Rows[i]["数量"].ToString(); grdMain.Rows[i].Cells[HRelationQtyCol].Value = oTable.Rows[i]["未关联数量"].ToString(); grdMain.Rows[i].Cells[HNotBarCode].Value = oTable.Rows[i]["未生成条码数量"].ToString(); grdMain.Rows[i].Cells[HSourceBillTypeIDCol].Value = oTable.Rows[i]["HBillType"].ToString(); } #endregion //确定 private void btnOK_Click(object sender, EventArgs e) { if (grdMain.CurrentRow == null) { MessageBox.Show("清选择一行!"); return; } HSelInterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[HMainIDCol].Value); HSelEntryID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[HSubIDCol].Value); HSourceBillTypeID = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[HSourceBillTypeIDCol].Value); HSourceBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[HSourceBillNoCol].Value); if (HSelInterID > 0 && HSelEntryID > 0) { OKTag = 1; this.Visible = false; } else { MessageBox.Show("选择了错误的行,清选择一行!"); return; } } //退出 private void btnTC_Click(object sender, EventArgs e) { OKTag = 0; this.Visible = false; } //双击列表 private void grdMain_DoubleClick(object sender, EventArgs e) { } private void txtHBarCode_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Return) { initGrid(); Display(); txtHBarCode.Focus(); txtHBarCode.SelectAll(); } } private void grdMain_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e) { if (e.RowIndex < grdMain.Rows.Count) { DataGridViewRow dgrSingle = grdMain.Rows[e.RowIndex]; try { var rowIndex = DBUtility.Xt_BaseBillFun.Fun_GetCol("未生成条码数量", grdMain); if (dgrSingle.Cells[rowIndex].Value == null) return; var passNumStr = dgrSingle.Cells[rowIndex].Value.ToString().Trim();//获取数量 var totalNumStr = dgrSingle.Cells[rowIndex-2].Value.ToString().Trim();//获取数量 if (string.IsNullOrEmpty(passNumStr)) return; if (decimal.Parse(passNumStr) <= 0) { // 设置单元格的背景色 dgrSingle.DefaultCellStyle.BackColor = Color.Green; } else if(decimal.Parse(passNumStr)>0&& decimal.Parse(passNumStr)