private void 扣水扣杂ToolStripMenuItem_Click(object sender, EventArgs e) { QC_SampleMix_ZhiYang selectedmix = this.qCSampleMixZhiYangBindingSource.Current as QC_SampleMix_ZhiYang; if (selectedmix != null) { koushuikouza form = new koushuikouza(selectedmix.MainSampleMixId, selectedmix.ZyDanHao); form.Show(); } else { MessageBox.Show("请选择制样单!"); } }
private void 制样_Click(object sender, EventArgs e) { if (!comboBox1.Text.StartsWith("RJ")) { MessageBox.Show("请选择正确单号"); return; } DbEntityTable <QC_Sample_Mix> mix = new DbEntityTable <QC_Sample_Mix>(); int mixid = 100000000; mix.LoadDataByWhere("main.CardID=@CardID", QC_Sample_Mix.FullStoreCode(comboBox1.Text)); if (mix.Count > 0) { mixid = mix[0].Sample_Mix_ID; } QC_SampleMix_ZhiYang zySample = QC_SampleMix_ZhiYang.GetById(mixid); if (zySample == null) { MessageBox.Show("找不到单据"); return; } if (zySample.SampleState < SampleState.组批完成) { MessageBox.Show("磁卡所对大桶还未组批完成"); return; } if (zySample.WLLX != "熔剂") { MessageBox.Show("物料不是熔剂请选择其他制样点"); return; } zySample.ZyDanHao = mix[0].CardID; zySample.SampleState = SampleState.开始制样; zySample.ZyWpCode = workpointCode; zySample.ZyRecvUser = LocalInfo.Current.user.ID; zySample.ZyRecvTime = DateTime.Now; if (zySample.SampleType == SampleType.普通样 || zySample.SampleType == SampleType.破包样) { DbEntityTable <QC_MatAllCheckItem> bjCheckItem = new DbEntityTable <QC_MatAllCheckItem>(); bjCheckItem.LoadDataByWhere("MATNCID=@MATNCID and JYLX='必检'", zySample.MatPK); foreach (var stdCheckItem in bjCheckItem) { QC_MixCheckItem ckItem = zySample.CheckItems.FirstOrDefault <QC_MixCheckItem>((ck) => ck.CheckItemNcId == stdCheckItem.CheckItemNcId); if (ckItem == null) { QC_MixCheckItem item = new QC_MixCheckItem(); item.CheckItemNcId = stdCheckItem.CheckItemNcId; item.CheckItemCode = stdCheckItem.CheckItemCode; item.CheckItemName = stdCheckItem.CheckItemName; item.CheckItemUnit = stdCheckItem.CheckItemUnit; item.CheckGroupCode = stdCheckItem.CheckGroupCode; item.CheckGroupName = stdCheckItem.CheckGroupName; item.CheckGroupType = stdCheckItem.CheckGroupType; item.CkgShortWord = stdCheckItem.CkgShortWord; item.Sample_Mix_ID = item.Sample_Mix_ID; item.CheckGroupVisIdx = stdCheckItem.CheckGroupVisIdx; item.Source = "检验标准-必检"; zySample.CheckItems.Add(item); } } DbEntityTable <QC_MatAllCheckItem> myCheckItem = new DbEntityTable <QC_MatAllCheckItem>(); myCheckItem.LoadDataByWhere("MATNCID=@MATNCID and JYLX='每月'", zySample.MatPK); DateTime yue = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); foreach (var stdCheckItem in myCheckItem) { object cntObj = DbContext.ExecuteScalar("SELECT count(*) FROM QC_MixCheckItem mck inner join qc_sample_mix mix on mix.SAMPLE_MIX_ID=mck.SAMPLE_MIX_ID where mix.Mix_Time>=@MixTime and mix.SampleType=" + (int)SampleType.普通样 + " and mix.SupplierCode=@SupplierCode and mix.MatPK=@MatPK and mck.CheckItemNcId=@CheckItemNcId", yue, zySample.SupplierCode, zySample.MatPK, stdCheckItem.CheckItemNcId); if (cntObj != null) { int cnt = Convert.ToInt32(cntObj); if (cnt == 0) { QC_MixCheckItem ckItem = zySample.CheckItems.FirstOrDefault <QC_MixCheckItem>((ck) => ck.CheckItemNcId == stdCheckItem.CheckItemNcId); if (ckItem == null) { QC_MixCheckItem item = new QC_MixCheckItem(); item.CheckItemNcId = stdCheckItem.CheckItemNcId; item.CheckItemCode = stdCheckItem.CheckItemCode; item.CheckItemName = stdCheckItem.CheckItemName; item.CheckItemUnit = stdCheckItem.CheckItemUnit; item.CheckGroupCode = stdCheckItem.CheckGroupCode; item.CheckGroupName = stdCheckItem.CheckGroupName; item.CheckGroupType = stdCheckItem.CheckGroupType; item.CkgShortWord = stdCheckItem.CkgShortWord; item.Sample_Mix_ID = item.Sample_Mix_ID; item.CheckGroupVisIdx = stdCheckItem.CheckGroupVisIdx; item.Source = "检验标准-每月"; zySample.CheckItems.Add(item); } } } } int wd2 = (int)DateTime.Now.DayOfWeek - 1; if (wd2 == -1) { wd2 = 6; } DateTime zhou1 = DateTime.Today.AddDays(0 - wd2); DbEntityTable <QC_MatAllCheckItem> meizhouCheckItem = new DbEntityTable <QC_MatAllCheckItem>(); meizhouCheckItem.LoadDataByWhere("MATNCID=@MATNCID and JYLX='每周'", zySample.MatPK); foreach (var stdCheckItem in meizhouCheckItem) { object cntObj = DbContext.ExecuteScalar("SELECT count(*) FROM QC_MixCheckItem mck inner join qc_sample_mix mix on mix.SAMPLE_MIX_ID=mck.SAMPLE_MIX_ID where mix.Mix_Time>=@MixTime and mix.SampleType=" + (int)SampleType.普通样 + " and mix.SupplierCode=@SupplierCode and mix.MatPK=@MatPK and mck.CheckItemNcId=@CheckItemNcId", zhou1, zySample.SupplierCode, zySample.MatPK, stdCheckItem.CheckItemNcId); if (cntObj != null) { int cnt = Convert.ToInt32(cntObj); if (cnt == 0) { QC_MixCheckItem ckItem = zySample.CheckItems.FirstOrDefault <QC_MixCheckItem>((ck) => ck.CheckItemNcId == stdCheckItem.CheckItemNcId); if (ckItem == null) { QC_MixCheckItem item = new QC_MixCheckItem(); item.CheckItemNcId = stdCheckItem.CheckItemNcId; item.CheckItemCode = stdCheckItem.CheckItemCode; item.CheckItemName = stdCheckItem.CheckItemName; item.CheckItemUnit = stdCheckItem.CheckItemUnit; item.CheckGroupCode = stdCheckItem.CheckGroupCode; item.CheckGroupName = stdCheckItem.CheckGroupName; item.CheckGroupType = stdCheckItem.CheckGroupType; item.CkgShortWord = stdCheckItem.CkgShortWord; item.Sample_Mix_ID = item.Sample_Mix_ID; item.CheckGroupVisIdx = stdCheckItem.CheckGroupVisIdx; item.Source = "检验标准-每周"; zySample.CheckItems.Add(item); } } } } DateTime tian1 = DateTime.Today; DbEntityTable <QC_MatAllCheckItem> meitianCheckItem = new DbEntityTable <QC_MatAllCheckItem>(); meizhouCheckItem.LoadDataByWhere("MATNCID=@MATNCID and JYLX='每天'", zySample.MatPK); foreach (var stdCheckItem in meizhouCheckItem) { object cntObj = DbContext.ExecuteScalar("SELECT count(*) FROM QC_MixCheckItem mck inner join qc_sample_mix mix on mix.SAMPLE_MIX_ID=mck.SAMPLE_MIX_ID where mix.Mix_Time>=@MixTime and mix.SampleType=" + (int)SampleType.普通样 + " and mix.SupplierCode=@SupplierCode and mix.MatPK=@MatPK and mck.CheckItemNcId=@CheckItemNcId", tian1, zySample.SupplierCode, zySample.MatPK, stdCheckItem.CheckItemNcId); if (cntObj != null) { int cnt = Convert.ToInt32(cntObj); if (cnt == 0) { QC_MixCheckItem ckItem = zySample.CheckItems.FirstOrDefault <QC_MixCheckItem>((ck) => ck.CheckItemNcId == stdCheckItem.CheckItemNcId); if (ckItem == null) { QC_MixCheckItem item = new QC_MixCheckItem(); item.CheckItemNcId = stdCheckItem.CheckItemNcId; item.CheckItemCode = stdCheckItem.CheckItemCode; item.CheckItemName = stdCheckItem.CheckItemName; item.CheckItemUnit = stdCheckItem.CheckItemUnit; item.CheckGroupCode = stdCheckItem.CheckGroupCode; item.CheckGroupName = stdCheckItem.CheckGroupName; item.CheckGroupType = stdCheckItem.CheckGroupType; item.CkgShortWord = stdCheckItem.CkgShortWord; item.Sample_Mix_ID = item.Sample_Mix_ID; item.CheckGroupVisIdx = stdCheckItem.CheckGroupVisIdx; item.Source = "检验标准-每天"; zySample.CheckItems.Add(item); } } } } } else if (zySample.SampleType == SampleType.校验样) { //加载校验样项目 QC_MixCheckItem_Table table = new QC_MixCheckItem_Table(); table.LoadDataByWhere("main.SAMPLE_VEH_ID=(select SAMPLE_VEH_ID from QC_Sample_Veh veh where veh.SAMPLE_MIX_ID=@SAMPLE_MIX_ID)", zySample.Sample_Mix_ID); foreach (var item in table) { item.Sample_Mix_ID = zySample.Sample_Mix_ID; item.Source = "校验样"; zySample.CheckItems.Add(item); } //DbContext.ExeSql("update t1 set t1.SAMPLE_MIX_ID =(select SAMPLE_MIX_ID from QC_Sample_Veh t2 where t2.SAMPLE_VEH_ID=t1.SAMPLE_VEH_ID) from QC_MIXCHECKITEM t1 where ISnull(t1.SAMPLE_VEH_ID,0)>0 and ISnull(t1.SAMPLE_MIX_ID,0)<=0"); } //生成样品分类 foreach (var item in zySample.CheckItems) { QC_MixCheckGroup mixCG = zySample.CheckGroups.FirstOrDefault <QC_MixCheckGroup>((mcg) => mcg.CheckGroupCode == item.CheckGroupCode); if (mixCG == null) { mixCG = new QC_MixCheckGroup(); mixCG.CheckGroupCode = item.CheckGroupCode; mixCG.CheckGroupName = item.CheckGroupName; mixCG.CheckGroupType = item.CheckGroupType; mixCG.CkgShortWord = item.CkgShortWord; mixCG.VisIdx = item.CheckGroupVisIdx; mixCG.StoreCode = zySample.ZyDanHao + item.CkgShortWord; mixCG.MatPK = zySample.MatPK; mixCG.SupplierCode = zySample.SupplierCode; mixCG.Sample_TBZD = zySample.Sample_TBZD; mixCG.Sample_Mix_ID = zySample.Sample_Mix_ID; mixCG.ZySample = zySample; zySample.CheckGroups.Add(mixCG); } mixCG.MixCheckItem.Add(item); } //加载物料设置样品分类 DbEntityTable <QC_MatCheckGroup> MatCheckGroup = new DbEntityTable <QC_MatCheckGroup>(); MatCheckGroup.LoadDataByWhere("MatNcId=@MatNcId", zySample.MatPK); for (int i = 0; i < MatCheckGroup.Count; i++) { QC_MixCheckGroup item = new QC_MixCheckGroup(); item.CheckGroupCode = MatCheckGroup[i].CheckGroupCode; item.CheckGroupName = MatCheckGroup[i].CheckGroupName; item.CheckGroupType = MatCheckGroup[i].CheckGroupType; item.CkgShortWord = MatCheckGroup[i].ShortWord; item.VisIdx = MatCheckGroup[i].CheckGroupVisIdx; item.StoreCode = zySample.ZyDanHao + MatCheckGroup[i].ShortWord; item.MatPK = zySample.MatPK; item.SupplierCode = zySample.SupplierCode; item.Sample_TBZD = zySample.Sample_TBZD; item.Sample_Mix_ID = zySample.Sample_Mix_ID; item.ZySample = zySample; zySample.CheckGroups.Add(item); } zySample.CheckGroups.Sort((tx, ty) => tx.VisIdx.CompareTo(ty.VisIdx)); foreach (var item in zySample.CheckGroups) { item.MatPK = zySample.MatPK; item.SupplierCode = zySample.SupplierCode; item.Sample_TBZD = zySample.Sample_TBZD; item.ZySample = zySample; item.Billtype = "未绑定样品扣"; item.LabState = "制样"; } zySample.SaveCheckGroups = true; zySample.SaveCheckItems = true; zySample.Save(); //生成Lab foreach (var ckg in zySample.CheckGroups) { if (!ckg.CheckGroupName.Contains("角质层") && (ckg.CheckGroupType == "立刻检验" || ckg.CheckGroupType == "后续检验")) { QC_Sample_Lab lb = new QC_Sample_Lab(); lb.MixCheckGroup.Add(ckg); lb.StoreCode = ckg.StoreCode; lb.WpCode = workpointCode; lb.Billtype = "未绑定样品扣"; lb.LabState = "制样"; lb.WLLX = zySample.WLLX; lb.CheckGroupCode = ckg.CheckGroupCode; lb.CheckGroupName = ckg.CheckGroupName; lb.CheckGroupType = ckg.CheckGroupType; lb.Sample_Mix_ID = ckg.Sample_Mix_ID; foreach (var ck in ckg.MixCheckItem) { QC_Sample_Value qcVal = new QC_Sample_Value(); qcVal.CheckItemNcId = ck.CheckItemNcId; qcVal.CheckItemCode = ck.CheckItemCode; qcVal.CheckItemName = ck.CheckItemName; qcVal.ActualVal = ck.ActualVal; lb.CheckVals.Add(qcVal); } lb.SaveCheckVals = true; zyMixSamples.LabTable.Add(lb); } } zyMixSamples.LabTable.Save(); zyMixSamples.Add(zySample); //lblRecvDanHao.Text = zySample.ZyShortDanHao; this.gridView1.FocusedRowHandle = this.gridView1.GetRowHandle(zyMixSamples.Count - 1); LabTabs(); rjmixs.LoadDataByWhere("main.SAMPLESTATE=@SAMPLESTATE and main.WLLX='熔剂'", SampleState.组批完成); comboBox1.Items.Clear(); foreach (var item in rjmixs) { comboBox1.Items.Add(QC_Sample_Mix.ShortStoreCode(item.CardID)); } this.printDocument1.Print(); }
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { //int curRow = 0; QC_SampleMix_ZhiYang zySample = this.qCSampleMixZhiYangBindingSource.Current as QC_SampleMix_ZhiYang; if (zySample != null && zySample.CheckGroups.Count > 0) { int printPage = zySample.CheckGroups.Count - curZyPrintPage; if (printPage >= 0 && printPage < zySample.CheckGroups.Count) { var item = zySample.CheckGroups[printPage]; string head = item.ShortStoreCode; string body = item.CheckGroupName; string riqi = zySample.ZyRecvTime == null ? "" : zySample.ZyRecvTime.Value.ToString("yyyyMM"); if (zySample.SampleType == SampleType.抽查样) { riqi += "(抽样)"; } Font f1 = new System.Drawing.Font("宋体", 21, FontStyle.Bold); SizeF headSize = e.Graphics.MeasureString(head, f1); Font f2 = new System.Drawing.Font("宋体", 12f, FontStyle.Bold); SizeF bodySize = e.Graphics.MeasureString(body, f2); Font f3 = new System.Drawing.Font("宋体", 12f, FontStyle.Bold); SizeF riqiSize = e.Graphics.MeasureString(riqi, f2); Rectangle rect = new Rectangle(9, 3, 112, 94); // e.Graphics.DrawRectangle(Pens.Black, rect); float topMargin = rect.Top + (rect.Height - headSize.Height - bodySize.Height - riqiSize.Height - 6) / 2; float leftMargin = rect.Left + (rect.Width - headSize.Width) / 2; e.Graphics.DrawString(head, f1, Brushes.Black, new PointF(leftMargin, topMargin)); float topMargin2 = topMargin + Math.Max(headSize.Height + 3, 12); float leftMargin2 = rect.Left + (rect.Width - bodySize.Width) / 2; e.Graphics.DrawString(body, f2, Brushes.Black, new PointF(leftMargin2, topMargin2)); float topMargin3 = topMargin2 + Math.Max(bodySize.Height + 2, 12); float leftMargin3 = rect.Left + (rect.Width - riqiSize.Width) / 2; e.Graphics.DrawString(riqi, f2, Brushes.Black, new PointF(leftMargin3, topMargin3)); } if (curZyPrintPage < zySample.CheckGroups.Count) { e.HasMorePages = true; curZyPrintPage++; } else { e.HasMorePages = false; curZyPrintPage = 1; } } else { e.HasMorePages = false; curZyPrintPage = 1; } }
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { //int curRow = 0; QC_SampleMix_ZhiYang zySample = this.qCSampleMixZhiYangBindingSource.Current as QC_SampleMix_ZhiYang; if (zySample != null && zySample.CheckGroups.Count > 0) { int printPage = zySample.CheckGroups.Count - curZyPrintPage; if (printPage >= 0 && printPage < zySample.CheckGroups.Count) { var item = zySample.CheckGroups[printPage]; string head = item.ShortStoreCode; string body = item.CheckGroupName; string riqi = zySample.ZyRecvTime == null ? "" : zySample.ZyRecvTime.Value.ToString("yyyyMM"); if (zySample.SampleType == SampleType.抽查样) { riqi += "(抽样)"; } DbEntityTable <QC_Material> mat = new DbEntityTable <QC_Material>(); mat.LoadDataByWhere("main.MatNcId=@MatNcId", zySample.MatPK); if (item.CheckGroupName == "大样留存样" && mat.Count == 1) { if (mat[0].MatCode == "13314") { riqi = riqi + mat[0].MatName + "-06"; } else if (mat[0].MatCode == "13316") { riqi = riqi + mat[0].MatName + "-05"; } else if (mat[0].MatCode == "13317") { riqi = riqi + mat[0].MatName + "-01"; } else if (mat[0].MatCode == "13318") { riqi = riqi + mat[0].MatName + "-02"; } else if (mat[0].MatCode == "13321") { riqi = riqi + mat[0].MatName + "-04"; } else if (mat[0].MatCode == "13331") { riqi = riqi + mat[0].MatName + "-03"; } else if (mat[0].MatCode == "13332") { riqi = riqi + mat[0].MatName + "-07"; } else if (mat[0].MatCode == "12612") { riqi = riqi + mat[0].MatName + "-01"; } else if (mat[0].MatCode == "12613") { riqi = riqi + mat[0].MatName + "-02"; } else if (mat[0].MatCode == "12614") { riqi = riqi + mat[0].MatName + "-03"; } else if (mat[0].MatCode == "12615") { riqi = riqi + mat[0].MatName + "-04"; } else if (mat[0].MatCode == "12616") { riqi = riqi + mat[0].MatName + "-05"; } else if (mat[0].MatCode == "12619") { riqi = riqi + mat[0].MatName + "-06"; } else { riqi = riqi + mat[0].MatName; } } Font f1 = new System.Drawing.Font("宋体", 21, FontStyle.Bold); SizeF headSize = e.Graphics.MeasureString(head, f1); Font f2 = new System.Drawing.Font("宋体", 12f, FontStyle.Bold); SizeF bodySize = e.Graphics.MeasureString(body, f2); Font f3 = new System.Drawing.Font("宋体", 12f, FontStyle.Bold); SizeF riqiSize = e.Graphics.MeasureString(riqi, f2); Rectangle rect = new Rectangle(9, 3, 112, 94); // e.Graphics.DrawRectangle(Pens.Black, rect); float topMargin = rect.Top + (rect.Height - headSize.Height - bodySize.Height - riqiSize.Height - 6) / 2; float leftMargin = rect.Left + (rect.Width - headSize.Width) / 2; e.Graphics.DrawString(head, f1, Brushes.Black, new PointF(leftMargin, topMargin)); float topMargin2 = topMargin + Math.Max(headSize.Height + 3, 12); float leftMargin2 = rect.Left + (rect.Width - bodySize.Width) / 2; e.Graphics.DrawString(body, f2, Brushes.Black, new PointF(leftMargin2, topMargin2)); float topMargin3 = topMargin2 + Math.Max(bodySize.Height + 2, 12); float leftMargin3 = rect.Left + (rect.Width - riqiSize.Width) / 2; e.Graphics.DrawString(riqi, f2, Brushes.Black, new PointF(leftMargin3, topMargin3)); } if (curZyPrintPage < zySample.CheckGroups.Count) { e.HasMorePages = true; curZyPrintPage++; } else { e.HasMorePages = false; curZyPrintPage = 1; } } else { e.HasMorePages = false; curZyPrintPage = 1; } }