private void Btn_Update_Partn_Click(object sender, EventArgs e) { string ERROR = Check_Info(); if (!string.IsNullOrEmpty(ERROR) ) { MessageBox.Show(ERROR, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int flag = 0; if (Txt_RULE_TYPE.Text == "NA") { flag = 0; } else { flag = 1; DataTable New_dt_snRuleInfo = publicfuntion.getNewTable(dt_snRuleInfo, string.Format("RULE_TYPE='{0}'", Txt_RULE_TYPE.Text)); string Change_Total = "将同时修改的料号为:\r\n"; if (New_dt_snRuleInfo.Rows.Count > 1) { foreach (DataRow item in New_dt_snRuleInfo.Rows) { Change_Total += item["PARTNUMBER"] + "\r\n"; } if (MessageBox.Show(Change_Total, "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel) { MessageBox.Show("修改已取消", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } } Dictionary <string, object> Dic = new Dictionary <string, object>(); FrmBLL.publicfuntion.SerializeControl(Dic, tabPage1); Dic.Add("UPCEANDATA", "NA"); Dic.Add("EMP_NO", sInfo.gUserInfo.userId); string Status = refWebtB_SnRule_PartNumber.Instance.UpdateB_SNRULE_PARTNUMBER(ReleaseData.DictionaryToJson(Dic), flag); /* string Status = refWebtB_SnRule_PartNumber.Instance.UpdateB_SNRULE_PARTNUMBER(new WebServices.tB_SnRule_PartNumber.B_SNRULE_PARTNUMBER_Table() * { * BOX_LAB_NAME = string.IsNullOrEmpty(Txt_BOX_LAB_NAME.Text.Trim()) ? "NA" : Txt_BOX_LAB_NAME.Text.Trim(), * CARTON_LAB_NAME = string.IsNullOrEmpty(Txt_CARTON_LAB_NAME.Text.Trim()) ? "NA" : Txt_CARTON_LAB_NAME.Text.Trim(), * CUST_BOX_LENG = int.Parse(string.IsNullOrEmpty(Txt_CUST_BOX_LENG.Text.Trim()) ? "0" : Txt_CUST_BOX_LENG.Text.Trim()), * * CUST_BOX_PREFIX = string.IsNullOrEmpty(Txt_CUST_BOX_PREFIX.Text.Trim()) ? "NA" : Txt_CUST_BOX_PREFIX.Text.Trim(), * CUST_BOX_STR = string.IsNullOrEmpty(Txt_CUST_BOX_STR.Text.Trim()) ? "001" : Txt_CUST_BOX_STR.Text.Trim(), * CUST_CARTON_LENG = int.Parse(string.IsNullOrEmpty(Txt_CUST_CARTON_LENG.Text.Trim()) ? "0" : Txt_CUST_CARTON_LENG.Text.Trim()), * * CUST_CARTON_POSTFIX = string.IsNullOrEmpty(Txt_CUST_CARTON_POSTFIX.Text.Trim()) ? "NA" : Txt_CUST_CARTON_POSTFIX.Text.Trim(), * CUST_CARTON_PREFIX = string.IsNullOrEmpty(Txt_CUST_CARTON_PREFIX.Text.Trim()) ? "NA" : Txt_CUST_CARTON_PREFIX.Text.Trim(), * CUST_CARTON_STR = string.IsNullOrEmpty(Txt_CUST_CARTON_STR.Text.Trim()) ? "001" : Txt_CUST_CARTON_STR.Text.Trim(), * * CUST_LAST_BOX = string.IsNullOrEmpty(Txt_CUST_LAST_BOX.Text.Trim()) ? "001" : Txt_CUST_LAST_BOX.Text.Trim(), * CUST_LAST_CARTON = string.IsNullOrEmpty(Txt_CUST_LAST_CARTON.Text.Trim()) ? "001" : Txt_CUST_LAST_CARTON.Text.Trim(), * CUST_LAST_PALLET = string.IsNullOrEmpty(Txt_CUST_LAST_PALLET.Text.Trim()) ? "001" : Txt_CUST_LAST_PALLET.Text.Trim(), * CUST_LAST_SN = string.IsNullOrEmpty(Txt_CUST_LAST_SN.Text.Trim()) ? "001" : Txt_CUST_LAST_SN.Text.Trim(), * * CUST_PALLET_LENG = int.Parse(string.IsNullOrEmpty(Txt_CUST_PALLET_LENG.Text.Trim()) ? "0" : Txt_CUST_PALLET_LENG.Text.Trim()), * CUST_PALLET_POSTFIX = string.IsNullOrEmpty(Txt_CUST_PALLET_POSTFIX.Text.Trim()) ? "NA" : Txt_CUST_PALLET_POSTFIX.Text.Trim(), * * CUST_PALLET_PREFIX = string.IsNullOrEmpty(Txt_CUST_PALLET_PREFIX.Text.Trim()) ? "NA" : Txt_CUST_PALLET_PREFIX.Text.Trim(), * CUST_PALLET_STR = string.IsNullOrEmpty(Txt_CUST_PALLET_STR.Text.Trim()) ? "001" : Txt_CUST_PALLET_STR.Text.Trim(), * CUST_PARTNUBMER = string.IsNullOrEmpty(Txt_CUST_PARTNUBMER.Text.Trim()) ? "NA" : Txt_CUST_PARTNUBMER.Text.Trim(), * CUST_PARTNUMBER_DESC = string.IsNullOrEmpty(Txt_CUST_PARTNUMBER_DESC.Text.Trim()) ? "NA" : Txt_CUST_PARTNUMBER_DESC.Text.Trim(), * * CUST_SN_LENG = int.Parse(string.IsNullOrEmpty(Txt_CUST_SN_LENG.Text.Trim()) ? "0" : Txt_CUST_SN_LENG.Text.Trim()), * CUST_SN_POSTFIX = string.IsNullOrEmpty(Txt_CUST_SN_POSTFIX.Text.Trim()) ? "NA" : Txt_CUST_SN_POSTFIX.Text.Trim(), * CUST_SN_PREFIX = string.IsNullOrEmpty(Txt_CUST_SN_PREFIX.Text.Trim()) ? "NA" : Txt_CUST_SN_PREFIX.Text.Trim(), * * CUST_SN_STR = string.IsNullOrEmpty(Txt_CUST_SN_STR.Text.Trim()) ? "001" : Txt_CUST_SN_STR.Text.Trim(), * * CUST_VENDER_CODE = string.IsNullOrEmpty(Txt_CUST_VENDER_CODE.Text.Trim()) ? "NA" : Txt_CUST_VENDER_CODE.Text.Trim(), * CUST_VERSION_CODE = string.IsNullOrEmpty(Txt_CUST_VERSION_CODE.Text.Trim()) ? "NA" : Txt_CUST_VERSION_CODE.Text.Trim(), * UPCEANDATA = "NA", * VERSION_CODE = string.IsNullOrEmpty(Txt_VERSION_CODE.Text.Trim()) ? "NA" : Txt_VERSION_CODE.Text.Trim(), * EMP_NO = sInfo.gUserInfo.userId, * PALLET_LAB_NAME = string.IsNullOrEmpty(Txt_PALLET_LAB_NAME.Text.Trim()) ? "NA" : Txt_PALLET_LAB_NAME.Text.Trim(), * PARTNUMBER = string.IsNullOrEmpty(Txt_PARTNUMBER.Text.Trim()) ? "NA" : Txt_PARTNUMBER.Text.Trim(), * RULE_TYPE = string.IsNullOrEmpty(Txt_RULE_TYPE.Text.Trim()) ? "NA" : Txt_RULE_TYPE.Text.Trim() * }, flag); */ if (Status == "OK") { LoadInfo(); Btn_PartN_Clear_Click(null, null); } else { MessageBox.Show(Status, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void bt_savecraft_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(this.txt_craftid.Text)) { throw new Exception("工艺编号不能为空"); } if (string.IsNullOrEmpty(this.txt_craftname.Text)) { throw new Exception("工艺描述不能为空"); } if (string.IsNullOrEmpty(this.cbx_beworkseg.Text)) { throw new Exception("请选择所属制程段"); } if (cbx_beworkseg.Text.Length > 15) { throw new Exception("制程段不能大于15位"); } if (txt_craftname.Text.Length > 18) { throw new Exception("工艺名称不能大于18位"); } if (string.IsNullOrEmpty(txt_testflag.Text)) { throw new Exception("工艺标记为空"); } ////if (string.IsNullOrEmpty(this.dgv_addcraftitem["CraftItem",0].Value.ToString())) if (this.dgv_addcraftitem.Rows.Count - 1 < 1) { if (MessageBoxEx.Show(string.Format("工艺\"{0}\"不存在工艺项目\n 是否确定?", this.txt_craftid.Text), "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) != DialogResult.Yes) { return; } } else { if (MessageBoxEx.Show(string.Format("工艺\"{0}\"存在[{1}]个工艺项目\n 是否确定?", this.txt_craftid.Text, this.dgv_addcraftitem.Rows.Count - 1), "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) != DialogResult.Yes) { return; } } //if (FrmBLL.publicfuntion.getNewTable(dgv_showcraftitem.DataSource as DataTable, string.Format("{0}='{1}'", (dgv_showcraftitem.DataSource as DataTable).Columns[1].ColumnName, tb_craftdesc.Text)).Rows.Count > 0) //{ // MessageBox.Show("工艺名称重复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // throw new Exception("工艺名称重复"); //} string err = string.Empty; string err1; //if ((err = refWebtCraftInfo.Instance.InsertRefCraftInfo(new WebServices.tCraftInfo.tCraftInfo1() // { // beworkseg = this.cb_bworkseg.Text.Trim(), // craftId = this.tb_craftid.Text.Trim(), // craftname = this.tb_craftdesc.Text.Trim(), // craftparameterurl = this.tb_craftparametfileurl.Text.Trim(), // TestFlag = tb_craftflag.Text.Trim() // }, this.GetCraftItem().ToArray(), out err1)) != "OK") Dictionary <string, object> dic = new Dictionary <string, object>(); publicfuntion.SerializeControl(dic, panel5); if ((err = refWebtCraftInfo.Instance.InsertRefCraftInfo(ReleaseData.DictionaryToJson(dic), ReleaseData.ListDictionaryToJson(GetCraftItem()), out err1)) != "OK") { this.mFrm.ShowPrgMsg(err, MainParent.MsgType.Error); return; } ShowCraftInfo(); this.mFrm.ShowPrgMsg(string.Format("工艺\"{0}\"添加成功", this.txt_craftname.Text), MainParent.MsgType.Outgoing); this.txt_craftname.Text = ""; this.txt_craftid.Text = ""; this.txt_CRAFTPARAMETERURL.Text = ""; this.tb_qutrycraftid.Text = ""; } catch (Exception ex) { this.mFrm.ShowPrgMsg(ex.Message, MainParent.MsgType.Error); } }
private void ExportDb(DataTable dgvDtTemp, DataGridView dgvhad) { try { this.mainfrm.ShowPrgMsg("正在导入数据", MainParent.MsgType.Outgoing); #region 20150811导入料站表时,删除整条线体料表 DataTable dtMachineLine = FrmBLL.ReleaseData.arrByteToDataTable(refWebtMachineInfo.Instance.GetAllMachineInfo()); string _Machine = null; string _PartNumber = string.Empty; string _PcbaSide = string.Empty; for (int i = 0; i < dgvhad.Rows.Count; i++) { _PartNumber = dgvhad["产品料号", i].Value.ToString(); _PcbaSide = dgvhad["PCB面", i].Value.ToString(); if (i == dgvhad.Rows.Count - 1) { _Machine += "'" + dgvhad["机器编号", i].Value.ToString() + "'"; } else { _Machine += "'" + dgvhad["机器编号", i].Value.ToString() + "',"; } } DataTable dtLine = ClsReadExcel.getNewTable(dtMachineLine, string.Format("MACHINEID IN ({0})", _Machine)); DataView dataView = dtLine.DefaultView; DataTable dataTableDistinct = dataView.ToTable(true, "LINEID"); string _SmtLine = null; for (int x = 0; x < dataTableDistinct.Rows.Count; x++) { if (x == dataTableDistinct.Rows.Count - 1) { _SmtLine += "'" + dataTableDistinct.Rows[x]["LINEID"].ToString() + "'"; } else { _SmtLine += "'" + dataTableDistinct.Rows[x]["LINEID"].ToString() + "',"; } } DataTable _SmtMachine = ClsReadExcel.getNewTable(dtMachineLine, string.Format("LINEID IN ({0})", _SmtLine)); List <string> LsMachine = new List <string>(); for (int y = 0; y < _SmtMachine.Rows.Count; y++) { LsMachine.Add(_SmtMachine.Rows[y]["MACHINEID"].ToString()); } string _StrErr = refWebSmtKpMaster.Instance.DeleteSmtKpMaster(LsMachine.ToArray(), _PartNumber, _PcbaSide); if (_StrErr != "OK") { throw new Exception("删除料站表头信息失败:" + _StrErr); } #endregion for (int i = 0; i < dgvhad.Rows.Count; i++) { DataTable dtTemp = ClsReadExcel.getNewTable(dgvDtTemp, string.Format("产品料号='{0}' and 产品描述='{1}' and 机器编号='{2}' and BOM版本='{3}'", dgvhad["产品料号", i].Value.ToString(), dgvhad["产品描述", i].Value.ToString(), dgvhad["机器编号", i].Value.ToString(), dgvhad["BOM版本", i].Value.ToString())); List <IDictionary <string, object> > lskpdetalt = new List <IDictionary <string, object> >(); Dictionary <string, object> kpdetalt = null; foreach (DataRow dr in dtTemp.Rows) { kpdetalt = new Dictionary <string, object>(); kpdetalt.Add("KPDESC", dr["品名与规格"].ToString()); kpdetalt.Add("KPDISTINCT", int.Parse(!string.IsNullOrEmpty(dr["优先级"].ToString()) ? dr["优先级"].ToString() : "0") > 1 ? "0" : "1"); kpdetalt.Add("KPNUMBER", dr["组件料号"].ToString()); kpdetalt.Add("LOCTION", dr["组件位置"].ToString()); kpdetalt.Add("PRIORITYCLASS", int.Parse(!string.IsNullOrEmpty(dr["优先级"].ToString()) ? dr["优先级"].ToString() : "0")); kpdetalt.Add("STATIONNO", dr["料站"].ToString()); if (!string.IsNullOrEmpty(dr["替代组"].ToString())) { kpdetalt.Add("REPLACEGROUP", dr["替代组"].ToString()); } if (!string.IsNullOrEmpty(dr["组件位置"].ToString().Trim())) { kpdetalt.Add("RESERVE1", GetKpUnit(dr["组件位置"].ToString().Trim())); } if (!string.IsNullOrEmpty(dr["FEEDER类型"].ToString())) { kpdetalt.Add("RESERVE", dr["FEEDER类型"].ToString()); } lskpdetalt.Add(kpdetalt); //lskpdetalt.Add(new WebServices.ExcelToDb.SMT_KP_DETALT() //{ // KPDesc = dr["品名与规格"].ToString(), // KPDistinct = int.Parse(!string.IsNullOrEmpty(dr["优先级"].ToString()) ? dr["优先级"].ToString() : "0") > 1 ? false : true, // KPNumber = dr["组件料号"].ToString(), // Loction = dr["组件位置"].ToString(), // loctionLen = dr["组件位置"].ToString().Length,---未增加此行 20150203 michael // //Masterid = _masterId, // Priorityclass = int.Parse(!string.IsNullOrEmpty(dr["优先级"].ToString()) ? dr["优先级"].ToString() : "0"), // Stationno = dr["料站"].ToString(), // Replacegroup = dr["替代组"].ToString(), // reserve1 = GetKpUnit(dr["组件位置"].ToString().Trim()), // reserve = dr["FEEDER类型"].ToString() //添加Feeder类型 //}); } Dictionary <string, object> SmtKpMater = new Dictionary <string, object>(); SmtKpMater.Add("BOMVER", dgvhad["BOM版本", i].Value.ToString()); SmtKpMater.Add("LINEID", dgvhad["机器编号", i].Value.ToString()); SmtKpMater.Add("RESERVE1", dgvhad["SMT程式", i].Value.ToString()); SmtKpMater.Add("MODELNAME", dgvhad["产品描述", i].Value.ToString()); SmtKpMater.Add("PARTNUMBER", dgvhad["产品料号", i].Value.ToString()); SmtKpMater.Add("PCBSIDE", dgvhad["PCB面", i].Value.ToString()); SmtKpMater.Add("USERID", this.mainfrm.gUserInfo.userId); //refWebExcelToDb.Instance.InsertMaterTable(new WebServices.ExcelToDb.SMT_KP_MASTER() //{ // bomver = dgvhad["BOM版本", i].Value.ToString(), // Lineid = dgvhad["机器编号", i].Value.ToString(), // reserve1 = dgvhad["SMT程式",i].Value.ToString(), // // masterId = _masterId, // modelname = dgvhad["产品描述", i].Value.ToString(), // partnumber = dgvhad["产品料号", i].Value.ToString(), // pcbside = dgvhad["PCB面", i].Value.ToString(), // Userid = this.mainfrm.gUserInfo.userId //}, lskpdetalt); refWebExcelToDb.Instance.InsertMaterTable(ReleaseData.DictionaryToJson(SmtKpMater), ReleaseData.ListDictionaryToJson(lskpdetalt)); } FrmBLL.publicfuntion.InserSystemLog(mainfrm.gUserInfo.userId, "导入料站表", "新增", "导入料站表: " + "产品料号:" + dgv_had["产品料号", 0].Value.ToString() + ";机器编号: " + dgv_had["机器编号", 0].Value.ToString()); this.mainfrm.ShowPrgMsg("数据导入成功.."); MessageBoxEx.Show("数据导入成功", "提示"); } catch (Exception ex) { if (ex.Message.IndexOf("FOREIGN KEY") != -1) { this.mainfrm.ShowPrgMsg("料站表中的[机器编号]不存在于系统,请先添加机器信息.", MainParent.MsgType.Error); } else { this.mainfrm.ShowPrgMsg(ex.Message, MainParent.MsgType.Error); } MessageBoxEx.Show("数据导入失败,错误信息如下:\n" + ex.Message, "提示"); } }