yangle
2023-05-10 05e8d342bbff483c73ac4fc481ea16f203a78ba1
WorkM/Á÷ת¿¨¹ÜÀí/MES_StationOutBillList_Bad.cs
@@ -47,6 +47,7 @@
            string sSql = "";
            string sWhere = "";
            bzd.Enabled = true;
            if (frmCondition.SqlStr.Trim().Length == 0)
            {
                sSql = "Select top 5000 * from " + ViewName + " Where 1=1 " + sWhere + sDlgWhere + " order by hmainid desc ";
@@ -496,7 +497,7 @@
            //LOT号
            if (txtHBillNo.Text.Trim() != "")
            {
                sFastSQL = sFastSQL + " and æµè½¬å¡å· like '%" + txtHBillNo.Text + "%'";
                sFastSQL = sFastSQL + " and å·¥åºæµè½¬å¡å· like '%" + txtHBillNo.Text + "%'";
            }
            //工作中心
            if (txtHCenterID.Text.Trim() != "")
@@ -614,16 +615,24 @@
        private void bzd_Click(object sender, EventArgs e)
        {
            //点击后入库按钮变灰
            bzd.Enabled = false;
            //根据选中的数据生成包装单
            int MainIDCol =  Fun_GetCol("hmainid");
            int SubIDCol = Fun_GetCol("hsubid");
            int BillNoCol = Fun_GetCol("单据号");
            DAL.ClsKf_ProductInBill oClsKf_ProductInBill ;
            int HUserK3Col = Fun_GetCol("K3用户");
            int HKeepCol = Fun_GetCol("K3保管");
            int HSecManagerCol = Fun_GetCol("K3验收");
            int HDeptCol = Fun_GetCol("K3部门");
            DAL.ClsKf_ProductInBill oClsKf_ProductInBill;
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            //获取系统参数
            Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
            if (oSystemParameter.ShowBill(ref DBUtility.ClsPub.sExeReturnInfo) == false)
            {
                MessageBox.Show("获取系统参数失败! " + DBUtility.ClsPub.sExeReturnInfo);
                bzd.Enabled = true;
                return;
            }
            //判断会计期是否合理
@@ -633,8 +642,40 @@
            if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(DateTime.Today, ref sYear, ref sPeriod, ref s) == false)
            {
                MessageBox.Show("会计期间有错误! " + DBUtility.ClsPub.sExeReturnInfo);
                bzd.Enabled = true;
                return;
            }
            string sHInterID = "";
            for (int i = 0; i < grdMain.SelectedRows.Count; i++)
            {
                sHInterID = sHInterID + "," + DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[MainIDCol].Value);
            }
            if (sHInterID=="")
            {
                MessageBox.Show("没有选中的单据明细行,请先选择要入库的单据!", "提示");
                bzd.Enabled = true;
                return;
            }
            else
            {
                DataSet DS = oCn.RunProcReturn("exec h_p_MES_StationOutBillList_Bad_PreProductIn '" + sHInterID + "'", "h_p_MES_StationOutBillList_Bad_PreProductIn", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS == null || DS.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("入库前判断失败!", "提示");
                    bzd.Enabled = true;
                    return;
                }
                else
                {
                    if (DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0][0]) == "1")
                    {
                        MessageBox.Show(DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HRemark"]));
                        bzd.Enabled = true;
                        return;
                    }
                }
            }
            Int64 n = 0;
            //循环 é€‰ä¸­è¡Œ
            for (int i = 0; i < grdMain.SelectedRows.Count; i++)
@@ -645,15 +686,23 @@
                oClsKf_ProductInBill.omodel.HInterID = ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[MainIDCol].Value);
                oClsKf_ProductInBill.omodel.HDate = DateTime.Today;
                oClsKf_ProductInBill.omodel.HBillNo = ClsPub.isStrNull(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[BillNoCol].Value);
                oClsKf_ProductInBill.omodel.HDeptID = 0;
                oClsKf_ProductInBill.omodel.HEmpID = 0;
                oClsKf_ProductInBill.omodel.HSecManagerID = 0;
                oClsKf_ProductInBill.omodel.HKeeperID = 0;
                oClsKf_ProductInBill.omodel.HDeptID = ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[HDeptCol].Value);
                oClsKf_ProductInBill.omodel.HEmpID = ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[HKeepCol].Value);
                oClsKf_ProductInBill.omodel.HSecManagerID = ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[HSecManagerCol].Value);
                oClsKf_ProductInBill.omodel.HKeeperID = ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[HKeepCol].Value);
                oClsKf_ProductInBill.omodel.HBillerID = ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[HUserK3Col].Value);
                oClsKf_ProductInBill.omodel.HRemark = "不良品同步";
                oClsKf_ProductInBill.omodel.HMaker =  DBUtility.ClsPub.CurUserName;
                oClsKf_ProductInBill.omodel.HWHID = 0;
                oClsKf_ProductInBill.omodel.HSupID = 0;
                oClsKf_ProductInBill.omodel.HExplanation = ""; 
                if(oClsKf_ProductInBill.omodel.HBillerID==0 || oClsKf_ProductInBill.omodel.HKeeperID==0
                    || oClsKf_ProductInBill.omodel.HEmpID==0 || oClsKf_ProductInBill.omodel.HDeptID==0
                    || oClsKf_ProductInBill.omodel.HSecManagerID ==0 )
                {
                    MessageBox.Show("没有设置金蝶用户、部门、保管、验收员! " + DBUtility.ClsPub.sExeReturnInfo);
                    continue;
                }
                if(oClsKf_ProductInBill.AddBill_StationOut_Bad("3710", oSystemParameter.omodel, ref DBUtility.ClsPub.sExeReturnInfo))
                {
                    n++;
@@ -663,13 +712,16 @@
                    MessageBox.Show("同步单据失败!"+ DBUtility.ClsPub.sExeReturnInfo);
                }
                //休眠5秒
                System.Threading.Thread.Sleep(5000);
                System.Threading.Thread.Sleep(2000);
                //
            }
            bzd.Enabled = true;
            //
            if (n > 0)
            {
                MessageBox.Show("同步单据完毕!一共有" + n.ToString() + "张入库单!");
                initGrid();
                Display();
            }
        }