chenhaozhe
2026-02-11 28e8091a515d24a9cf82251f383f055a2ab0cff9
合并分支
84个文件已修改
6个文件已添加
19440 ■■■■■ 已修改文件
BLL/bin/Release/BLL.dll 补丁 | 查看 | 原始文档 | blame | 历史
BLL/bin/Release/BLL.pdb 补丁 | 查看 | 原始文档 | blame | 历史
BLL/bin/Release/DAL.dll 补丁 | 查看 | 原始文档 | blame | 历史
BLL/bin/Release/DAL.pdb 补丁 | 查看 | 原始文档 | blame | 历史
BLL/bin/Release/DBUtility.dll 补丁 | 查看 | 原始文档 | blame | 历史
BLL/bin/Release/DBUtility.pdb 补丁 | 查看 | 原始文档 | blame | 历史
BLL/bin/Release/Model.dll 补丁 | 查看 | 原始文档 | blame | 历史
BLL/bin/Release/Model.pdb 补丁 | 查看 | 原始文档 | blame | 历史
BLL/bin/Release/Pub_Class.dll 补丁 | 查看 | 原始文档 | blame | 历史
BLL/bin/Release/Pub_Class.pdb 补丁 | 查看 | 原始文档 | blame | 历史
BLL/bin/Release/Pub_Control.dll 补丁 | 查看 | 原始文档 | blame | 历史
BLL/bin/Release/Pub_Control.pdb 补丁 | 查看 | 原始文档 | blame | 历史
BLL/bin/Release/SQLHelper.dll 补丁 | 查看 | 原始文档 | blame | 历史
BLL/bin/Release/SQLHelper.pdb 补丁 | 查看 | 原始文档 | blame | 历史
DAL/DAL.csproj 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DAL/bin/Release/DAL.dll 补丁 | 查看 | 原始文档 | blame | 历史
DAL/bin/Release/DAL.pdb 补丁 | 查看 | 原始文档 | blame | 历史
DAL/bin/Release/DBUtility.dll 补丁 | 查看 | 原始文档 | blame | 历史
DAL/bin/Release/DBUtility.pdb 补丁 | 查看 | 原始文档 | blame | 历史
DAL/bin/Release/Model.dll 补丁 | 查看 | 原始文档 | blame | 历史
DAL/bin/Release/Model.pdb 补丁 | 查看 | 原始文档 | blame | 历史
DAL/bin/Release/Pub_Class.dll 补丁 | 查看 | 原始文档 | blame | 历史
DAL/bin/Release/Pub_Class.pdb 补丁 | 查看 | 原始文档 | blame | 历史
DAL/bin/Release/Pub_Control.dll 补丁 | 查看 | 原始文档 | blame | 历史
DAL/bin/Release/Pub_Control.pdb 补丁 | 查看 | 原始文档 | blame | 历史
DAL/bin/Release/SQLHelper.dll 补丁 | 查看 | 原始文档 | blame | 历史
DAL/bin/Release/SQLHelper.pdb 补丁 | 查看 | 原始文档 | blame | 历史
DAL/仓库管理/ClsKf_ProductReceiveMaterialBill.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DAL/成本管理/ClsCB_ItemMoneyBillMain .cs 276 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DBUtility/bin/Release/DBUtility.dll 补丁 | 查看 | 原始文档 | blame | 历史
DBUtility/bin/Release/DBUtility.pdb 补丁 | 查看 | 原始文档 | blame | 历史
DBUtility/bin/Release/Pub_Class.dll 补丁 | 查看 | 原始文档 | blame | 历史
DBUtility/bin/Release/Pub_Class.pdb 补丁 | 查看 | 原始文档 | blame | 历史
DBUtility/bin/Release/Pub_Control.dll 补丁 | 查看 | 原始文档 | blame | 历史
DBUtility/bin/Release/Pub_Control.pdb 补丁 | 查看 | 原始文档 | blame | 历史
DBUtility/bin/Release/SQLHelper.dll 补丁 | 查看 | 原始文档 | blame | 历史
DBUtility/bin/Release/SQLHelper.pdb 补丁 | 查看 | 原始文档 | blame | 历史
DBUtility/obj/Release/DBUtility.csproj.AssemblyReference.cache 补丁 | 查看 | 原始文档 | blame | 历史
DBUtility/obj/Release/DBUtility.csproj.GenerateResource.Cache 补丁 | 查看 | 原始文档 | blame | 历史
DBUtility/obj/Release/DBUtility.dll 补丁 | 查看 | 原始文档 | blame | 历史
DBUtility/obj/Release/DBUtility.pdb 补丁 | 查看 | 原始文档 | blame | 历史
Model/Model.csproj 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Model/bin/Release/DBUtility.dll 补丁 | 查看 | 原始文档 | blame | 历史
Model/bin/Release/DBUtility.pdb 补丁 | 查看 | 原始文档 | blame | 历史
Model/bin/Release/Model.dll 补丁 | 查看 | 原始文档 | blame | 历史
Model/bin/Release/Model.pdb 补丁 | 查看 | 原始文档 | blame | 历史
Model/bin/Release/Pub_Class.dll 补丁 | 查看 | 原始文档 | blame | 历史
Model/bin/Release/Pub_Class.pdb 补丁 | 查看 | 原始文档 | blame | 历史
Model/bin/Release/Pub_Control.dll 补丁 | 查看 | 原始文档 | blame | 历史
Model/bin/Release/Pub_Control.pdb 补丁 | 查看 | 原始文档 | blame | 历史
Model/bin/Release/SQLHelper.dll 补丁 | 查看 | 原始文档 | blame | 历史
Model/bin/Release/SQLHelper.pdb 补丁 | 查看 | 原始文档 | blame | 历史
Model/obj/Release/Model.csproj.AssemblyReference.cache 补丁 | 查看 | 原始文档 | blame | 历史
Model/obj/Release/Model.dll 补丁 | 查看 | 原始文档 | blame | 历史
Model/obj/Release/Model.pdb 补丁 | 查看 | 原始文档 | blame | 历史
Model/obj/x86/Release/Model.csproj.AssemblyReference.cache 补丁 | 查看 | 原始文档 | blame | 历史
Model/成本管理/ClsCB_ItemMoneyBillMain_1.cs 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Model/成本管理/ClsCB_ItemMoneyBillSub_1.cs 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Pub_Class/bin/Release/Pub_Class.dll 补丁 | 查看 | 原始文档 | blame | 历史
Pub_Class/bin/Release/Pub_Class.pdb 补丁 | 查看 | 原始文档 | blame | 历史
Pub_Control/bin/Release/Pub_Class.dll 补丁 | 查看 | 原始文档 | blame | 历史
Pub_Control/bin/Release/Pub_Class.pdb 补丁 | 查看 | 原始文档 | blame | 历史
Pub_Control/bin/Release/Pub_Control.dll 补丁 | 查看 | 原始文档 | blame | 历史
Pub_Control/bin/Release/Pub_Control.pdb 补丁 | 查看 | 原始文档 | blame | 历史
SQLHelper/bin/Release/Pub_Class.dll 补丁 | 查看 | 原始文档 | blame | 历史
SQLHelper/bin/Release/Pub_Class.pdb 补丁 | 查看 | 原始文档 | blame | 历史
SQLHelper/bin/Release/SQLHelper.dll 补丁 | 查看 | 原始文档 | blame | 历史
SQLHelper/bin/Release/SQLHelper.pdb 补丁 | 查看 | 原始文档 | blame | 历史
SQLHelper/obj/Release/SQLHelper.csproj.AssemblyReference.cache 补丁 | 查看 | 原始文档 | blame | 历史
SQLHelper/obj/Release/SQLHelper.dll 补丁 | 查看 | 原始文档 | blame | 历史
SQLHelper/obj/Release/SQLHelper.pdb 补丁 | 查看 | 原始文档 | blame | 历史
SyntacticSugar/bin/Debug/SyntacticSugar.dll 补丁 | 查看 | 原始文档 | blame | 历史
SyntacticSugar/bin/Debug/SyntacticSugar.pdb 补丁 | 查看 | 原始文档 | blame | 历史
SyntacticSugar/obj/Debug/SyntacticSugar.csproj.AssemblyReference.cache 补丁 | 查看 | 原始文档 | blame | 历史
SyntacticSugar/obj/Debug/SyntacticSugar.csproj.FileListAbsolute.txt 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SyntacticSugar/obj/Debug/SyntacticSugar.dll 补丁 | 查看 | 原始文档 | blame | 历史
SyntacticSugar/obj/Debug/SyntacticSugar.pdb 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/BaseSet/Gy_MaterialController.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/CJGL/Cj_CheckBarcodeController.cs 141 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/CJGL/Cj_SingleStationController.cs 116 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/成本管理/CB_ItemMoneyBillController.cs 1362 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/成本管理/CB_WipProcessTableController.cs 287 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/条码管理/WEBSController.cs 257 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/DLL/ClsKf_MateOutBackBill.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/ListModels.cs 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Properties/PublishProfiles/FolderProfile8.pubxml.user 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Web References/WebS/Reference.cs 11664 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Web References/WebS/WebService1.wsdl 5201 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/WebAPI.csproj 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/WebAPI.csproj.user 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BLL/bin/Release/BLL.dll
Binary files differ
BLL/bin/Release/BLL.pdb
Binary files differ
BLL/bin/Release/DAL.dll
Binary files differ
BLL/bin/Release/DAL.pdb
Binary files differ
BLL/bin/Release/DBUtility.dll
Binary files differ
BLL/bin/Release/DBUtility.pdb
Binary files differ
BLL/bin/Release/Model.dll
Binary files differ
BLL/bin/Release/Model.pdb
Binary files differ
BLL/bin/Release/Pub_Class.dll
Binary files differ
BLL/bin/Release/Pub_Class.pdb
Binary files differ
BLL/bin/Release/Pub_Control.dll
Binary files differ
BLL/bin/Release/Pub_Control.pdb
Binary files differ
BLL/bin/Release/SQLHelper.dll
Binary files differ
BLL/bin/Release/SQLHelper.pdb
Binary files differ
DAL/DAL.csproj
@@ -101,6 +101,7 @@
    <Compile Include="仓库管理\ClsKf_ProductReceiveMaterialBill.cs" />
    <Compile Include="基础资料\其他基础资料\ClsGy_MatePrice_Ctl.cs" />
    <Compile Include="工资管理\ClsGy_SteppedPriceCoefficientBill .cs" />
    <Compile Include="成本管理\ClsCB_ItemMoneyBillMain  .cs" />
    <Compile Include="源单\InterFace源单\Cls_S_IF_ICMOBillList_CusBarCodeBill_KaiBei.cs" />
    <Compile Include="源单\InterFace源单\Cls_S_IF_MoveStockRequestBillList.cs" />
    <Compile Include="生产管理\ClsSc_ShiftsBeginInfoBill.cs" />
DAL/bin/Release/DAL.dll
Binary files differ
DAL/bin/Release/DAL.pdb
Binary files differ
DAL/bin/Release/DBUtility.dll
Binary files differ
DAL/bin/Release/DBUtility.pdb
Binary files differ
DAL/bin/Release/Model.dll
Binary files differ
DAL/bin/Release/Model.pdb
Binary files differ
DAL/bin/Release/Pub_Class.dll
Binary files differ
DAL/bin/Release/Pub_Class.pdb
Binary files differ
DAL/bin/Release/Pub_Control.dll
Binary files differ
DAL/bin/Release/Pub_Control.pdb
Binary files differ
DAL/bin/Release/SQLHelper.dll
Binary files differ
DAL/bin/Release/SQLHelper.pdb
Binary files differ
DAL/²Ö¿â¹ÜÀí/ClsKf_ProductReceiveMaterialBill.cs
@@ -77,6 +77,7 @@
                oCn.RunProc("UpDate Kf_ProductReceiveMaterialBillMain set  " +
                " HBillNo='" + omodel.HBillNo + "'" +  //固定赋值===============
                ",HDate='" + omodel.HDate + "'" +
                ",HBillSubType='" + omodel.HBillSubType + "'" +
                ",HYear='" + omodel.HYear + "'" +
                ",HPeriod='" + omodel.HPeriod + "'" +
                ",HRemark='" + omodel.HRemark + "'" +
@@ -195,7 +196,7 @@
                ",HEmpID,HDeptID,HKeeperID,HOrgID) " +
                " values(" +
                "'" + this.BillType + "'" +
                ",'" + this.HBillSubType + "'" +
                ",'" + omodel.HBillSubType.ToString() + "'" +
                "," + omodel.HInterID.ToString() + "" +
                ",'" + omodel.HBillNo + "'" +
                ",'" + omodel.HDate + "'" +
DAL/³É±¾¹ÜÀí/ClsCB_ItemMoneyBillMain .cs
New file
@@ -0,0 +1,276 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
namespace DAL
{
    public class ClsCB_ItemMoneyBillMain : DBUtility.ClsXt_BaseBill
    {
        public Model.ClsCB_ItemMoneyBillMain_1 omodel = new Model.ClsCB_ItemMoneyBillMain_1();
        public List<Model.ClsCB_ItemMoneyBillSub_1> DetailColl = new List<Model.ClsCB_ItemMoneyBillSub_1>();
        public ClsCB_ItemMoneyBillMain()
        {
            base.MvarItemKeySub = "CB_ItemMoneyBillSub";
            base.MvarItemKeySub2 = "";
            base.MvarItemKeySub3 = "";
            base.MvarItemKeySub4 = "";
            base.MvarItemKey = "CB_ItemMoneyBillMain";
            base.MvarReportTitle = "成本费用单";
            base.BillType = "1802";
        }
        #region å›ºå®šä»£ç 
        ~ClsCB_ItemMoneyBillMain()
        {
            DetailColl = null;
        }
        #endregion   è‡ªå®šä¹‰æ–¹æ³•
        //修改单据
        //修改单据
        public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                string HBillSubType = string.IsNullOrEmpty(omodel.HBillSubType) ? "1802" : omodel.HBillSubType;
                oCn.BeginTran();
                //更新主表
                string mainSql = "Update CB_ItemMoneyBillMain set " +
                       "HBillNo = '" + omodel.HBillNo + "'" +
                       ",HDate = '" + omodel.HDate + "'" +
                       ",HYear = " + omodel.HYear.ToString() +
                       ",HPeriod = " + omodel.HPeriod.ToString() +
                       ",HRemark = '" + (omodel.HRemark ?? "") + "'" +
                       ",HUpDater = '" + DBUtility.ClsPub.CurUserName + "'" +
                       ",HUpDateDate = getdate()" +
                       ",HDeptID = " + omodel.HDeptID.ToString() +
                       ",HEmpID = " + omodel.HEmpID.ToString() +
                       ",HExplanation = '" + (omodel.HExplanation ?? "") + "'" +
                       ",HInnerBillNo = '" + (omodel.HInnerBillNo ?? "") + "'" +
                       ",HICMOBillNo = '" + (omodel.HICMOBillNo ?? "") + "'" +
                       ",HBillSubType = '" + HBillSubType + "'" +
                       ",HBeginDate = '" + (omodel.HBeginDate == DateTime.MinValue ? DateTime.Now : omodel.HBeginDate) + "'" +
                       ",HEndDate = '" + (omodel.HEndDate == DateTime.MinValue ? DateTime.Now : omodel.HEndDate) + "'" +
                       " where HInterID = " + lngBillKey.ToString();
                oCn.RunProc(mainSql);
                //删除关联
                DeleteRelation(ref sReturn, lngBillKey);
                //删除子表
                DeleteBillSub(lngBillKey);
                //插入子表
                if (DetailColl != null && DetailColl.Count > 0)
                {
                    foreach (Model.ClsCB_ItemMoneyBillSub_1 oSub in DetailColl)
                    {
                        if (oSub == null)
                            continue;
                        string subSql = "insert into CB_ItemMoneyBillSub" +
                               "(HInterID,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" +
                               ",HMoney,HRemark" +
                               ",HCostItemID,HDeptID,HQty,HPrice,HMaterID,HWaster,HDate,HBeginBalance,HEndBalance,HTimes) " +
                               " values(" +
                               lngBillKey.ToString() + "," +
                               (oSub.HEntryID != null ? oSub.HEntryID.ToString() : "0") + "," +
                               (oSub.HSourceInterID != null && oSub.HSourceInterID != 0 ? oSub.HSourceInterID.ToString() : "0") + "," +
                               (oSub.HSourceEntryID != null && oSub.HSourceEntryID != 0 ? oSub.HSourceEntryID.ToString() : "0") + ",'" +
                               (oSub.HSourceBillNo ?? "") + "','" + (oSub.HSourceBillType ?? "") + "'," +
                               (oSub.HMoney != null && oSub.HMoney != 0 ? oSub.HMoney.ToString() : "0") + ",'" + (oSub.HRemark ?? "") + "'," +
                               (oSub.HCostItemID != null && oSub.HCostItemID != 0 ? oSub.HCostItemID.ToString() : "0") + "," +
                               (oSub.HDeptID != null && oSub.HDeptID != 0 ? oSub.HDeptID.ToString() : "0") + "," +
                               (oSub.HQty != null && oSub.HQty != 0 ? oSub.HQty.ToString() : "0") + "," +
                               (oSub.HPrice != null && oSub.HPrice != 0 ? oSub.HPrice.ToString() : "0") + "," +
                               (oSub.HMaterID != null && oSub.HMaterID != 0 ? oSub.HMaterID.ToString() : "0") + "," +
                               (oSub.HWaster != null && oSub.HWaster != 0 ? oSub.HWaster.ToString() : "0") + ",'" +
                               (oSub.HDate != null && oSub.HDate != DateTime.MinValue ? oSub.HDate.ToString() : DateTime.Now.ToString()) + "'," +
                               (oSub.HBeginBalance != null && oSub.HBeginBalance != 0 ? oSub.HBeginBalance.ToString() : "0") + "," +
                               (oSub.HEndBalance != null && oSub.HEndBalance != 0 ? oSub.HEndBalance.ToString() : "0") + "," +
                               (oSub.HTimes != null && oSub.HTimes != 0 ? oSub.HTimes.ToString() : "0") +
                               ")";
                        oCn.RunProc(subSql);
                    }
                }
                sReturn = "修改单据成功!";
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                throw (e);
            }
        }
        //显示单据
        //新增单据
        public override bool AddBill(ref string sReturn)
        {
            try
            {
                // å¾—到mainid
                omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
                string HBillSubType = string.IsNullOrEmpty(omodel.HBillSubType) ? "1802" : omodel.HBillSubType;
                oCn.BeginTran();
                // æ’入主表
                string mainSql = "Insert Into CB_ItemMoneyBillMain" +
                        "(HBillType,HBillSubType,HInterID,HBillNo,HDate" +
                        ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
                        ",HDeptID,HEmpID,HExplanation,HInnerBillNo" +
                        ",HICMOBillNo,HBeginDate,HEndDate,HOrgID,HMaterID) " +
                        " values('" + this.BillType + "','" + HBillSubType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" +
                        ", " + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + (omodel.HRemark ?? "") + "','" + DBUtility.ClsPub.CurUserName + "',getdate()" +
                        ", " + omodel.HDeptID.ToString() + "," + omodel.HEmpID.ToString() + ",'" + (omodel.HExplanation ?? "") + "','" + (omodel.HInnerBillNo ?? "") + "'" +
                        ",'" + (omodel.HICMOBillNo ?? "") + "'" +
                        ",'" + (omodel.HBeginDate == DateTime.MinValue ? DateTime.Now : omodel.HBeginDate) + "'" +
                        ",'" + (omodel.HEndDate == DateTime.MinValue ? DateTime.Now : omodel.HEndDate) + "'," +
                        omodel.HOrgID.ToString() + ",0) ";
                oCn.RunProc(mainSql);
                // æ’入子表
                if (DetailColl != null && DetailColl.Count > 0)
                {
                    foreach (Model.ClsCB_ItemMoneyBillSub_1 oSub in DetailColl)
                    {
                        if (oSub == null)
                            continue;
                        string subSql = "insert into CB_ItemMoneyBillSub" +
                                "(HInterID,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" +
                                ",HMoney,HRemark" +
                                ",HCostItemID,HDeptID,HQty,HPrice,HMaterID,HWaster,HDate,HBeginBalance,HEndBalance,HTimes) " +
                                " values(" +
                                omodel.HInterID.ToString() + "," +
                                (oSub.HEntryID != null ? oSub.HEntryID.ToString() : "0") + "," +
                                (oSub.HSourceInterID != null && oSub.HSourceInterID != 0 ? oSub.HSourceInterID.ToString() : "0") + "," +
                                (oSub.HSourceEntryID != null && oSub.HSourceEntryID != 0 ? oSub.HSourceEntryID.ToString() : "0") + ",'" +
                                (oSub.HSourceBillNo ?? "") + "','" + (oSub.HSourceBillType ?? "") + "'," +
                                (oSub.HMoney != null && oSub.HMoney != 0 ? oSub.HMoney.ToString() : "0") + ",'" + (oSub.HRemark ?? "") + "'," +
                                (oSub.HCostItemID != null && oSub.HCostItemID != 0 ? oSub.HCostItemID.ToString() : "0") + "," +
                                (oSub.HDeptID != null && oSub.HDeptID != 0 ? oSub.HDeptID.ToString() : "0") + "," +
                                (oSub.HQty != null && oSub.HQty != 0 ? oSub.HQty.ToString() : "0") + "," +
                                (oSub.HPrice != null && oSub.HPrice != 0 ? oSub.HPrice.ToString() : "0") + "," +
                                (oSub.HMaterID != null && oSub.HMaterID != 0 ? oSub.HMaterID.ToString() : "0") + "," +
                                (oSub.HWaster != null && oSub.HWaster != 0 ? oSub.HWaster.ToString() : "0") + ",'" +
                                (oSub.HDate != null && oSub.HDate != DateTime.MinValue ? oSub.HDate.ToString() : DateTime.Now.ToString()) + "'," +
                                (oSub.HBeginBalance != null && oSub.HBeginBalance != 0 ? oSub.HBeginBalance.ToString() : "0") + "," +
                                (oSub.HEndBalance != null && oSub.HEndBalance != 0 ? oSub.HEndBalance.ToString() : "0") + "," +
                                (oSub.HTimes != null && oSub.HTimes != 0 ? oSub.HTimes.ToString() : "0") +
                                ")";
                        oCn.RunProc(subSql);
                    }
                }
                sReturn = "新增单据成功!";
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                if (oCn != null)
                {
                    oCn.RollBack();
                }
                throw (e);
            }
        }
        public override bool ShowBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                //查询主表
                DataSet Ds;
                Ds = oCn.RunProcReturn("Select * from CB_ItemMoneyBillMain Where HInterID=" + lngBillKey.ToString(), "CB_ItemMoneyBillMain");
                if (Ds.Tables[0].Rows.Count == 0)
                {
                    sReturn = "单据未找到!";
                    return false;
                }
                //固定赋值===========================================
                omodel.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"]);
                omodel.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"]);
                omodel.HBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillType"]);
                omodel.HBillSubType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillSubType"]);
                omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]);
                omodel.HDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HDate"]);
                omodel.HBillNo = Ds.Tables[0].Rows[0]["HBillNo"].ToString().Trim();
                omodel.HBillStatus = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HBillStatus"]);
                omodel.HCheckItemNowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckItemNowID"]);
                omodel.HCheckItemNextID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckItemNextID"]);
                omodel.HCheckFlowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckFlowID"]);
                omodel.HRemark = Ds.Tables[0].Rows[0]["HRemark"].ToString().Trim();
                omodel.HBackDate = Ds.Tables[0].Rows[0]["HBackDate"].ToString().Trim();
                omodel.HBacker = Ds.Tables[0].Rows[0]["HBacker"].ToString().Trim();
                omodel.HCheckDate = Ds.Tables[0].Rows[0]["HCheckDate"].ToString().Trim();
                omodel.HChecker = Ds.Tables[0].Rows[0]["HChecker"].ToString().Trim();
                omodel.HMaker = Ds.Tables[0].Rows[0]["HMaker"].ToString().Trim();
                omodel.HMakeDate = Ds.Tables[0].Rows[0]["HMakeDate"].ToString().Trim();
                omodel.HUpDateDate = Ds.Tables[0].Rows[0]["HUpDateDate"].ToString().Trim();
                omodel.HUpDater = Ds.Tables[0].Rows[0]["HUpDater"].ToString().Trim();
                omodel.HCloseDate = Ds.Tables[0].Rows[0]["HCloseDate"].ToString().Trim();
                omodel.HCloseMan = Ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim();
                omodel.HCloseType = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HCloseType"]);
                omodel.HDeleteDate = Ds.Tables[0].Rows[0]["HDeleteDate"].ToString().Trim();
                omodel.HDeleteMan = Ds.Tables[0].Rows[0]["HDeleteMan"].ToString().Trim();
                //========================================================
                omodel.HExplanation = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HExplanation"]);
                omodel.HInnerBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInnerBillNo"]);
                //
                //循环
                DataSet DsSub;
                DsSub = oCn.RunProcReturn("Select * from CB_ItemMoneyBillSub Where HInterID=" + lngBillKey.ToString() + " order by HEntryID ", "CB_ItemMoneyBillSub");
                DetailColl.Clear();//清空
                for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
                {
                    Model.ClsCB_ItemMoneyBillSub_1 oSub = new Model.ClsCB_ItemMoneyBillSub_1();
                    // å›ºå®šèµ‹å€¼===============================================
                    oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]);
                    oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]);
                    oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceInterID"]);
                    oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceEntryID"]);
                    oSub.HSourceBillType = DsSub.Tables[0].Rows[i]["HSourceBillType"].ToString().Trim();
                    oSub.HSourceBillNo = DsSub.Tables[0].Rows[i]["HSourceBillNo"].ToString().Trim();
                    oSub.HRelationQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationQty"]);
                    oSub.HRelationMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationMoney"]);
                    oSub.HCloseMan = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HCloseMan"]);
                    oSub.HCloseType = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[i]["HCloseType"]);
                    oSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HEntryCloseDate"]);
                    oSub.HRemark = DsSub.Tables[0].Rows[i]["HRemark"].ToString().Trim();
                    //===================================================
                    DetailColl.Add(oSub);
                }
                sReturn = "显示单据成功!";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
    }
}
DBUtility/bin/Release/DBUtility.dll
Binary files differ
DBUtility/bin/Release/DBUtility.pdb
Binary files differ
DBUtility/bin/Release/Pub_Class.dll
Binary files differ
DBUtility/bin/Release/Pub_Class.pdb
Binary files differ
DBUtility/bin/Release/Pub_Control.dll
Binary files differ
DBUtility/bin/Release/Pub_Control.pdb
Binary files differ
DBUtility/bin/Release/SQLHelper.dll
Binary files differ
DBUtility/bin/Release/SQLHelper.pdb
Binary files differ
DBUtility/obj/Release/DBUtility.csproj.AssemblyReference.cache
Binary files differ
DBUtility/obj/Release/DBUtility.csproj.GenerateResource.Cache
Binary files differ
DBUtility/obj/Release/DBUtility.dll
Binary files differ
DBUtility/obj/Release/DBUtility.pdb
Binary files differ
Model/Model.csproj
@@ -128,6 +128,8 @@
    <Compile Include="基础资料\基础资料\ClsGy_ProjectMoneyClass_Model.cs" />
    <Compile Include="基础资料\基础资料\ClsGy_RepairClass_Model.cs" />
    <Compile Include="基础资料\基础资料\ClsGy_RepairCheckClass_Model.cs" />
    <Compile Include="成本管理\ClsCB_ItemMoneyBillMain_1.cs" />
    <Compile Include="成本管理\ClsCB_ItemMoneyBillSub_1.cs" />
    <Compile Include="物流管理\ClsCg_CarTrajectoryBillMain.cs" />
    <Compile Include="物流管理\ClsCg_CarTrajectoryBillSub.cs" />
    <Compile Include="物流管理\ClsPay_WayBillPaymentBillMain.cs" />
Model/bin/Release/DBUtility.dll
Binary files differ
Model/bin/Release/DBUtility.pdb
Binary files differ
Model/bin/Release/Model.dll
Binary files differ
Model/bin/Release/Model.pdb
Binary files differ
Model/bin/Release/Pub_Class.dll
Binary files differ
Model/bin/Release/Pub_Class.pdb
Binary files differ
Model/bin/Release/Pub_Control.dll
Binary files differ
Model/bin/Release/Pub_Control.pdb
Binary files differ
Model/bin/Release/SQLHelper.dll
Binary files differ
Model/bin/Release/SQLHelper.pdb
Binary files differ
Model/obj/Release/Model.csproj.AssemblyReference.cache
Binary files differ
Model/obj/Release/Model.dll
Binary files differ
Model/obj/Release/Model.pdb
Binary files differ
Model/obj/x86/Release/Model.csproj.AssemblyReference.cache
Binary files differ
Model/³É±¾¹ÜÀí/ClsCB_ItemMoneyBillMain_1.cs
New file
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Model
{
     public class ClsCB_ItemMoneyBillMain_1 : DBUtility.ClsXt_BaseBillMain
    {
        public int HEmpID;  // --职员
        public int HDeptID;// --部门
        public string HICMOBillNo; // --任务单号
        public string HExplanation; //    --摘要
        public string HInnerBillNo; // --内部单据号
        public DateTime HBeginDate; // --开始日期
        public DateTime HEndDate; // --结束日期
        public Int64 HOrgID; //组织
    }
}
Model/³É±¾¹ÜÀí/ClsCB_ItemMoneyBillSub_1.cs
New file
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Model
{
    public class ClsCB_ItemMoneyBillSub_1: DBUtility.ClsXt_BaseBillSub
    {
        public int HCostItemID;         // æˆæœ¬é¡¹ç›®ï¼ˆé€‰è´¹ç”¨é¡¹ç›®ï¼‰
        public int HDeptID;             // éƒ¨é—¨
        public double HQty;             // æ•°é‡
        public double HPrice;           // å•ä»·
        public double HMoney;           // é‡‘额
        public int HMaterID;            // ç‰©æ–™å†…码
        public double HWaster;          // æŸè€—
        public DateTime HDate;          // æ—¥æœŸ
        public decimal HBeginBalance;   // å¼€å§‹æ•°å€¼
        public decimal HEndBalance;     // ç»“束数值
        public decimal HTimes;          // æ—¶é—´å‘¨æœŸ
    }
}
Pub_Class/bin/Release/Pub_Class.dll
Binary files differ
Pub_Class/bin/Release/Pub_Class.pdb
Binary files differ
Pub_Control/bin/Release/Pub_Class.dll
Binary files differ
Pub_Control/bin/Release/Pub_Class.pdb
Binary files differ
Pub_Control/bin/Release/Pub_Control.dll
Binary files differ
Pub_Control/bin/Release/Pub_Control.pdb
Binary files differ
SQLHelper/bin/Release/Pub_Class.dll
Binary files differ
SQLHelper/bin/Release/Pub_Class.pdb
Binary files differ
SQLHelper/bin/Release/SQLHelper.dll
Binary files differ
SQLHelper/bin/Release/SQLHelper.pdb
Binary files differ
SQLHelper/obj/Release/SQLHelper.csproj.AssemblyReference.cache
Binary files differ
SQLHelper/obj/Release/SQLHelper.dll
Binary files differ
SQLHelper/obj/Release/SQLHelper.pdb
Binary files differ
SyntacticSugar/bin/Debug/SyntacticSugar.dll
Binary files differ
SyntacticSugar/bin/Debug/SyntacticSugar.pdb
Binary files differ
SyntacticSugar/obj/Debug/SyntacticSugar.csproj.AssemblyReference.cache
Binary files differ
SyntacticSugar/obj/Debug/SyntacticSugar.csproj.FileListAbsolute.txt
@@ -24,3 +24,4 @@
D:\工作代码\智云迈思\MES\MES-WEB-API\SyntacticSugar\obj\Debug\SyntacticSugar.csproj.CoreCompileInputs.cache
D:\工作代码\智云迈思\MES\MES-WEB-API\SyntacticSugar\obj\Debug\SyntacticSugar.dll
D:\工作代码\智云迈思\MES\MES-WEB-API\SyntacticSugar\obj\Debug\SyntacticSugar.pdb
D:\工作代码\智云迈思\MES\MES-WEB-API\SyntacticSugar\obj\Debug\SyntacticSugar.csproj.AssemblyReference.cache
SyntacticSugar/obj/Debug/SyntacticSugar.dll
Binary files differ
SyntacticSugar/obj/Debug/SyntacticSugar.pdb
Binary files differ
WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
@@ -4834,7 +4834,7 @@
                        "," + HPrintQty + ",'" + HMouldStatus + "'," + HWHID + "," + HRoutingID + "," + HCaveQty +
                        "," + HBOMID + ",'" + HVersion + "'," + HSPGroupID + "," + HSPID + ",'" + HDesignLife + "','" + HNowSupID + "','" + HNowSupTypeID + "'" +
                        ",'" + HUseLife + "','" + HLeaveLife + "','" + HProdQty + "','" + HProdWeight + "','" + HMouldOWNER + "','" + HSaveLife + "','" + HMouldDotCheckRuleInterID + "','" + HMouldMaintainRuleInterID + "','" + HBarCode + "'," + HMadeSupID +
                        ",'" + HMouldClass + "'," + HNowWHID + "," + HNowSPID + ",'" + HInitLife + " ) ");
                        ",'" + HMouldClass + "'," + HNowWHID + "," + HNowSPID + ",'" + HInitLife + "' ) ");
                    }
                    else
                    {
WebAPI/Controllers/CJGL/Cj_CheckBarcodeController.cs
@@ -22,7 +22,7 @@
        #region ä¸‰ç åˆä¸€ï¼Œåˆ¤æ–­æ‰«æç‰©æ–™æ¡ç ç»‘定信息是否一致
        [Route("CheckBarcodeController/Get_BarCode_BarcodeCheck")]
        [HttpGet]
        public object CheckBarcode(string HBarCode_Pallet, string HBarCode_Destination, string HBarCode_MiddleBox, string HBarCode_SN, int HBarCodeType,int HInterID, string HBillNo,string HMaker,string HBillType)
        public object CheckBarcode(string HBarCode_Pallet, string HBarCode_Destination, string HBarCode_MiddleBox, string HBarCode_SN, int HBarCodeType, int HInterID, string HBillNo, string HMaker, string HBillType)
        {
            try
            {
@@ -68,7 +68,7 @@
        [Route("CheckBarcodeController/Save_BarCode_BarcodeCheck")]
        [HttpGet]
        public object Save_BarCode_BarcodeCheck(Int64 HInterID, string HBillNo,string HBillType)
        public object Save_BarCode_BarcodeCheck(Int64 HInterID, string HBillNo, string HBillType)
        {
            try
            {
@@ -76,7 +76,7 @@
                DataSet ds = oCn.RunProcReturn("exec h_p_WMS_BarCodeBingCheckBill_Insert " + HInterID.ToString() + ",'" + HBillNo + "','" + HBillType + "'", "h_p_WMS_BarCodeBingCheckBill_Insert");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                {
                    oCn.RollBack();
                    objJsonResult.code = "0";
@@ -122,5 +122,140 @@
        }
        #endregion
        #region æ‹†ç®±å°å«
        [Route("CheckBarcodeController/UnpackMiddleBox")]
        [HttpGet]
        public object UnpackMiddleBox(string HBarCode_Middle, int signal, string HMaker, string HDate)
        {
            try
            {
                if (signal == 1)//扫码
                {
                    DataSet ds = oCn.RunProcReturn("select a.HCaseCode ä¸­ç®±ç ,a.HBarCode å¯¹åº”çš„SN码,b.HNumber ç‰©æ–™ä»£ç ,b.HName ç‰©æ–™åç§° from Gy_CaseCodeRelation a left join Gy_Material b on a.HMaterID=b.HItemID where HCaseCode='" + HBarCode_Middle + "'", "Gy_CaseCodeRelation");
                    if (ds.Tables[0].Rows[0]["中箱码"].ToString() == "" || ds == null)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "条码不存在!请检查是否装箱";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "成功";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
                else
                {
                    oCn.BeginTran();
                    oCn.RunProc("delete from Gy_CaseCodeRelation where HCaseCode='" + HBarCode_Middle + "'");
                    DataSet dss = oCn.RunProcReturn("select * from Gy_BarCodeBill where HBarCode=' " + HBarCode_Middle + "'", "Gy_BarCodeBill");
                    if (dss != null && dss.Tables.Count > 0)
                    {
                        oCn.RunProc("delete from Gy_BarCodeBill where HBarCode='" + HBarCode_Middle + "'");
                    }
                    oCn.RunProc("insert into System_log VALUES('" + HDate + "','" + HMaker + "',''," + "'小卫拆箱条码" + HBarCode_Middle + "'," + "'APP-中箱码拆箱'" + ",''," + "'删除条码')");
                    oCn.Commit();
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "成功";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "错误请联系管理员";
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region sn装箱小卫
        [Route("CheckBarcodeController/PackedBoxSn")]
        [HttpGet]
        public object PackedBoxSn(string HBarCode, string HMaker, string HDate)
        {
            try
            {
                DataSet ds = oCn.RunProcReturn("select a.HBarCode sn码,a.HItemID,b.Hname ç‰©æ–™åç§°,b.hnumber ç‰©æ–™ä»£ç  from Gy_BarCodeBill a LEFT JOIN Gy_Material b on a.hmaterid=b.hitemid where HBarCode='" + HBarCode + "'", "Gy_BarCodeBill");
                if(ds.Tables[0].Rows.Count==0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "该sn码不存在,请检查!!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                DataSet dss = oCn.RunProcReturn("select * from Gy_CaseCodeRelation where HBarCode='" + HBarCode + "'", "Gy_CaseCodeRelation");
                int counts=dss.Tables[0].Rows.Count;
                if (counts > 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "该sn码已经装箱,请检查!!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "成功";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region sn装箱小卫提交
        [Route("CheckBarcodeController/submitPackedBoxSn")]
        [HttpGet]
        public object submitPackedBoxSn(string HItemIDs, string HMaker, string HDate)
        {
            try
            {
                DataSet ds = oCn.RunProcReturn("exec h_p_Gy_CaseCodeBySN  '"+ HItemIDs+ "'", "h_p_Gy_CaseCodeBySN");
                if (ds.Tables[0].Rows[0]["HBack"] == "2")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "中箱码已存在请重新生成";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "成功";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}
WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
@@ -3777,6 +3777,122 @@
        }
        #endregion
        #region å°å«ç»„托缓存 æŸ¥è¯¢
        [Route("Cj_SingleStation/xiaoweizutuo_CacheList")]
        [HttpGet]
        public object xiaoweizutuo_CacheList(string sWhere, string user, string gnsy)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (gnsy != "" && gnsy != null)
                {
                    //查看权限
                    if (!DBUtility.ClsPub.Security_Log(gnsy, 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "无查看权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Sc_PackUnionBill_Temp" +
                        " order by æ ˆæ¿ç  desc,中箱码,SN码", "h_v_Sc_PackUnionBill_Temp");
                }
                else
                {
                    string sql1 = "select * from h_v_Sc_PackUnionBill_Temp where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by æ ˆæ¿ç  desc,中箱码,SN码";
                    ds = oCN.RunProcReturn(sql, "h_v_Sc_PackUnionBill_Temp");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å°å«ç»„托缓存 åˆ é™¤
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("Cj_SingleStation/deleteBill")]
        [HttpGet]
        public object deleteBill(string HInterID, string user,string gnsy)
        {
            try
            {
                if (gnsy != "" && gnsy != null)
                {
                    //查看权限
                    if (!DBUtility.ClsPub.Security_Log(gnsy, 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "无查看权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                if (HInterID == null || HInterID.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID不能为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();
                oCN.RunProc("delete from Sc_PackUnionBill_Temp where HInterID = " + HInterID);
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
    }
WebAPI/Controllers/³É±¾¹ÜÀí/CB_ItemMoneyBillController.cs
New file
@@ -0,0 +1,1362 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Pub_Class;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.Http;
using WebAPI.Models;
using WebAPI.Controllers.SCGL.日计划管理;
using System.IO;
using System.Linq;
using System.Text;
namespace WebAPI.Controllers
{
    //成本费用单Controller
    public class CB_ItemMoneyBillController : ApiController
    {
        //成本费用单
        //获取系统参数    CB_ItemMoneyBillMain      CB_ItemMoneyBill
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
        public DAL.ClsCB_ItemMoneyBillMain BillOld = new DAL.ClsCB_ItemMoneyBillMain();
        public DAL.ClsCB_ItemMoneyBillMain BillNew0 = new DAL.ClsCB_ItemMoneyBillMain();
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        DataSet ds;
        #region æˆæœ¬è´¹ç”¨å•列表 æŸ¥è¯¢
        /// <summary>
        /// è¿”回项目阶段列表
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("CB_ItemMoneyBillTran/CB_ItemMoneyBillMainList")]
        [HttpGet]
        public object CB_ItemMoneyBillMainList(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("CB_ItemMoney_Query", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_CB_ItemMoneyBillMainList order by å•据号 desc", "h_v_CB_ItemMoneyBillMainList");
                }
                else
                {
                    string sql1 = "select * from h_v_CB_ItemMoneyBillMainList where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by å•据号 desc";
                    ds = oCN.RunProcReturn(sql, "h_v_CB_ItemMoneyBillMainList");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region æˆæœ¬è´¹ç”¨å•保存成本费用单保存 æ–°å¢ž/编辑
        [Route("CB_ItemMoneyBillTran/SaveCB_ItemMoneyBillMain")]
        [HttpPost]
        public object SaveCB_ItemMoneyBillMain ([FromBody] JObject msg)
        {
            var _value = msg["msg"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string msg3 = sArray[1].ToString(); //子表
            string refSav = sArray[2].ToString();//操作方式数据类型 1添加 3修改 2 å¤åˆ¶
            string msg4 = sArray[3].ToString();//用户名
            DBUtility.ClsPub.CurUserName = msg4;
            string UserName = "";
            string s = "";
            ListModels oListModels = new ListModels();
            try
            {
                //编辑权限
                if (!DBUtility.ClsPub.Security_Log_second("CB_ItemMoney_Edit", 1, false, msg4))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无保存权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                DAL.ClsCB_ItemMoneyBillMain oBill = new DAL.ClsCB_ItemMoneyBillMain();
                List<Model.ClsCB_ItemMoneyBillMain_1> lsmain = new List<Model.ClsCB_ItemMoneyBillMain_1>();
                msg2 = msg2.Replace("\\", "");
                msg2 = msg2.Replace("\n", "");  //\n
                lsmain = oListModels.getObjectByJson_CB_ItemMoneyBillMain(msg2);
                foreach (Model.ClsCB_ItemMoneyBillMain_1 oItem in lsmain)
                {
                    if (refSav == "Add")
                    {
                        //单据号是否重复
                        if (BillNew0.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID))
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据号重复!不允许保存!";
                            objJsonResult.data = 1;
                            return objJsonResult;
                        }
                    }
                    if (refSav == "Update")
                    {
                        if (BillOld.ShowBill(oItem.HInterID, ref s) == false)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "此单据有误!";
                            objJsonResult.data = 1;
                            return objJsonResult;
                        }
                        //判断是否可编辑
                        if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "此单据已经被审核,不允许修改!";
                            objJsonResult.data = 1;
                            return objJsonResult;
                        }
                        if (BillOld.omodel.HBillStatus > 1)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "此单据处于不可编辑状态,不允许修改!";
                            objJsonResult.data = 1;
                            return objJsonResult;
                        }
                        if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld, ref s))
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = s + ",不允许修改";
                            objJsonResult.data = 1;
                            return objJsonResult;
                        }
                    }
                    UserName = oItem.HMaker;  //制单人
                    oItem.HBillType = "1802";
                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
                    oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
                    if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "保存失败!没有单据日期,无法保存!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    oBill.omodel = oItem;
                }
                // è¡¨ä½“数据
                //按 },{来拆分数组 //去掉【和】
                msg3 = msg3.Substring(1, msg3.Length - 2);
                msg3 = msg3.Replace("\\", "");
                msg3 = msg3.Replace("\n", "");  //\n
                List<Model.ClsCB_ItemMoneyBillSub_1> ls = new List<Model.ClsCB_ItemMoneyBillSub_1>();
                ls = oListModels.getObjectByJson_CB_ItemMoneyBillSub(msg3);
                int i = 0;
                foreach (Model.ClsCB_ItemMoneyBillSub_1 oItemSub in ls)
                {
                    i++;
                    oItemSub.HEntryID = i;
                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                    oItemSub.HCloseType = false;   //关闭类型
                    oBill.DetailColl.Add(oItemSub);
                }
                //进行 ä¼šè®¡æœŸé—´ ç»“è´¦ çš„判断和控制
                int sYear = 0;
                int sPeriod = 0;
                DateTime HDate = DateTime.Now;
                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
                {
                    objJsonResult.Message = s;
                    return objJsonResult;
                }
                //保存
                //保存完毕后处理
                bool bResult;
                if (refSav == "Add")
                {
                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                }
                else if (refSav == "Update")
                {
                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                }
                else
                {
                    bResult = false;
                }
                if (bResult)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
                objJsonResult.data = 1;
                return objJsonResult;
            }
        }
        #endregion
        #region æˆæœ¬è´¹ç”¨å• ç¼–辑页面初始化
        [Route("CB_ItemMoneyBillTran/CB_ItemMoneyBillMainEditList")]
        [HttpGet]
        public object CB_ItemMoneyBillMainEditList(long HInterID)
        {
            try
            {
                List<DataTable> tableList = new List<DataTable>();
                ds = oCN.RunProcReturn("exec h_p_CB_ItemMoneyBillMain_Edit @HInterID = " + HInterID, "h_p_CB_ItemMoneyBillMain_Edit");
                tableList.Add(ds.Tables[0]);
                tableList.Add(ds.Tables[1]);
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "false!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "Sucess!";
                    objJsonResult.data = tableList;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region æˆæœ¬è´¹ç”¨å• åˆ é™¤
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("CB_ItemMoneyBillTran/DeleteCB_ItemMoneyBillMain")]
        [HttpGet]
        public object DeleteCB_ItemMoneyBillMain (string HInterID, string user)
        {
            try
            {
                string s = "";
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("CB_ItemMoney_Drop", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无删除权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (HInterID == null || HInterID.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID不能为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (BillOld.ShowBill(long.Parse(HInterID), ref s) == false)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "此单据有误!";
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
                //判断是否可编辑
                if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "此单据已经被审核,不允许删除!";
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
                //删除前控制=========================================
                string sql1 = "exec h_p_CB_ItemMoneyBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
                ds = oCN.RunProcReturn(sql1, "h_p_CB_ItemMoneyBill _BeforeDelCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:删除前判断失败,请与网络管理人员联系";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //==================================================================================
                //进行 ä¼šè®¡æœŸé—´ ç»“è´¦ çš„判断和控制
                int sYear = 0;
                int sPeriod = 0;
                DateTime HDate = DateTime.Now;
                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
                {
                    objJsonResult.Message = s;
                    return objJsonResult;
                }
                oCN.BeginTran();
                oCN.RunProc("delete from CB_ItemMoneyBillMain  where HInterID = " + HInterID);
                oCN.RunProc("delete from CB_ItemMoneyBillSub where HInterID= " + HInterID);
                //删除后控制==================================================================================
                string sql2 = "exec h_p_CB_ItemMoneyBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
                ds = oCN.RunProcReturn(sql2, "h_p_CB_ItemMoneyBill _AfterDelCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    s = "删除后判断失败,请与网络管理人员联系";
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:" + s;
                    objJsonResult.data = null;
                    oCN.RollBack();
                    return objJsonResult;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    s = ds.Tables[0].Rows[0]["HRemark"].ToString();
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:" + s;
                    objJsonResult.data = null;
                    oCN.RollBack();
                    return objJsonResult;
                }
                //==============================================================================================
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "删除成功";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region æˆæœ¬è´¹ç”¨å• å®¡æ ¸/反审核
        /// <summary>
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">审核(0),反审核(1)</param>
        /// <param name="CurUserName">审核人</param>
        /// <returns></returns>
        [Route("CB_ItemMoneyBillTran/AuditCB_ItemMoneyBillMain")]
        [HttpGet]
        public object AuditCB_ItemMoneyBillMain (int HInterID, int IsAudit, string CurUserName)
        {
            string ModRightNameCheck = "CB_ItemMoney_Check";
            DBUtility.ClsPub.CurUserName = CurUserName;
            try
            {
                //审核权限
                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "审核失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //HInterID数据判断
                if (HInterID <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID小于0!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                Int64 lngBillKey = 0;
                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //对HInterID进行类型的转换
                DAL.ClsCB_ItemMoneyBillMain oBill = new DAL.ClsCB_ItemMoneyBillMain();                              //实例化单据操作类,用于进行相关操作
                //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作
                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //根据HInterID获取该单据的数据
                {
                    if (oBill.omodel.HCloseMan.Trim() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已关闭!不能再次审核!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (oBill.omodel.HDeleteMan.Trim() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已作废!不能再次审核!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (IsAudit == 0)  //审核判断
                    {
                        if (oBill.omodel.HChecker.Trim() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已审核!不能再次审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    if (IsAudit == 1) //反审核判断
                    {
                        if (oBill.omodel.HChecker.Trim() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据未审核!不需要反审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //进行需要进行的审核/反审核操作
                if (IsAudit == 0) //审核提交
                {
                    //进行 ä¼šè®¡æœŸé—´ ç»“è´¦ çš„判断和控制
                    string s = "";
                    int sYear = 0;
                    int sPeriod = 0;
                    DateTime HDate = DateTime.Now;
                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
                    {
                        objJsonResult.Message = s;
                        return objJsonResult;
                    }
                    oCN.BeginTran();
                    //记录返回信息
                    string msg = "";
                    //审核前控制=========================================
                    string sql1 = "exec h_p_CB_ItemMoneyBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_CB_ItemMoneyBill_BeforeCheckCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        oCN.RollBack();
                        return objJsonResult;
                    }
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        oCN.RollBack();
                        return objJsonResult;
                    }
                    //==================================================================================
                    //审核提交
                    if (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_CB_ItemMoneyBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        oCN.Commit();
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核成功!" + msg;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                if (IsAudit == 1) //反审核提交
                {
                    //反审核前控制=========================================
                    string sql1 = "exec h_p_CB_ItemMoneyBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_CB_ItemMoneyBill_BeforeUnCheckCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核失败!原因:反审核前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //===========================================================
                    //进行 ä¼šè®¡æœŸé—´ ç»“è´¦ çš„判断和控制
                    string s = "";
                    int sYear = 0;
                    int sPeriod = 0;
                    DateTime HDate = DateTime.Now;
                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
                    {
                        objJsonResult.Message = s;
                        return objJsonResult;
                    }
                    //反审核提交AbandonCheck
                    if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_CB_ItemMoneyBill_AfterUnCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核成功";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region æˆæœ¬è´¹ç”¨å• å…³é—­/反关闭
        /// <summary>
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">关闭(0),反关闭(1)</param>
        /// <param name="CurUserName">关闭人</param>
        /// <returns></returns>
        [Route("CB_ItemMoneyBillTran/CloseCB_ItemMoneyBill")]
        [HttpGet]
        public object CloseCB_ItemMoneyBill (int HInterID, int IsAudit, string CurUserName)
        {
            string ModRightNameCheck = "CB_ItemMoney_Close";
            DBUtility.ClsPub.CurUserName = CurUserName;
            try
            {
                //检查权限
                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "关闭失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //HInterID数据判断
                if (HInterID <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID小于0!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                Int64 lngBillKey = 0;
                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //对HInterID进行类型的转换
                DAL.ClsCB_ItemMoneyBillMain oBill = new DAL.ClsCB_ItemMoneyBillMain();              //实例化单据操作类,用于进行相关操作
                //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作
                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //根据HInterID获取该单据的数据
                {
                    if (oBill.omodel.HDeleteMan.Trim() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已作废!不能进行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (oBill.omodel.HChecker.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据未审核!不能进行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (IsAudit == 0)  //关闭判断
                    {
                        if (oBill.omodel.HCloseMan.Trim() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已关闭!不能再次关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    if (IsAudit == 1) //反关闭判断
                    {
                        if (oBill.omodel.HCloseMan.Trim() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据未关闭!不需要反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //进行需要进行的关闭/反关闭操作
                if (IsAudit == 0) //关闭提交
                {
                    //关闭提交
                    if (oBill.CloseBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭成功";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                if (IsAudit == 1) //反关闭提交
                {
                    //反关闭提交
                    if (oBill.CancelClose(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭成功";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "关闭失败或者反关闭失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region æˆæœ¬è´¹ç”¨å• ä½œåºŸ/反作废
        /// <summary>
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">作废(0),反作废(1)</param>
        /// <param name="CurUserName">作废人</param>
        /// <returns></returns>
        [Route("CB_ItemMoneyBillTran/DeleteCB_ItemMoneyBill")]
        [HttpGet]
        public object DeleteCB_ItemMoneyBill (int HInterID, int IsAudit, string CurUserName)
        {
            string ModRightNameCheck = "CB_ItemMoney_Delete";
            DBUtility.ClsPub.CurUserName = CurUserName;
            try
            {
                //检查权限
                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "作废失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //HInterID数据判断
                if (HInterID <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID小于0!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                Int64 lngBillKey = 0;
                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //对HInterID进行类型的转换
                DAL.ClsCB_ItemMoneyBillMain oBill = new DAL.ClsCB_ItemMoneyBillMain();              //实例化单据操作类,用于进行相关操作
                //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作
                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //根据HInterID获取该单据的数据
                {
                    if (oBill.omodel.HChecker.Trim() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已审核!不能进行作废!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (IsAudit == 0)  //作废判断
                    {
                        if (oBill.omodel.HDeleteMan.Trim() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已作废!不能再作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    if (IsAudit == 1) //反作废判断
                    {
                        if (oBill.omodel.HDeleteMan.Trim() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据未作废!不需要反作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //进行需要进行的作废/反作废操作
                if (IsAudit == 0) //作废提交
                {
                    //作废提交
                    if (oBill.Cancelltion(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "作废成功";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "作废失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                if (IsAudit == 1) //反关闭提交
                {
                    //反关闭提交
                    if (oBill.AbandonCancelltion(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反作废成功";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反作废失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "作废失败或者反作废失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region æ–‡ä»¶ä¸Šä¼ 
        [Route("CB_ItemMoneyBillController/CB_ItemMoneyBill_Excel")]
        [HttpPost]
        public json CB_ItemMoneyBill_Excel()
        {
            json res = new json();
            try
            {
                //获取文件名称
                var file = HttpContext.Current.Request.Files[0];
                //获取文件物理路径
                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
                //保存文件
                file.SaveAs(ExcelPath);
                SCGL.日计划管理.NpoiHelper np = new NpoiHelper();
                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
                //删除文件
                File.Delete(ExcelPath);
                //创建临时表
                DataTable provisional = new DataTable("dt2");
                //添加列名
                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
                {
                    provisional.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
                }
                provisional.Columns.Add("单据号", typeof(string));
                //添加数据
                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
                {
                    DataRow row = provisional.NewRow();
                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
                    {
                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
                    }
                    provisional.Rows.Add(row);
                }
                //判断列
                string error = JudgmentColumns(provisional);
                if (error.Length > 0)
                {
                    res.code = "0";
                    res.count = 0;
                    res.Message = $"Excel模板存在错误,{error}\r\n";
                    res.data = null;
                    return res;
                }
                for (int i = 0; i <= provisional.Rows.Count - 1; i++)
                {
                    //string HBillNo= DBUtility.ClsPub.CreateBillCode("1802", ref DBUtility.ClsPub.sExeReturnInfo, true);
                    //provisional.Rows[i]["单据号"] = HBillNo;
                    string HDepNumber = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["部门代码"].ToString());
                    string HDepName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["部门"].ToString());
                    string HEmpNumber = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["职员代码"].ToString());
                    string HEmpName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["职员"].ToString());
                    string HICMOBillNo = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["生产订单号"].ToString());
                    string HCostItemNumber = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["成本项目代码"].ToString());
                    string HCostItemName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["成本项目"].ToString());
                    //string HEntryID = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["子表内码"].ToString());
                    string HDepNumber_sub = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["子部门代码"].ToString());
                    string HDepName_sub = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["子部门"].ToString());
                    string HMaterNumber = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["物料编码"].ToString());
                    string HMaterName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["物料名称"].ToString());
                    string HQty = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["数量"].ToString());
                    string HPrice = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["单价"].ToString());
                    string HMoney = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["金额"].ToString());
                    string HWaster = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["损耗量"].ToString());
                    //string HRelationQty = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["关联数量"].ToString());
                    //string HRelationMoney = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["关联金额"].ToString());
                    string remark = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["备注"].ToString());
                    //获取真实行数
                    int line = i + 1;
                }
                res.code = "1";
                res.count = 1;
                res.Message = error;
                res.data = provisional;
                return res;
            }
            catch (Exception e)
            {
                res.code = "0";
                res.count = 0;
                res.Message = "Exception!" + e.ToString();
                res.data = null;
                return res;
            }
        }
        /// <summary>
        /// åˆ¤æ–­åˆ—
        /// </summary>
        /// <param name="provisional"></param>
        /// <returns></returns>
        private static string JudgmentColumns(DataTable provisional)
        {
            var error = "";
            //查询没有的列
            //if (!provisional.Columns.Contains("子表内码"))
            //    error += "没有找到【子表内码】的标题,";
            if (!provisional.Columns.Contains("物料编码"))
                error += "没有找到【物料编码】的标题,";
            return error;
        }
        #endregion
        #region ä¸Šä¼ ä¿å­˜
        [Route("CB_ItemMoneyBillController/Excel_btnSave")]
        [HttpPost]
        public object Excel_btnSave([FromBody] JObject sMainSub)
        {
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string user = sArray[1].ToString();
            string organ = sArray[2].ToString();
            json res = new json();
            try
            {
                oCN.BeginTran();
                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
                foreach (JObject item in Excel)
                {
                    Dictionary<string, string> dic = new Dictionary<string, string>();
                    foreach (var itm in item.Properties())
                    {
                        dic.Add(itm.Name, itm.Value.ToString());
                    }
                    list.Add(dic);
                }
                // 1. æ”¶é›†æ‰€æœ‰éœ€è¦æŸ¥è¯¢çš„æ•°æ®
                var HBillnos = list.Select(x => x["单据号"].ToString()).Distinct().ToList();
                var HDeptNames = list.Select(x => x["部门"].ToString()).Distinct().ToList();
                var HDeptNumbers = list.Select(x => x["部门代码"].ToString()).Distinct().ToList();
                var HDeptNames_sub = list.Select(x => x["子部门"].ToString()).Distinct().ToList();
                var HDeptNumbers_sub = list.Select(x => x["子部门代码"].ToString()).Distinct().ToList();
                var materialNumbers = list.Select(x => x["物料编码"].ToString()).Distinct().ToList();
                var materialNames = list.Select(x => x["物料名称"].ToString()).Distinct().ToList();
                var EmpNumbers = list.Select(x => x["职员代码"].ToString()).Distinct().ToList();
                var EmpNames = list.Select(x => x["职员"].ToString()).Distinct().ToList();
                var CostNumbers = list.Select(x => x["成本项目代码"].ToString()).Distinct().ToList();
                var CostNames = list.Select(x => x["成本项目"].ToString()).Distinct().ToList();
                var ICMONumbers = list.Select(x => x["生产订单号"].ToString()).Distinct().ToList();
                // 2. æ‰¹é‡æŸ¥è¯¢ç”Ÿäº§è®¢å•内码
                string ICMOQuery = $"SELECT HInterID,HBillNo FROM Sc_ICMOBillMain WHERE HBillNo IN ({string.Join(",", ICMONumbers.Select(s => $"'{s.Replace("'", "''")}'"))})";
                DataSet icmoData = oCN.RunProcReturn(ICMOQuery, "Sc_ICMOBillMain");
                Dictionary<string, int> ICMODict = new Dictionary<string, int>();
                foreach (DataRow row in icmoData.Tables[0].Rows)
                {
                    ICMODict[row["HBillNo"].ToString()] = (int)row["HInterID"];
                }
                // 2. æ‰¹é‡æŸ¥è¯¢ä¸»å­è¡¨éƒ¨é—¨ä¿¡æ¯
                string supplierQuery = $"SELECT HItemID, HName FROM Gy_Department WHERE HName IN ({string.Join(",", HDeptNames.Select(s => $"'{s.Replace("'", "''")}'"))})";
                DataSet supData = oCN.RunProcReturn(supplierQuery, "Gy_Department");
                Dictionary<string, int> supplierDict = new Dictionary<string, int>();
                foreach (DataRow row in supData.Tables[0].Rows)
                {
                    supplierDict[row["HName"].ToString()] = (int)row["HItemID"];
                }
                // 2.1 æ‰¹é‡æŸ¥è¯¢ä¸»å­è¡¨éƒ¨é—¨ä¿¡æ¯
                string supplierQuery_sub = $"SELECT HItemID, HName FROM Gy_Department WHERE HName IN ({string.Join(",", HDeptNames_sub.Select(s => $"'{s.Replace("'", "''")}'"))})";
                DataSet supData_sub = oCN.RunProcReturn(supplierQuery_sub, "Gy_Department");
                Dictionary<string, int> supplierDict_sub = new Dictionary<string, int>();
                foreach (DataRow row in supData_sub.Tables[0].Rows)
                {
                    supplierDict_sub[row["HName"].ToString()] = (int)row["HItemID"];
                }
                // 3. æ‰¹é‡æŸ¥è¯¢ç‰©æ–™ä¿¡æ¯
                string materialQuery =
                $"SELECT HItemID, HNumber, HName FROM Gy_Material WHERE HNumber IN ({string.Join(",", materialNumbers.Select(m => $"'{m.Replace("'", "''")}'"))}) AND HName IN ({string.Join(",", materialNames.Select(m => $"'{m.Replace("'", "''")}'"))})";
                DataSet materData = oCN.RunProcReturn(materialQuery, "Gy_Material");
                Dictionary<string, int> materialDict = new Dictionary<string, int>();
                foreach (DataRow row in materData.Tables[0].Rows)
                {
                    string key = $"{row["HNumber"]}_{row["HName"]}";
                    materialDict[key] = (int)row["HItemID"];
                }
                // 3. æ‰¹é‡æŸ¥è¯¢èŒå‘˜ä¿¡æ¯
                string EmployeeQuery =
                $"SELECT HItemID, HNumber, HName FROM Gy_Employee WHERE HNumber IN ({string.Join(",", EmpNumbers.Select(m => $"'{m.Replace("'", "''")}'"))}) AND HName IN ({string.Join(",", EmpNames.Select(m => $"'{m.Replace("'", "''")}'"))})";
                DataSet EmpData = oCN.RunProcReturn(EmployeeQuery, "Gy_Employee");
                Dictionary<string, int> EmpDict = new Dictionary<string, int>();
                foreach (DataRow row in EmpData.Tables[0].Rows)
                {
                    string key = $"{row["HName"].ToString()}";
                    EmpDict[key] = (int)row["HItemID"];
                }
                // 3. æ‰¹é‡æŸ¥è¯¢chengbenxiangmu信息
                string CostQuery = $"SELECT HItemID, HNumber, HName FROM Gy_ItemMoney_1 WHERE HNumber IN ({string.Join(",", CostNumbers.Select(m => $"'{m.Replace("'", "''")}'"))}) AND HName IN ({string.Join(",", CostNames.Select(m => $"'{m.Replace("'", "''")}'"))})";
                DataSet CostData = oCN.RunProcReturn(CostQuery, "Gy_ItemMoney_1");
                Dictionary<string, int> CostDict = new Dictionary<string, int>();
                foreach (DataRow row in CostData.Tables[0].Rows)
                {
                    string key = $"{row["HName"].ToString()}";
                    CostDict[key] = (int)row["HItemID"];
                }
                // 4. æŸ¥è¯¢ç”¨æˆ·ä¿¡æ¯
                DataSet emp = oCN.RunProcReturn($"SELECT Czybm FROM Gy_Czygl WHERE Czymc = '{user.Replace("'", "''")}'", "Gy_Czygl");
                if (emp.Tables[0].Rows.Count == 0)
                {
                    res.code = "0";
                    res.count = 0;
                    res.Message = "用户不存在!";
                    res.data = null;
                    return res;
                }
                string HUserID = emp.Tables[0].Rows[0]["Czybm"].ToString();
                // 5. æ£€æŸ¥ç¼ºå¤±çš„部门和物料,并记录行号
                List<string> missingSupplierMessages = new List<string>();
                List<string> missingMaterialMessages = new List<string>();
                // éåŽ†æ¯ä¸€è¡Œæ•°æ®ï¼Œè®°å½•è¡Œå·ï¼ˆä»Ž1开始)
                for (int i = 0; i < list.Count; i++)
                {
                    var item = list[i];
                    int lineNumber = i + 1; // è¡Œå·ä»Ž1开始
                    string ICMOcheck = item["生产订单号"];
                    string supplier = item["部门"];
                    string materialNumber = item["物料编码"];
                    string materialName = item["物料名称"];
                    string materialKey = $"{materialNumber}_{materialName}";
                    // æ£€æŸ¥ä¾›åº”商
                    if (!supplierDict.ContainsKey(supplier))
                    {
                        missingSupplierMessages.Add($"第{lineNumber}行的部门【{supplier}】");
                    }
                    // æ£€æŸ¥ç‰©æ–™
                    if (!materialDict.ContainsKey(materialKey))
                    {
                        missingMaterialMessages.Add($"第{lineNumber}行的物料【{materialName}(编码:{materialNumber})】");
                    }
                    // æ£€æŸ¥ç”Ÿäº§è®¢å•
                    if (!string.IsNullOrEmpty(ICMOcheck) && !ICMODict.ContainsKey(ICMOcheck))
                    {
                        missingMaterialMessages.Add($"第{lineNumber}行的生产订单【{ICMOcheck}】");
                    }
                }
                StringBuilder errorMessage = new StringBuilder();
                if (missingSupplierMessages.Any())
                {
                    errorMessage.Append("以下部门未维护:");
                    errorMessage.Append(string.Join("、", missingSupplierMessages));
                    errorMessage.Append(";");
                }
                if (missingMaterialMessages.Any())
                {
                    errorMessage.Append("以下物料未维护:");
                    errorMessage.Append(string.Join("、", missingMaterialMessages));
                    errorMessage.Append(";");
                }
                if (errorMessage.Length > 0)
                {
                    res.code = "0";
                    res.count = 0;
                    res.Message = errorMessage.ToString();
                    res.data = null;
                    return res;
                }
                // 6. æ‰¹é‡æŸ¥è¯¢å·²å­˜åœ¨çš„记录
                var materialIds = list.Select(x => materialDict[$"{x["物料编码"]}_{x["物料名称"]}"]).Distinct().ToList();
                var supplierIds = list.Select(x => supplierDict_sub[x["部门"]]).Distinct().ToList();
                string existQuery = $"select * from h_v_CB_ItemMoneyBillMain_Edit_excel WHERE HMaterID IN ({string.Join(",", materialIds)}) AND HDeptID_sub IN ({string.Join(",", supplierIds)})";
                DataSet existData = oCN.RunProcReturn(existQuery, "h_v_CB_ItemMoneyBillMain_Edit_excel");
                HashSet<string> existRecords = new HashSet<string>();
                foreach (DataRow row in existData.Tables[0].Rows)
                {
                    existRecords.Add($"{row["HMaterID"]}_{row["HDeptID_sub"]}");
                }
                // 7. æŒ‰ç…§éƒ¨é—¨ä»£ç ã€éƒ¨é—¨ã€èŒå‘˜ä»£ç ã€èŒå‘˜ã€ç”Ÿäº§è®¢å•号进行分组
                var groupedData = list.GroupBy(item => new
                {
                    éƒ¨é—¨ä»£ç  = item["部门代码"],
                    éƒ¨é—¨ = item["部门"],
                    èŒå‘˜ä»£ç  = item["职员代码"],
                    èŒå‘˜ = item["职员"],
                    ç”Ÿäº§è®¢å•号 = item["生产订单号"]
                }).ToList();
                StringBuilder insertSql = new StringBuilder();
                StringBuilder insertSql_sub = new StringBuilder();
                string currentDate = DateTime.Today.ToString("yyyy-MM-dd");
                foreach (var group in groupedData)
                {
                    var firstItem = group.First();
                    // èŽ·å–ç»„ä¿¡æ¯
                    int HSupplierID = supplierDict_sub[firstItem["部门"]];
                    int EmpID = EmpDict[firstItem["职员"]];
                    string ICMO = firstItem["生产订单号"];
                    int ICMOInterID = !string.IsNullOrEmpty(ICMO) && ICMODict.ContainsKey(ICMO) ? ICMODict[ICMO] : 0;
                    // ç”Ÿæˆä¸»è¡¨ID和单据号(每组生成一个)
                    string HBillNo = DBUtility.ClsPub.CreateBillCode("1802", ref DBUtility.ClsPub.sExeReturnInfo, true);
                    long HInterID = DBUtility.ClsPub.CreateBillID("1802", ref DBUtility.ClsPub.sExeReturnInfo);
                    // æ£€æŸ¥è¯¥ç»„是否已存在(根据部门ID和物料ID组合)
                    bool groupExists = false;
                    foreach (var item in group)
                    {
                        int HMaterID = materialDict[$"{item["物料编码"]}_{item["物料名称"]}"];
                        string recordKey = $"{HMaterID}_{HSupplierID}";
                        if (existRecords.Contains(recordKey))
                        {
                            groupExists = true;
                            break;
                        }
                    }
                    if (!groupExists)
                    {
                        // æ’入主表(每组插入一次)
                        insertSql.AppendLine($"INSERT INTO CB_ItemMoneyBillMain  ([HInterID], [HBillNo], [HDate], [HYear], [HPeriod], [HBillType], [HBillSubType], [HBillStatus], [HCheckItemNowID], [HCheckItemNextID], [HCheckFlowID], [HRemark], [HBacker], [HBackDate], [HBackRemark], [HChecker], [HCheckDate], [HMaker], [HMakeDate], [HUpDater], [HUpDateDate], [HCloseMan], [HCloseDate], [HCloseType], [HDeleteMan], [HDeleteDate], [HMainSourceBillType], [HMainSourceInterID], [HMainSourceEntryID], [HMainSourceBillNo], [HPrintQty],  [HEmpID], [HDeptID], [HICMOInterID], [HMaterID], [HICMOBillNo], [HExplanation], [HInnerBillNo], [HBeginDate], [HEndDate], [HOrgID]) VALUES (");
                        insertSql.AppendLine($"'{HInterID}', '{HBillNo}', '{DateTime.Now}', {DateTime.Now.Year}, {DateTime.Now.Month}, {"1802"}, '{"1802"}', '{"1"}',  '{"0"}', '{"0"}', '{"0"}', '{"excel导入"}', '{""}', '{DateTime.Now}', '{""}', '{""}', '{DateTime.Now}', '{""}', '{DateTime.Now}', '{""}', '{DateTime.Now}', '{""}', '{DateTime.Now}', '{"0"}', '{""}', '{DateTime.Now}', '{""}', '{"0"}', '{"0"}', '{""}', '{"0"}', '{EmpID}', '{HSupplierID}', '{ICMOInterID}','{0}','{ICMO}','{""}','{"0"}','{DateTime.Now}','{DateTime.Now}','{"100038"}');");
                        // æ’入子表(组内每个物料插入一次)
                        int HEntryID = 1;
                        foreach (var item in group)
                        {
                            int HMaterID = materialDict[$"{item["物料编码"]}_{item["物料名称"]}"];
                            int HCostID = CostDict[item["成本项目"]];
                            insertSql_sub.AppendLine($"INSERT INTO [CB_ItemMoneyBillSub] ([HInterID], [HEntryID], [HCloseMan], [HEntryCloseDate], [HCloseType], [HRemark],[HSourceInterID], [HSourceEntryID], [HSourceBillNo], [HSourceBillType],[HRelationQty], [HRelationMoney], [HBillNo_bak], [HCostItemID],[HDeptID], [HQty], [HPrice], [HMoney],[HMaterID], [HWaster], [HDate], [HBeginBalance], [HEndBalance], [HTimes]) VALUES (");
                            insertSql_sub.AppendLine($"'{HInterID}', '{HEntryID}', '{""}', '{DateTime.Now}', '{"0"}', '{"excel导入"}','{"0"}', '{"0"}',  '{"0"}', '{"0"}','{"0"}', '{"0"}', '{""}', '{HCostID}', '{HSupplierID}', '{item["数量"]}', '{item["单价"]}', '{item["金额"]}','{HMaterID}', '{item["损耗量"] ?? "0"}', '{DateTime.Now}', '{"0"}', '{"0"}', '{"0"}');");
                            HEntryID++;
                        }
                    }
                }
                // æ‰§è¡Œæ‰¹é‡æ“ä½œ
                if (insertSql.Length > 0)
                {
                    oCN.RunProc(insertSql.ToString());
                }
                if (insertSql_sub.Length > 0)
                {
                    oCN.RunProc(insertSql_sub.ToString());
                }
                oCN.Commit();
                res.code = "1";
                res.count = groupedData.Count;
                res.Message = $"导入成功! å…±å¤„理{groupedData.Count}组数据";
                res.data = null;
                return res;
            }
            catch (Exception e)
            {
                //oCN.Rollback();
                LogService.Write(e);
                res.code = "0";
                res.count = 0;
                res.Message = "Exception!" + e.ToString();
                res.data = null;
                return res;
            }
        }
        #endregion
    }
}
WebAPI/Controllers/³É±¾¹ÜÀí/CB_WipProcessTableController.cs
New file
@@ -0,0 +1,287 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Pub_Class;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.Http;
using WebAPI.Models;
using WebAPI.Controllers.SCGL.日计划管理;
using System.IO;
using System.Linq;
using System.Text;
namespace WebAPI.Controllers.成本管理
{
    public class CB_WipProcessTableController : ApiController
    {
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
        public DAL.ClsCB_ItemMoneyBillMain BillOld = new DAL.ClsCB_ItemMoneyBillMain();
        public DAL.ClsCB_ItemMoneyBillMain BillNew0 = new DAL.ClsCB_ItemMoneyBillMain();
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        DataSet ds;
        #region æ–‡ä»¶ä¸Šä¼ 
        [Route("CB_WipProcessTableController/CB_WipProcessTable_Excel")]
        [HttpPost]
        public json CB_WipProcessTable_Excel()
        {
            json res = new json();
            try
            {
                //获取文件名称
                var file = HttpContext.Current.Request.Files[0];
                //获取文件物理路径
                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
                //保存文件
                file.SaveAs(ExcelPath);
                SCGL.日计划管理.NpoiHelper np = new NpoiHelper();
                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
                //删除文件
                File.Delete(ExcelPath);
                //创建临时表
                DataTable provisional = new DataTable("dt2");
                //添加列名
                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
                {
                    provisional.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
                }
                //provisional.Columns.Add("单据号", typeof(string));
                //添加数据
                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
                {
                    DataRow row = provisional.NewRow();
                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
                    {
                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
                    }
                    provisional.Rows.Add(row);
                }
                //判断列
                string error = JudgmentColumns(provisional);
                if (error.Length > 0)
                {
                    res.code = "0";
                    res.count = 0;
                    res.Message = $"Excel模板存在错误,{error}\r\n";
                    res.data = null;
                    return res;
                }
                for (int i = 0; i <= provisional.Rows.Count - 1; i++)
                {
                    string HProcName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["产出工序"].ToString());
                    string HCusName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["客户"].ToString());
                    string HPartNumber = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["成品料号"].ToString());
                    string HWIPQty = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["WIP数量"].ToString());
                    string HInProcessWIPQty = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["在制WIP数量"].ToString());
                    string HPanelQty = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["拼版数"].ToString());
                    string HLot = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["LOT"].ToString());
                    string HOrderTime = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["下单时间"].ToString());
                    string HStartTime = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["投产时间"].ToString());
                    string HOutputTime = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["产出时间"].ToString());
                    string HProductionTime = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["生产时间"].ToString());
                    string HStatus = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["状态"].ToString());
                    string HStayTime = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["停留时间(分钟)"].ToString());
                    //string remark = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["备注"].ToString());
                    //获取真实行数
                    int line = i + 1;
                }
                res.code = "1";
                res.count = 1;
                res.Message = error;
                res.data = provisional;
                return res;
            }
            catch (Exception e)
            {
                res.code = "0";
                res.count = 0;
                res.Message = "Exception!" + e.ToString();
                res.data = null;
                return res;
            }
        }
        /// <summary>
        /// åˆ¤æ–­åˆ—
        /// </summary>
        /// <param name="provisional"></param>
        /// <returns></returns>
        private static string JudgmentColumns(DataTable provisional)
        {
            var error = "";
            //查询没有的列
            if (!provisional.Columns.Contains("客户"))
                error += "没有找到【客户】的标题,";
            if (!provisional.Columns.Contains("成品料号"))
                error += "没有找到【成品料号】的标题,";
            return error;
        }
        #endregion
        #region ä¸Šä¼ ä¿å­˜
        [Route("CB_WipProcessTableController/Excel_btnSave")]
        [HttpPost]
        public object Excel_btnSave([FromBody] JObject sMainSub)
        {
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string user = sArray[1].ToString();
            string organ = sArray[2].ToString();
            json res = new json();
            try
            {
                oCN.BeginTran();
                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
                foreach (JObject item in Excel)
                {
                    Dictionary<string, string> dic = new Dictionary<string, string>();
                    foreach (var itm in item.Properties())
                    {
                        dic.Add(itm.Name, itm.Value.ToString());
                    }
                    list.Add(dic);
                }
                // 4. æŸ¥è¯¢ç”¨æˆ·ä¿¡æ¯
                DataSet emp = oCN.RunProcReturn($"SELECT Czybm FROM Gy_Czygl WHERE Czymc = '{user.Replace("'", "''")}'", "Gy_Czygl");
                if (emp.Tables[0].Rows.Count == 0)
                {
                    res.code = "0";
                    res.count = 0;
                    res.Message = "用户不存在!";
                    res.data = null;
                    return res;
                }
                string HUserID = emp.Tables[0].Rows[0]["Czybm"].ToString();
                StringBuilder errorMessage = new StringBuilder();
                StringBuilder insertSql = new StringBuilder();
                StringBuilder updateSql = new StringBuilder();
                string currentDate = DateTime.Today.ToString("yyyy-MM-dd");
                int HEntryID = 1;
                // éåŽ†æ•°æ®å¹¶éªŒè¯
                for (int i = 0; i < list.Count; i++)
                {
                    var item = list[i];
                    List<string> intFields = new List<string>
                    {
                        "WIP数量", "在制WIP数量", "拼版数"
                    };
                    bool hasError = false;
                    foreach (var field in intFields)
                    {
                        if (item.ContainsKey(field))
                        {
                            string value = item[field];
                            // æ£€æŸ¥æ˜¯å¦ä¸ºæ•´æ•°
                            if (!string.IsNullOrWhiteSpace(value))
                            {
                                if (!int.TryParse(value, out _))
                                {
                                    errorMessage.AppendLine($"第{i + 1}行数据错误:字段 '{field}' çš„值 '{value}' ä¸æ˜¯æœ‰æ•ˆçš„æ•´æ•°");
                                    hasError = true;
                                }
                            }
                        }
                    }
                    // å¦‚果有错误,跳过插入
                    if (hasError)
                    {
                        continue;
                    }
                    insertSql.AppendLine($"INSERT INTO CB_WipProcessTable  ([HYear], [HPeriod], [HDay], [HProcName], [HCusName], [HPartNumber], [HWIPQty], [HInProcessWIPQty], [HPanelQty], [HLot], [HOrderTime], [HStartTime], [HOutputTime], [HProductionTime], [HStatus], [HStayTime], [HChecker], [HCheckDate], [HMaker], [HMakeDate], [HUpDater], [HUpDateDate], [HCloseMan], [HCloseDate], [HCloseType], [HDeleteMan], [HDeleteDate], [HReamrk]) VALUES (");
                    insertSql.AppendLine($" {DateTime.Now.Year}, {DateTime.Now.Month}, {DateTime.Now.Day}, '{item["产出工序"]}', '{item["客户"]}',  '{item["成品料号"]}', '{item["WIP数量"]}', '{item["在制WIP数量"]}', '{item["拼版数"]}', '{item["LOT"]}', '{item["下单时间"]}', '{item["投产时间"]}', '{item["产出时间"]}', '{item["生产时间"]}', '{item["状态"]}', '{item["停留时间(分钟)"]}', '{""}', '{""}', '{user}', '{DateTime.Now}', '{""}', '{DateTime.Now}', '{""}', '{""}', '{"0"}', '{""}', '{""}', '{"excel导入"}');");
                }
                if (errorMessage.Length > 0)
                {
                    //oCN.Rollback();
                    res.code = "0";
                    res.count = 0;
                    res.Message = "数据验证失败:\n" + errorMessage.ToString();
                    res.data = null;
                    return res;
                }
                if (insertSql.Length == 0)
                {
                    // oCN.Rollback();
                    res.code = "0";
                    res.count = 0;
                    res.Message = "没有有效的整数数据可以导入";
                    res.data = null;
                    return res;
                }
                // æ‰§è¡Œæ‰¹é‡æ“ä½œ
                if (insertSql.Length > 0)
                {
                    oCN.RunProc(insertSql.ToString());
                }
                //if (updateSql.Length > 0)
                //{
                //    oCN.RunProc(updateSql.ToString());
                //    oCN.RunProc(updateSql_sub.ToString());
                //}
                oCN.Commit();
                res.code = "1";
                res.count = 1;
                res.Message = "导入成功!";
                res.data = null;
                return res;
            }
            catch (Exception e)
            {
                //oCN.Rollback();
                LogService.Write(e);
                res.code = "0";
                res.count = 0;
                res.Message = "Exception!" + e.ToString();
                res.data = null;
                return res;
            }
        }
        #endregion
    }
}
WebAPI/Controllers/ÌõÂë¹ÜÀí/WEBSController.cs
@@ -4696,6 +4696,66 @@
        #endregion
        #region ç”Ÿäº§é€€åº“    ä¸Šä¼ ç”Ÿå•
        #region ç”Ÿäº§é€€åº“    æ ¡éªŒæ¨¡å¼
        /// <summary>
        /// ç”Ÿäº§é€€åº“校验上传
        /// </summary>
        /// <returns></returns>
        [Route("WEBSController/set_SaveProductInBackBill_BillCheck_Json")]
        [HttpPost]
        public object set_SaveProductInBackBill_BillCheck_Json([FromBody] JObject oMain)
        {
            var _value = oMain["oMain"].ToString();
            string msg1 = _value.ToString();
            try
            {
                List<Model.ClsKf_ICStockBillMain> lsmain = new List<Model.ClsKf_ICStockBillMain>();
                ListModels oListModels = new ListModels();
                lsmain = oListModels.getICStockBillMainByJson(msg1);
                WebAPI.WebS.ClsKf_ICStockBillMain websLsmain = new WebS.ClsKf_ICStockBillMain();
                websLsmain.HInterID = lsmain[0].HInterID;
                websLsmain.HBillNo = lsmain[0].HBillNo;
                websLsmain.HBillType = "1245";
                websLsmain.HMaker = lsmain[0].HMaker;
                websLsmain.HSTOCKORGID = lsmain[0].HSTOCKORGID;
                if (oWebs.set_SaveProductInBackBill_BillCheck(websLsmain, ref DBUtility.ClsPub.sErrInfo))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //成功!
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //失败!
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "生产退库校验失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
        #region é‡‡è´­é€€æ–™    ä¸Šä¼ ç”Ÿå•
        #region é‡‡è´­é€€æ–™    æ–°å¢žæ¨¡å¼
@@ -4777,6 +4837,62 @@
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "采购退料单上传失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region é‡‡è´­é€€æ–™    æ ¡éªŒæ¨¡å¼
        /// <summary>
        /// é‡‡è´­é€€æ–™æ ¡éªŒä¸Šä¼ 
        /// </summary>
        /// <returns></returns>
        [Route("WEBSController/set_SavePOStockInBackBill_BillCheck_Json")]
        [HttpPost]
        public object set_SavePOStockInBackBill_BillCheck_Json([FromBody] JObject oMain)
        {
            var _value = oMain["oMain"].ToString();
            string msg1 = _value.ToString();
            try
            {
                List<Model.ClsKf_ICStockBillMain> lsmain = new List<Model.ClsKf_ICStockBillMain>();
                ListModels oListModels = new ListModels();
                lsmain = oListModels.getICStockBillMainByJson(msg1);
                WebAPI.WebS.ClsKf_ICStockBillMain websLsmain = new WebS.ClsKf_ICStockBillMain();
                websLsmain.HInterID = lsmain[0].HInterID;
                websLsmain.HBillNo = lsmain[0].HBillNo;
                websLsmain.HBillType = "1239";
                websLsmain.HMaker = lsmain[0].HMaker;
                websLsmain.HSTOCKORGID = lsmain[0].HSTOCKORGID;
                if (oWebs.set_SavePOStockInBackBill_BillCheck(websLsmain, ref DBUtility.ClsPub.sErrInfo))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //成功!
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //失败!
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "采购退料校验失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -5005,6 +5121,122 @@
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "销售退货单上传失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region é”€å”®é€€è´§    æ ¡éªŒæ¨¡å¼
        /// <summary>
        /// é”€å”®é€€è´§æ ¡éªŒä¸Šä¼ 
        /// </summary>
        /// <returns></returns>
        [Route("WEBSController/set_SaveSellOutBackBill_BillCheck_Json")]
        [HttpPost]
        public object set_SaveSellOutBackBill_BillCheck_Json([FromBody] JObject oMain)
        {
            var _value = oMain["oMain"].ToString();
            string msg1 = _value.ToString();
            try
            {
                List<Model.ClsKf_ICStockBillMain> lsmain = new List<Model.ClsKf_ICStockBillMain>();
                ListModels oListModels = new ListModels();
                lsmain = oListModels.getICStockBillMainByJson(msg1);
                WebAPI.WebS.ClsKf_ICStockBillMain websLsmain = new WebS.ClsKf_ICStockBillMain();
                websLsmain.HInterID = lsmain[0].HInterID;
                websLsmain.HBillNo = lsmain[0].HBillNo;
                websLsmain.HBillType = "1247";
                websLsmain.HMaker = lsmain[0].HMaker;
                websLsmain.HSTOCKORGID = lsmain[0].HSTOCKORGID;
                if (oWebs.set_SaveSellOutBackBill_BillCheck(websLsmain, ref DBUtility.ClsPub.sErrInfo))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //成功!
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //失败!
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "销售退货校验失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
        #region å§”外退料    ä¸Šä¼ ç”Ÿå•
        #region å§”外退料    æ ¡éªŒæ¨¡å¼
        /// <summary>
        /// å§”外退料校验上传
        /// </summary>
        /// <returns></returns>
        [Route("WEBSController/set_SaveEntrustOutBackBill_BillCheck_Json")]
        [HttpPost]
        public object set_SaveEntrustOutBackBill_BillCheck_Json([FromBody] JObject oMain)
        {
            var _value = oMain["oMain"].ToString();
            string msg1 = _value.ToString();
            try
            {
                List<Model.ClsKf_ICStockBillMain> lsmain = new List<Model.ClsKf_ICStockBillMain>();
                ListModels oListModels = new ListModels();
                lsmain = oListModels.getICStockBillMainByJson(msg1);
                WebAPI.WebS.ClsKf_ICStockBillMain websLsmain = new WebS.ClsKf_ICStockBillMain();
                websLsmain.HInterID = lsmain[0].HInterID;
                websLsmain.HBillNo = lsmain[0].HBillNo;
                websLsmain.HBillType = "1238";
                websLsmain.HMaker = lsmain[0].HMaker;
                websLsmain.HSTOCKORGID = lsmain[0].HSTOCKORGID;
                if (oWebs.set_SaveEntrustOutBackBill_BillCheck(websLsmain, ref DBUtility.ClsPub.sErrInfo))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //成功!
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //失败!
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "委外退料校验失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -9066,6 +9298,29 @@
        #endregion
        #endregion
        #region æ ¹æ®sn码寻找对应的中箱码
        [Route("WEBSController/getMiddleCodeBySn")]
        [HttpGet]
        public object getMiddleCodeBySn(string HBarCode,int HStockOrgID)
        {
            DataSet dss = oCn.RunProcReturn("select * from Gy_CaseCodeRelation where HBarCode='"+ HBarCode + "'", "Gy_CaseCodeRelation");
            if (dss.Tables[0].Rows[0]["HCaseCode"].ToString() == "" || dss == null)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "未找到sn码所对应的中箱码";
                objJsonResult.data = null;
                return objJsonResult;
            }
            objJsonResult.code = "1";
            objJsonResult.count = 1;
            objJsonResult.Message = "成功";
            objJsonResult.data = dss.Tables[0];
            return objJsonResult;
        }
        #endregion
        #endregion
@@ -13953,7 +14208,7 @@
        {
            try
            {
                ds = oCn.RunProcReturn("select * from GetMaterMesByCarBarCode where å°è½¦='" + CarBarCode.ToString() + "'" , "GetMaterMesByCarBarCode");
                ds = oCn.RunProcReturn("select * from GetMaterMesByCarBarCode where HQty>=0 and å°è½¦='" + CarBarCode.ToString() + "'" , "GetMaterMesByCarBarCode");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
WebAPI/DLL/ClsKf_MateOutBackBill.cs
@@ -46,6 +46,7 @@
                ",HDate='" + omodel.HDate + "'" +
                ",HYear='" + omodel.HYear.ToString() + "'" +
                ",HPeriod='" + omodel.HPeriod.ToString() + "'" +
                ",HBillSubType='" + omodel.HBillSubType.ToString() + "'" +
                ",HRemark='" + omodel.HRemark + "'" +
                ",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" +
                ",HUpDateDate=getdate()" +
@@ -124,7 +125,7 @@
                ",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 + "','" + omodel.HBillSubType.ToString() + "'," + 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) +
WebAPI/ListModels.cs
@@ -1991,6 +1991,30 @@
            return list;
        }
        /// <summary>
        /// å¤„理成本费用单json
        /// </summary>
        /// <param name="jsonString"></param>
        /// <returns></returns>
        public List<Model.ClsCB_ItemMoneyBillMain_1> getObjectByJson_CB_ItemMoneyBillMain(string jsonString)
        {
            jsonString = "[" + jsonString.ToString() + "]";
            List<Model.ClsCB_ItemMoneyBillMain_1> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsCB_ItemMoneyBillMain_1>>(jsonString);
            return list;
        }
        /// <summary>
        /// å¤„理新增其他应收单子表的json
        /// </summary>
        /// <param name="jsonString"></param>
        /// <returns></returns>
        public List<Model.ClsCB_ItemMoneyBillSub_1> getObjectByJson_CB_ItemMoneyBillSub(string jsonString)
        {
            jsonString = "[" + jsonString.ToString() + "]";
            List<Model.ClsCB_ItemMoneyBillSub_1> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsCB_ItemMoneyBillSub_1>>(jsonString);
            return list;
        }
        /// <summary>
        /// å¤„理新增其他应付单表的json
WebAPI/Properties/PublishProfiles/FolderProfile8.pubxml.user
@@ -5,7 +5,7 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <_PublishTargetUrl>D:\gz\wy\MES-WEB-API</_PublishTargetUrl>
    <History>True|2026-01-27T06:38:42.1847305Z;True|2026-01-27T14:35:31.4859936+08:00;True|2026-01-27T14:18:36.2122726+08:00;True|2026-01-27T14:03:03.8424130+08:00;True|2026-01-27T13:14:23.0197795+08:00;True|2026-01-27T11:26:12.7603302+08:00;True|2026-01-27T11:23:11.2980950+08:00;True|2026-01-27T11:17:42.7742881+08:00;True|2026-01-27T10:27:13.8894331+08:00;True|2026-01-27T10:22:33.6468907+08:00;True|2026-01-27T10:13:18.5553398+08:00;False|2026-01-27T10:10:23.9320618+08:00;True|2026-01-27T10:00:58.3355300+08:00;False|2026-01-27T10:00:37.4820904+08:00;True|2026-01-27T09:45:12.8813559+08:00;True|2026-01-27T09:41:43.1787804+08:00;True|2026-01-27T09:40:22.3478291+08:00;True|2026-01-27T09:39:19.6165154+08:00;True|2026-01-27T09:37:31.7523727+08:00;True|2026-01-27T08:33:15.6345855+08:00;True|2026-01-27T08:25:27.8955175+08:00;False|2026-01-27T08:24:59.4512268+08:00;True|2026-01-26T16:40:38.8412768+08:00;True|2026-01-26T16:16:41.7932895+08:00;True|2026-01-26T16:15:35.4808695+08:00;True|2026-01-26T16:08:19.1707669+08:00;True|2026-01-26T16:07:38.4808637+08:00;True|2026-01-26T16:00:28.5139031+08:00;True|2026-01-26T15:56:20.5415856+08:00;True|2026-01-26T15:47:55.9662192+08:00;True|2026-01-26T15:40:45.2534281+08:00;True|2026-01-26T15:39:09.6931174+08:00;True|2026-01-26T15:37:51.9154771+08:00;True|2026-01-26T15:33:35.6039826+08:00;True|2026-01-26T15:31:52.9425047+08:00;True|2026-01-26T15:30:45.3923302+08:00;True|2026-01-26T15:29:05.0429905+08:00;True|2026-01-26T15:27:05.4558977+08:00;True|2026-01-26T15:26:29.2629885+08:00;True|2026-01-26T15:25:43.3181913+08:00;True|2026-01-26T15:25:14.6706698+08:00;True|2026-01-26T15:24:20.6134253+08:00;True|2026-01-26T15:23:57.0303408+08:00;True|2026-01-26T15:20:06.4088432+08:00;True|2026-01-26T15:19:31.8076951+08:00;True|2026-01-26T15:14:49.8542368+08:00;</History>
    <History>True|2026-02-04T06:14:08.6815293Z;True|2026-02-04T14:12:55.3426756+08:00;True|2026-02-04T14:06:04.8563633+08:00;True|2026-02-04T13:59:45.8674762+08:00;True|2026-02-04T13:59:40.8476722+08:00;True|2026-02-04T13:49:27.8178193+08:00;True|2026-02-04T13:47:17.9531917+08:00;True|2026-02-04T13:33:13.4905042+08:00;True|2026-02-04T11:13:26.7587124+08:00;True|2026-02-04T10:44:11.8398866+08:00;True|2026-02-04T10:37:30.4140022+08:00;True|2026-02-04T10:10:15.2756301+08:00;True|2026-02-04T10:06:43.8401980+08:00;True|2026-02-04T09:43:16.4168165+08:00;True|2026-02-04T09:38:57.6155453+08:00;True|2026-02-04T09:36:23.7275649+08:00;True|2026-02-04T09:18:39.5157535+08:00;True|2026-02-04T08:55:39.8422012+08:00;True|2026-02-04T08:50:53.2493857+08:00;True|2026-02-04T08:49:13.6401738+08:00;True|2026-02-04T08:47:44.4063649+08:00;True|2026-02-04T08:27:35.3397920+08:00;True|2026-02-04T08:11:10.8455212+08:00;False|2026-02-04T08:10:46.8065171+08:00;True|2026-02-03T11:17:54.1264839+08:00;True|2026-02-03T11:13:07.3503801+08:00;True|2026-02-03T10:57:22.0499756+08:00;True|2026-02-03T10:49:51.5729577+08:00;False|2026-02-03T10:49:34.3419439+08:00;True|2026-02-02T16:46:50.4584549+08:00;True|2026-02-02T16:42:58.9718820+08:00;True|2026-02-02T16:37:04.3367393+08:00;True|2026-02-02T16:25:15.8758401+08:00;True|2026-02-02T16:23:39.5355352+08:00;False|2026-02-02T16:22:23.6470725+08:00;True|2026-01-27T14:38:42.1847305+08:00;True|2026-01-27T14:35:31.4859936+08:00;True|2026-01-27T14:18:36.2122726+08:00;True|2026-01-27T14:03:03.8424130+08:00;True|2026-01-27T13:14:23.0197795+08:00;True|2026-01-27T11:26:12.7603302+08:00;True|2026-01-27T11:23:11.2980950+08:00;True|2026-01-27T11:17:42.7742881+08:00;True|2026-01-27T10:27:13.8894331+08:00;True|2026-01-27T10:22:33.6468907+08:00;True|2026-01-27T10:13:18.5553398+08:00;False|2026-01-27T10:10:23.9320618+08:00;True|2026-01-27T10:00:58.3355300+08:00;False|2026-01-27T10:00:37.4820904+08:00;True|2026-01-27T09:45:12.8813559+08:00;True|2026-01-27T09:41:43.1787804+08:00;True|2026-01-27T09:40:22.3478291+08:00;True|2026-01-27T09:39:19.6165154+08:00;True|2026-01-27T09:37:31.7523727+08:00;True|2026-01-27T08:33:15.6345855+08:00;True|2026-01-27T08:25:27.8955175+08:00;False|2026-01-27T08:24:59.4512268+08:00;True|2026-01-26T16:40:38.8412768+08:00;True|2026-01-26T16:16:41.7932895+08:00;True|2026-01-26T16:15:35.4808695+08:00;True|2026-01-26T16:08:19.1707669+08:00;True|2026-01-26T16:07:38.4808637+08:00;True|2026-01-26T16:00:28.5139031+08:00;True|2026-01-26T15:56:20.5415856+08:00;True|2026-01-26T15:47:55.9662192+08:00;True|2026-01-26T15:40:45.2534281+08:00;True|2026-01-26T15:39:09.6931174+08:00;True|2026-01-26T15:37:51.9154771+08:00;True|2026-01-26T15:33:35.6039826+08:00;True|2026-01-26T15:31:52.9425047+08:00;True|2026-01-26T15:30:45.3923302+08:00;True|2026-01-26T15:29:05.0429905+08:00;True|2026-01-26T15:27:05.4558977+08:00;True|2026-01-26T15:26:29.2629885+08:00;True|2026-01-26T15:25:43.3181913+08:00;True|2026-01-26T15:25:14.6706698+08:00;True|2026-01-26T15:24:20.6134253+08:00;True|2026-01-26T15:23:57.0303408+08:00;True|2026-01-26T15:20:06.4088432+08:00;True|2026-01-26T15:19:31.8076951+08:00;True|2026-01-26T15:14:49.8542368+08:00;</History>
  </PropertyGroup>
  <ItemGroup>
    <File Include="apiapp.json">
@@ -45,28 +45,28 @@
      <publishTime>02/22/2013 16:43:40</publishTime>
    </File>
    <File Include="bin/BLL.dll">
      <publishTime>01/27/2026 14:18:22</publishTime>
      <publishTime>02/04/2026 14:05:56</publishTime>
    </File>
    <File Include="bin/BLL.pdb">
      <publishTime>01/27/2026 14:18:22</publishTime>
      <publishTime>02/04/2026 14:05:56</publishTime>
    </File>
    <File Include="bin/BouncyCastle.Crypto.dll">
      <publishTime>12/18/2020 05:32:28</publishTime>
    </File>
    <File Include="bin/DAL.dll">
      <publishTime>01/27/2026 14:18:20</publishTime>
      <publishTime>02/04/2026 14:05:54</publishTime>
    </File>
    <File Include="bin/DAL.pdb">
      <publishTime>01/27/2026 14:18:20</publishTime>
      <publishTime>02/04/2026 14:05:54</publishTime>
    </File>
    <File Include="bin/Dapper.dll">
      <publishTime>07/22/2016 22:52:40</publishTime>
    </File>
    <File Include="bin/DBUtility.dll">
      <publishTime>01/26/2026 09:55:44</publishTime>
      <publishTime>02/02/2026 16:23:19</publishTime>
    </File>
    <File Include="bin/DBUtility.pdb">
      <publishTime>01/26/2026 09:55:44</publishTime>
      <publishTime>02/02/2026 16:23:19</publishTime>
    </File>
    <File Include="bin/Fleck.dll">
      <publishTime>04/22/2021 11:48:12</publishTime>
@@ -138,10 +138,10 @@
      <publishTime>07/25/2012 19:48:56</publishTime>
    </File>
    <File Include="bin/Model.dll">
      <publishTime>01/27/2026 14:02:44</publishTime>
      <publishTime>02/03/2026 10:57:09</publishTime>
    </File>
    <File Include="bin/Model.pdb">
      <publishTime>01/27/2026 14:02:44</publishTime>
      <publishTime>02/03/2026 10:57:09</publishTime>
    </File>
    <File Include="bin/Models/ClsSc_MouldScrapOutBillMain.cs">
      <publishTime>11/12/2025 10:43:47</publishTime>
@@ -177,25 +177,25 @@
      <publishTime>11/13/2012 12:19:34</publishTime>
    </File>
    <File Include="bin/Pub_Class.dll">
      <publishTime>01/26/2026 09:55:42</publishTime>
      <publishTime>02/02/2026 16:23:17</publishTime>
    </File>
    <File Include="bin/Pub_Class.pdb">
      <publishTime>01/26/2026 09:55:42</publishTime>
      <publishTime>02/02/2026 16:23:17</publishTime>
    </File>
    <File Include="bin/Pub_Control.dll">
      <publishTime>01/26/2026 09:55:43</publishTime>
      <publishTime>02/02/2026 16:23:18</publishTime>
    </File>
    <File Include="bin/Pub_Control.pdb">
      <publishTime>01/26/2026 09:55:43</publishTime>
      <publishTime>02/02/2026 16:23:18</publishTime>
    </File>
    <File Include="bin/RestSharp.dll">
      <publishTime>08/31/2012 06:22:50</publishTime>
    </File>
    <File Include="bin/SQLHelper.dll">
      <publishTime>01/26/2026 09:55:43</publishTime>
      <publishTime>02/02/2026 16:23:18</publishTime>
    </File>
    <File Include="bin/SQLHelper.pdb">
      <publishTime>01/26/2026 09:55:43</publishTime>
      <publishTime>02/02/2026 16:23:18</publishTime>
    </File>
    <File Include="bin/Swashbuckle.Core.dll">
      <publishTime>02/16/2015 01:57:08</publishTime>
@@ -315,22 +315,22 @@
      <publishTime>05/09/2023 10:43:40</publishTime>
    </File>
    <File Include="bin/TopSdk.dll">
      <publishTime>01/22/2026 16:36:48</publishTime>
      <publishTime>01/27/2026 14:47:22</publishTime>
    </File>
    <File Include="bin/TopSdk.pdb">
      <publishTime>01/22/2026 16:36:48</publishTime>
      <publishTime>01/27/2026 14:47:22</publishTime>
    </File>
    <File Include="bin/WebActivatorEx.dll">
      <publishTime>11/24/2014 19:18:48</publishTime>
    </File>
    <File Include="bin/WebAPI.dll">
      <publishTime>01/27/2026 14:38:37</publishTime>
      <publishTime>02/04/2026 14:14:04</publishTime>
    </File>
    <File Include="bin/WebAPI.pdb">
      <publishTime>01/27/2026 14:38:37</publishTime>
      <publishTime>02/04/2026 14:14:04</publishTime>
    </File>
    <File Include="bin/WebAPI.XmlSerializers.dll">
      <publishTime>01/27/2026 14:38:41</publishTime>
      <publishTime>02/04/2026 14:14:07</publishTime>
    </File>
    <File Include="bin/WebGrease.dll">
      <publishTime>07/18/2013 01:03:52</publishTime>
@@ -555,7 +555,7 @@
      <publishTime>11/12/2025 10:43:47</publishTime>
    </File>
    <File Include="Web.config">
      <publishTime>01/27/2026 10:27:13</publishTime>
      <publishTime>02/02/2026 16:23:36</publishTime>
    </File>
  </ItemGroup>
</Project>
WebAPI/Web References/WebS/Reference.cs
Diff too large
WebAPI/Web References/WebS/WebService1.wsdl
Diff too large
WebAPI/WebAPI.csproj
@@ -705,6 +705,8 @@
    <Compile Include="Controllers\基础资料\基础资料\Gy_CostCenterController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Gy_CostItemFixRateController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Gy_CostItemAverageTypeController.cs" />
    <Compile Include="Controllers\成本管理\CB_ItemMoneyBillController.cs" />
    <Compile Include="Controllers\成本管理\CB_WipProcessTableController.cs" />
    <Compile Include="Controllers\检验申请单\QC_RequestCheckBillController.cs" />
    <Compile Include="Controllers\物流管理\其他结算单\YF_PayMentOtherBillTranController.cs" />
    <Compile Include="Controllers\物流管理\出运单\WLYayBillController.cs" />
@@ -1293,6 +1295,7 @@
    <Folder Include="bin\" />
    <Folder Include="Controllers\项目管理\基础建模\" />
    <Folder Include="obj\x86\Debug\" />
    <Folder Include="Views\CB_WipProcessTable\" />
    <Folder Include="Views\Cg_ContractTransportBillList\" />
    <Folder Include="Views\Cg_PODemandPlanBill\" />
    <Folder Include="Views\Cg_PurchaseReturn\" />
WebAPI/WebAPI.csproj.user
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
    <LastActiveSolutionConfig>Debug|x86</LastActiveSolutionConfig>
    <UseIISExpress>true</UseIISExpress>
    <Use64BitIISExpress />
    <IISExpressSSLPort />
@@ -9,7 +9,7 @@
    <IISExpressWindowsAuthentication>disabled</IISExpressWindowsAuthentication>
    <IISExpressUseClassicPipelineMode>false</IISExpressUseClassicPipelineMode>
    <UseGlobalApplicationHostFile />
    <NameOfLastUsedPublishProfile>D:\WorkBench\MES-WEB-API\WebAPI\Properties\PublishProfiles\FolderProfile4.pubxml</NameOfLastUsedPublishProfile>
    <NameOfLastUsedPublishProfile>D:\工作代码\智云迈思\MES\MES-WEB-API\WebAPI\Properties\PublishProfiles\FolderProfile2.pubxml</NameOfLastUsedPublishProfile>
    <ProjectView>ShowAllFiles</ProjectView>
  </PropertyGroup>
  <ProjectExtensions>