Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        /// <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;
            }
        }
Exemplo n.º 3
0
        //执行打印
        private void Printing()
        {
            int MinQty     = SqlInput.ChangeNullToInt(txt_MinPackage.Text.Trim(), 0);
            int TotalQty   = SqlInput.ChangeNullToInt(txt_Qty.Text.Trim(), 0);
            int packageQty = TotalQty / MinQty;
            int lastQty    = TotalQty % MinQty;

            if (lastQty > 0)
            {
                packageQty++;
            }
            string snString      = string.Empty;
            string barCodeString = string.Empty;

            Model.Model_MaterialBarCode bar = new Model.Model_MaterialBarCode();
            Dictionary <string, string> dic = new Dictionary <string, string>();

            for (int i = 1; i <= packageQty; i++)//循环打印条码
            {
                dic.Clear();
                snString = getSN();
                if (string.IsNullOrEmpty(snString))
                {
                    new PubUtils().ShowNoteNGMsg("获取流水码失败!", 1, grade.SevereError);
                    return;
                }

                txtSN.Text = snString;

                barCodeString     = snString + "|" + cbo_MaterialCode.Text.Trim() + "|" + txt_Qty.Text.Trim() + "|" + txt_SUPPLIER_CODE.Text.Trim() + "|" + DateTime.Parse(dtpProductionDate.Text.Trim()).ToString("yyyyMMdd");
                bar.SUPPLIER_CODE = txt_SUPPLIER_CODE.Text.Trim();      //供应商代码
                dic.Add("SUPPLIER_CODE", bar.SUPPLIER_CODE);
                bar.MaterialCode = cbo_MaterialCode.Text.Split('*')[0]; //物料代码
                dic.Add("MaterialCode", bar.MaterialCode);
                bar.RowNumber = cbo_MaterialCode.Text.Split('*')[1];    //行号
                dic.Add("RowNumber", bar.RowNumber);
                bar.MaterialDesc = txt_MaterialDesc.Text.Trim();        //型号规格
                dic.Add("MaterialDesc", bar.MaterialDesc);
                bar.QTY = MinQty.ToString();                            //数量
                if (i == packageQty)
                {
                    dic.Add("QTY", lastQty.ToString());
                }
                else
                {
                    dic.Add("QTY", MinQty.ToString());
                }

                bar.BEGIN_DATE = dtpProductionDate.Value.ToString("yyMMdd"); //生产日期
                dic.Add("BEGIN_DATE", bar.BEGIN_DATE);
                bar.PO = cbo_PO.Text.Trim();                                 //采购订单号
                dic.Add("PO", bar.PO + "|" + bar.RowNumber);
                bar.SN = snString;
                dic.Add("SN", bar.SN);
                bar.QRCODE = bar.SUPPLIER_CODE + "|" + bar.MaterialCode + "|" + bar.SN + "|Q" + bar.QTY + "|D" + bar.BEGIN_DATE + "|" + bar.PO + "|" + bar.RowNumber;
                dic.Add("QRCODE", bar.QRCODE);
                Common.BLL.Bll_Print.PrintTemplet("来料打印", dic);
            }

            Reset();
        }
Exemplo n.º 4
0
        /// <summary>
        /// 分盘方法
        /// </summary>
        /// <param name="varLogInfo">日志信息</param>
        public void Panels(int cutTimes)
        {
            string    sqlSelectRollInfo = string.Format(@"
SELECT  a.Storage_SN ,
        a.QTY ,
        a.MaterialCode ,
        a.Location_SN ,
        a.SerialNumber ,
        a.DateCode ,
        a.MPN
FROM    dbo.T_Bllb_StockInfo_tbsi AS a
        LEFT JOIN dbo.T_Bllb_Storage_tbs AS b ON a.Storage_SN = b.Storage_SN
WHERE   a.SerialNumber = '{0}'", txt_Reelid.Text.Trim());
            DataTable dtRollInfo        = NMS.QueryDataTable(PubUtils.uContext, sqlSelectRollInfo);

            if (dtRollInfo.Rows.Count > 0)
            {
                txt_Reelid.Text    = txt_Reelid.Text.Trim();
                txtHourseName.Text = dtRollInfo.Rows[0]["Storage_SN"].ToString();
                txtMaterialNo.Text = dtRollInfo.Rows[0]["MaterialCode"].ToString();
                txtRollNum.Text    = dtRollInfo.Rows[0]["QTY"].ToString();
                string    sql     = GetPreNotPreStandardInsert(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")
                    {
                        int index = int.Parse(dt_temp.Rows[0][1].ToString());
                        //分盘插入后的新条码的GUID
                        string fguid = dt_temp.Rows[0][2].ToString();
                        //流水号
                        string flowNumber = string.Format("{0}{1}", currentDate, (long.Parse(flownum) + cutTimes).ToString().PadLeft(6, '0'));
                        //生成的新条码
                        string newBarCode = CreateNewBarCode(flowNumber);
                        //新的ReelId
                        string newReelid = newBarCode;
                        //最后要更新的条码规则的Reelid
                        Model.Model_MaterialBarCode bar = new Model.Model_MaterialBarCode();
                        bar.MaterialCode = txtMaterialNo.Text.Trim();            //物料代码
                        bar.QTY          = Convert.ToString(txtSigleCount.Text); //数量


                        barobject.BarCode      = newBarCode;//打印的条码
                        barobject.partNo       = txtMaterialNo.Text;
                        barobject.SingleNumber = Convert.ToInt32(txtSigleCount.Text);
                        if (barobject.PrintOwn("002"))
                        {
                            bool result = NMS.ExecTransql(CIT.MES.PubUtils.uContext, GetUpdateMdcDatVStorage(newReelid, fguid, txt_Reelid.Text, Convert.ToDecimal(txtSigleCount.Text)));
                            if (result == true)
                            {
                                lbLogInfo.Items.Add(string.Format("分盘成功!唯一码:{0}", newReelid));
                                GetMaterialInfo(txt_Reelid.Text.Trim());
                            }
                            else
                            {
                                lbLogInfo.Items.Add("分盘失败!");
                                return;
                            }
                        }
                    }
                }
                else
                {
                    //物料预注册失败
                    new PubUtils().ShowNoteNGMsg("物料预注册失败!", 1, grade.OrdinaryError);
                    return;
                }
            }
            else
            {
                new PubUtils().ShowNoteNGMsg("不存在该料卷!", 1, grade.OrdinaryError);
                SaveLogInfo(string.Format("输入了一个不存在的料卷:{0}", txt_BarCode.Text.Trim()));
                return;
            }
        }
Exemplo n.º 5
0
        //执行打印
        private void Printing()
        {
            #region 采购清点
            string doc_no       = string.Empty;                 //清点单号
            string MaterialCode = txt_MaterialCode.Text.Trim(); //料号
            int    qty          = 0;
            qty = SqlInput.ChangeNullToInt(txt_Qty.Text, 0);    //数量
            //判断清点单是否已生成,若无则自动生成清点单
            DataTable dt_doc = NMS.QueryDataTable(PubUtils.uContext, string.Format("SELECT S_Doc_NO  FROM T_Bllb_StorageDoc_tbsd WHERE PO='{0}'and DATEDIFF(DAY,GETDATE(),Create_Time)=0 AND S_Doc_Type='1' AND Close_Flag='N' ORDER BY Create_Time DESC", txt_PO.Text.Trim()));
            if (dt_doc.Rows.Count == 0)
            {
                dt_doc = NMS.QueryDataTable(PubUtils.uContext, "SELECT  TOP 1 RIGHT(S_Doc_NO,4)+1  FROM T_Bllb_StorageDoc_tbsd WHERE DATEDIFF(DAY,GETDATE(),Create_Time)=0  AND S_Doc_Type='1' ORDER BY Create_Time DESC");
                if (dt_doc.Rows.Count > 0)
                {
                    doc_no = "QD" + DateTime.Now.ToString("yyMMdd") + SqlInput.ChangeNullToInt(dt_doc.Rows[0][0], 0).ToString("0000");
                }
                else
                {
                    doc_no = "QD" + DateTime.Now.ToString("yyMMdd") + "0001";
                }

                string sql_qd_insert = string.Format(@"INSERT INTO dbo.T_Bllb_StorageDoc_tbsd
                                                    ( S_Doc_NO ,
                                                      S_Doc_Type ,
                                                      Create_Time ,
                                                      Creator ,
                                                      PO ,
                                                      POID
                                                    )
                                            VALUES  ( '{0}' , -- S_Doc_NO - nvarchar(50)
                                                      '1' , -- S_Doc_Type - nvarchar(10)
                                                      GETDATE() , -- Create_Time - datetime
                                                      '{1}' , -- Creator - nvarchar(50)
                                                      '{2}' , -- PO - nvarchar(50)
                                                      '{3}' -- POID - nvarchar(50)      
                                                    )", doc_no, PubUtils.uContext.UserID, txt_PO.Text.Trim(), poid);

                NMS.ExecTransql(PubUtils.uContext, sql_qd_insert);
            }
            else
            {
                doc_no = dt_doc.Rows[0][0].ToString();
            }
            int    totalQty  = 0;
            string sql_exist = string.Format(@"SELECT S_Doc_NO,QTY FROM T_Bllb_StorageDocMaterial_tsdm WHERE S_Doc_NO='{0}' and MaterialCode='{1}'", doc_no, txt_MaterialCode.Text.Trim());
            //判断清点单中是否已存在某物料
            DataTable dt_doc_material = NMS.QueryDataTable(PubUtils.uContext, sql_exist);
            if (dt_doc_material.Rows.Count == 0)
            {
                string sql_insert = string.Format(@"INSERT INTO dbo.T_Bllb_StorageDocMaterial_tsdm
                                                    ( S_Doc_NO ,
                                                      MaterialCode ,
                                                      QTY ,
                                                      PO_DetailID 
                                                    )
                                            VALUES  ( '{0}' , -- S_Doc_NO - nvarchar(50)
                                                      '{1}' , -- MaterialCode - nvarchar(50)
                                                       {2} , -- QTY - int
                                                      '{3}'  -- PO_DetailID - nvarchar(50) 
                                                    )", doc_no, MaterialCode, qty, po_detailid);

                NMS.ExecTransql(PubUtils.uContext, sql_insert);
                totalQty = qty;
            }
            else
            {
                string sql_update = string.Format(@"UPDATE T_Bllb_StorageDocMaterial_tsdm SET QTY=QTY+{1} WHERE S_Doc_NO='{0}' and MaterialCode='{2}'", doc_no, qty, txt_MaterialCode.Text.Trim());
                NMS.ExecTransql(PubUtils.uContext, sql_update);
                totalQty = SqlInput.ChangeNullToInt(dt_doc_material.Rows[0]["QTY"].ToString(), 0) + qty;
            }
            if (IsSendCheck)
            {
                //判断是否存在IQC单据若无,则新增
                iqc_no = string.Empty;//IQC检验单号
                string    sql_iqc_no = string.Format(@"
SELECT  [IQC_NO]
FROM    T_Bllb_IQCDoc_tbid
WHERE   S_DOC_NO = '{0}'
        AND OVER_FLAG = 'N'
        AND CREATE_TIME >= CONVERT(CHAR(10), GETDATE(), 120)
        AND Type = 'IQC' AND MaterialCode='{1}'", doc_no, txt_MaterialCode.Text.Trim());
                DataTable dt_IQC     = NMS.QueryDataTable(PubUtils.uContext, sql_iqc_no);
                if (dt_IQC.Rows.Count > 0)//修改送检数量
                {
                    iqc_no = dt_IQC.Rows[0][0].ToString();
                    string sql_iqc_update = string.Format(@"UPDATE T_Bllb_IQCDoc_tbid SET QTY=QTY+{1} WHERE IQC_NO='{0}' AND MaterialCode='{2}'", iqc_no, txt_Qty.Text.Trim(), txt_MaterialCode.Text.Trim());
                    NMS.ExecTransql(PubUtils.uContext, sql_iqc_update);
                }
                else//新增IQC单据
                {
                    DataTable dt_iqcwater = NMS.QueryDataTable(PubUtils.uContext, @"
SELECT TOP 1
        RIGHT(IQC_NO, 4) + 1
FROM    T_Bllb_IQCDoc_tbid
WHERE   CREATE_TIME >= CONVERT(CHAR(10), GETDATE(), 120)
        AND Type = 'IQC'
ORDER BY IQC_NO DESC ");
                    if (dt_iqcwater.Rows.Count > 0)
                    {
                        iqc_no = "IQC" + DateTime.Now.ToString("yyMMdd") + SqlInput.ChangeNullToInt(dt_iqcwater.Rows[0][0], 0).ToString("0000");
                    }
                    else
                    {
                        iqc_no = "IQC" + DateTime.Now.ToString("yyMMdd") + "0001";//IQC检验单号
                    }
                    string sql_iql_insert = string.Format(@"INSERT INTO dbo.T_Bllb_IQCDoc_tbid
                                                    ( IQC_NO ,
                                                      MaterialCode ,         
                                                      QTY ,     
                                                      CREATE_TIME ,   
		                                              S_DOC_NO,
		                                              PO
                                                    )
                                            VALUES  ( '{0}' , 
                                                      '{1}' ,  
                                                      {2} ,      
                                                      GETDATE() ,
		                                              '{3}',
		                                              '{4}' 
                                                    )", iqc_no, MaterialCode, qty, doc_no, txt_PO.Text.Trim());
                    NMS.ExecTransql(PubUtils.uContext, sql_iql_insert);
                }
            }
            //采购单物料清点数累计
            string sql_qd = string.Format(@" UPDATE T_Bllb_PODetail_tbpd SET ClearQty= ISNULL(ClearQty,0)+{2}  WHERE PO='{0}'  and MaterialCode='{1}'", txt_PO.Text.Trim(), MaterialCode, qty);
            NMS.ExecTransql(PubUtils.uContext, sql_qd);
            #endregion

            int MinQty     = SqlInput.ChangeNullToInt(txt_MinPackage.Text.Trim(), 0);
            int TotalQty   = SqlInput.ChangeNullToInt(txt_Qty.Text.Trim(), 0);
            int packageQty = TotalQty / MinQty;
            int lastQty    = TotalQty % MinQty;
            if (lastQty > 0)
            {
                packageQty++;
            }
            string snString                 = string.Empty;
            string barCodeString            = string.Empty;
            Model.Model_MaterialBarCode bar = new Model.Model_MaterialBarCode();
            Dictionary <string, string> dic = new Dictionary <string, string>();
            for (int i = 1; i <= packageQty; i++)//循环打印条码
            {
                dic.Clear();
                snString = GetSnNumber(); //getSN();
                if (string.IsNullOrEmpty(snString))
                {
                    new PubUtils().ShowNoteNGMsg("获取流水码失败!", 1, grade.SevereError);
                    return;
                }
                bar.MaterialCode = txt_MaterialCode.Text.Trim();//物料代码
                dic.Add("MaterialCode", bar.MaterialCode);
                if (i == packageQty && lastQty != 0)
                {
                    bar.QTY = lastQty.ToString();//数量
                    dic.Add("QTY", lastQty.ToString());
                }
                else
                {
                    bar.QTY = MinQty.ToString();//数量
                    dic.Add("QTY", MinQty.ToString());
                }
                bar.BEGIN_DATE = txt_DateCode.Text.Trim(); //生产日期
                dic.Add("BEGIN_DATE", bar.BEGIN_DATE);
                bar.PO = txt_PO.Text.Trim();               //采购订单号
                dic.Add("PO", bar.PO);
                bar.MPN = txt_MPN.Text.Trim();             //MPN
                dic.Add("MPN", bar.MPN);
                bar.SN = snString;
                dic.Add("SN", bar.SN);
                bar.QRCODE = snString;
                dic.Add("QRCODE", bar.QRCODE);
                string sql_detail_insert = string.Format(@"
                                        INSERT INTO dbo.T_Bllb_StorageDocDetail_tbsdd
                                                ( S_Doc_NO ,
                                                  MaterialCode ,
                                                  QTY ,
                                                  Create_Time ,
                                                  Creator ,
                                                  SerialNumber ,  
                                                  PO_DetailID,
                                                  Lot_No,
                                                  MPN,
                                                  DateCode,
                                                  Version
                                                )
                                        VALUES  ( '{0}' , -- S_Doc_NO - nvarchar(50)
                                                  '{1}' , -- MaterialCode - nvarchar(50)
                                                  {2} , -- QTY - int
                                                  GETDATE() , -- Create_Time - datetime
                                                  '{3}' , -- Creator - nvarchar(50)
                                                  '{4}' , -- SerialNumber - nvarchar(50)   
                                                  '{5}',  -- PO_DetailID - nvarchar(50)
                                                  '{6}',
                                                  '{7}',
                                                  '{8}',
                                                  '{9}'
                                                )", doc_no, MaterialCode, bar.QTY, PubUtils.uContext.UserID, bar.QRCODE, po_detailid, txtLotNo.Text.Trim(), txt_MPN.Text.Trim(), txt_DateCode.Text.Trim(), txtVersion.Text.Trim());
                NMS.ExecTransql(PubUtils.uContext, sql_detail_insert);
                string sql_barcode_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, txt_MaterialCode.Text.Trim(), bar.QTY, PubUtils.uContext.UserID, Guid.NewGuid().ToString());
                NMS.ExecTransql(PubUtils.uContext, sql_barcode_log);
                if (IsSendCheck)
                {
                    //保存物料SN到IQC单据中
                    string sql_sn_iqc = string.Format(@"
                INSERT INTO T_Bllb_IQCProduct_tbip(
                                        TBIP_ID,
                                        IQC_NO,
                                        SERIAL_NUMBER,
                                        QTY)
                                        VALUES( 
                                        '{0}',
                                        '{1}',
                                        '{2}',{3})",
                                                      Guid.NewGuid(), iqc_no, bar.QRCODE, bar.QTY
                                                      );
                    NMS.ExecTransql(PubUtils.uContext, sql_sn_iqc);
                }
                Common.BLL.Bll_Print.PrintTemplet("安费诺来料打印", dic);
                bar = new Model.Model_MaterialBarCode();
            }
            new PubUtils().ShowNoteOKMsg("打印成功");
            ClearControl();
            txt_MPN.Focus();
        }