WarM/ÌõÂë´òÓ¡/Kf_WeighToBarCode.cs
@@ -60,6 +60,7 @@
            txtHBarCode.Text = "";
            grdMain.DataSource = null;
            grdSub.DataSource = null;
            chkHDYFlag.Checked = true;
        }
        //窗体加载
@@ -461,15 +462,36 @@
            BarCode_Display();
            grdMain.Rows[0].Selected = true;
            //打印条码
            sBarCodeItemID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[0].Index].Cells[Fun_GetCol("HItemID")].Value).ToString();
            Sub_SetReport("物料条码");
            Report.Print(false);
            Thread.Sleep(1000);
            //自动打印
            if (chkHDYFlag.Checked == true)
            {
                //打印条码
                Sub_SetReport("物料条码");
                Report.Print(false);
                Thread.Sleep(1000);
            }
            else
            {
                //选择打印模板
                BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
                oFrm.sBillName = ModName;
                oFrm.sBillModel = ModCaption;
                oFrm.ShowDialog();
                if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
                {
                    Sub_SetReport(oFrm.sOpenTmp);
                    Report.Print(false);
                    Thread.Sleep(1000);
                }
            }
            txtHQty.Text = "";
            txtHWeightQyt.Text = "";
            txtHKDQty.Text = "";
            txtHBarcodeNo.Text = "";
            txtHRemark.Text = "";
            txtHRemark.Tag = 0;
            txtHQty.Focus();
        }
@@ -489,6 +511,11 @@
            else if (DBUtility.ClsPub.isDoule( txtHWeightQyt.Text) == 0)
            {
                MessageBox.Show("请输入正确重量!", "提示");
                return false;
            }
            else if (DBUtility.ClsPub.isInt(txtHBarcodeNo.Text) == 0)
            {
                MessageBox.Show("请输入包号!", "提示");
                return false;
            }
            else if (HWhID==0)
@@ -568,6 +595,8 @@
            string HMaterName = "";
            string HMaterModel = "";
            string ProcessExchangeBillNo = "";
            Int64 HBarcodeNo = 0;       //包数
            Int64 HBadReasonID = 0;     //不良原因ID
            HBarCode = TM;
            HBarCodeType = DBUtility.ClsPub.isStrNull(cmbHBarCodeType.Text);
@@ -579,6 +608,8 @@
            HMaterName = DBUtility.ClsPub.isStrNull(txtHMaterName.Text);
            HMaterModel = DBUtility.ClsPub.isStrNull(txtHMaterModel.Text);
            ProcessExchangeBillNo = DBUtility.ClsPub.isStrNull(txtHBillNo.Text);
            HBarcodeNo = DBUtility.ClsPub.isLong(txtHBarcodeNo.Text);
            HBadReasonID = DBUtility.ClsPub.isLong(txtHRemark.Tag);
            try
            {
@@ -591,16 +622,16 @@
                ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
                ",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate,HMaterialJQty,HMaterialMQty " +
                ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HGiveAwayFlag " +
                ",HOrderInterID,HOrderEntryID,HOrderBillNo " +
                ",HOrderInterID,HOrderEntryID,HOrderBillNo,HCustomQty1 " +
                ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo " +
                ") Values ("
                + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
                + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + HMaker + "',getdate(),0," + HQty.ToString()
                + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "',''"
                + ", 1,1," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'"
                + ", 1," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'"
                + ", 0,'',getdate(),'','" + sDate + "'," + HMaterialJQty.ToString() + "," + HMaterialMQty.ToString()
                + ", " + HStockOrgID.ToString() + "," + HStockOrgID.ToString() + ",''," + HInterID.ToString() + ",0"
                + ", " + ProcessExchangeInterID.ToString() + ",0,'" + ProcessExchangeBillNo + "'"
                + ", " + ProcessExchangeInterID.ToString() + ",0,'" + ProcessExchangeBillNo + "'," + HBadReasonID.ToString()
                + ",'" + HMaterName + "','" + HMaterModel + "',''," + HAuxPropID.ToString() + ",'','')");
                //回填最大流水号
@@ -623,7 +654,7 @@
                    + "," + HWhID.ToString() + ",0," + HSPID.ToString() + ",0,0,''"
                    +",0," + HQty.ToString() + ",1,'" + HBatchNo + "','" + HBarCode + "',''"
                    +",'" + HMaker + "',getdate()," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillType + "','" + HSourceBillNo + "'"
                    +",0,0,'0',0,'',0"
                    +",0,0,'',0,'',0"
                    +"," + HStockOrgID.ToString() + "," + HStockOrgID.ToString() + "," + HStockOrgID.ToString() + ",'','称重入库生成','2'"
                    +",0,0,'',0)");
@@ -708,5 +739,202 @@
        #endregion
        #region  //作废
        private void cmdZF_Click(object sender, EventArgs e)
        {
            if (grdMain.CurrentRow == null)
            {
                MessageBox.Show("请先选择需要作废的条码!", "提示");
                return;
            }
            else
            {
                if (MessageBox.Show("确定要作废所选条码?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                {
                    return;
                }
                else
                {
                    string HRemark = "";
                    string HItemID = "";
                    string HBarCode = "";
                    string HBarCode2 = "";
                    for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
                    {
                        HItemID = HItemID + "," + DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("hmainid")].Value.ToString());
                        HBarCode = HBarCode + ",'" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value) + "'";
                        if (i != 0 && i % 100 == 0)
                        {
                            HBarCode2 = HBarCode2 + "#" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
                        }
                        else
                        {
                            HBarCode2 = HBarCode2 + "," + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
                        }
                        if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("作废标记")].Value) != "")
                        {
                            HRemark = HRemark + "、" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
                        }
                    }
                    if (HRemark != "")
                    {
                        MessageBox.Show("所选条码编号:"+ HRemark.Remove(0, 1)+" å·²ä½œåºŸï¼Œä¸å…è®¸é‡å¤ä½œåºŸï¼", "提示");
                        return;
                    }
                    HItemID = HItemID.Remove(0, 1);     //去掉字符串第一个字符
                    HBarCode = HBarCode.Remove(0, 1);
                    HBarCode2 = HBarCode2.Remove(0, 1);
                    try
                    {
                        oCn.BeginTran();
                        string[] NewBarCode;
                        NewBarCode = HBarCode2.Split(Convert.ToChar("#"));
                        //作废条码
                        oCn.RunProc("update Gy_BarCodeBill set HStopflag=1,HDeleteMan='" + DBUtility.ClsPub.CurUserName + "',HDeleteDate=getdate() where HItemID in (" + HItemID + ")", ref DBUtility.ClsPub.sExeReturnInfo);
                        //删除条码出入库临时表记录
                        oCn.RunProc("delete from KF_PonderationBillMain_Temp where HInterID=" + HInterID.ToString() + " and HBillType='" + HBillType + "' and HBarCode in (" + HBarCode + ")", ref DBUtility.ClsPub.sExeReturnInfo);
                        //写入系统日志
                        for (int i = 0; i <= NewBarCode.Length - 1; i++)
                        {
                            oCn.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.ComputerName + "','作废条码:" + NewBarCode[i] + "','称重入库模块','" + DBUtility.ClsPub.IPAddress + "','作废'", ref DBUtility.ClsPub.sExeReturnInfo);
                        }
                        oCn.Commit();
                    }
                    catch (Exception e2)
                    {
                        oCn.RollBack();
                        MessageBox.Show("作废条码失败!" + e2.Message, "提示");
                        return;
                    }
                    //刷新称重记录列表信息
                    BarCode_Display();
                    MessageBox.Show("所选条码编号:" + HBarCode.Remove(0, 1) + " ä½œåºŸæˆåŠŸï¼", "提示");
                }
            }
        }
        #endregion
        #region  //反作废
        private void cmdFZF_Click(object sender, EventArgs e)
        {
            if (grdMain.CurrentRow == null)
            {
                MessageBox.Show("请先选择需要反作废的条码!", "提示");
                return;
            }
            else
            {
                if (MessageBox.Show("确定要反作废所选条码?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                {
                    return;
                }
                else
                {
                    string HRemark = "";
                    string HItemID = "";
                    string HBarCode = "";
                    string HBarCode2 = "";
                    for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
                    {
                        HItemID = HItemID + "," + DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("hmainid")].Value.ToString());
                        HBarCode = HBarCode + ",'" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value) + "'";
                        if (i != 0 && i % 100 == 0)
                        {
                            HBarCode2 = HBarCode2 + "#" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
                        }
                        else
                        {
                            HBarCode2 = HBarCode2 + "," + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
                        }
                        if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("作废标记")].Value) == "")
                        {
                            HRemark = HRemark + "、" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
                        }
                    }
                    if (HRemark != "")
                    {
                        MessageBox.Show("所选条码编号:" + HRemark.Remove(0, 1) + " æœªä½œåºŸï¼Œä¸å…è®¸åä½œåºŸï¼", "提示");
                        return;
                    }
                    HItemID = HItemID.Remove(0, 1);     //去掉字符串第一个字符
                    HBarCode = HBarCode.Remove(0, 1);
                    HBarCode2 = HBarCode2.Remove(0, 1);
                    try
                    {
                        oCn.BeginTran();
                        string[] NewBarCode;
                        NewBarCode = HBarCode2.Split(Convert.ToChar("#"));
                        //反作废条码
                        oCn.RunProc("update Gy_BarCodeBill set HStopflag=0,HDeleteMan='',HDeleteDate=null where HItemID in (" + HItemID + ")", ref DBUtility.ClsPub.sExeReturnInfo);
                        //删除条码出入库临时表记录
                        oCn.RunProc("delete from KF_PonderationBillMain_Temp where HInterID=" + HInterID.ToString() + " and HBillType='" + HBillType + "' and HBarCode in (" + HBarCode + ")", ref DBUtility.ClsPub.sExeReturnInfo);
                        //写入条码出入库临时表
                        oCn.RunProc("Insert into KF_PonderationBillMain_Temp " +
                        "(HInterID,HBillNo,HBillType,HMaterID,HAuxPropID,HProcID" +
                        ",HWhID,HSCWHID,HStockPlaceID,HOutStockPlaceID,HGroupID,HAddr" +
                        ",HQtyMust,HQty,HPieceQty,HBatchNo,HBarCode,HBarCode_Pack" +
                        ",HMaker,HMakeDate,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
                        ",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag,HMTONo,HPlanMode" +
                        ",HSTOCKORGID,HOtherOrgID,HOWNERID,HOWNERTYPEID,HExpressNumber,HSubBillType" +
                        ",HCusID,HDeptID,HCusBarCode,HMulSourceBill) " +
                        " select " + HInterID.ToString() + ",'" + HBillNo + "','" + HBillType + "',HMaterID,HAuxPropID,0" +
                        ",HWhID,0,HSPID,0,0,''" +
                        ",0,HQty,1,HBatchNo,HBarCode,''" +
                        ",'" + HMaker + "',getdate(),HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
                        ",0,0,'',0,'',0" +
                        ",HSTOCKORGID,HSTOCKORGID,HSTOCKORGID,'','称重入库生成-反作废','2'" +
                        ",0,0,'',0" +
                        "from Gy_BarCodeBill with(nolock) where HItemID in (" + HItemID + ")"
                        );
                        //写入系统日志
                        for (int i = 0; i <= NewBarCode.Length - 1; i++)
                        {
                            oCn.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.ComputerName + "','反作废条码:" + NewBarCode[i] + "','称重入库模块','" + DBUtility.ClsPub.IPAddress + "','反作废'", ref DBUtility.ClsPub.sExeReturnInfo);
                        }
                        oCn.Commit();
                    }
                    catch (Exception e2)
                    {
                        oCn.RollBack();
                        MessageBox.Show("反作废条码失败!" + e2.Message, "提示");
                        return;
                    }
                    //刷新称重记录列表信息
                    BarCode_Display();
                    MessageBox.Show("所选条码编号:" + HBarCode.Remove(0, 1) + " åä½œåºŸæˆåŠŸï¼", "提示");
                }
            }
        }
        #endregion
        #region  //备注   ä¸è‰¯åŽŸå› é€‰æ‹©
        private void cmdHBadReasonID_Click(object sender, EventArgs e)
        {
            DAL.ClsGy_BadReason_View oBadReason = new DAL.ClsGy_BadReason_View();
            if (oBadReason.RefreshView())
            {
                this.txtHRemark.Text = oBadReason.oModel.HName;
                this.txtHRemark.Tag = oBadReason.oModel.HItemID.ToString();
            }
        }
        #endregion
    }
}