using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Stone.Common; using Stone.Entity; using Stone.WinBiz.JISAdmin; namespace Stone.WinModule.JISAdmin.ReOrder { public partial class frmEdiPrintReOrderAssemble : Stone.WinModule.frmBase { public frmEdiPrintReOrderAssemble() { InitializeComponent(); } private void frmEdiPrintReOrderAssemble_Load(object sender, EventArgs e) { this.cbFields.SelectedIndex = 0; this.timer1.Interval = Convert.ToInt32(MyAppconfig.ReadValue("EDI显示刷新时间")) * 1000; this.timer1.Enabled = true; } private void btnQuery_Click(object sender, EventArgs e) { try { string Fields = this.cbFields.SelectedItem.ToString(); string value = this.txtKey.Text.Trim(); string d1 = MyDateTime.Format(this.dateTimePicker1.Value, MyDateTimeType.Date) + " 00:00:00"; string d2 = MyDateTime.Format(this.dateTimePicker2.Value, MyDateTimeType.Date) + " 23:59:59"; string strWhere = "[IsPrintAssemble]={0} and [SwetTime]>='{1}' and [SwetTime]<='{2}' {3}"; object[] obj = new object[10]; obj[0] = rbPrint1.Checked ? "1" : "0"; obj[1] = d1; obj[2] = d2; obj[3] = " and " + Fields + "='" + value + "'"; if (value == "") obj[3] = ""; strWhere = string.Format(strWhere, obj); Entity_t_JIS_Seq5000_ReOrder t_JIS_Seq5000_ReOrder = new Entity_t_JIS_Seq5000_ReOrder(); this.dgrdView1.DataSource = t_JIS_Seq5000_ReOrder.GetData("", strWhere, "[SwetTime], [SequenceNumber] asc").Tables[0]; MyGridViewStyle.SetDataGridRowNumber(this.dgrdView1); MyGridViewStyle.SetDataGridMenuCommon(this.dgrdView1); MyGridViewStyle.GetGridViewState(this.dgrdView1, "ReOrderJIS装配单"); this.dgrdView1.Columns["ID"].Visible = false; this.dgrdView1.Columns["SequenceNumber"].HeaderText = "EINSTEIN Seq"; this.lblState.Text = "记录:" + this.dgrdView1.Rows.Count.ToString(); } catch (Exception ex) { this.lblShow.Text = ex.Message; } } private void btnRePrint_Click(object sender, EventArgs e) { try { if (!MyMessageBox.ShowQuestion("是否要补打装配单?")) return; if (this.dgrdView1.SelectedRows.Count == 0) throw new Exception("请选择需要补打的多条记录!"); string ids = ""; for (int i = 0; i < this.dgrdView1.SelectedRows.Count; i++) { ids += this.dgrdView1.SelectedRows[i].Cells["ID"].Value.ToString() + ","; } if (ids.Length > 0) ids = ids.Substring(0, ids.Length - 1); string strWhere = "[ID] in (" + ids + ")"; Entity_t_JIS_Seq5000_ReOrder t_JIS_Seq5000_ReOrder = new Entity_t_JIS_Seq5000_ReOrder(); DataSet dsData = t_JIS_Seq5000_ReOrder.GetData("", strWhere, "[SwetTime], [SequenceNumber] ASC"); if (dsData.Tables[0].Select("[IsPrintAssemble]=0").Length > 0) throw new Exception("没有可打印的数据"); dsData.Tables[0].TableName = "BillHead"; F_JIS5000_Print_ReOrder.PrintAssembly(dsData); btnQuery_Click(new object(), new EventArgs()); } catch (Exception ex) { MyMessageBox.ShowErrorMessage(ex.Message); } } private void btnPrintLabel_Click(object sender, EventArgs e) { try { if (!MyMessageBox.ShowQuestion("是否要补打零件标签?")) return; if (this.dgrdView1.SelectedRows.Count == 0) throw new Exception("请选择需要补打的多条记录!"); string ids = ""; for (int i = 0; i < this.dgrdView1.SelectedRows.Count; i++) { ids += this.dgrdView1.SelectedRows[i].Cells["ID"].Value.ToString() + ","; } if (ids.Length > 0) ids = ids.Substring(0, ids.Length - 1); string strWhere = "[ID] in (" + ids + ")"; Entity_t_JIS_Seq5000_ReOrder t_JIS_Seq5000_ReOrder = new Entity_t_JIS_Seq5000_ReOrder(); DataSet dsData = t_JIS_Seq5000_ReOrder.GetData("", strWhere, "[SwetTime],[SequenceNumber] ASC"); if (dsData.Tables[0].Select("[IsPrintAssemble]=0").Length > 0) throw new Exception("没有可打印的数据"); dsData.Tables[0].TableName = "BillHead"; F_JIS5000_Print_ReOrder.PrintAssemblyLabel(dsData); btnQuery_Click(new object(), new EventArgs()); } catch (Exception ex) { MyMessageBox.ShowErrorMessage(ex.Message); } } private void btnSet_Click(object sender, EventArgs e) { MyGridViewStyle.Show(this.dgrdView1, "ReOrderJIS装配单"); } private void btnOutPut_Click(object sender, EventArgs e) { try { Stone.Common.MyExport.ShowExport(this.dgrdView1); } catch (Exception ex) { MyMessageBox.ShowInfoMessage(ex.Message); } } private void chkAuto_CheckedChanged(object sender, EventArgs e) { AutoUpdate(); } private void timer1_Tick(object sender, EventArgs e) { AutoUpdate(); } private void AutoUpdate() { if (chkAuto.Checked) { this.lblShow.Text = "自动刷新中..."; this.Update(); btnQuery_Click(new object(), new EventArgs()); this.lblShow.Text = DateTime.Now.ToString() + " 自动刷新完成,下次刷新 " + Convert.ToString(this.timer1.Interval / 1000) + " 秒以后"; } else { this.lblShow.Text = "自动刷新关闭"; } } private void btnInsert_Click(object sender, EventArgs e) { try { if (this.dgrdView1.SelectedRows.Count == 0) throw new Exception("请选择一条要插单的记录!"); if (!MyMessageBox.ShowQuestion("是否要线下插单?")) return; string ID = this.dgrdView1.SelectedRows[0].Cells["ID"].Value.ToString(); Entity_t_JIS_Seq5000_ReOrder t_JIS_Seq5000_ReOrder = new Entity_t_JIS_Seq5000_ReOrder(); DataSet dsData = t_JIS_Seq5000_ReOrder.GetData("[ID]=" + ID); if (dsData.Tables[0].Rows.Count == 0) { throw new Exception("插单的记录不存在"); } if (Convert.ToInt32(dsData.Tables[0].Rows[0]["IsAssemble"]) == 0) { throw new Exception("只有装配完成的才能线下插单"); } Gm_WMS.DataAccess.DataService.LocalDBService db = new Gm_WMS.DataAccess.DataService.LocalDBService(); db.Exec_NonQuery("UPDATE t_JIS_Seq5000_ReOrder SET [IsInsert]=1, [IsPrintAssemble]=0, [IsAssemble]=0, [IsTransport]=0 WHERE [ID]=" + ID); btnQuery_Click(new object(), new EventArgs()); MyMessageBox.ShowInfoMessage("插单完成"); } catch (Exception ex) { MyMessageBox.ShowErrorMessage(ex.Message); } } } }