/// <summary> /// 登记方法 /// </summary> private void QcInfoAdd() { try { if (lvwUserList.SelectedRows.Count > 0) { int id = Convert.ToInt32(lvwUserList.SelectedRows[0].Cells["DRAW_EXAM_INTERFACE_ID"].Value); StringBuilder sbMessage = new StringBuilder(); int QCInfo_Dictionary_ID = 0; int QCInfo_STATE = 0; var dictionary = DictionaryDAL.Query(); foreach (var m in dictionary) { if (m.Dictionary_Name == "质检中") { QCInfo_Dictionary_ID = m.Dictionary_ID; } if (m.Dictionary_Name == "启动") { QCInfo_STATE = m.Dictionary_ID; //数据状态(启动) } } int irnt = 0; #region ykWarning: 和U9交互 纸种为 LSOP1的不和U9交互 ,测试的时候,可以删除U9交互,发布的时候务必要还原。 //#if !DEBUG string PROD_ID = lvwUserList.SelectedRows[0].Cells["PROD_ID"].Value.ToString(); if (isIdebarJoinU9(PROD_ID)) { DataSet ds = LinQBaseDao.Query("select SHIPMENT_NO,CNTR_NO from dbo.DRAW_EXAM_INTERFACE where DRAW_EXAM_INTERFACE_ID=" + id); if (ds.Tables[0].Rows.Count > 0) { string SHIPMENT_NO = ds.Tables[0].Rows[0][0].ToString(); if (!gainData(SHIPMENT_NO, id)) { string CNTR_NO = ds.Tables[0].Rows[0][0].ToString(); MessageBox.Show(CNTR_NO + "从U9获取数据失败,不能登记!"); return; } } else { MessageBox.Show("登记失败!"); return; } } else { DataSet ds = LinQBaseDao.Query("select SHIPMENT_NO,CNTR_NO from dbo.DRAW_EXAM_INTERFACE where DRAW_EXAM_INTERFACE_ID=" + id); if (ds.Tables[0].Rows.Count > 0) { RegisterLoosePaperDistribution rpdb = new RegisterLoosePaperDistribution(); rpdb.R_DRAW_EXAM_INTERFACE_ID = id; rpdb.issend = false; LinQBaseDao.InsertOne(dc, rpdb); } } //#endif #endregion if (YesNoDengJi(id)) { MessageBox.Show("该信息已登记过", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Bangding_Load(RegistrationWhere());//更新数据 ids.Clear(); return; } var qf = new QCInfo(); qf.QCInfo_Dictionary_ID = QCInfo_Dictionary_ID; qf.QCInfo_STATE = QCInfo_STATE; int k = QCInfoDAL.GetIntDRAWCount(id);//抽样总次数 qf.QCInfo_PumpingPackets = k; #region 周意 规则加上后需要修改 //e ReckonWaterTestCount(qf.QCInfo_ID); qf.QCInfo_UnpackBefore_MOIST_PER_COUNT = OneCQCount + TwoCQCount; qf.QCInfo_UnpackBack_MOIST_COUNT = OneCHCount + TwoCHCount; #endregion qf.QCInfo_DRAW_EXAM_INTERFACE_ID = id; qf.QCInfo_DEGREE = 1; //检测次数 qf.QCInfo_TIME = DateTime.Now; //日期时间 qf.QCInfo_Client_ID = Common.CLIENTID; //客户端配置编号 qf.QCInfo_UserId = EMEWE.Common.Converter.ToInt(Common.USERID); //记录人:当前登录人 //修改抽样表状态 Action <DRAW_EXAM_INTERFACE> ap = n => { //liemrao begin update 20160901 //n.IS_DengJi = Convert.ToChar("Y"); n.IS_DengJi = "Y"; //end update }; Expression <Func <DRAW_EXAM_INTERFACE, bool> > p1 = n => n.DRAW_EXAM_INTERFACE_ID == id; bool rboolDRAW_EXAM_INTERFACEDAL = DRAW_EXAM_INTERFACEDAL.Update(p1, ap); if (rboolDRAW_EXAM_INTERFACEDAL) { if (QCInfoDAL.addQCInfoDAL(qf)) { irnt++; sbMessage.Append(id + ","); Common.WriteLogData("新增", "登记数据抽样编号为:" + id, Common.NAME); //操作日志 #region 抽包 getPackets(qf.QCInfo_ID, id); #endregion } else { //修改抽样表状态 Action <DRAW_EXAM_INTERFACE> ap2 = n => { n.IS_DengJi = null; }; Expression <Func <DRAW_EXAM_INTERFACE, bool> > p2 = n => n.DRAW_EXAM_INTERFACE_ID == id; DRAW_EXAM_INTERFACEDAL.Update(p2, ap2); } } if (!string.IsNullOrEmpty(sbMessage.ToString())) { DialogResult dia = MessageBox.Show("登记数据抽样编号为:" + sbMessage.ToString() + "成功\r\n是否现场抽包?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dia.Equals(DialogResult.Yes)) { tChoosePacks.Enabled = false; ChoosePacks(); tChoosePacks.Enabled = true; } } else//没有选中 { MessageBox.Show("请选择列表再开始质检!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch { MessageBox.Show("登记失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } finally { page = new PageControl(); page.PageMaxCount = tscbxPageSize2.SelectedItem.ToString(); Bangding_Load(RegistrationWhere());//更新数据 } }
private void btn_CarAdd_Click(object sender, EventArgs e) { try { DRAW_EXAM_INTERFACE d = new DRAW_EXAM_INTERFACE(); QCInfo c = new QCInfo(); RegisterLoosePaperDistribution r = new RegisterLoosePaperDistribution(); Packets p = new Packets(); if (txt_SHIPMENT_NO.Text != "") { d.SHIPMENT_NO = txt_SHIPMENT_NO.Text.Trim(); } else { MessageBox.Show("送货单号不能为空"); return; } if (txt_PO_NO.Text != "") { d.PO_NO = txt_PO_NO.Text.Trim(); } else { MessageBox.Show("采购单号不能为空"); return; } if (cmb_PROD_ID.Text != "") { d.PROD_ID = cmb_PROD_ID.Text.Trim(); } else { MessageBox.Show("货品不能为空"); return; } if (txt_CNTR_NO.Text != "") { d.CNTR_NO = txt_CNTR_NO.Text.Trim(); } else { MessageBox.Show("车牌号不能为空"); return; } DataTable dt = LinQBaseDao.Query("select * from Unusualstandard where Unusualstandard_PROD ='" + cmb_PROD_ID.Text.Trim() + "' ").Tables[0]; if (dt != null && dt.Rows.Count > 0) { d.DEGRADE_MATERIAL_PERCT = Convert.ToDecimal(dt.Rows[0]["Unusualstandard_DEGRADE_MATERIAL_PERCT"]); d.DEGRADE_MOISTURE_PERCT = Convert.ToDecimal(dt.Rows[0]["Unusualstandard_DEGRADE_MOISTURE_PERCT"]); d.DEGRADE_OUTTHROWS_PERCT = Convert.ToDecimal(dt.Rows[0]["DEGRADE_OUTTHROWS_PERCT"]); } //过数表填写数据 d.COMPANY_ID = "9"; d.CREATE_DTTM = d.WEIGHT_DATE = DateTime.Now; d.WEIGHT_TICKET_NO = txt_WEIGHT_TICKET_NO.Text.Trim(); d.REF_NO = txt_REF_NO.Text.Trim(); d.NO_OF_BALES = Convert.ToInt32(txtsendNum.Text.Trim()); d.DRAW_ONE = 0; d.DRAW_TWO = 0; d.DRAW_THREE = 0; d.DRAW_FOUR = 0; d.DRAW_FIVE = 0; d.DRAW_SIX = 0; d.DRAW_7 = 0; d.DRAW_8 = 0; d.DRAW_9 = 0; d.DRAW_10 = 0; d.DRAW_11 = 0; d.DRAW_12 = 0; d.DRAW_13 = 0; d.DRAW_14 = 0; d.IS_FINISHED = "Y"; d.CREATE_BY = Common.USERNAME; //记录人:当前登录人 d.IS_DengJi = "Y"; d.FINISHED_BY = ""; d.FINISHED_DTTM = Convert.ToDateTime("1900 - 01 - 01 00:00:00"); d.RECV_RMA_METHOD = ""; d.TRANS_TO_WPIS_FLAG = "Y"; d.TRANS_TO_WPIS_DTTM = DateTime.Now; d.TRANS_TO_DTS_FLAG = ""; d.TRANS_TO_DTS_DTTM = Convert.ToDateTime("1900 - 01 - 01 00:00:00"); //d.IsSource = "手动"; string[] dtsList = txtchkNum.Text.Split(','); for (int i = 0; i < dtsList.Length; i++) { switch (i) { case 0: d.DRAW_ONE = Convert.ToInt32(dtsList[i]); break; case 1: d.DRAW_TWO = Convert.ToInt32(dtsList[i]); break; case 2: d.DRAW_THREE = Convert.ToInt32(dtsList[i]); break; case 3: d.DRAW_FOUR = Convert.ToInt32(dtsList[i]); break; case 4: d.DRAW_FIVE = Convert.ToInt32(dtsList[i]); break; case 5: d.DRAW_SIX = Convert.ToInt32(dtsList[i]); break; case 6: d.DRAW_7 = Convert.ToInt32(dtsList[i]); break; case 7: d.DRAW_8 = Convert.ToInt32(dtsList[i]); break; case 8: d.DRAW_9 = Convert.ToInt32(dtsList[i]); break; case 9: d.DRAW_10 = Convert.ToInt32(dtsList[i]); break; case 10: d.DRAW_11 = Convert.ToInt32(dtsList[i]); break; case 11: d.DRAW_12 = Convert.ToInt32(dtsList[i]); break; case 12: d.DRAW_13 = Convert.ToInt32(dtsList[i]); break; case 13: d.DRAW_14 = Convert.ToInt32(dtsList[i]); break; } } int result = 0; DRAW_EXAM_INTERFACEDAL.InsertOneCarInfo(d, out result); if (result > 0) { //MessageBox.Show("添加成功!"); //this.Close(); // LoadData(); //查询新增过数ID //质检登记成功填写数据 int result2 = 0; r.OrganizationID = "ChongQingPaper"; r.R_DRAW_EXAM_INTERFACE_ID = result; r.DepartmentCode = txtBuMen_Code.Text.Trim(); r.ExtensionField2 = txtDuiWei_code.Text.Trim(); r.issend = false; RegisterLoosePaperDistributionDAL.InsertOneCarInfo(r, out result2); //质检表填写数据 int result3 = 0; c.QCInfo_Dictionary_ID = 8; c.QCInfo_STATE = 2; c.QCInfo_DEGREE = 1; c.QCInfo_UnpackBefore_MOIST_PER_COUNT = 0; c.QCInfo_UnpackBack_MOIST_COUNT = 0; c.QCInfo_TIME = DateTime.Now; //日期时间 c.QCInfo_Client_ID = Common.CLIENTID; //客户端配置编号 c.QCInfo_UserId = EMEWE.Common.Converter.ToInt(Common.USERID); //记录人:当前登录人 c.QCInfo_DRAW_EXAM_INTERFACE_ID = result; c.QCInfo_PumpingPackets = dtsList.Length; c.QCInfo_DRAW = txtchkNum.Text.Trim(); if (dtsList.Length <= 4) { c.QCInfo_MOIST_Count = dtsList.Length * 8; } else { c.QCInfo_MOIST_Count = 32; } QCInfoDAL.InsertOneCarInfo(c, out result3); if (result > 0) { MessageBox.Show("添加成功!"); int result4 = 0; p.Packets_DTS = txtchkNum.Text.Trim(); p.Packets_this = "1"; p.Packets_QCInfo_DRAW_EXAM_INTERFACE_ID = result; p.Packets_Time = DateTime.Now; PacketsDAL.InsertOneCarInfo(p, out result4); this.Close(); // LoadData(); } } } catch (Exception err) { } }
/// <summary> /// 调用U9接口 /// </summary> /// <param name="DRAW_EXAM_INTERFACE_ID">登记编号</param> /// <param name="QcInfoid">质检编号</param> /// <returns></returns> public static string updataIsU9(int DRAW_EXAM_INTERFACE_ID, string QcInfoid) { try { Expression <Func <DRAW_EXAM_INTERFACE, bool> > funDRAW_EXAM_INTERFACE = n => n.DRAW_EXAM_INTERFACE_ID == DRAW_EXAM_INTERFACE_ID; if (isIdebarJoinU9(DRAW_EXAM_INTERFACEDAL.Query(funDRAW_EXAM_INTERFACE).FirstOrDefault().PROD_ID)) { DataTable issendDT = LinQBaseDao.Query("select issend from RegisterLoosePaperDistribution where R_DRAW_EXAM_INTERFACE_ID=" + DRAW_EXAM_INTERFACE_ID).Tables[0]; if (issendDT.Rows.Count > 0) { object str = issendDT.Rows[0][0]; bool b = Convert.ToBoolean(str); if (!b) { string sql = "select QCInfo_PumpingPackets,QCInfo_BAGWeight,ExtensionField2,QCInfo_ID,SHIPMENT_NO,DepartmentCode from View_QCInfo where QCInfo_ID='" + QcInfoid + "'"; DataSet ds = LinQBaseDao.Query(sql); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { int count = int.Parse(ds.Tables[0].Rows[0]["QCInfo_PumpingPackets"].ToString()); double whiet = Convert.ToDouble(ds.Tables[0].Rows[0]["QCInfo_BAGWeight"].ToString());//重量 string dw = ds.Tables[0].Rows[0]["ExtensionField2"].ToString(); string bd = ds.Tables[0].Rows[0]["QCInfo_ID"].ToString(); string cgd = ds.Tables[0].Rows[0]["SHIPMENT_NO"].ToString(); string bmdm = ds.Tables[0].Rows[0]["DepartmentCode"].ToString(); object CountObj = LinQBaseDao.GetSingle("select count(*) from QCRecord where QCRecord_TestItems_ID=(select TestItems_ID from TestItems where TestItems_NAME='废纸包重') and QCRecord_UPDATE_REASON is NULL and QCRecord_QCInfo_ID=" + QcInfoid); if (count != (int)CountObj) { DialogResult dr = MessageBox.Show("质检信息不一致是否继续发送数据到U9", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Hand); if (dr.Equals(DialogResult.No)) { return("失败"); } } if (count > 0 && whiet > 0 && dw != "" && bd != "" && cgd != "" && bmdm != "") { bool isSend = U9Class.sendDate(count, whiet, dw, bd, cgd, bmdm); if (isSend) { //发送成功修改标识 int result = LinQBaseDao.ExecuteSql("update dbo.RegisterLoosePaperDistribution set issend=1 where R_DRAW_EXAM_INTERFACE_ID=" + DRAW_EXAM_INTERFACE_ID); return(""); } else { return("失败"); } } else { MessageBox.Show("数据不完整无法发送数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Hand); return("失败"); } } } } } } return(""); } catch (Exception err) { return("失败"); } }