using Stone.Common; using Stone.WinBiz.ProductionPlan; using Stone.WinBiz.SystemData; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Stone.WinModule.ProductionPlan { public partial class frmPlanRelease : Stone.WinModule.frmBase { private string CarModelCode = ""; private DataTable dtData = null; private DataTable dtAll = null; public frmPlanRelease() { InitializeComponent(); } private void frmPlanRelease_Load(object sender, EventArgs e) { } private void tlbOutPut_Click(object sender, EventArgs e) { try { Stone.Common.MyExport.ShowExport(this.dgrdView); } catch (Exception ex) { MyMessageBox.ShowErrorMessage(ex.Message); } } private void btnSerach_Click(object sender, EventArgs e) { try { UpdateLeft(); } catch (Exception ex) { MyMessageBox.ShowErrorMessage(ex.Message); } } private void dgrdLeft_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) return; if (dgrdLeft.Rows.Count == 0) throw new Exception("当前没有数据"); CarModelCode = dgrdLeft.Rows[e.RowIndex].Cells["CarModelCode"].Value.ToString(); UpdateGrid(); } catch (Exception ex) { MyMessageBox.ShowErrorMessage(ex.Message); } } private void UpdateLeft() { string date1 = this.txtD1.Value.ToString("yyyy-MM-dd 00:00:00"); string date2 = this.txtD2.Value.ToString("yyyy-MM-dd 23:59:59"); string sql = $@" select CarModelCode, COUNT(*) as c from t_Edi_Planned where IsMajor=1 and time>='{date1}' and time<='{date2}' and [lineStationCode]='D3ASJIS01' and [PartType]='02' group by CarModelCode order by CarModelCode asc "; DataSet dsData = F_EDI.GetData(sql); this.dgrdLeft.DataSource = dsData.Tables[0]; this.dgrdLeft.Columns["CarModelCode"].HeaderText = "车型"; this.dgrdLeft.Columns["c"].HeaderText = "数量"; MyGridViewStyle.GetGridViewState(this.dgrdView, this.Text); MyGridViewStyle.SetDataGridRowNumber(this.dgrdView); this.lblStateRecord.Text = "记录数:" + dsData.Tables[0].Rows.Count; } private void UpdateGrid() { string date1 = this.txtD1.Value.ToString("yyyy-MM-dd 00:00:00"); string date2 = this.txtD2.Value.ToString("yyyy-MM-dd 23:59:59"); string sql = $@" select time, vehicleModelCode, productionNumber, itemNumber, description, quantity, sequenceNumber, assemblyDate, partType, CarModelCode from t_Edi_Planned where IsMajor=1 and [CarModelCode]='{CarModelCode}' and time>='{date1}' and time<='{date2}' and [lineStationCode]='D3ASJIS01' and [PartType]='02' order by assemblyDate asc "; dtData = F_EDI.GetData(sql).Tables[0]; sql = $"select * from t_Edi_Planned where [CarModelCode]='{CarModelCode}' and time>='{date1}' and time<='{date2}' and [lineStationCode]='D3ASJIS01' and [PartType]='02' order by assemblyDate asc"; dtAll = F_EDI.GetData(sql).Tables[0]; this.dgrdView.DataSource = dtData; this.dgrdView.Columns["time"].HeaderText = "EDI时间"; this.dgrdView.Columns["vehicleModelCode"].HeaderText = "车型代码"; this.dgrdView.Columns["productionNumber"].HeaderText = "生产号"; this.dgrdView.Columns["itemNumber"].HeaderText = "零件号"; this.dgrdView.Columns["description"].HeaderText = "描述"; this.dgrdView.Columns["quantity"].HeaderText = "数量"; this.dgrdView.Columns["sequenceNumber"].HeaderText = "排序号"; this.dgrdView.Columns["assemblyDate"].HeaderText = "要货时间"; this.dgrdView.Columns["partType"].HeaderText = "零件类型"; this.dgrdView.Columns["CarModelCode"].HeaderText = "车型"; MyGridViewStyle.GetGridViewState(this.dgrdView, this.Text); MyGridViewStyle.SetDataGridRowNumber(this.dgrdView); this.lblStateRecord.Text = "记录数:" + dtData.Rows.Count; } private void frmPlanRelease_FormClosing(object sender, FormClosingEventArgs e) { if(this.dgrdView.DataSource != null) { MyGridViewStyle.SaveGridViewState(this.dgrdView, this.Text); } } private void tlbRelease_Click(object sender, EventArgs e) { this.tlbRelease.Enabled = false; this.Update(); try { if (this.dgrdView.Rows.Count == 0) throw new Exception("当前没有数据"); if(MyMessageBox.ShowQuestion($"是否要发布 {this.dgrdView.Rows.Count} 条记录?")) { DataTable dtData = (DataTable)this.dgrdView.DataSource; F_Plan.ReleasePlan(dtData, dtAll); MyMessageBox.ShowInfoMessage("发布成功"); } } catch (Exception ex) { MyMessageBox.ShowErrorMessage(ex.Message); } finally { this.tlbRelease.Enabled = true; } } } }