private void 查询_Click(object sender, EventArgs e) { string storecode = textBox1.Text.Trim(); if (!string.IsNullOrEmpty(storecode)) { bool find = false; string jydh = QC_Sample_Mix.FullStoreCode(storecode); foreach (var item in this.lableiji) { if (item.JyCode == jydh) { this.curLab = item; find = true; break; } } if (find == false) { MessageBox.Show("未查到数据"); } // curLab.CheckVals.LoadDataByWhere("main.Sample_Lab_ID=@Sample_Lab_ID", curLab.Sample_Lab_ID); SetGridViewFocuse(); } }
private void _Click(object sender, EventArgs e) { int i = 0; StringBuilder sb = new StringBuilder(); try { foreach (var item in test) { if (item.Shangchuan) { hyy.LoadDataByWhere("JyCode=@JyCode", QC_Sample_Mix.FullStoreCode(item.SampleName)); if (hyy.Count > 0) { vals.LoadDataByWhere("main.Sample_Lab_ID=@Sample_Lab_ID", hyy[0].Sample_Lab_ID); if (vals.Count > 0) { foreach (var it in vals) { if (it.CheckItemName == item.CheckItemName && (it.CheckVal == "" || it.CheckVal == null)) { it.CheckVal = item.Value; item.Shangchuan = true; i++; sb.Append("单号:" + item.SampleName + "," + "检验项目" + item.CheckItemName + "上传成功"); sb.Append("\r\n"); } } vals.Save(); } } } } test.Save(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } if (i > 0) { MessageBox.Show(i.ToString() + "条数据上传完成" + "\r\n" + sb.ToString()); } else { MessageBox.Show("没有可匹配项目"); } reloadData(); }
private void _Click(object sender, EventArgs e) { int i = 0; foreach (var item in test) { if (item.Shangchuan) { hyy.LoadDataByWhere("JyCode=@JyCode", QC_Sample_Mix.FullStoreCode(item.SampleName)); if (hyy.Count > 0) { vals.LoadDataByWhere("main.Sample_Lab_ID=@Sample_Lab_ID", hyy[0].Sample_Lab_ID); } else { vals.Clear(); } if (vals.Count > 0) { foreach (var it in vals) { if ((it.CheckItemCode == item.CheckItemCode || (it.CheckItemCode == "10120" && item.CheckItemCode == "10002")) && (it.CheckVal == "" || it.CheckVal == null)) { it.CheckVal = item.Value; item.Shangchuan = true; i++; } } } else { item.Shangchuan = false; } } vals.Save(); } test.Save(); if (i > 0) { MessageBox.Show(i.ToString() + "条数据上传完成"); } else { MessageBox.Show("没有可匹配项目"); } }
private void 查询_Click(object sender, EventArgs e) { string storecode = textBox1.Text.Trim(); if (!string.IsNullOrEmpty(storecode)) { string fullCode = QC_Sample_Mix.FullStoreCode(storecode); QC_Sample_Lab sellLab = zyMixSamples.LabTable.FirstOrDefault <QC_Sample_Lab>((lb) => lb.StoreCode == fullCode); if (sellLab != null) { if (xtraTabControl1.SelectedTabPage != null && xtraTabControl1.SelectedTabPage.Text != sellLab.CheckGroupName) { foreach (XtraTabPage tabPage in xtraTabControl1.TabPages) { if (tabPage.Text == sellLab.CheckGroupName) { xtraTabControl1.SelectedTabPage = tabPage; break; } } } int idx = this.labTable.IndexOf(sellLab); this.gridView3.FocusedRowHandle = this.gridView3.GetRowHandle(idx); ; } else { MessageBox.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(); }
/// <summary> /// 绑扣 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button9_Click(object sender, EventArgs e) { if (CardID == "") { MessageBox.Show("请刷扣"); return; } DbEntityTable <QC_IC_Info> hycrds = new DbEntityTable <QC_IC_Info>(); hycrds.LoadDataByWhere("CardID=@CardID and CardType=@CardType ", CardID, "CUT002"); if (hycrds.Count == 0) { CardID = ""; label2.Text = "该扣类型不对!"; label2.ForeColor = Color.Red; return; } var view = gridView2; if (mixDanHao.Count < 1) { MessageBox.Show("没有大样单号!请刷新"); return; } QC_Sample_Mix bill = view.GetFocusedRow() as QC_Sample_Mix; if (bill == null) { MessageBox.Show("没有大样单号!"); return; } bill.CardID = CardID; bill.StoreCode = QC_Sample_Mix.FullStoreCode(bill.StoreCode); IDbConnection conn = DbContext.GetDefaultConnection(); conn.Open(); IDbTransaction trans = conn.BeginTransaction(); bill.Save(trans); foreach (var qcic in hycrds) { qcic.SampleId = bill.Sample_Mix_ID; } hycrds.Save(trans); trans.Commit(); conn.Close(); label2.Text = ""; CardID = ""; //foreach (var item in mixDanHao) //{ // if (item.Sample_Mix_ID == bill.Sample_Mix_ID) // { // item.CardID = CardID; // item.StoreCode = QC_Sample_Mix.FullStoreCode(bill.StoreCode); // break; // } //} //mixDanHao.Save(); initDanHao(); }