yxj
2023-09-15 8dca4525e644e06117969e7dd3184912055d0d3d
WebAPI/DLL/ClsKf_MateOutBill.cs
@@ -39,8 +39,8 @@
            {
                //
                oCn.BeginTran();
                //更新主表
                oCn.RunProc("UpDate Kf_ICStockBillMain set  " +
                string mainSql = "UpDate Kf_ICStockBillMain set  " +
                " HBillNo='" + omodel.HBillNo + "'" +  //固定赋值===============
                ",HDate='" + omodel.HDate + "'" +
                ",HYear='" + omodel.HYear.ToString() + "'" +
@@ -60,16 +60,75 @@
                ",HExplanation='" + omodel.HExplanation + "'" +
                ",HInnerBillNo='" + omodel.HInnerBillNo + "'" +
                ",HRedBlueFlag=" + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) +
                " where HInterID=" + lngBillKey.ToString());
                " where HInterID=" + lngBillKey.ToString();
                //判断使用客户,根据客户进行个性化调整
                Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
                string sErrMsg = "";
                oSystemParameter.ShowBill(ref sErrMsg);
                if (oSystemParameter.omodel.WMS_CampanyName == "")          //乔一客户
                {
                    mainSql = "UpDate Kf_ICStockBillMain set " +
                        " HBillNo='" + omodel.HBillNo +
                        "',HDate='" + omodel.HDate +
                        "',HYear='" + omodel.HYear.ToString() +
                        "',HPeriod='" + omodel.HPeriod.ToString() +
                        "',HRemark='" + omodel.HRemark +
                        "',HUpDater='" + DBUtility.ClsPub.CurUserName +
                        "',HUpDateDate=getdate()" +
                        //========================================
                        ",HSupID=" + omodel.HSupID.ToString() +
                        ",HWHID=" + omodel.HWHID.ToString() +
                        ",HSCWHID=" + omodel.HSCWHID.ToString() +
                        ",HEmpID=" + omodel.HEmpID.ToString() +
                        ",HManagerID=" + omodel.HManagerID.ToString() +
                        ",HSecManagerID=" + omodel.HSecManagerID.ToString() +
                        ",HKeeperID=" + omodel.HKeeperID.ToString() +
                        ",HDeptID=" + omodel.HDeptID.ToString() +
                        ",HExplanation='" + omodel.HExplanation +
                        "',HInnerBillNo='" + omodel.HInnerBillNo +
                        "',HRedBlueFlag=" + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) +
                        ",HICMOInterID=" + omodel.HICMOInterID +
                        ",HICMOEntryID=" + omodel.HICMOEntryID +
                        ",HICMOBillNo='" + omodel.HICMOBillNo +
                        "',HProcExchInterID=" + omodel.HProcExchInterID +
                        ",HProcExchEntryID=" + omodel.HProcExchEntryID +
                        ",HProcExchBillNo='" + omodel.HProcExchBillNo +
                        "',HMaterID=" + omodel.HMaterID +
                        ",HMaterName='" + omodel.HMaterName +
                        "',HVerNo='" + omodel.HVerNo +
                        "',HModel='" + omodel.HModel +
                        "',HModel2='" + omodel.HModel2 +
                        "',HPieceQty='" + omodel.HPieceQty +
                        "',HCusID=" + omodel.HCusID +
                        ",HWeight=" + omodel.HWeight +
                        ",HLong=" + omodel.HLong +
                        ",HSingleWeight=" + omodel.HSingleWeigth +
                        ",HMaterSumWeight=" + omodel.HMaterSumWeight +
                        ",HMaterEmpID=" + omodel.HMaterEmpID +
                        ",HMachineSpeed=" + omodel.HMachineSpeed +
                        ",HWaterRush=" + omodel.HWaterRush +
                        ",HWaterQty=" + omodel.HWaterQty +
                        ",HWaterRate=" + omodel.HWaterRate +
                        " where HInterID=" + lngBillKey.ToString();
                }
                //更新主表
                oCn.RunProc(mainSql);
                //删除关联
                DeleteRelation(ref sReturn, lngBillKey);
                //删除子表
                DeleteBillSub(lngBillKey);
                //插入子表
                omodel.HInterID = lngBillKey;
                foreach (Models.ClsKf_MateOutBillSub oSub in DetailColl)
                {
                    oCn.RunProc("Insert into Kf_ICStockBillSub " +
                    string subSql = "Insert into Kf_ICStockBillSub " +
                      " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
                      ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
                      ",HMaterID,HPropertyID,HSecUnitID,HSecUnitRate,HUnitID,HQtyMust" +
@@ -83,7 +142,52 @@
                      "," + oSub.HQty.ToString() + "," + oSub.HPrice.ToString() + "," + oSub.HMoney.ToString() + "," + oSub.HWHID.ToString() + "," + oSub.HSCWHID.ToString() + "," + oSub.HSPID.ToString() +
                      "," + oSub.HSCSPID.ToString() + "," + oSub.HSPGroupID.ToString() + ",'" + oSub.HBatchNo + "'," + oSub.HPOOrderInterID.ToString() + "," + oSub.HPOOrderEntryID.ToString() + ",'" + oSub.HPOOrderBillNo + "'" +
                      "," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'" +
                      ") ");
                      ") ";
                    if (oSystemParameter.omodel.WMS_CampanyName == "")          //乔一客户
                    {
                        subSql = "Insert into Kf_ICStockBillSub" +
                            "(HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HMaterID,HPropertyID,HSecUnitID,HSecUnitRate,HUnitID,HQtyMust" +
                            ",HRate,HQty,HPrice,HMoney,HWHID,HSCWHID,HSPID,HSCSPID,HSPGroupID,HBatchNo,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo)" +
                            " values(" +
                            omodel.HInterID.ToString() +
                            "," + oSub.HEntryID.ToString() +
                            ",'" + oSub.HCloseMan +
                            "','" + oSub.HEntryCloseDate.ToShortDateString() +
                            "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) +
                            ",'" + oSub.HRemark +
                            "'," + oSub.HSourceInterID.ToString() +
                            "," + oSub.HSourceEntryID.ToString() +
                            ",'" + oSub.HSourceBillNo +
                            "','" + oSub.HSourceBillType +
                            "'," + oSub.HRelationQty.ToString() +
                            "," + oSub.HRelationMoney.ToString() +
                            "," + oSub.HMaterID.ToString() +
                            "," + oSub.HPropertyID.ToString() +
                            "," + oSub.HSecUnitID.ToString() +
                            "," + oSub.HSecUnitRate.ToString() +
                            "," + oSub.HUnitID.ToString() +
                            "," + oSub.HQtyMust.ToString() +
                            "," + oSub.HRate.ToString() +
                            "," + oSub.HQty.ToString() +
                            "," + oSub.HPrice.ToString() +
                            "," + oSub.HMoney.ToString() +
                            "," + oSub.HWHID.ToString() +
                            "," + oSub.HSCWHID.ToString() +
                            "," + oSub.HSPID.ToString() +
                            "," + oSub.HSCSPID.ToString() +
                            "," + oSub.HSPGroupID.ToString() +
                            ",'" + oSub.HBatchNo +
                            "'," + oSub.HPOOrderInterID.ToString() +
                            "," + oSub.HPOOrderEntryID.ToString() +
                            ",'" + oSub.HPOOrderBillNo +
                            "'," + oSub.HSeOrderInterID.ToString() +
                            "," + oSub.HSeOrderEntryID.ToString() +
                            ",'" + oSub.HSeOrderBillNo +
                            "') ";
                    }
                    oCn.RunProc(subSql);
                }
                //
                //foreach (Model.ClsKf_MateOutBillSub oSub in DetailColl)
@@ -115,7 +219,7 @@
            {
                //得到mainid
                omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
                omodel.HBillNo = DBUtility.ClsPub.CreateBillCode(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
                //omodel.HBillNo = DBUtility.ClsPub.CreateBillCode(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
                //若MAINDI重复则重新获取
                if (IsExistBillNo(ref DBUtility.ClsPub.sExeReturnInfo, omodel.HBillNo, Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew, omodel.HInterID))
                {
@@ -127,22 +231,86 @@
                }
                //
                oCn.BeginTran();
                //主表
                oCn.RunProc("Insert Into Kf_ICStockBillMain   " +
                string mainSql = "Insert Into Kf_ICStockBillMain   " +
                "(HBillType,HBillSubType,HInterID,HBillNo,HDate" +
                ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
                ",HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" +
                ",HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag" +
                ") " +
                " values('" + this.BillType + "','"  + this.HBillSubType + "'," +omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" +
                " values('" + this.BillType + "','" + this.HBillSubType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" +
                ", " + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + DBUtility.ClsPub.CurUserName + "',getdate()" +
                ", " + omodel.HSupID.ToString() + "," + omodel.HWHID.ToString() + "," + omodel.HSCWHID.ToString() + "," + omodel.HEmpID.ToString() + "," + omodel.HManagerID.ToString() + "," + omodel.HSecManagerID.ToString() +
                ", " + omodel.HKeeperID.ToString() + "," + omodel.HDeptID.ToString() + ",'" + omodel.HExplanation + "','" + omodel.HInnerBillNo + "'," + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) +
                ") ");
                ") ";
                //判断使用客户,根据客户进行个性化调整
                Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
                string sErrMsg = "";
                oSystemParameter.ShowBill(ref sErrMsg);
                if (oSystemParameter.omodel.WMS_CampanyName == "")          //乔一客户
                {
                    mainSql = "Insert Into Kf_ICStockBillMain" +
                        "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HYear,HPeriod,HRemark,HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HMaker,HMakeDate,HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID,HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag" +
                        ",HICMOInterID,HICMOEntryID,HICMOBillNo,HProcExchInterID,HProcExchEntryID,HProcExchBillNo,HMaterID,HMaterName,HVerNo,HModel,HModel2,HPieceQty,HCusID,HWeight,HLong,HSingleWeight,HMaterSumWeight,HMaterEmpID" +
                        ",HMachineSpeed,HWaterRush,HWaterQty,HWaterRate) " +
                        " values(" +
                        "'" + this.BillType +
                        "','" + this.HBillSubType +
                        "'," + omodel.HInterID.ToString() +
                        ",'" + omodel.HBillNo +
                        "','" + omodel.HDate +
                        "'," + omodel.HYear.ToString() +
                        "," + omodel.HPeriod.ToString() +
                        ",'" + omodel.HRemark +
                        "'," + omodel.HProcExchInterID +
                        ",'" + omodel.HProcExchBillNo +
                        "','" + "3772" +
                        "','" + DBUtility.ClsPub.CurUserName +
                        "',getdate()" +
                        "," + omodel.HSupID.ToString() +
                        "," + omodel.HWHID.ToString() +
                        "," + omodel.HSCWHID.ToString() +
                        "," + omodel.HEmpID.ToString() +
                        "," + omodel.HManagerID.ToString() +
                        "," + omodel.HSecManagerID.ToString() +
                        ", " + omodel.HKeeperID.ToString() +
                        "," + omodel.HDeptID.ToString() +
                        ",'" + omodel.HExplanation +
                        "','" + omodel.HInnerBillNo +
                        "'," + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) +
                        "," + omodel.HICMOInterID +
                        "," + omodel.HICMOEntryID +
                        ",'" + omodel.HICMOBillNo +
                        "'," + omodel.HProcExchInterID +
                        "," + omodel.HProcExchEntryID +
                        ",'" + omodel.HProcExchBillNo +
                        "'," + omodel.HMaterID +
                        ",'" + omodel.HMaterName +
                        "','" + omodel.HVerNo +
                        "','" + omodel.HModel +
                        "','" + omodel.HModel2 +
                        "','" + omodel.HPieceQty +
                        "'," + omodel.HCusID +
                        "," + omodel.HWeight +
                        "," + omodel.HLong +
                        "," + omodel.HSingleWeigth +
                        "," + omodel.HMaterSumWeight +
                        "," + omodel.HMaterEmpID +
                        "," + omodel.HMachineSpeed +
                        "," + omodel.HWaterRush +
                        "," + omodel.HWaterQty +
                        "," + omodel.HWaterRate +
                        ")";
                }
                //主表
                oCn.RunProc(mainSql);
                //插入子表
                foreach (Models.ClsKf_MateOutBillSub oSub in DetailColl)
                {
                    oCn.RunProc("Insert into Kf_ICStockBillSub " +
                    string subSql = "Insert into Kf_ICStockBillSub " +
                      " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
                      ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
                      ",HMaterID,HPropertyID,HSecUnitID,HSecUnitRate,HUnitID,HQtyMust" +
@@ -156,7 +324,51 @@
                      "," + oSub.HQty.ToString() + "," + oSub.HPrice.ToString() + "," + oSub.HMoney.ToString() + "," + oSub.HWHID.ToString() + "," + oSub.HSCWHID.ToString() + "," + oSub.HSPID.ToString() +
                      "," + oSub.HSCSPID.ToString() + "," + oSub.HSPGroupID.ToString() + ",'" + oSub.HBatchNo + "'," + oSub.HPOOrderInterID.ToString() + "," + oSub.HPOOrderEntryID.ToString() + ",'" + oSub.HPOOrderBillNo + "'" +
                      "," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'" +
                      ") ");
                      ") ";
                    if (oSystemParameter.omodel.WMS_CampanyName == "")              //乔一客户
                    {
                        subSql = "Insert into Kf_ICStockBillSub" +
                            "(HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HMaterID,HPropertyID,HSecUnitID,HSecUnitRate,HUnitID,HQtyMust" +
                            ",HRate,HQty,HPrice,HMoney,HWHID,HSCWHID,HSPID,HSCSPID,HSPGroupID,HBatchNo,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo)" +
                            " values(" +
                            omodel.HInterID.ToString() +
                            "," + oSub.HEntryID.ToString() +
                            ",'" + oSub.HCloseMan +
                            "','" + oSub.HEntryCloseDate.ToShortDateString() +
                            "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) +
                            ",'" + oSub.HRemark +
                            "'," + oSub.HSourceInterID.ToString() +
                            "," + oSub.HSourceEntryID.ToString() +
                            ",'" + oSub.HSourceBillNo +
                            "','" + oSub.HSourceBillType +
                            "'," + oSub.HRelationQty.ToString() +
                            "," + oSub.HRelationMoney.ToString() +
                            "," + oSub.HMaterID.ToString() +
                            "," + oSub.HPropertyID.ToString() +
                            "," + oSub.HSecUnitID.ToString() +
                            "," + oSub.HSecUnitRate.ToString() +
                            "," + oSub.HUnitID.ToString() +
                            "," + oSub.HQtyMust.ToString() +
                            "," + oSub.HRate.ToString() +
                            "," + oSub.HQty.ToString() +
                            "," + oSub.HPrice.ToString() +
                            "," + oSub.HMoney.ToString() +
                            "," + oSub.HWHID.ToString() +
                            "," + oSub.HSCWHID.ToString() +
                            "," + oSub.HSPID.ToString() +
                            "," + oSub.HSCSPID.ToString() +
                            "," + oSub.HSPGroupID.ToString() +
                            ",'" + oSub.HBatchNo +
                            "'," + oSub.HPOOrderInterID.ToString() +
                            "," + oSub.HPOOrderEntryID.ToString() +
                            ",'" + oSub.HPOOrderBillNo +
                            "'," + oSub.HSeOrderInterID.ToString() +
                            "," + oSub.HSeOrderEntryID.ToString() +
                            ",'" + oSub.HSeOrderBillNo +
                            "') ";
                    }
                        oCn.RunProc(subSql);
                }
                //
                //foreach (Model.ClsKf_MateOutBillSub oSub in DetailColl)
@@ -233,8 +445,41 @@
                omodel.HExplanation = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HExplanation"]);
                omodel.HInnerBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInnerBillNo"]);
                omodel.HRedBlueFlag = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HRedBlueFlag"]);
                //
                //判断使用客户,根据客户进行个性化调整
                Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
                string sErrMsg = "";
                oSystemParameter.ShowBill(ref sErrMsg);
                if (oSystemParameter.omodel.WMS_CampanyName == "")              //乔一客户
                {
                    omodel.HICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HICMOInterID"]);
                    omodel.HICMOEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HICMOEntryID"]);
                    omodel.HICMOBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HICMOBillNo"]);
                    omodel.HProcExchInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HProcExchInterID"]);
                    omodel.HProcExchEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HProcExchEntryID"]);
                    omodel.HProcExchBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcExchBillNo"]);
                    omodel.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]);
                    omodel.HMaterName = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMaterName"]);
                    omodel.HVerNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HVerNo"]);
                    omodel.HModel = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HModel"]);
                    omodel.HModel2 = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HModel2"]);
                    omodel.HPieceQty = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HPieceQty"]);
                    omodel.HCusID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCusID"]);
                    omodel.HWeight = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HWeight"]);
                    omodel.HLong = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HLong"]);
                    omodel.HSingleWeigth = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HSingleWeight"]);
                    omodel.HMaterSumWeight = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HMaterSumWeight"]);
                    omodel.HMaterEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterEmpID"]);
                    omodel.HMachineSpeed = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HMachineSpeed"]);
                    omodel.HWaterRush = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HWaterRush"]);
                    omodel.HWaterQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HWaterQty"]);
                    omodel.HWaterRate = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HWaterRate"]);
                }
                    //
                //循环
                DataSet DsSub ;
                DsSub = oCn.RunProcReturn("Select * from Kf_ICStockBillSub Where HInterID=" + lngBillKey.ToString(), "Kf_ICStockBillSub");
@@ -277,6 +522,12 @@
                    oSub.HSeOrderInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSeOrderInterID"]);
                    oSub.HSeOrderEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSeOrderEntryID"]);
                    oSub.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HSeOrderBillNo"]);
                    if (oSystemParameter.omodel.WMS_CampanyName == "")              //乔一客户
                    {
                        oSub.HRate = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[0]["HRate"]);
                    }
                    DetailColl.Add(oSub);
                }
                sReturn = "显示单据成功!";