/// <summary> /// 打印标签(根据标签数据源打印) /// </summary> /// <param name="printTemplateName">标签名</param> /// <param name="Value">关键值</param> /// <param name="msg">返回信息</param> /// <returns></returns> public static bool PrintTemplet(string printTemplateName, string Value, ref string msg) { Dictionary <string, string> dic = new Dictionary <string, string>(); string strSql = string.Format(@"SELECT LabelSQL FROM T_Bllb_LabelSource_tbls WHERE LabelName='{0}'", printTemplateName); DataTable dt_LabelSQL = NMS.QueryDataTable(PubUtils.uContext, strSql);//获取标签的SQL语句 if (dt_LabelSQL.Rows.Count > 0) { string labelSql = SqlInput.ChangeNullToString(dt_LabelSQL.Rows[0][0]); if (labelSql == string.Empty) { msg = "标签数据源SQL语句为空"; return(false); } DataTable dt_lableSource = NMS.QueryDataTable(PubUtils.uContext, string.Format(labelSql, Value));//执行获取数据SQL语句 foreach (DataColumn dc in dt_lableSource.Columns) { dic.Add(dc.ColumnName, dt_lableSource.Rows[0][dc.ColumnName].ToString()); } } else { msg = "标签" + printTemplateName + "没有SQL语句"; return(false); } return(CIT.MES.IO.InOutPut.PrintTemplet(printTemplateName, dic)); }
private void tol_del_Click(object sender, EventArgs e) { if (dgv_po.CurrentCell == null || dgv_po.CurrentCell.RowIndex == -1) { new PubUtils().ShowNoteNGMsg("请先选中行", 2, grade.OrdinaryError); return; } DataGridViewRow dgvr = dgv_po.Rows[dgv_po.CurrentCell.RowIndex]; if (SqlInput.ChangeNullToString(dgvr.Cells["PO类型编码"].Value) != "客供单") { new PubUtils().ShowNoteNGMsg("仅客供单可以删除", 2, grade.OrdinaryError); return; } string POCode = SqlInput.ChangeNullToString(dgvr.Cells["PO订单编号"].Value); DataTable dt = BLL_Bllb_POMain_tbpm.GetPostatus(POCode); if (dt.Select("CurrentReceiveQty<>0 or ClearQty<>0").Length > 0) { MsgBox.Error("已收数量或者清点数量不为零时,不可以删除"); return; } else { BLL_Bllb_POMain_tbpm.DeletePocode(POCode); new PubUtils().ShowNoteOKMsg("删除成功"); QueryData(); } }
private void tol_del_Click(object sender, EventArgs e) { if (dgv_DocCollect.CurrentCell == null || dgv_DocCollect.CurrentCell.RowIndex == -1) { new PubUtils().ShowNoteNGMsg("请先选中行", 2, grade.OrdinaryError); return; } DataGridViewRow dgvr = dgv_DocCollect.Rows[dgv_DocCollect.CurrentCell.RowIndex]; string s_doc_no = SqlInput.ChangeNullToString(dgvr.Cells["S_Doc_NO"].Value); DataTable dt = BLL_Bllb_StorageDoc_tbsd.Query("where S_Doc_NO='" + s_doc_no + "'"); if (dt.Rows.Count > 0) { if (SqlInput.ChangeNullToString(dt.Rows[0]["Status"]) != "1") { new PubUtils().ShowNoteNGMsg("仅开立中的单据可以删除!", 2, grade.OrdinaryError); return; } } if (BLL_Bllb_StorageDoc_tbsd.Delete("where S_Doc_NO='" + s_doc_no + "'") == true) { Query(); new PubUtils().ShowNoteOKMsg("删除成功"); } }
private bool ValidateDocHead(out string msg) { if (cbo_Type.SelectedValue.ToString() == "-1") { msg = "请先选择单据类型"; return(false); } if (string.IsNullOrEmpty(txtBeforeDoc.Text.Trim())) { msg = "请输入上游单据"; return(false); } string sqlcmd = string.Format("SELECT FGuid,SfcNo,WoCode,TBT_ID,Product,Line FROM SfcDatProduct WHERE SfcNo='{0}'", txtBeforeDoc.Text.Trim()); DataTable dt_sfcno = CIT.Wcf.Utils.NMS.QueryDataTable(CIT.MES.PubUtils.uContext, sqlcmd); //if (dt_sfcno.Rows.Count == 0) //{ // msg = "上游单据错误"; // return false; //} if (dt_sfcno.Rows.Count > 0) { _PLCode = SqlInput.ChangeNullToString(dt_sfcno.Rows[0]["Line"]); //线别代码 _WoCode = SqlInput.ChangeNullToString(dt_sfcno.Rows[0]["WoCode"]); //工单 _SfcNo = SqlInput.ChangeNullToString(dt_sfcno.Rows[0]["SfcNo"]); //制令单 } msg = "OK"; return(true); }
/// <summary> /// 产品初始化 /// </summary> /// <param name="SN"></param> /// <returns></returns> public static bool Init(string SN, string sfcno, ref string msg) { string strSql = string.Format(@"SELECT A.TBPS_ID,B.OVER_FLAG FROM T_Bllb_productKey_tbpk A LEFT JOIN dbo.T_Bllb_productInfo_tbpi B ON B.TBPS_ID = A.TBPS_ID WHERE A.KEY_SN='{0}' AND B.SfcNo='{1}'", SN, sfcno); DataTable dt_ID = NMS.QueryDataTable(PubUtils.uContext, strSql); if (dt_ID.Rows.Count == 0) { strSql = string.Format(@"SELECT TBPS_ID,OVER_FLAG FROM dbo.T_Bllb_productInfo_tbpi WHERE SERIAL_NUMBER='{0}' AND SfcNo='{1}' AND LAST_FLAG='Y' ORDER BY INPUT_TIME DESC", SN, sfcno); dt_ID = NMS.QueryDataTable(PubUtils.uContext, strSql); } if (dt_ID.Rows.Count == 0) { msg = "当前制令单中未找到此产品SN"; return(false); } strSql = string.Format(@"DELETE FROM dbo.T_Bllb_productInfo_tbpi WHERE TBPS_ID='{0}' DELETE FROM dbo.T_Bllb_productKey_tbpk WHERE TBPS_ID='{0}' DELETE FROM dbo.T_Bllb_productStatus_tbps WHERE TBPS_ID='{0}' ", dt_ID.Rows[0][0].ToString()); if (SqlInput.ChangeNullToString(dt_ID.Rows[0]["OVER_FLAG"]) == "Y") { strSql += string.Format(@" UPDATE dbo.SfcDatProduct SET InputQty=InputQty-1,ActQty=ActQty-1 WHERE SfcNo='{0}'", sfcno); } else { strSql += string.Format(@" UPDATE dbo.SfcDatProduct SET InputQty=InputQty-1 WHERE SfcNo='{0}'", sfcno); } return(NMS.ExecTransql(PubUtils.uContext, strSql)); }
private void txt_Begin_LocationSN_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { //if (Bll_Bllb_StorageDocDetail_tbsdd.IsReturn(txt_Begin_LocationSN.Text.Trim()).Rows.Count > 0) //{ // new PubUtils().ShowNoteNGMsg("物料SN已退料", 1, grade.OrdinaryError); // return; //} //校验物料SN是否在库 string check_IsInStock = string.Format(" Where SerialNumber='{0}' and Lock_Flag='7'", txt_Begin_LocationSN.Text.Trim()); DataTable dt_isInStock = Bll_Bllb_StockInfo_tbsi.QueryStock(check_IsInStock); if (dt_isInStock.Rows.Count > 0) { sfcNo = SqlInput.ChangeNullToString(dt_isInStock.Rows[0]["SfcNo"]); //输入物料SN生成退料单据号 dt_return_doc = Bll_Bllb_StorageDocDetail_tbsdd.Create_Return_Doc(txt_Begin_LocationSN.Text.Trim()); if (dt_return_doc.Rows[0]["Result"].ToString() == "0") { new PubUtils().ShowNoteNGMsg("物料SN不在发料单中", 1, grade.OrdinaryError); return; } _s_doc_no = dt_return_doc.Rows[0]["S_Doc_NO"].ToString(); _before_Doc_NO = dt_return_doc.Rows[0]["Before_Doc_NO"].ToString();//发料单 _materialCode = dt_return_doc.Rows[0]["MaterialCode"].ToString(); //_iqc_doc = Bll_Bllb_IQCDoc_tbid.GetIqcDocByMaterialCode(_materialCode, _before_Doc_NO);//输入料号生成退料送检单(屏蔽生成送检单) DataTable DIP_Qty = Bll_Bllb_StorageDocDetail_tbsdd.Query_SN_Qty(txt_Begin_LocationSN.Text.Trim(), _materialCode); if (DIP_Qty.Rows.Count > 0) { txt_Qty.Text = DIP_Qty.Rows[0]["Qty"].ToString(); txt_Qty.Focus(); txt_Qty.ReadOnly = false; } else { DataTable SMT_Qty = Bll_Bllb_StockInfo_tbsi.Query_SN_Qty(txt_Begin_LocationSN.Text.Trim(), _materialCode); if (SMT_Qty.Rows.Count > 0) { txt_Qty.Text = SMT_Qty.Rows[0]["Qty"].ToString(); txt_Qty.Focus(); txt_Qty.ReadOnly = false; } } } else { new PubUtils().ShowNoteNGMsg("物料状态不对或物料SN错误", 2, grade.OrdinaryError); return; } } }
/// <summary> /// 流程校验 /// </summary> /// <param name="serial_Number"></param> /// <param name="TBS_ID"></param> /// <returns></returns> public static string CheckRoute(string serial_Number, string TBS_ID, ref string TBTG_ID, ref string WIP_TBTG_ID) { string msg = string.Empty; //返回信息 string TBT_ID = string.Empty; //工艺ID bool is_error = false; string F_TBTG_ID = string.Empty; //产品最后过的工艺工序ID DataTable dt_Product = QueryProductSN(serial_Number); if (dt_Product.Rows.Count > 0)//已投产的产品(在制品) { #region 已投产的产品 //if (SqlInput.ChangeNullToString(dt_Product.Rows[0]["OVER_FLAG"]) == "Y") //{ // msg = "产品已流程结束"; // return msg; //} TBT_ID = SqlInput.ChangeNullToString(dt_Product.Rows[0]["TBT_ID"]);//工艺ID if (TBT_ID == string.Empty) { msg = "制令单未配置工艺"; return(msg); } F_TBTG_ID = dt_Product.Rows[0]["TBTG_ID"].ToString();//产品最后过的工艺工序ID if (dt_Product.Rows[0]["ERROR_FLAG"].ToString() == "Y") { is_error = true; } //获取工位ID对应的工艺工序ID DataTable dt_TBTG_ID = QueryTechGroup(TBT_ID, TBS_ID); if (dt_TBTG_ID.Rows.Count == 0) { msg = "工位不在当前产品所在的工艺中"; return(msg); } //流程校验 //msg = CheckRoute(TBT_ID, F_TBTG_ID, TBS_ID, is_error, ref TBTG_ID); msg = CheckRoute(TBT_ID, F_TBTG_ID, TBS_ID, is_error, ref TBTG_ID, ref WIP_TBTG_ID); if (msg != "OK") { return(msg); } return("OK"); #endregion } else { return("非首站不能进行产品投入"); } }
private void dgv_StorageMaterial_CellClick(object sender, DataGridViewCellEventArgs e) { if (dgv_StorageMaterial.CurrentCell == null || dgv_StorageMaterial.CurrentCell.RowIndex == -1) { return; } dgvStorageDetail.DataSource = null; string queryWhere = string.Format(@" where a.S_Doc_NO='{0}' and a.MaterialCode='{1}'", SqlInput.ChangeNullToString(dgv_StorageMaterial.Rows[dgv_StorageMaterial.CurrentCell.RowIndex].Cells[S_Doc_NO_Material.Name].Value), SqlInput.ChangeNullToString(dgv_StorageMaterial.Rows[dgv_StorageMaterial.CurrentCell.RowIndex].Cells[MaterialCode.Name].Value)); dtStorageDetail = BLL_Bllb_StorageDoc_tbsd.QueryStorageDetail(queryWhere); dgvStorageDetail.DataSource = dtStorageDetail; }
/// <summary> /// 通过关键件找到产品条码 /// </summary> /// <param name="KeySN"></param> /// <returns></returns> public string GetSerialNumberByKeySN(string KeySN) { string strSql = string.Format(@"SELECT tbpi.SERIAL_NUMBER FROM T_Bllb_productInfo_tbpi tbpi left join T_Bllb_productKey_tbpk tbpk on tbpi.TBPS_ID=tbpk.TBPS_ID WHERE tbpk.KEY_SN='{0}'", KeySN); DataTable dt = NMS.QueryDataTable(PubUtils.uContext, strSql.ToString()); if (dt.Rows.Count > 0) { return(SqlInput.ChangeNullToString(dt.Rows[0][0])); } else { return(string.Empty); } }
private bool CheckData(out string msg) { msg = "OK"; if (lbLogInfo.Items.Count >= 1000) { //数据项太多了--清除 lbLogInfo.Items.Clear(); lbLogInfo.Items.Add("日志大于1000条,清空"); } if (txt_BarCode.Text == string.Empty) { msg = "料卷信息为空"; return(false); } if (txtSigleCount.Text == string.Empty) { msg = "单盘物料数量为空"; return(false); } if (txtDiskNum.Text == string.Empty) { msg = "分盘数量为空"; return(false); } DataTable dt = NMS.QueryDataTable(PubUtils.uContext, string.Format("SELECT * FROM dbo.T_Bllb_StockInfo_tbsi WHERE SerialNumber='{0}'", txt_BarCode.Text.Trim())); if (dt.Rows.Count > 0) { Location_SN = SqlInput.ChangeNullToString(dt.Rows[0]["Location_SN"]); if (!string.IsNullOrEmpty(Location_SN)) { msg = "料盘上架中"; return(false); } Lock_Flag = SqlInput.ChangeNullToString(dt.Rows[0]["Lock_Flag"]); if (!(Lock_Flag == "7" || Lock_Flag == "0")) { msg = "料盘状态不允许分盘"; return(false); } } else { msg = "料盘编号错误!"; return(false); } return(true); }
private void Form_ReelPrint_Load(object sender, EventArgs e) { if (dgvrSelected != null) { txt_PO.Text = SqlInput.ChangeNullToString(dgvrSelected.Cells["PO订单编号"].Value); txt_MaterialCode.Text = SqlInput.ChangeNullToString(dgvrSelected.Cells["料号"].Value); } string sql_isSendCheck = string.Format(@"SELECT * FROM dbo.MdcdatMaterial WHERE MaterialCode='{0}'", txt_MaterialCode.Text.Trim()); DataTable dtCheck = NMS.QueryDataTable(PubUtils.uContext, sql_isSendCheck); if (dtCheck.Rows.Count > 0) { IsSendCheck = SqlInput.ChangeNullToString(dtCheck.Rows[0]["IsSendCheck"]) == "是" ? true : false; } txt_MPN.Focus(); }
/// <summary> /// 获取下一个工艺工序ID /// </summary> /// <param name="F_TBTG_ID">父级工艺工序ID</param> /// <param name="isNormalGroup">是否为未正常工序(非维修工序)</param> /// <returns></returns> public static string GetNextTechGroupID(string F_TBTG_ID, bool isNormalGroup) { string strSql = string.Format(@"SELECT A.TBTG_ID FROM T_Bllb_techGroupRelation_tbtgr A LEFT JOIN T_Bllb_technologyGroup_tbtg B ON A.F_TBTG_ID=B.TBTG_ID LEFT JOIN T_Bllb_group_tbg C ON B.TBG_ID=C.TBG_ID WHERE A.TBTG_ID='{0}' AND C.GROUP_TYPE='{1}'", F_TBTG_ID, isNormalGroup == true?"0":"1"); DataTable dt = CIT.Wcf.Utils.NMS.QueryDataTable(PubUtils.uContext, strSql); if (dt.Rows.Count > 0) { return(SqlInput.ChangeNullToString(dt.Rows[0][0])); } else { return(string.Empty); } }
private void Form_ShowDocDetail_Load(object sender, EventArgs e) { StringBuilder strbildLook = new StringBuilder(); foreach (DataGridViewRow dgvr in list_dgvr) { string s_doc_no = SqlInput.ChangeNullToString(dgvr.Cells["S_Doc_NO"].Value); strbildLook.AppendFormat(@" SELECT a.S_Doc_NO AS '单据号' , CASE a.S_Doc_Type WHEN c.TYPE_CODE THEN c.TYPE_NAME END AS '单据类型' , b.SerialNumber AS '条码' , b.MaterialCode AS '料号' , b.DateCode , b.QTY AS '数量' , b.MPN, a.Creator AS '创建人' , a.Create_Time AS '创建时间' , a.Before_Doc_No AS '上游单据' , CASE a.IsAutoCreate WHEN 'N' THEN '人工开单' WHEN 'Y' THEN '自动生成' ELSE '人工开单' END '是否自动生成' FROM dbo.T_Bllb_StorageDoc_tbsd AS a LEFT JOIN dbo.T_Bllb_StorageDocDetail_tbsdd AS b ON a.S_Doc_NO = b.S_Doc_NO LEFT JOIN dbo.T_Bllb_DocType_tbdt AS c ON c.TYPE_CODE = a.S_Doc_Type WHERE a.S_Doc_NO = '{0}'", s_doc_no); } if (strbildLook.Length > 0) { ds = CIT.Wcf.Utils.NMS.QueryDataSet(CIT.MES.PubUtils.uContext, strbildLook.ToString()); foreach (DataTable dt in ds.Tables) { TabPage tab_Page = new TabPage(); tab_Page.Text = SqlInput.ChangeNullToString(dt.Rows[0]["单据号"]); DataGridView t_dgvr = new DataGridView(); t_dgvr.DataSource = dt; t_dgvr.ReadOnly = true; t_dgvr.AllowUserToAddRows = false; t_dgvr.Dock = DockStyle.Fill; tab_Page.Controls.Add(t_dgvr); tab_data.TabPages.Add(tab_Page); } } }
/// <summary> /// 获取当前的料卷信息 /// </summary> /// <param name="reelid"></param> public void GetMaterialInfo(string reelid) { string querySql = string.Format(@" SELECT a.SerialNumber,a.QTY,a.Location_SN,a.Storage_SN,a.Area_SN,a.DateCode,a.MPN,f.PO,a.Lock_Flag, b.Storage_Name,c.Area_Name,d.Location_Name, a.MaterialCode FROM dbo.T_Bllb_StockInfo_tbsi AS a LEFT JOIN dbo.T_Bllb_Storage_tbs AS b ON b.Storage_SN=a.Storage_SN LEFT JOIN dbo.T_Bllb_StorageArea_tbsa AS c ON c.Area_SN=a.Area_SN LEFT JOIN dbo.T_Bllb_StorageLocation_tbsl AS d ON d.Location_SN=a.Location_SN LEFT JOIN dbo.T_Bllb_StorageDocDetail_tbsdd AS e ON e.SerialNumber=a.SerialNumber LEFT JOIN dbo.T_Bllb_StorageDoc_tbsd AS f ON f.S_Doc_NO=e.S_Doc_NO WHERE a.SerialNumber='{0}'", reelid); dt_MaterialInfo = NMS.QueryDataTable(PubUtils.uContext, querySql); if (dt_MaterialInfo.Rows.Count > 0) { Location_SN = SqlInput.ChangeNullToString(dt_MaterialInfo.Rows[0]["Location_SN"]); if (!string.IsNullOrEmpty(Location_SN)) { txt_BarCode.SelectAll(); new PubUtils().ShowNoteNGMsg("料盘上架中", 1, grade.OrdinaryError); return; } Lock_Flag = SqlInput.ChangeNullToString(dt_MaterialInfo.Rows[0]["Lock_Flag"]); if (!(Lock_Flag == "7" || Lock_Flag == "0")) { txt_BarCode.SelectAll(); new PubUtils().ShowNoteNGMsg("料盘当前状态不允许分盘", 1, grade.OrdinaryError); return; } txtHourseName.Text = dt_MaterialInfo.Rows[0]["Storage_Name"].ToString(); txtRollNum.Text = dt_MaterialInfo.Rows[0]["QTY"].ToString(); txtMaterialNo.Text = dt_MaterialInfo.Rows[0]["MaterialCode"].ToString(); txt_Reelid.Text = reelid; } else { txt_BarCode.SelectAll(); new PubUtils().ShowNoteNGMsg("料盘信息错误", 1, grade.OrdinaryError); return; } }
/// <summary> /// 校验容器条码规则 /// </summary> /// <param name="ruleName">规则名称</param> /// <param name="ContainerSN">容器SN</param> /// <param name="productCode">容器内产品的产品代码</param> /// <param name="msg"></param> /// <returns></returns> public static bool CheckContainerSNRule(string ruleName, string ContainerSN, string productCode, ref string msg) { string strSql = string.Format(@"SELECT IS_CHECK_SN_LENGTH, SN_LENGTH,IS_CHECK_SAME_STRING,SAME_STRING,SAME_STRING_BEGIN, MATERIAL_FLAG,MATERIAL_LENGTH,MATERIAL_CODE_BEGIN,SN_BEGIN FROM T_Bllb_barcodeRule_tbbr T WHERE T.RULE_NAME ='{0}'", ruleName); DataTable dt_Rule = CIT.Wcf.Utils.NMS.QueryDataTable(PubUtils.uContext, strSql); if (dt_Rule.Rows.Count > 0) { //检验长度 if (SqlInput.ChangeNullToString(dt_Rule.Rows[0]["IS_CHECK_SN_LENGTH"]) == "Y" & SqlInput.ChangeNullToInt(dt_Rule.Rows[0]["SN_LENGTH"], 0) != ContainerSN.Length) { msg = "容器条码长度不正确"; return(false); } //校验固定字符 if (SqlInput.ChangeNullToString(dt_Rule.Rows[0]["IS_CHECK_SAME_STRING"]) == "Y") { string sameString = SqlInput.ChangeNullToString(dt_Rule.Rows[0]["SAME_STRING"]); int length = sameString.Length; int begin = SqlInput.ChangeNullToInt(dt_Rule.Rows[0]["SAME_STRING_BEGIN"], 0) - 1;//数据库保存是从1开始,实际中位置编号是从0开始,故要减1 if (ContainerSN.Substring(begin, length) != sameString) { msg = "容器条码的固定字符不正确"; return(false); } } //校验产品代码 if (SqlInput.ChangeNullToString(dt_Rule.Rows[0]["MATERIAL_FLAG"]) != "0") { int length = SqlInput.ChangeNullToInt(dt_Rule.Rows[0]["MATERIAL_LENGTH"], 0); int m_begin = SqlInput.ChangeNullToInt(dt_Rule.Rows[0]["MATERIAL_CODE_BEGIN"], 0) - 1; int sn_begin = SqlInput.ChangeNullToInt(dt_Rule.Rows[0]["SN_BEGIN"], 0) - 1; if (ContainerSN.Substring(sn_begin, length) != productCode.Substring(m_begin, length)) { msg = "容器条码中的产品代码不正确"; return(false); } } } return(true); }
private void 新增ToolStripMenuItem_Click(object sender, EventArgs e) { if (cbo_Type.SelectedValue.ToString() == "-1") { MsgBox.Error("请选择类型"); return; } string sqlcmd = string.Format("SELECT * FROM T_Bllb_SecondClass_tbsc WHERE Type='{0}' AND Class='{1}'", cbo_Type.Text, txt_Class.Text.Trim()); if (NMS.QueryDataTable(PubUtils.uContext, sqlcmd).Rows.Count > 0) { new PubUtils().ShowNoteNGMsg("该类型的等级已存在", 2, grade.RepeatedError); return; } if (cbo_Type.SelectedValue.ToString() != "2") { if (dgv_SencondClass.Rows.Count == 1) { MsgBox.Error("红胶或锡膏只允行添加一行数据"); return; } } if (dgv_SencondClass.Rows.Count != 0) { if (!ValidataInput(dgv_SencondClass.Rows[dgv_SencondClass.Rows.Count - 1])) { return; } } dgv_SencondClass.Rows.Add(); int rowindex = dgv_SencondClass.Rows.Count - 1; dgv_SencondClass.Rows[rowindex].Cells["OrderNum"].Value = rowindex + 1; if (dgv_SencondClass.Rows.Count == 2) { expose_time = SqlInput.ChangeNullToString(dgv_SencondClass.Rows[0].Cells["ExposeTime"].Value); ExposeTime.ReadOnly = true; } dgv_SencondClass.Rows[rowindex].Cells["ExposeTime"].Value = expose_time; }
private void cbo_MaterialCode_SelectedIndexChanged(object sender, EventArgs e) { //cbo_MaterialCode.TextChanged -= cbo_MaterialCode_TextChanged; txt_MaterialDesc.Text = string.Empty; if (cbo_MaterialCode.Text != string.Empty) { DataTable dt_Spec = bll_Material.SelectNameAndSpec(cbo_MaterialCode.Text.Split('*')[0]); if (dt_Spec.Rows.Count == 0) { new PubUtils().ShowNoteNGMsg("未维护该物料基础信息!", 1, grade.OrdinaryError); cbo_PO_SelectedIndexChanged(null, null); return; } else { txt_MaterialDesc.Text = SqlInput.ChangeNullToString(dt_Spec.Rows[0]["Spec"]); txt_MinPackage.Text = SqlInput.ChangeNullToInt(dt_Spec.Rows[0]["PackagingMin"], 1).ToString(); } } //cbo_MaterialCode.TextChanged += cbo_MaterialCode_TextChanged; }
/// <summary> /// 判断是否产品代码一致 /// </summary> /// <param name="tbpi"></param> /// <returns></returns> public bool CheckProductSame(T_Bllb_productInfo_tbpi tbpi, ref string msg) { // string strSql = string.Format(@"SELECT A.TBPS_ID,W.Version from T_Bllb_productInfo_tbpi A LEFT JOIN dbo.SfcDatProduct B ON A.SfcNo=B.SfcNo //LEFT JOIN dbo.T_Work_Number W ON B.WoCode=W.WoCode // where SERIAL_NUMBER = '{0}' and B.Product = '{1}' AND LAST_FLAG = 'Y' AND W.Version='{2}'", tbpi.SERIAL_NUMBER, tbpi.ProductCode,tbpi.Version); // return NMS.QueryDataTable(PubUtils.uContext, strSql).Rows.Count == 0 ? false : true; string strSql = string.Format(@"SELECT W.C_PartNumber, B.Product,A.TBPS_ID,W.Version from T_Bllb_productInfo_tbpi A LEFT JOIN dbo.SfcDatProduct B ON A.SfcNo=B.SfcNo LEFT JOIN dbo.T_Work_Number W ON B.WoCode=W.WoCode where SERIAL_NUMBER = '{0}' AND LAST_FLAG = 'Y' ", tbpi.SERIAL_NUMBER, tbpi.ProductCode, tbpi.Version); DataTable dt_check = NMS.QueryDataTable(PubUtils.uContext, strSql); if (dt_check.Rows.Count > 0) { string str_product = SqlInput.ChangeNullToString(dt_check.Rows[0]["Product"]); //产品 string str_Version = SqlInput.ChangeNullToString(dt_check.Rows[0]["Version"]); //版本 string str_C_PartNumber = SqlInput.ChangeNullToString(dt_check.Rows[0]["C_PartNumber"]); //版本 if (str_product != tbpi.ProductCode) { msg = "产品有误,扫描产品为" + str_product; return(false); } else if (str_Version != tbpi.Version) { msg = "产品版本有误,扫描产品版本为" + str_Version; return(false); } else if (str_C_PartNumber != tbpi.C_PartNumber) { msg = "客户料号有误,扫描客户料号为" + str_C_PartNumber; return(false); } msg = string.Empty; return(true); } else { msg = "产品条码不存在"; return(false); } }
/// <summary> /// 获取返工/维修回流的工艺工序ID /// </summary> /// <param name="TBPS_ID"></param> /// <param name="TBS_ID"></param> /// <param name="msg"></param> /// <returns></returns> public static string GetNextRe_TBTG_ID_BY_TBPS_ID(string TBPS_ID, string TBS_ID, ref string msg) { string strSql = string.Format(@"SELECT tbps.RE_TBTG_ID,tbtgs.TBTG_ID FROM T_Bllb_productInfo_tbpi tbbi left join t_bllb_productStatus_tbps tbps on tbbi.tbps_id=tbps.tbps_id LEFT JOIN SfcDatProduct sfc on tbbi.sfcno=sfc.sfcno left join T_Bllb_techGroupStation_tbtgs tbtgs on tbtgs.TBT_ID=sfc.TBT_ID left join T_Bllb_station_tbs tbs on tbs.TBS_ID=tbtgs.TBS_ID where tbbi.last_flag='Y' and tbbi.TBPS_ID='{0}' and tbs.TBS_ID='{1}'", TBPS_ID, TBS_ID); DataTable dt = CIT.Wcf.Utils.NMS.QueryDataTable(PubUtils.uContext, strSql); if (dt.Rows.Count > 0) { string re_tbtg_id = SqlInput.ChangeNullToString(dt.Rows[0]["RE_TBTG_ID"]); if (re_tbtg_id != string.Empty & re_tbtg_id == SqlInput.ChangeNullToString(dt.Rows[0]["TBTG_ID"])) { msg = "OK"; return(re_tbtg_id); } else { if (re_tbtg_id != string.Empty) { strSql = string.Format(@"SELECT TBG.GROUP_NAME FROM T_Bllb_technologyGroup_tbtg TBTG LEFT JOIN T_Bllb_group_tbg TBG ON TBG.TBG_ID=TBTG.TBG_ID WHERE TBTG.TBTG_ID='{0}'", re_tbtg_id); DataTable dt_g = CIT.Wcf.Utils.NMS.QueryDataTable(PubUtils.uContext, strSql); if (dt_g.Rows.Count > 0) { msg = "下一个工序为" + SqlInput.ChangeNullToString(dt_g.Rows[0][0]); } } return(string.Empty); } } else { msg = "工位不在产品工艺中"; return(string.Empty); } }
private void cbo_PO_SelectedIndexChanged(object sender, EventArgs e) { txt_MaterialDesc.Text = string.Empty; //初始化物料数据源 lstInitMaterial.Clear(); cbo_MaterialCode.Items.Clear(); lstNewMaterial.Clear(); DataTable dt_Material = BLL.Bll_Bllb_POMain_tbpm.GetList(cbo_PO.Text); if (dt_Material.Rows.Count > 0) { foreach (DataRow dr in dt_Material.Rows) { lstInitMaterial.Add(dr["MaterialCode"].ToString() + "*" + dr["RowNumber"].ToString()); } txt_SUPPLIER_CODE.Text = SqlInput.ChangeNullToString(dt_Material.Rows[0]["SupplierCode"]);//供应商代码 } else { txt_SUPPLIER_CODE.Text = string.Empty; } cbo_MaterialCode.Items.AddRange(lstInitMaterial.ToArray()); }
/// <summary> /// 汇总工单条码规则 /// </summary> /// <param name="woCode"></param> /// <returns></returns> public static bool DealWoCodeRule(string woCode) { //删除工单解析中的条码规则 string strSql = string.Format(@" DELETE FROM T_Bllb_projectRule_tbpr WHERE WoCode='{0}'", woCode); CIT.Wcf.Utils.NMS.ExecTransql(PubUtils.uContext, strSql); //获取产品条码规则 strSql = string.Format(@"SELECT sfc.WoCode,sfc.SFCNO,sfc.Product,KM.MaterialCode,KM.TBKT_ID FROM SfcdatProduct sfc left join T_Bllb_wocodeBom_tbwb WB on sfc.wocode=wb.wocode LEFT JOIN T_Bllb_keyMaterial_tbkm KM ON WB.MaterialCode=KM.MaterialCode WHERE sfc.WOCODE='{0}'", woCode); DataTable dt_sfc = CIT.Wcf.Utils.NMS.QueryDataTable(PubUtils.uContext, strSql); if (dt_sfc.Rows.Count == 0) { return(false); } //指令单条码规则 strSql = string.Format(@"INSERT INTO T_Bllb_projectRule_tbpr(WoCode,TBMR_ID,TBKT_ID,MaterialCode) SELECT sfc.WoCode,SMR.TBMR_ID,KM.TBKT_ID,KM.MaterialCode FROM SfcdatProduct sfc INNER JOIN T_Bllb_keyMaterial_tbkm KM ON sfc.Product=KM.MaterialCode INNER JOIN T_Bllb_specMaterialRule_tbsmr SMR ON SMR.MaterialCode=KM.MaterialCode INNER JOIN T_Bllb_keyType_tbkt KT ON KT.TBKT_ID=KM.TBKT_ID WHERE KT.KEY_TYPE = '0' AND sfc.WoCode='{0}' AND SMR.TBSMR_TYPE='0' AND SMR.TBSMR_TYPE_VALUE='{1}' AND SMR.MaterialCode='{2}' ORDER BY SMR.TBSMR_TYPE ASC", woCode, dt_sfc.Rows[0]["sfcno"], dt_sfc.Rows[0]["product"]); CIT.Wcf.Utils.NMS.ExecTransql(PubUtils.uContext, strSql); string strSql_check = string.Format(@"SELECT COUNT(1) FROM T_Bllb_projectRule_tbpr T LEFT JOIN T_Bllb_materialRule_tbmb MR ON T.TBMR_ID = MR.TBMR_ID WHERE T.WoCode = '{0}' AND MR.MATERIALCODE = '{1}'", woCode, dt_sfc.Rows[0]["product"]); if (CIT.Wcf.Utils.NMS.GetTableCount(PubUtils.uContext, strSql_check) == 0) { ///工单条码规则 strSql = string.Format(@"INSERT INTO T_Bllb_projectRule_tbpr(WoCode,TBMR_ID,TBKT_ID,MaterialCode) SELECT sfc.WoCode,SMR.TBMR_ID,KM.TBKT_ID,KM.MaterialCode FROM SfcdatProduct sfc INNER JOIN T_Bllb_keyMaterial_tbkm KM ON sfc.Product=KM.MaterialCode INNER JOIN T_Bllb_specMaterialRule_tbsmr SMR ON SMR.MaterialCode=KM.MaterialCode INNER JOIN T_Bllb_keyType_tbkt KT ON KT.TBKT_ID=KM.TBKT_ID WHERE KT.KEY_TYPE = '0' AND sfc.WoCode='{0}' AND SMR.TBSMR_TYPE='1' AND SMR.TBSMR_TYPE_VALUE='{1}' AND SMR.MaterialCode='{2}' ORDER BY SMR.TBSMR_TYPE ASC", woCode, dt_sfc.Rows[0]["wocode"], dt_sfc.Rows[0]["product"]); CIT.Wcf.Utils.NMS.ExecTransql(PubUtils.uContext, strSql); if (CIT.Wcf.Utils.NMS.GetTableCount(PubUtils.uContext, strSql_check) == 0) { ///机种条码规则 strSql = string.Format(@"INSERT INTO T_Bllb_projectRule_tbpr(WoCode,TBMR_ID,TBKT_ID,MaterialCode) SELECT sfc.WoCode,SMR.TBMR_ID,KM.TBKT_ID,KM.MaterialCode FROM SfcdatProduct sfc INNER JOIN T_Bllb_keyMaterial_tbkm KM ON sfc.Product=KM.MaterialCode INNER JOIN T_Bllb_specMaterialRule_tbsmr SMR ON SMR.MaterialCode=KM.MaterialCode INNER JOIN T_Bllb_keyType_tbkt KT ON KT.TBKT_ID=KM.TBKT_ID WHERE KT.KEY_TYPE = '0' AND sfc.WoCode='{0}' AND SMR.TBSMR_TYPE='2' AND SMR.TBSMR_TYPE_VALUE='{1}' AND SMR.MaterialCode='{1}' ORDER BY SMR.TBSMR_TYPE ASC", woCode, dt_sfc.Rows[0]["product"]); CIT.Wcf.Utils.NMS.ExecTransql(PubUtils.uContext, strSql); if (CIT.Wcf.Utils.NMS.GetTableCount(PubUtils.uContext, strSql_check) == 0) { //默认条码规则 strSql = string.Format(@"INSERT INTO T_Bllb_projectRule_tbpr(WoCode,TBMR_ID,TBKT_ID,MaterialCode) SELECT SFC.WoCode,MR.TBMR_ID,KM.TBKT_ID,KM.MaterialCode FROM SfcdatProduct SFC INNER JOIN T_Bllb_keyMaterial_tbkm KM ON SFC.product=KM.MaterialCode INNER JOIN T_Bllb_materialRule_tbmb MR ON MR.MaterialCode=KM.MaterialCode INNER JOIN T_Bllb_keyType_tbkt KT ON KT.TBKT_ID=KM.TBKT_ID WHERE KT.KEY_TYPE = '0' AND MR.DEFAULT_FLAG='Y' AND SFC.WOCODE='{0}' AND MR.MaterialCode='{1}'", woCode, dt_sfc.Rows[0]["product"]); CIT.Wcf.Utils.NMS.ExecTransql(PubUtils.uContext, strSql); } } } //BOM物料条码规则 foreach (DataRow dr in dt_sfc.Rows) { if (SqlInput.ChangeNullToString(dr["TBKT_ID"]) == string.Empty || SqlInput.ChangeNullToString(dr["Product"]) == SqlInput.ChangeNullToString(dr["MaterialCode"]))//若是没有BOM物料不是关键件或者料号与产品一致,则继续下一个 { continue; } //指令单条码规则 strSql = string.Format(@"INSERT INTO T_Bllb_projectRule_tbpr(WoCode,TBMR_ID,TBKT_ID) SELECT '{0}' WoCode,SMR.TBMR_ID,KM.TBKT_ID FROM T_Bllb_keyMaterial_tbkm KM INNER JOIN T_Bllb_specMaterialRule_tbsmr SMR ON SMR.MaterialCode=KM.MaterialCode INNER JOIN T_Bllb_keyType_tbkt KT ON KT.TBKT_ID=KM.TBKT_ID WHERE KT.KEY_TYPE = '1' AND SMR.TBSMR_TYPE='0' AND SMR.TBSMR_TYPE_VALUE='{1}' AND SMR.MaterialCode='{2}' ORDER BY SMR.TBSMR_TYPE ASC", woCode, dr["sfcno"], dr["MaterialCode"]); CIT.Wcf.Utils.NMS.ExecTransql(PubUtils.uContext, strSql); strSql_check = string.Format(@"SELECT COUNT(1) FROM T_Bllb_projectRule_tbpr T LEFT JOIN T_Bllb_materialRule_tbmb MR ON T.TBMR_ID = MR.TBMR_ID WHERE T.WoCode = '{0}' AND MR.MATERIALCODE = '{1}'", woCode, dr["MaterialCode"]); if (CIT.Wcf.Utils.NMS.GetTableCount(PubUtils.uContext, strSql_check) == 0)///指令单条码规则 { //工单条码规则 strSql = string.Format(@"INSERT INTO T_Bllb_projectRule_tbpr(WoCode,TBMR_ID,TBKT_ID) SELECT '{0}' WoCode,SMR.TBMR_ID,KM.TBKT_ID FROM T_Bllb_keyMaterial_tbkm KM INNER JOIN T_Bllb_specMaterialRule_tbsmr SMR ON SMR.MaterialCode=KM.MaterialCode INNER JOIN T_Bllb_keyType_tbkt KT ON KT.TBKT_ID=KM.TBKT_ID WHERE KT.KEY_TYPE = '1' AND SMR.TBSMR_TYPE='1' AND SMR.TBSMR_TYPE_VALUE='{1}' AND SMR.MaterialCode='{2}' ORDER BY SMR.TBSMR_TYPE ASC", woCode, dr["wocode"], dr["MaterialCode"]); CIT.Wcf.Utils.NMS.ExecTransql(PubUtils.uContext, strSql); if (CIT.Wcf.Utils.NMS.GetTableCount(PubUtils.uContext, strSql_check) == 0)///工单条码规则 { //机种条码规则 strSql = string.Format(@"INSERT INTO T_Bllb_projectRule_tbpr(WoCode,TBMR_ID,TBKT_ID) SELECT '{0}' WoCode,SMR.TBMR_ID,KM.TBKT_ID FROM T_Bllb_keyMaterial_tbkm KM INNER JOIN T_Bllb_specMaterialRule_tbsmr SMR ON SMR.MaterialCode=KM.MaterialCode INNER JOIN T_Bllb_keyType_tbkt KT ON KT.TBKT_ID=KM.TBKT_ID WHERE KT.KEY_TYPE = '1' AND SMR.TBSMR_TYPE='2' AND SMR.TBSMR_TYPE_VALUE='{1}' AND SMR.MaterialCode='{2}' ORDER BY SMR.TBSMR_TYPE ASC", woCode, dr["product"], dr["MaterialCode"]); CIT.Wcf.Utils.NMS.ExecTransql(PubUtils.uContext, strSql); if (CIT.Wcf.Utils.NMS.GetTableCount(PubUtils.uContext, strSql_check) == 0)///机种条码规则 { //默认条码规则 strSql = string.Format(@"INSERT INTO T_Bllb_projectRule_tbpr(WoCode,TBMR_ID,TBKT_ID) SELECT '{0}' WoCode,MR.TBMR_ID,KM.TBKT_ID FROM T_Bllb_keyMaterial_tbkm KM INNER JOIN T_Bllb_materialRule_tbmb MR ON MR.MaterialCode=KM.MaterialCode INNER JOIN T_Bllb_keyType_tbkt KT ON KT.TBKT_ID=KM.TBKT_ID WHERE KT.KEY_TYPE = '1' AND MR.DEFAULT_FLAG='Y' AND MR.MaterialCode='{1}'", woCode, dr["MaterialCode"]); CIT.Wcf.Utils.NMS.ExecTransql(PubUtils.uContext, strSql);//默认条码规则 } else//无条码规则 { strSql = string.Format(@"INSERT INTO T_Bllb_projectRule_tbpr(WoCode,TBMR_ID,TBKT_ID,MaterialCode) VALUES('{0}','','','{1}')", woCode, dr["MaterialCode"]); CIT.Wcf.Utils.NMS.ExecTransql(PubUtils.uContext, strSql); } } } } return(true); }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_ok_Click(object sender, EventArgs e) { bool isSuccess = false; T_Bllb_SecondClass_tbsc SC = new T_Bllb_SecondClass_tbsc(); lstInsert.Clear(); foreach (DataGridViewRow row in dgv_SencondClass.Rows) { if (!ValidataInput(row)) { return; } if (cbo_Type.SelectedValue.ToString() != string.Empty)//类型 { SC.Type = cbo_Type.Text.ToString(); } if (txt_Class.Text.Trim() != string.Empty)//等级 { SC.Class = txt_Class.Text.Trim(); } if (row.Cells["OrderNum"].Value != null)//序号 { SC.OrderNum = SqlInput.ChangeNullToString(row.Cells["OrderNum"].Value); } if (row.Cells["Condition"].Value != null)//条件 { SC.Condition = SqlInput.ChangeNullToString(row.Cells["Condition"].Value); } if (row.Cells["TemperatureMaxTime"].Value != null)//最大回温时间 { SC.TemperatureMaxTime = SqlInput.ChangeNullToInt(row.Cells["TemperatureMaxTime"].Value, 0); } if (row.Cells["TemperatureMinTime"].Value != null)//最小回温时间 { SC.TemperatureMinTime = SqlInput.ChangeNullToInt(row.Cells["TemperatureMinTime"].Value, 0); } if (row.Cells["ExposeTime"].Value != null)//暴露时间 { SC.ExposeTime = SqlInput.ChangeNullToInt(row.Cells["ExposeTime"].Value, 0); } if (row.Cells["InHouseTime"].Value != null)//冷藏时间 { SC.InHouseTime = SqlInput.ChangeNullToInt(row.Cells["InHouseTime"].Value, 0); } if (row.Cells["SplitTime"].Value != null)//拆分次数 { SC.SplitTime = SqlInput.ChangeNullToString(row.Cells["SplitTime"].Value); } if (row.Cells["RoastMaxTemperature"].Value != null)//最大烘烤温度 { SC.RoastMaxTemperature = SqlInput.ChangeNullToDecimal(row.Cells["RoastMaxTemperature"].Value, 0); } if (row.Cells["RoastMinTemperature"].Value != null)//最小烘烤温度 { SC.RoastMinTemperature = SqlInput.ChangeNullToDecimal(row.Cells["RoastMinTemperature"].Value, 0); } if (row.Cells["RoastTime"].Value != null)//烘烤时间 { SC.RoastTime = SqlInput.ChangeNullToInt(row.Cells["RoastTime"].Value, 0); } if (row.Cells["Remark"].Value != null)//备注 { //SC.Remark = row.Cells["Remark"].Value.ToString(); SC.Remark = SqlInput.ChangeNullToString(row.Cells["Remark"].Value); } lstInsert.Add(SC); SC = new T_Bllb_SecondClass_tbsc(); } if (lstInsert.Count > 0) { isSuccess = T_Bllb_SecondClass_tbsc_DAL.Insert(lstInsert); } if (isSuccess) { new PubUtils().ShowNoteOKMsg("保存成功!"); this.result = DialogResult.OK; this.Close(); } }
/// <summary> /// 分盘方法 /// </summary> /// <param name="varLogInfo">日志信息</param> public void PlayCutDiskMethod(int cutTimes) { string queryBarcodeInfo = string.Format(@" SELECT a.SerialNumber,a.QTY,a.Location_SN,a.Storage_SN,a.Area_SN, b.Storage_Name,c.Area_Name,d.Location_Name, a.MaterialCode FROM dbo.T_Bllb_StockInfo_tbsi AS a LEFT JOIN dbo.T_Bllb_Storage_tbs AS b ON a.Storage_SN=b.Storage_SN LEFT JOIN dbo.T_Bllb_StorageArea_tbsa AS c ON c.Storage_SN=b.Storage_SN LEFT JOIN dbo.T_Bllb_StorageLocation_tbsl AS d ON c.Area_SN=d.Area_SN WHERE a.SerialNumber='{0}'", txt_Reelid.Text.Trim()); DataTable dtInfo = NMS.QueryDataTable(PubUtils.uContext, queryBarcodeInfo); if (dtInfo.Rows.Count > 0) { txt_Reelid.Text = txt_Reelid.Text.Trim(); txtHourseName.Text = dtInfo.Rows[0]["Storage_Name"].ToString(); txtMaterialNo.Text = dtInfo.Rows[0]["MaterialCode"].ToString(); txtRollNum.Text = dtInfo.Rows[0]["QTY"].ToString(); string sql = GetCopySqlFromOldBarcode(txt_Reelid.Text); DataTable dt_temp = NMS.QueryDataTable(CIT.MES.PubUtils.uContext, sql); if (dt_temp.Rows.Count > 0) { if (dt_temp.Rows[0][0].ToString() == "1") { //分盘插入后的新条码的GUID string new_barcode_guid = dt_temp.Rows[0][1].ToString(); //流水号 string flowNumber = string.Format("{0}", (long.Parse(flowNum) + cutTimes).ToString().PadLeft(6, '0')); //生成的新条码 string new_barcode = CreateNewBarCode(flowNumber); //旧条码 DataRow[] drs = dt_MaterialInfo.Select(string.Format("SerialNumber='{0}'", txt_BarCode.Text.Trim())); if (drs.Length == 0) { new PubUtils().ShowNoteNGMsg("条码不存在", 2, grade.OrdinaryError); return; } Model.Model_MaterialBarCode bar = new Model.Model_MaterialBarCode(); Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Clear(); bar.MaterialCode = txtMaterialNo.Text.Trim(); //物料代码 dic.Add("MaterialCode", bar.MaterialCode); bar.QTY = txtSigleCount.Text.ToString(); //数量 dic.Add("QTY", bar.QTY.Trim()); bar.BEGIN_DATE = SqlInput.ChangeNullToString(drs[0]["DateCode"]); //生产日期 dic.Add("BEGIN_DATE", bar.BEGIN_DATE); bar.PO = SqlInput.ChangeNullToString(drs[0]["PO"]); //采购订单号 dic.Add("PO", bar.PO); bar.MPN = SqlInput.ChangeNullToString(drs[0]["MPN"]); //MPN dic.Add("MPN", bar.MPN); bar.SN = new_barcode; dic.Add("SN", bar.SN); bar.QRCODE = new_barcode; dic.Add("QRCODE", bar.QRCODE); if (Common.BLL.Bll_Print.PrintTemplet("安费诺来料打印", dic)) { bool result = NMS.ExecTransql(CIT.MES.PubUtils.uContext, UpdateStockInfo(new_barcode, _old_reelid, new_barcode_guid, Convert.ToDecimal(txtSigleCount.Text))); if (result == true) { lbLogInfo.Items.Add(string.Format("分盘成功!唯一码:{0}", new_barcode)); GetMaterialInfo(txt_Reelid.Text.Trim()); } else { lbLogInfo.Items.Add("分盘失败!"); return; } bar = new Model.Model_MaterialBarCode(); } } else { //物料预注册失败 new PubUtils().ShowNoteNGMsg("物料预注册失败!", 1, grade.OrdinaryError); return; } } } else { new PubUtils().ShowNoteNGMsg("不存在该料卷!", 1, grade.OrdinaryError); WriteLogToControl(string.Format("输入了一个不存在的料卷:{0}", txt_BarCode.Text.Trim())); return; } }
/// <summary> /// 打印外包装标签 /// </summary> /// <param name="SN"></param> /// <returns></returns> public static bool PrintContain_1_Info(string SN, string lableName, ref string msg) { if (SN == string.Empty) { msg = "箱条码不能为空"; return(false); } else if (lableName == string.Empty) { msg = "打印标签不能为空"; return(false); } Model.Model_PackageInfo _obj_PackageInfo = new Model_PackageInfo(); T_Bllb_packageOne_tbpo tbpo = new T_Bllb_packageOne_tbpo(); string strSql = string.Format(@"select isnull(SUM(tbpi.QTY),0) as QTY,sfc.PO,tbpo.CONTAINER_SN_1 AS BOXID, SFC.Product AS PRODUCTCODE,'12个月' as ACTIVE_LENGTH from T_Bllb_packageOne_tbpo as tbpo inner join T_Bllb_productInfo_tbpi as tbpi on tbpo.TBPS_ID=tbpi.TBPS_ID inner join SfcDatProduct sfc on sfc.SfcNo=tbpi.SfcNo where tbpo.CONTAINER_SN_1='{0}' GROUP BY sfc.PO,tbpo.CONTAINER_SN_1,SFC.Product", SN); DataTable dt_qty = NMS.QueryDataTable(PubUtils.uContext, strSql.ToString()); if (dt_qty.Rows.Count == 0) { msg = "条码不是箱条码"; return(false); } _obj_PackageInfo.QTY = SqlInput.ChangeNullToInt(dt_qty.Rows[0]["QTY"], 0).ToString();//容器实装数量 if (_obj_PackageInfo.QTY == "0") { msg = "箱子中没有产品"; return(false); } _obj_PackageInfo.PO = SqlInput.ChangeNullToString(dt_qty.Rows[0]["PO"]); _obj_PackageInfo.PRODUCTCODE = SqlInput.ChangeNullToString(dt_qty.Rows[0]["PRODUCTCODE"]); _obj_PackageInfo.P1 = SqlInput.ChangeNullToString(dt_qty.Rows[0]["PRODUCTCODE"]); _obj_PackageInfo.ACTIVE_LENGTH = "12个月"; _obj_PackageInfo.BEGIN_DATE = DateTime.Now.ToString("yyyyMMdd"); _obj_PackageInfo.END_DATE = DateTime.Now.AddMonths(12).ToString("yyyyMMdd"); _obj_PackageInfo.E1 = DateTime.Now.AddMonths(12).ToString("yyyyMMdd"); _obj_PackageInfo.BOXID = SqlInput.ChangeNullToString(dt_qty.Rows[0]["BOXID"]); if (Bll_Common.GetSysParameter("DZ", "DZ006", ref msg)) { string[] strs = msg.Split('|'); if (strs.Length >= 2) { _obj_PackageInfo.SUPPLIER = strs[0]; _obj_PackageInfo.SUPPLIER_CODE = strs[1]; } else { msg = "在系统参数【单值】中的【DZ006】配置供应商信息"; return(false); } } else { msg = "在系统参数【单值】中的【DZ006】配置供应商信息"; return(false); } if (_obj_PackageInfo.PrintOwn(lableName)) { //标识为已打印外包装标签 strSql = string.Format("update T_Bllb_packageOne_tbpo set PRINT_FLAG='Y' where CONTAINER_SN_1='{0}'", tbpo.CONTAINER_SN_1); NMS.ExecTransql(PubUtils.uContext, strSql); } return(true); }
/// <summary> /// 产品过站 /// </summary> /// <param name="serialNumber"></param> /// <param name="TBS_ID"></param> /// <param name="TBTG_ID"></param> /// <param name="WIP_TBTG_ID"></param> /// <param name="lst_error"></param> /// <param name="msg"></param> /// <returns></returns> public static bool PassGroup(string serialNumber, string TBS_ID, string TBTG_ID, string WIP_TBTG_ID, List <string> lst_error, ref string msg) { //获取TBPS_ID(产品状态ID)、TBG_ID(工序ID)、PLCODE(线别代码) string UseId = PubUtils.uContext.UserID; //员工号 bool newInput = false; //是否新投入的产品 #region 查询产品信息 DataTable dt_Product = QueryProductSN(serialNumber);//查询产品信息 if (dt_Product.Rows.Count == 0) { msg = "不存在条码" + serialNumber; return(false); } string sfcNo = dt_Product.Rows[0]["SFCNO"].ToString(); //制令单 string TBPS_ID = dt_Product.Rows[0]["TBPS_ID"].ToString(); //产品状态ID(在产品信息表中不是唯一) string once_Over_Flag = dt_Product.Rows[0]["ONCE_OVER_FLAG"].ToString(); //是否曾经流程结束(Y/N)(针对流程结束又原单返工情况) string TBT_ID = dt_Product.Rows[0]["TBT_ID"].ToString(); //工艺ID string PLCode = SqlInput.ChangeNullToString(dt_Product.Rows[0]["LINE"]); //线别代码 #endregion #region 工艺信息 string TBG_ID = string.Empty; //工序ID string inout_Type = string.Empty; //工艺工序类型 //string TBTG_ID = string.Empty;//工艺工序ID //获取工艺工序ID对应的工艺工序信息 DataTable dt_TBTG_ID = QueryTechGroup(TBT_ID, TBTG_ID); if (dt_TBTG_ID.Rows.Count == 0) { msg = "工位不在当前产品所在的工艺中"; return(false); } else { inout_Type = SqlInput.ChangeNullToString(dt_TBTG_ID.Rows[0]["INOUT_TYPE"]);//投入产出标识 //TBTG_ID = SqlInput.ChangeNullToString(dt_TBTG_ID.Rows[0]["TBTG_ID"]);//工艺工序ID TBG_ID = SqlInput.ChangeNullToString(dt_TBTG_ID.Rows[0]["TBG_ID"]);//工序ID } #endregion #region 新增/修改产品状态信息表 //1.1、新增/修改产品状态信息表 Model_Bllb_productStatus_tbps obj_Status = new Model_Bllb_productStatus_tbps(); obj_Status.PLCode = PLCode; //线别代码 obj_Status.SfcNo = sfcNo; //制令单 obj_Status.TBTG_ID = TBTG_ID; //工艺工序ID obj_Status.WIP_TBTG_ID = WIP_TBTG_ID; //下一个工艺工序ID if (newInput == true) //新投入产品 { obj_Status.TBPS_ID = Guid.NewGuid().ToString(); //产品状态ID TBPS_ID = obj_Status.TBPS_ID; InsertProductStatus(obj_Status); //新增产品状态信息 } else//在制品 { obj_Status.TBPS_ID = TBPS_ID;//产品状态ID UpdateProductStatus(obj_Status); } #endregion #region 过站记录 Model.Model_Bllb_productPass_tbpp obj_Pass = new Model.Model_Bllb_productPass_tbpp(); obj_Pass.TBG_ID = TBG_ID; //工序ID obj_Pass.TBPP_ID = Guid.NewGuid().ToString(); //过站记录ID obj_Pass.TBPS_ID = TBPS_ID; //产品状态ID obj_Pass.PLCode = PLCode; //线别代码 obj_Pass.TBS_ID = TBS_ID; //工位ID //1.2、添加产品过站记录表 if (lst_error.Count > 0) { obj_Pass.STATE_FLAG = "1"; //不良品 InsertProductPass(obj_Pass); //不良品过站记录 foreach (string str_TBEC_ID in lst_error) { //1.3、添加不良信息 Model.Model_Bllb_productError_tbpe obj_pe = new Model.Model_Bllb_productError_tbpe(); obj_pe.ERROR_MAN = UseId; //打不良人 obj_pe.TBEC_ID = str_TBEC_ID; //不良代码ID obj_pe.TBPE_ID = Guid.NewGuid().ToString(); //不良记录ID obj_pe.TBPS_ID = TBPS_ID; //产品状态ID obj_pe.TBS_ID = TBS_ID; //工位ID obj_pe.TBG_ID = TBG_ID; //工序ID InsertProductError(obj_pe); } //1.4、产品标识为不良 UpdateErrorFlag(serialNumber);//产品标识为不良 } else { obj_Pass.STATE_FLAG = "0"; //良品 InsertProductPass(obj_Pass); //良品过站记录 } //1.4、新增产品信息 Model.Model_Bllb_productInfo_tbpi obj_Info = new Model.Model_Bllb_productInfo_tbpi(); obj_Info.QTY = 1; //数量 obj_Info.SERIAL_NUMBER = serialNumber; //产品SN if (lst_error.Count > 0) { obj_Info.ERROR_FLAG = "Y";//是否不良 } else { obj_Info.ERROR_FLAG = "N"; //是否不良 } obj_Info.LAST_FLAG = "Y"; //是否最新记录 obj_Info.OVER_FLAG = "N"; //是否流程结束 obj_Info.REPAIR_FLAG = "N"; //是否维修过 obj_Info.SCRAP_FLAG = "N"; //是否报废 obj_Info.ONCE_OVER_FLAG = "N"; //是否曾经流程结束过(是针对原单返工的情况) obj_Info.SfcNo = sfcNo; //制令单 obj_Info.TBPI_ID = Guid.NewGuid().ToString(); //唯一码 obj_Info.TBPS_ID = TBPS_ID; //产品状态ID if (inout_Type == "0" || inout_Type == "3") //主线投入或者主线投入产出标识 { obj_Info.AUXILIARY_FLAG = "N"; } else if (inout_Type == "2")//辅助线投入 { obj_Info.SERIAL_NUMBER = string.Empty; obj_Info.AUXILIARY_FLAG = "Y"; } else if (inout_Type == "1") //产出工序 { if (lst_error.Count > 0) //是否不良 { obj_Info.OVER_FLAG = "N"; //是否流程结束 obj_Info.ONCE_OVER_FLAG = once_Over_Flag; //是否曾经流程结束(Y/N)(针对流程结束又原单返工情况) } else { obj_Info.OVER_FLAG = "Y"; //是否流程结束 obj_Info.ONCE_OVER_FLAG = "Y"; //是否曾经流程结束(Y/N)(针对流程结束又原单返工情况) } } if (inout_Type == "0") //投入工序(注意考虑回流情况) { if (newInput == true) //新投入产品 { //1.4、新增产品信息 InsertProdcutInfo(obj_Info); } } else if (inout_Type == "1")//1:产出工序 { //1.4、修改产品信息表() UpdateOverTech(obj_Info); //新增产品信息 if (once_Over_Flag == "N" || obj_Info.ERROR_FLAG == "N") //是否是流程结束后又原单返工 { //1.5、修改制令单的产出数(是否流程结束过,若是则不增加制令单产出数)(注意流程结束后隔天返工情况) UpdateSfcNo_ActQty(sfcNo, 1); } } else if (inout_Type == "2")//辅助投入工序 { //1.4、修改产品信息表 if (newInput == true) //新投入产品 { InsertProdcutInfo(obj_Info); //辅助投入时,产品SN设置为空,可用于验证辅助产品是否被组合到主线产品上,为空是还没被组合,组合后为空的辅助产品条码赋值为主线产品条码 } } else if (inout_Type == "3")//投入产出工序 { //1.4、新增产品信息表 if (newInput == true)//新投入产品 { InsertProdcutInfo(obj_Info); } if (once_Over_Flag == "N")//是否是流程结束后又原单返工 { //1.5、修改制令单的产出数(是否流程结束过,若是则不增加制令单产出数)(注意流程结束后隔天返工情况) UpdateSfcNo_ActQty(sfcNo, 1); } } #endregion //if (lst_error.Count == 0) //{ // AUTO_QA(); //} #region 数据统计 Model_Bllb_groupStatistics_tbgs obj = new Model_Bllb_groupStatistics_tbgs(); if (lst_error.Count > 0) { obj.ERROR_NUM = 1;//打不良次数 } else { obj.ERROR_NUM = 0; //打不良次数 } obj.PASS_NUM = 1; //过站次数 obj.SfcNo = sfcNo; //制令单 obj.TBTG_ID = TBTG_ID; //工艺工序ID InsertOrUpdateGroupStatistics(obj); //统计过站次数和打不良次数 if (WIP_TBTG_ID != string.Empty) //下一个工序的统计信息 { obj.PASS_NUM = 0; obj.TBTG_ID = WIP_TBTG_ID; obj.ERROR_NUM = 0; InsertOrUpdateWipGroupStatistics(obj);//判断下一个工序是否有统计数据,若是没有则新增一个 } #endregion return(true); }
private void Query() { #region 所选项汇总 如:只选择仓库就对仓库汇总,只选择仓库库区就对仓库库区汇总 //StringBuilder strGroup = new StringBuilder(); //string querywhere = string.Empty; //string querycolumn = ",b.Storage_Name"; //strGroup.Append("b.Storage_Name"); //if (cbo_stockName.SelectedValue.ToString() != string.Empty) //{ // querywhere += string.Format(" AND b.Storage_Name='{0}'", cbo_stockName.Text.ToString()); //} //if (SqlInput.ChangeNullToString(cbo_area.SelectedValue) != string.Empty) //{ // querywhere += string.Format(" AND c.Area_Name='{0}'", cbo_area.Text.ToString()); // querycolumn += string.Format(",c.Area_Name"); // strGroup.Append(",c.Area_Name"); //} //if (SqlInput.ChangeNullToString(cbo_location.SelectedValue) != string.Empty) //{ // querywhere += string.Format(" AND d.Location_Name='{0}'", cbo_location.Text.ToString()); // querycolumn += string.Format(",d.Location_Name"); // strGroup.Append(",d.Location_Name"); //} //if (txt_materialCode.Text.Trim() != string.Empty) //{ // querywhere += string.Format(" AND a.MaterialCode='{0}'", txt_materialCode.Text.Trim()); //} //querycolumn += string.Format(",a.MaterialCode"); //strGroup.Append(",a.MaterialCode"); //DataTable dt_Stock = Bll_Bllb_StockInfo_tbsi.SelectAll(querywhere, querycolumn, strGroup.ToString()); //if (!dt_Stock.Columns.Contains("Area_Name")) // dt_Stock.Columns.Add("Area_Name"); //if (!dt_Stock.Columns.Contains("Location_Name")) // dt_Stock.Columns.Add("Location_Name"); //if (!dt_Stock.Columns.Contains("MaterialCode")) // dt_Stock.Columns.Add("MaterialCode"); //if (!dt_Stock.Columns.Contains("QTY")) // dt_Stock.Columns.Add("QTY"); //dtSource = dt_Stock.Copy(); //dgv_stockAll.DataSource = dtSource; #endregion #region 仓库库区库位料号都带出来 string strWhere = " Where 1=1 "; if (cbo_stockName.SelectedValue.ToString() != string.Empty) { strWhere += string.Format(" AND b.Storage_Name='{0}' ", cbo_stockName.Text); } if (SqlInput.ChangeNullToString(cbo_area.SelectedValue) != string.Empty) { strWhere += string.Format(" AND c.Area_Name='{0}'", cbo_area.Text); } if (SqlInput.ChangeNullToString(cbo_location.SelectedValue) != string.Empty) { strWhere += string.Format(" AND d.Location_Name='{0}'", cbo_location.Text); } if (txt_materialCode.Text.Trim() != string.Empty) { strWhere += string.Format(" AND a.MaterialCode='{0}'", txt_materialCode.Text.Trim()); } DataTable dt = Bll_Bllb_StockInfo_tbsi.SelectStock(strWhere); dgv_stockAll.DataSource = dt; #endregion }
/// <summary> /// 导出EXCEL /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnExport_Click(object sender, EventArgs e) { try { string filepath = string.Empty; SaveFileDialog sd = new SaveFileDialog(); sd.Title = "保存EXECL文件"; sd.Filter = "*.xls|*.xls"; sd.FilterIndex = 1; if (sd.ShowDialog() != DialogResult.OK) { return; } filepath = sd.FileName; if (File.Exists(filepath)) { File.Delete(filepath); } #region 注释掉 只导出所选项 //string querywhere = string.Empty; //string querycolumn = ",b.Storage_Name as '仓库'"; //StringBuilder strGroup = new StringBuilder(); //strGroup.Append("b.Storage_Name"); //if (cbo_stockName.SelectedValue.ToString() != string.Empty) //{ // querywhere += string.Format(" AND b.Storage_Name='{0}'", cbo_stockName.Text.ToString()); //} //if (SqlInput.ChangeNullToString(cbo_area.SelectedValue) != string.Empty) //{ // querywhere += string.Format(" AND c.Area_Name='{0}'", cbo_area.Text.ToString()); // querycolumn += string.Format(",c.Area_Name as '库区'"); // strGroup.Append(",c.Area_Name"); //} //if (SqlInput.ChangeNullToString(cbo_location.SelectedValue) != string.Empty) //{ // querywhere += string.Format(" AND d.Location_Name='{0}'", cbo_location.Text.ToString()); // querycolumn += string.Format(",d.Location_Name as '库位'"); // strGroup.Append(",d.Location_Name"); //} //if (txt_materialCode.Text.Trim() != string.Empty) //{ // querywhere += string.Format(" AND a.MaterialCode='{0}'", txt_materialCode.Text.Trim()); //} //querycolumn += string.Format(",a.MaterialCode as '料号'"); //strGroup.Append(",a.MaterialCode"); //DataTable dt_all = Bll_Bllb_StockInfo_tbsi.QueryExportAll(querywhere, querycolumn, strGroup.ToString()); //dt_all.Columns["QTY"].SetOrdinal(dt_all.Columns.Count - 1); #endregion #region 仓库、库区、库位、料号导出 string strWhere = " Where 1=1"; if (cbo_stockName.SelectedValue.ToString() != string.Empty) { strWhere += string.Format(" AND b.Storage_Name='{0}' ", cbo_stockName.Text); } if (SqlInput.ChangeNullToString(cbo_area.SelectedValue) != string.Empty) { strWhere += string.Format(" AND c.Area_Name='{0}'", cbo_area.Text); } if (SqlInput.ChangeNullToString(cbo_location.SelectedValue) != string.Empty) { strWhere += string.Format(" AND d.Location_Name='{0}'", cbo_location.Text); } if (txt_materialCode.Text.Trim() != string.Empty) { strWhere += string.Format("AND a.MaterialCode='{0}'", txt_materialCode.Text.Trim()); } DataTable dt_all = Bll_Bllb_StockInfo_tbsi.StockExportAll(strWhere); #endregion Common.Helper.ExcelHelper.TableToExcel(dt_all, filepath); new PubUtils().ShowNoteOKMsg("导出成功"); } catch { new PubUtils().ShowNoteNGMsg("导出失败", 2, grade.OrdinaryError); } }
private void txtQrcode_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { if (string.IsNullOrEmpty(txtQrcode.Text.Trim())) { new CIT.MES.PubUtils().ShowNoteNGMsg("SN不能为空", 2, CIT.MES.grade.OrdinaryError); return; } string strSql = string.Format(@" IF NOT EXISTS ( SELECT * FROM dbo.T_Bllb_StorageDocDetail_tbsdd WHERE SerialNumber = '{0}' ) BEGIN SELECT '0' , 'Reelid未清点过,无法重打' RETURN END ELSE BEGIN IF NOT EXISTS ( SELECT * FROM dbo.T_Bllb_StockInfo_tbsi WHERE SerialNumber = '{0}' AND Lock_Flag IN ( '0', '7' ) ) BEGIN SELECT '0' , '此Reelid不允许重打' RETURN END SELECT 1 , a.PO , c.*,D.QTY NOW_QTY FROM dbo.T_Bllb_POMain_tbpm AS a INNER JOIN dbo.T_Bllb_PODetail_tbpd AS b ON a.POID = b.POID INNER JOIN T_Bllb_StorageDocDetail_tbsdd AS c ON c.PO_DetailID = b.PO_DetailID INNER JOIN T_Bllb_StockInfo_tbsi D ON D.SerialNumber=C.SerialNumber WHERE c.SerialNumber = '{0}' RETURN END ", txtQrcode.Text.Trim()); DataTable dtQRCode = CIT.Wcf.Utils.NMS.QueryDataTable(CIT.MES.PubUtils.uContext, strSql); if (dtQRCode.Rows.Count == 0) { MsgBox.Error("DB数据异常"); txtQrcode.SelectAll(); return; } if (dtQRCode.Rows[0][0].ToString() == "0") { MsgBox.Error(dtQRCode.Rows[0][1].ToString()); txtQrcode.SelectAll(); return; } Model.Model_MaterialBarCode bar = new Model.Model_MaterialBarCode(); Dictionary <string, string> dic = new Dictionary <string, string>(); bar.MaterialCode = SqlInput.ChangeNullToString(dtQRCode.Rows[0]["MaterialCode"]); //料号 dic.Add("MaterialCode", bar.MaterialCode); bar.QTY = SqlInput.ChangeNullToString(dtQRCode.Rows[0]["NOW_QTY"]); //数量 dic.Add("QTY", SqlInput.ChangeNullToString(dtQRCode.Rows[0]["NOW_QTY"])); bar.MPN = SqlInput.ChangeNullToString(dtQRCode.Rows[0]["MPN"]); //MPN dic.Add("MPN", bar.MPN); bar.PO = SqlInput.ChangeNullToString(dtQRCode.Rows[0]["PO"]); //采购订单号 dic.Add("PO", bar.PO); bar.QRCODE = SqlInput.ChangeNullToString(dtQRCode.Rows[0]["SerialNumber"]); //条码 dic.Add("QRCODE", bar.QRCODE); bar.BEGIN_DATE = SqlInput.ChangeNullToString(dtQRCode.Rows[0]["DateCode"]); //DateCode dic.Add("BEGIN_DATE", bar.BEGIN_DATE); Common.BLL.Bll_Print.PrintTemplet("安费诺来料打印", dic); string str_qcode_log = string.Format(@" INSERT INTO dbo.T_Bllb_MaterialLog_tbml ( SerialNumber , CreateTime , OperateType , MaterialCode , QTY , Creator , TBML_ID ) VALUES ( '{0}' , -- SerialNumber - nvarchar(200) GETDATE() , -- CreateTime - datetime '重打标签' , -- OperateType - nvarchar(50) '{1}' , -- MaterialCode - nvarchar(50) '{2}', -- QTY - int '{3}' , -- Creator - nvarchar(50) '{4}' -- TBML_ID - nvarchar(50) )", bar.QRCODE, bar.MaterialCode, bar.QTY, CIT.MES.PubUtils.uContext.UserID, Guid.NewGuid().ToString()); CIT.Wcf.Utils.NMS.ExecTransql(CIT.MES.PubUtils.uContext, str_qcode_log); bar = new Model.Model_MaterialBarCode(); new CIT.MES.PubUtils().ShowNoteOKMsg("打印成功"); txtQrcode.SelectAll(); } }
private void btn_ok_Click(object sender, EventArgs e) { T_Bllb_StorageDoc_tbsd SC = new T_Bllb_StorageDoc_tbsd(); T_Bllb_StorageDocMaterial_tsdm SCD = new T_Bllb_StorageDocMaterial_tsdm(); bool isSucess = false; if (_IsAddOrEdit == false)//新增 { if (txt_DOC_NO.Text != string.Empty) { SC.S_Doc_NO = txt_DOC_NO.Text.Trim();//单据号 } if (cbo_SourceStorage.SelectedValue.ToString() != string.Empty) { SC.Source_Storage = cbo_SourceStorage.SelectedValue.ToString();//原仓库 } if (cbo_TargetStorage.SelectedValue.ToString() != string.Empty) { SC.Target_Storage = cbo_TargetStorage.SelectedValue.ToString();//目的仓库 } if (txt_memo.Text != string.Empty) { SC.Memo = txt_memo.Text.Trim();//备注 } if (cbo_SourceStorage.SelectedValue.ToString() == cbo_TargetStorage.SelectedValue.ToString()) { new PubUtils().ShowNoteNGMsg("原仓库不能跟目的仓库相同", 2, grade.OrdinaryError); return; } lstMaterial.Clear(); foreach (DataGridViewRow row in dgv_MaterialMoveAdd.Rows) { if (!ValiMaterialCode(row)) { return; } SCD.S_Doc_NO = txt_DOC_NO.Text.Trim(); SCD.RowNumber = SqlInput.ChangeNullToInt(row.Cells["RowNumber"].Value, 0); //行号 SCD.MaterialCode = SqlInput.ChangeNullToString(row.Cells["MaterialCode"].Value); //料号 row.Cells["StorageQTY"].Value = Bll_Bllb_StockInfo_tbsi.GetQty(cbo_SourceStorage.SelectedValue.ToString(), SqlInput.ChangeNullToString(row.Cells["MaterialCode"].Value)); SCD.QTY = SqlInput.ChangeNullToInt(row.Cells["StorageQTY"].Value, 0); //库存量 SCD.Plan_Qty = SqlInput.ChangeNullToInt(row.Cells["Plan_Qty"].Value, 0); //计划数量 lstMaterial.Add(SCD); SCD = new T_Bllb_StorageDocMaterial_tsdm(); } if (lstMaterial.Count > 0) { if (Bll_Bllb_StorageDoc_tbsd.InsertDoc(SC)) { isSucess = Bll_Bllb_StorageDocMaterial_tsdm.InsertMaterial(lstMaterial); } } } else//修改 { lstMaterial.Clear(); foreach (DataGridViewRow row in dgv_MaterialMoveAdd.Rows) { if (!ValiMaterialCode(row)) { return; } SCD.S_Doc_NO = txt_DOC_NO.Text.Trim(); SCD.RowNumber = SqlInput.ChangeNullToInt(row.Cells["RowNumber"].Value, 0); //行号 SCD.MaterialCode = SqlInput.ChangeNullToString(row.Cells["MaterialCode"].Value); //料号 row.Cells["StorageQTY"].Value = Bll_Bllb_StockInfo_tbsi.GetQty(cbo_SourceStorage.SelectedValue.ToString(), SqlInput.ChangeNullToString(row.Cells["MaterialCode"].Value)); SCD.QTY = SqlInput.ChangeNullToInt(row.Cells["StorageQTY"].Value, 0); //库存量 SCD.Plan_Qty = SqlInput.ChangeNullToInt(row.Cells["Plan_Qty"].Value, 0); //计划数量 lstMaterial.Add(SCD); SCD = new T_Bllb_StorageDocMaterial_tsdm(); } if (lstMaterial.Count > 0) { string strWhere = string.Format("S_Doc_NO ='{0}'", txt_DOC_NO.Text.Trim()); if (Bll_Bllb_StorageDocMaterial_tsdm.DeleteMaterial(strWhere)) { isSucess = Bll_Bllb_StorageDocMaterial_tsdm.InsertMaterial(lstMaterial); } } } if (isSucess) { new PubUtils().ShowNoteOKMsg("保存成功!"); this.result = DialogResult.OK; this.Close(); } }
private bool ValiMaterialCode(DataGridViewRow row) { if (row.Cells["MaterialCode"].EditedFormattedValue.ToString() == string.Empty) { new PubUtils().ShowNoteNGMsg("料号不能为空", 2, grade.RepeatedError); return(false); } string strSql = string.Format("select * from T_Bllb_StockInfo_tbsi where MaterialCode='{0}'", row.Cells["MaterialCode"].EditedFormattedValue); DataTable dt_MaterialExist = NMS.QueryDataTable(PubUtils.uContext, strSql); if (dt_MaterialExist.Rows.Count == 0) { new PubUtils().ShowNoteNGMsg("料号不存在", 2, grade.OrdinaryError); return(false); } if (_IsAddOrEdit == true && dgv_MaterialMoveAdd.Rows.Count == 1) { return(true); } if (_IsAddOrEdit == false) { string str_Exist = string.Format("select * from T_Bllb_StorageDocMaterial_tsdm where MaterialCode='{0}' and S_Doc_NO='{1}'", row.Cells["MaterialCode"].EditedFormattedValue, txt_DOC_NO.Text.Trim()); DataTable dt_Exist = NMS.QueryDataTable(PubUtils.uContext, str_Exist); if (dt_Exist.Rows.Count > 0) { new PubUtils().ShowNoteNGMsg("单据不能添加重复的料号", 2, grade.OrdinaryError); return(false); } } foreach (DataGridViewRow dgvr in dgv_MaterialMoveAdd.Rows) { if (dgvr.Index == row.Index) { continue; } if (SqlInput.ChangeNullToString(dgvr.Cells["MaterialCode"].EditedFormattedValue) == SqlInput.ChangeNullToString(row.Cells["MaterialCode"].EditedFormattedValue)) { new PubUtils().ShowNoteNGMsg("料号不能重复添加", 2, grade.OrdinaryError); return(false); } } if (row.Cells["StorageQTY"].Value != null) { if (row.Cells["Plan_Qty"].EditedFormattedValue == null) { new PubUtils().ShowNoteNGMsg("计划数量不能为空", 2, grade.OrdinaryError); return(false); } } if (!(row.Cells["Plan_Qty"].Value == null && row.Cells["StorageQTY"].Value == null)) { if (SqlInput.ChangeNullToInt(row.Cells["Plan_Qty"].EditedFormattedValue, 0) > SqlInput.ChangeNullToInt(row.Cells["StorageQTY"].Value, 0)) { new PubUtils().ShowNoteNGMsg("计划数量必须小于库存数量", 2, grade.OrdinaryError); return(false); } } return(true); }