yusijie
2022-12-31 1fd77f77cb40a46ad3ed530e87849edbaa01b376
器具状态;器具报废申请;器具寿命耗用;设备状态
4个文件已修改
17个文件已添加
2402 ■■■■■ 已修改文件
DAL/DAL.csproj 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DAL/基础资料/公用基础资料/ClsGy_EquipStatus_Ctl.cs 103 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DAL/基础资料/公用基础资料/ClsGy_MouldStatus_Ctl.cs 103 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DAL/生产管理/模具管理/ClsSc_MouldStatusChangeBill.cs 231 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Model/Model.csproj 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Model/基础资料/基础资料/ClsGy_EquipStatus_Model.cs 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Model/基础资料/基础资料/ClsGy_MouldStatus_Model.cs 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Model/生产管理/模具管理/ClsSc_MouldLifeUseBillMain.cs 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Model/生产管理/模具管理/ClsSc_MouldLifeUseBillSub.cs 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Model/生产管理/模具管理/ClsSc_MouldStatusChangeBillMain.cs 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Model/生产管理/模具管理/ClsSc_MouldStatusChangeBillSub.cs 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Model/生产管理/设备管理/ClsSb_EquipStatusChangeBillMain.cs 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Model/生产管理/设备管理/ClsSb_EquipStatusChangeBillSub.cs 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/MJGL/Sc_MouldLifeUseBillController.cs 286 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/MJGL/Sc_MouldScrapRequestBillController.cs 293 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/MJGL/Sc_MouldStatusChangeBillController.cs 286 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/SBGL/Sb_EquipStatusChangeBillController.cs 287 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/基础资料/基础资料/Gy_EquipStatusController.cs 311 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/基础资料/基础资料/Gy_MouldStatusController.cs 313 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/ListModels.cs 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/WebAPI.csproj 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DAL/DAL.csproj
@@ -86,6 +86,8 @@
    <Compile Include="仓库管理\条码管理\ClsKF_BarCodeStatusChangeBill.cs" />
    <Compile Include="基础资料\InterFace基础资料\ClsIF_ORGANIZATIONS_View.cs" />
    <Compile Include="基础资料\公用基础资料\ClsGy_CustLocation_Ctl.cs" />
    <Compile Include="基础资料\公用基础资料\ClsGy_EquipStatus_Ctl.cs" />
    <Compile Include="基础资料\公用基础资料\ClsGy_MouldStatus_Ctl.cs" />
    <Compile Include="基础资料\公用基础资料\ClsGy_Operator_Ctl.cs" />
    <Compile Include="基础资料\公用基础资料\ClsGy_RateType_Ctl.cs" />
    <Compile Include="基础资料\公用基础资料\ClsGy_Staff_Ctl.cs" />
@@ -600,6 +602,7 @@
    <Compile Include="生产管理\模具管理\ClsSc_MouldProdOutInBill.cs" />
    <Compile Include="生产管理\模具管理\ClsSc_MouldRepairInBill.cs" />
    <Compile Include="生产管理\模具管理\ClsSc_MouldRepairOutBill.cs" />
    <Compile Include="生产管理\模具管理\ClsSc_MouldStatusChangeBill.cs" />
    <Compile Include="生产管理\设备管理\ClsSb_EquipSparepartsBill.cs" />
    <Compile Include="生产管理\设备管理\ClsSb_EquipSparepartsChangeBill.cs" />
    <Compile Include="质检管理\ClsQC_FirstPieceCheckBill.cs" />
DAL/»ù´¡×ÊÁÏ/¹«Óûù´¡×ÊÁÏ/ClsGy_EquipStatus_Ctl.cs
New file
@@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
namespace DAL
{
    public class ClsGy_EquipStatus_Ctl : DBUtility.ClsGy_Base_Ctl
    {
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        //原代码 ç”¨äºŽ æ›¿æ¢å­é¡¹ç›®
        public string HOldNumber;
        public Model.ClsGy_EquipStatus_Model oModel = new Model.ClsGy_EquipStatus_Model();
        //新增
        public override bool AddNew()
        {
            try
            {
                oCn.BeginTran();
                oCn.RunProc($@"insert into Gy_EquipStatus(HNumber,HName ,HShortNumber  ,HParentID ,HLevel
                                ,HEndFlag  ,HStopflag  ,HRemark ,HHelpCode ,HUseFlag
                                 ,HMakeTime ,HMakeEmp ,HCheckEmp ,HCheckTime ,HModifyEmp
                                 ,HModifyTime ,HStopEmp ,HStopTime ,HUSEORGID,HCREATEORGID)
                                values('{oModel.HNumber}','{oModel.HName}','{oModel.HShortNumber}',{oModel.HParentID},{oModel.HLevel}
                                ,{(oModel.HEndFlag == true ? 1 : 0)},{(oModel.HStopflag == true ? 1 : 0)},'{oModel.HRemark}','{oModel.HHelpCode}','{oModel.HUseFlag}'
                                ,GETDATE(),'{oModel.HMakeEmp}','','',''
                                ,'','','',{oModel.HUSEORGID},{oModel.HCREATEORGID})"
                                , ref DBUtility.ClsPub.sExeReturnInfo);
                //修改上级为非末级代码
                oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                oCn.RollBack();
                throw (e);
            }
        }
        //修改
        public override bool ModifyByID(Int64 sItemID)
        {
            try
            {
                oCn.BeginTran();
                oCn.RunProc("Update " + MvarItemKey + " set " +
                    " HNumber='" + oModel.HNumber + "'" +
                    ",HName='" + oModel.HName + "'" +
                    ",HShortNumber='" + oModel.HShortNumber + "'" +
                    ",HParentID=" + oModel.HParentID.ToString() +
                    ",HLevel=" + oModel.HLevel.ToString() +
                    ",HEndflag=" + Convert.ToString(oModel.HEndFlag ? 1 : 0) +
                    ",HStopflag=" + Convert.ToString(oModel.HStopflag ? 1 : 0) +
                    ",HRemark= '" + oModel.HRemark + "'" +
                    ",HHelpCode='" + oModel.HHelpCode + "'" +
                     ",HModifyEmp ='" + oModel.HMakeEmp + "'" +
                      ",HModifyTime   =getdate()" +
                  " Where HItemID=" + sItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                //修改子项目代码
                //oCn.RunProc("exec h_p_Gy_UpdateNumber '" + MvarItemKey + "','" + oModel.HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo);
                //将上级 ä¸ºéžæœ«çº§
                oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                //
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                oCn.RollBack();
                throw (e);
            }
        }
        //根据代码判断信息
        public override bool HavParentCode(string sCode, Int64 sItemID)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select * from " + MvarItemKey + " Where HStopflag=0 and HNumber='" + sCode + "' and HItemID<>" + sItemID, MvarItemKey, ref Pub_Class.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return false;
                else
                {
                    oModel.HItemID = Convert.ToInt64(DS.Tables[0].Rows[0]["HItemID"]);
                    return true;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
        //构造函数
        public ClsGy_EquipStatus_Ctl()
        {
            MvarItemKey = "Gy_EquipStatus";
            MvarReportTitle = "设备状态";
            oModel = new Model.ClsGy_EquipStatus_Model();
        }
    }
}
DAL/»ù´¡×ÊÁÏ/¹«Óûù´¡×ÊÁÏ/ClsGy_MouldStatus_Ctl.cs
New file
@@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
namespace DAL
{
    public class ClsGy_MouldStatus_Ctl : DBUtility.ClsGy_Base_Ctl
    {
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        //原代码 ç”¨äºŽ æ›¿æ¢å­é¡¹ç›®
        public string HOldNumber;
        public Model.ClsGy_MouldStatus_Model oModel = new Model.ClsGy_MouldStatus_Model();
        //新增
        public override bool AddNew()
        {
            try
            {
                oCn.BeginTran();
                oCn.RunProc($@"insert into Gy_MouldStatus(HNumber,HName ,HShortNumber  ,HParentID ,HLevel
                                ,HEndFlag  ,HStopflag  ,HRemark ,HHelpCode ,HUseFlag
                                 ,HMakeTime ,HMakeEmp ,HCheckEmp ,HCheckTime ,HModifyEmp
                                 ,HModifyTime ,HStopEmp ,HStopTime ,HUSEORGID,HCREATEORGID)
                                values('{oModel.HNumber}','{oModel.HName}','{oModel.HShortNumber}',{oModel.HParentID},{oModel.HLevel}
                                ,{(oModel.HEndFlag == true ? 1 : 0)},{(oModel.HStopflag == true ? 1 : 0)},'{oModel.HRemark}','{oModel.HHelpCode}','{oModel.HUseFlag}'
                                ,GETDATE(),'{oModel.HMakeEmp}','','',''
                                ,'','','',{oModel.HUSEORGID},{oModel.HCREATEORGID})"
                                , ref DBUtility.ClsPub.sExeReturnInfo);
                //修改上级为非末级代码
                oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                oCn.RollBack();
                throw (e);
            }
        }
        //修改
        public override bool ModifyByID(Int64 sItemID)
        {
            try
            {
                oCn.BeginTran();
                oCn.RunProc("Update " + MvarItemKey + " set " +
                    " HNumber='" + oModel.HNumber + "'" +
                    ",HName='" + oModel.HName + "'" +
                    ",HShortNumber='" + oModel.HShortNumber + "'" +
                    ",HParentID=" + oModel.HParentID.ToString() +
                    ",HLevel=" + oModel.HLevel.ToString() +
                    ",HEndflag=" + Convert.ToString(oModel.HEndFlag ? 1 : 0) +
                    ",HStopflag=" + Convert.ToString(oModel.HStopflag ? 1 : 0) +
                    ",HRemark= '" + oModel.HRemark + "'" +
                    ",HHelpCode='" + oModel.HHelpCode + "'" +
                     ",HModifyEmp ='" + oModel.HMakeEmp + "'" +
                      ",HModifyTime   =getdate()" +
                  " Where HItemID=" + sItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                //修改子项目代码
                //oCn.RunProc("exec h_p_Gy_UpdateNumber '" + MvarItemKey + "','" + oModel.HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo);
                //将上级 ä¸ºéžæœ«çº§
                oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                //
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                oCn.RollBack();
                throw (e);
            }
        }
        //根据代码判断信息
        public override bool HavParentCode(string sCode, Int64 sItemID)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select * from " + MvarItemKey + " Where HStopflag=0 and HNumber='" + sCode + "' and HItemID<>" + sItemID, MvarItemKey, ref Pub_Class.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return false;
                else
                {
                    oModel.HItemID = Convert.ToInt64(DS.Tables[0].Rows[0]["HItemID"]);
                    return true;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
        //构造函数
        public ClsGy_MouldStatus_Ctl()
        {
            MvarItemKey = "Gy_MouldStatus";
            MvarReportTitle = "器具状态";
            oModel = new Model.ClsGy_MouldStatus_Model();
        }
    }
}
DAL/Éú²ú¹ÜÀí/Ä£¾ß¹ÜÀí/ClsSc_MouldStatusChangeBill.cs
New file
@@ -0,0 +1,231 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
namespace DAL
{
    public class ClsSc_MouldStatusChangeBill : DBUtility.ClsXt_BaseBill
    {
        public Model.ClsSc_MouldStatusChangeBillMain omodel = new Model.ClsSc_MouldStatusChangeBillMain();
        public List<Model.ClsSc_MouldStatusChangeBillSub> DetailColl = new List<Model.ClsSc_MouldStatusChangeBillSub>();
        public ClsSc_MouldStatusChangeBill()
        {
            base.MvarItemKeySub = "Sc_MouldStatusChangeBillSub";
            base.MvarItemKeySub2 = "";
            base.MvarItemKeySub3 = "";
            base.MvarItemKeySub4 = "";
            base.MvarItemKey = "Sc_MouldStatusChangeBillMain";
            base.MvarReportTitle = "器具状态变更单";
            base.BillType = "3844";
            base.HBillSubType = "3844";
        }
        //修改单据
        public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                //
                oCn.BeginTran();
                //更新主表
                oCn.RunProc("UpDate Sc_MouldStatusChangeBillMain set  " +
                " HReason='" + omodel.HReason + "'" +  //固定赋值===============
                ",HExplanation='" + omodel.HExplanation + "'" +
                ",HYear='" + omodel.HYear.ToString() + "'" +
                ",HPeriod='" + omodel.HPeriod.ToString() + "'" +
                ",HBillStatus=" + omodel.HBillStatus.ToString() +
                ",HRemark='" + omodel.HRemark + "'" +
                ",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" +
                ",HUpDateDate=getdate()" +
                //========================================
                ",HEmpID=" + omodel.HEmpID.ToString() +
                ",HDeptID=" + omodel.HDeptID.ToString() +
                " where HInterID=" + lngBillKey.ToString());
                //删除关联
                DeleteRelation(ref sReturn, lngBillKey);
                //删除子表
                DeleteBillSub(lngBillKey);
                //插入子表
                omodel.HInterID = lngBillKey;
                foreach (Model.ClsSc_MouldStatusChangeBillSub oSub in DetailColl)
                {
                    oCn.RunProc("Insert into Sc_MouldStatusChangeBillSub " +
                      " (HInterID,HEntryID,HBillNo_bak,HRemark" +
                      ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
                     ",HMaterID,HUnitID,HQtyMust,HQty,HStatusID_Old,HStatusID_New" +
                      ") values("
                      + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HBillNo_bak + "','" + oSub.HRemark + "',"
                      + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
                      "," + oSub.HMaterID + "," + oSub.HUnitID + "," + 0 + "," + oSub.HQty + "," + oSub.HStatusID_Old + "," + oSub.HStatusID_New + ") ");
                }
                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);
                omodel.HBillNo = DBUtility.ClsPub.CreateBillCode(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
                //若MAINDI重复则重新获取
                if (IsExistBillNo(ref DBUtility.ClsPub.sExeReturnInfo, omodel.HBillNo, Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew, omodel.HInterID))
                {
                    omodel.HBillNo = DBUtility.ClsPub.CreateBillCode(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
                }
                if (IsExistMainID(ref DBUtility.ClsPub.sExeReturnInfo, omodel.HInterID, Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew))
                {
                    omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
                }
                //
                oCn.BeginTran();
                //主表
                //oCN.RunProc(@"Insert Into Sc_MouldStatusChangeBillMain
                //        (HInterID,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillNo,HBillStatus
                //     ,HRemark,HBackRemark,HMaker,HMakeDate,HMainSourceBillType,HMainSourceInterID
                //     ,HMainSourceEntryID,HMainSourceBillNo,HPrintQty,HEmpID,HDeptID,HReason,HExplanation,HInnerBillNo)
                //",'" + omodel.HBillNo + "','" + omodel.HDate + "'" +
            oCn.RunProc("Insert Into Sc_MouldStatusChangeBillMain   " +
                "(HBillType,HBillSubType,HInterID,HYear,HPeriod,HDate,HBillNo,HBillStatus" +
                ",HRemark,HBackRemark,HMaker,HMakeDate,HMainSourceBillType,HMainSourceInterID" +
                ",HMainSourceEntryID,HMainSourceBillNo,HPrintQty,HEmpID,HDeptID,HReason,HExplanation,HInnerBillNo" +
                ") " +
                " values('" + this.BillType + "','" + this.HBillSubType + "'," + omodel.HInterID.ToString() +
                "," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HDate + "','" + omodel.HBillNo +
                "'," + omodel.HBillStatus + ",'" + omodel.HRemark + "','" + omodel.HBackRemark + "','" + omodel.HMaker +
                "','" + omodel.HMakeDate + "','" + omodel.HMainSourceBillType + "'," + omodel.HMainSourceInterID +
                "," + omodel.HMainSourceEntryID + ",'" + omodel.HMainSourceBillNo + "'," + omodel.HPrintQty +
                "," + omodel.HEmpID + "," + omodel.HDeptID + ",'" + omodel.HReason + "','" + omodel.HExplanation +
                "','" + omodel.HInnerBillNo + "'" + ") ");
                //插入子表
                foreach (Model.ClsSc_MouldStatusChangeBillSub oSub in DetailColl)
                {
                    oCn.RunProc("Insert into Sc_MouldStatusChangeBillSub " +
                     " (HInterID,HEntryID,HBillNo_bak,HRemark" +
                     ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
                    ",HMaterID,HUnitID,HQtyMust,HQty,HStatusID_Old,HStatusID_New" +
                     ") values("
                     + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HBillNo_bak + "','" + oSub.HRemark + "',"
                     + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
                     "," + oSub.HMaterID + "," + oSub.HUnitID + "," + 0 + "," + oSub.HQty + "," + oSub.HStatusID_Old + "," + oSub.HStatusID_New + ") ");
                }
                sReturn = "新增单据成功!";
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                throw (e);
            }
        }
        //显示单据
        public override bool ShowBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                //查询主表
                DataSet Ds;
                Ds = oCn.RunProcReturn("Select * from Sc_MouldStatusChangeBillMain Where HInterID=" + lngBillKey.ToString(), "Sc_MouldStatusChangeBillMain");
                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 = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillNo"]);
                omodel.HBillStatus = 1;
                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 = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRemark"]);
                omodel.HBackDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBackDate"]);
                omodel.HBacker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBacker"]);
                omodel.HCheckDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCheckDate"]);
                omodel.HChecker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HChecker"]);
                omodel.HMaker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMaker"]);
                omodel.HMakeDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMakeDate"]);
                omodel.HUpDateDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HUpDateDate"]);
                omodel.HUpDater = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HUpDater"]);
                omodel.HCloseDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCloseDate"]);
                omodel.HCloseMan = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCloseMan"]);
                omodel.HCloseType = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HCloseType"]);
                omodel.HDeleteDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HDeleteDate"]);
                omodel.HDeleteMan = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HDeleteMan"]);
                omodel.HMainSourceBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMainSourceBillType"]);
                omodel.HMainSourceInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMainSourceInterID"]);
                omodel.HMainSourceEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMainSourceEntryID"]);
                omodel.HMainSourceBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMainSourceBillNo"]);
                omodel.HPrintQty = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPrintQty"]);
                //========================================================
                omodel.HEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HEmpID"]);
                omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HDeptID"]);
                omodel.HReason = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HReason"]);
                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 Sc_MouldStatusChangeBillSub Where HInterID=" + lngBillKey.ToString(), "Sc_MouldStatusChangeBillSub");
                DetailColl.Clear();//清空
                for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
                {
                    Model.ClsSc_MouldStatusChangeBillSub oSub = new Model.ClsSc_MouldStatusChangeBillSub();
                    // å›ºå®šèµ‹å€¼===============================================
                    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 = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HSourceBillType"]);
                    oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HSourceBillNo"]);
                    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 = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HRemark"]);
                    oSub.HBillNo_bak = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HBillNo_bak"]);
                    //===================================================
                    oSub.HMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMaterID"]);
                    oSub.HUnitID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HUnitID"]);
                    oSub.HQty = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HQty"]);
                    oSub.HStatusID_Old = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HStatusID_Old"]);
                    oSub.HStatusID_New = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HStatusID_New"]);
                    DetailColl.Add(oSub);
                }
                sReturn = "显示单据成功!";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
    }
}
Model/Model.csproj
@@ -330,6 +330,8 @@
    <Compile Include="基础资料\基础资料\ClsGy_CareFor_Model.cs" />
    <Compile Include="基础资料\基础资料\ClsGy_CheckToolsType_Model.cs" />
    <Compile Include="基础资料\基础资料\ClsGy_CustLocation_Model.cs" />
    <Compile Include="基础资料\基础资料\ClsGy_EquipStatus_Model.cs" />
    <Compile Include="基础资料\基础资料\ClsGy_MouldStatus_Model.cs" />
    <Compile Include="基础资料\基础资料\ClsGy_Operator_Model.cs" />
    <Compile Include="基础资料\基础资料\ClsGy_RateType_Model.cs" />
    <Compile Include="基础资料\基础资料\ClsGy_Staff_Model.cs" />
@@ -531,6 +533,8 @@
    <Compile Include="生产管理\模具管理\ClsSc_MouldEntrustOutPlanBillSub.cs" />
    <Compile Include="生产管理\模具管理\ClsSc_MouldLifeChangeBillMain.cs" />
    <Compile Include="生产管理\模具管理\ClsSc_MouldLifeChangeBillSub.cs" />
    <Compile Include="生产管理\模具管理\ClsSc_MouldLifeUseBillMain.cs" />
    <Compile Include="生产管理\模具管理\ClsSc_MouldLifeUseBillSub.cs" />
    <Compile Include="生产管理\模具管理\ClsSc_MouldMaintainBillMain.cs" />
    <Compile Include="生产管理\模具管理\ClsSc_MouldMaintainBillSub.cs" />
    <Compile Include="生产管理\模具管理\ClsSc_MouldMaintainPlanBillMain.cs" />
@@ -565,6 +569,8 @@
    <Compile Include="生产管理\模具管理\ClsSc_MouldReportBillSub.cs" />
    <Compile Include="生产管理\模具管理\ClsSc_MouldScrapRequestBillMain.cs" />
    <Compile Include="生产管理\模具管理\ClsSc_MouldScrapRequestBillSub.cs" />
    <Compile Include="生产管理\模具管理\ClsSc_MouldStatusChangeBillMain.cs" />
    <Compile Include="生产管理\模具管理\ClsSc_MouldStatusChangeBillSub.cs" />
    <Compile Include="生产管理\模具管理\ClsSc_MouldStockBillMain.cs" />
    <Compile Include="生产管理\模具管理\ClsSc_MouldStockBillSub.cs" />
    <Compile Include="生产管理\设备管理\ClsSb_EquipConkBookBillMain.cs" />
@@ -592,6 +598,8 @@
    <Compile Include="生产管理\设备管理\ClsSb_EquipSparepartsBillSub.cs" />
    <Compile Include="生产管理\设备管理\ClsSb_EquipSparepartsChangeBillMain.cs" />
    <Compile Include="生产管理\设备管理\ClsSb_EquipSparepartsChangeBillSub.cs" />
    <Compile Include="生产管理\设备管理\ClsSb_EquipStatusChangeBillMain.cs" />
    <Compile Include="生产管理\设备管理\ClsSb_EquipStatusChangeBillSub.cs" />
    <Compile Include="生产管理\设备管理\ClsSc_EquipMaintainBillSub_Item.cs" />
    <Compile Include="生产管理\设备管理\ClsSc_EquipMaintainPlanBillSub_Item.cs" />
    <Compile Include="生产管理\设备管理\ClsSc_ICMOBillMain.cs" />
Model/»ù´¡×ÊÁÏ/»ù´¡×ÊÁÏ/ClsGy_EquipStatus_Model.cs
New file
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Model
{
    public class ClsGy_EquipStatus_Model : DBUtility.ClsGy_Base_Model
    {
        public DateTime HMakeTime { get; set; }
        public DateTime HCheckTime { get; set; }
        public DateTime HModifyTime { get; set; }
        public DateTime HStopTime { get; set; }
        public string HMakeEmp { get; set; }
        public string HCheckEmp { get; set; }
        public string HModifyEmp { get; set; }
        public string HStopEmp { get; set; }
        public int HUSEORGID { get; set; }
        public int HCREATEORGID { get; set; }
    }
}
Model/»ù´¡×ÊÁÏ/»ù´¡×ÊÁÏ/ClsGy_MouldStatus_Model.cs
New file
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Model
{
    public class ClsGy_MouldStatus_Model : DBUtility.ClsGy_Base_Model
    {
        public DateTime HMakeTime { get; set; }
        public DateTime HCheckTime { get; set; }
        public DateTime HModifyTime { get; set; }
        public DateTime HStopTime { get; set; }
        public string HMakeEmp { get; set; }
        public string HCheckEmp { get; set; }
        public string HModifyEmp { get; set; }
        public string HStopEmp { get; set; }
        public int HUSEORGID { get; set; }
        public int HCREATEORGID { get; set; }
    }
}
Model/Éú²ú¹ÜÀí/Ä£¾ß¹ÜÀí/ClsSc_MouldLifeUseBillMain.cs
New file
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Model
{
    public class ClsSc_MouldLifeUseBillMain : DBUtility.ClsXt_BaseBillMain
    {
        public Int64 HPrintQty; //打印次数
        public Int64 HMangerID;            //负责人
        public Int64 HDeptID;            //部门
        public string HReason;            //调整原因
        public string HExplanation;          //摘要
        public string HInnerBillNo;            //内部单据号
    }
}
Model/Éú²ú¹ÜÀí/Ä£¾ß¹ÜÀí/ClsSc_MouldLifeUseBillSub.cs
New file
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Model
{
    public class ClsSc_MouldLifeUseBillSub : DBUtility.ClsXt_BaseBillSub
    {
        public string HBillNo_bak;        //单据号(备份,以免内码丢失,找不到对应主表)
        public Int64 HItemSubID; //自增列(GUID)
        public Int64 HMaterID;                    //器具
        public Int64 HUnitID;                    //新器具
        public double HDesignLife; // --设计寿命
        public double HLeaveLife; //--原剩余寿命
        public double HUseLife; // --本次耗用
        public double HNewLeaveLife;// --本次剩余寿命
    }
}
Model/Éú²ú¹ÜÀí/Ä£¾ß¹ÜÀí/ClsSc_MouldStatusChangeBillMain.cs
New file
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Model
{
    public class ClsSc_MouldStatusChangeBillMain : DBUtility.ClsXt_BaseBillMain
    {
        public Int64 HPrintQty; //打印次数
        public Int64 HEmpID;            //申请人
        public Int64 HDeptID;            //部门
        public string HReason;            //变更原因
        public string HExplanation;          //摘要
        public string HInnerBillNo;            //内部单据号
    }
}
Model/Éú²ú¹ÜÀí/Ä£¾ß¹ÜÀí/ClsSc_MouldStatusChangeBillSub.cs
New file
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Model
{
    public class ClsSc_MouldStatusChangeBillSub : DBUtility.ClsXt_BaseBillSub
    {
        public string HBillNo_bak;        //单据号(备份,以免内码丢失,找不到对应主表)
        public Int64 HItemSubID; //自增列(GUID)
        public Int64 HMaterID;
        public Int64 HUnitID;
        public decimal HQtyMust;
        public decimal HQty;
        public Int64 HStatusID_Old;
        public Int64 HStatusID_New;
    }
}
Model/Éú²ú¹ÜÀí/É豸¹ÜÀí/ClsSb_EquipStatusChangeBillMain.cs
New file
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Model
{
    public class ClsSb_EquipStatusChangeBillMain : DBUtility.ClsXt_BaseBillMain
    {
        public Int64 HPrintQty; //打印次数
        public Int64 HEmpID;            //申请人
        public Int64 HDeptID;            //部门
        public string HReason;            //变更原因
        public string HExplanation;          //摘要
        public string HInnerBillNo;            //内部单据号
    }
}
Model/Éú²ú¹ÜÀí/É豸¹ÜÀí/ClsSb_EquipStatusChangeBillSub.cs
New file
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Model
{
    public class ClsSb_EquipStatusChangeBillSub : DBUtility.ClsXt_BaseBillSub
    {
        public string HBillNo_bak;        //单据号(备份,以免内码丢失,找不到对应主表)
        public Int64 HItemSubID; //自增列(GUID)
        public Int64 HEquipID;
        public Int64 HUnitID;
        public decimal HQtyMust;
        public decimal HQty;
        public Int64 HStatusID_Old;
        public Int64 HStatusID_New;
    }
}
WebAPI/Controllers/MJGL/Sc_MouldLifeUseBillController.cs
New file
@@ -0,0 +1,286 @@
using DBUtility;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebAPI.Models;
namespace WebAPI.Controllers.MJGL
{
    public class Sc_MouldLifeUseBillController : ApiController
    {
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        DataSet ds;
        #region [器具寿命耗用单列表]
        [Route("Sc_MouldLifeUseBill/list")]
        [HttpGet]
        public object list(string sWhere, string user)
        {
            try
            {
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Sc_MouldLifeUseBillList order by HMainID asc", "h_v_Sc_MouldLifeUseBillList");
                }
                else
                {
                    string sql1 = "select * from h_v_Sc_MouldLifeUseBillList where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by HMainID asc";
                    ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldLifeUseBillList");
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region [根据ID查找记录]
        [Route("Sc_MouldLifeUseBill/cx")]
        [HttpGet]
        public object cx(long HInterID)
        {
            try
            {
                ds = oCN.RunProcReturn("select * from h_v_Sc_MouldLifeUseBillList where HMainID =" + HInterID, "h_v_Sc_MouldLifeUseBillList");
                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 = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å™¨å…·å¯¿å‘½è€—用单 ä¿å­˜/编辑功能
        [Route("Sc_MouldLifeUseBill/MouldLifeUseBillEdit")]
        [HttpPost]
        public object MouldLifeUseBillEdit([FromBody] JObject sMainSub)
        {
            try
            {
                var _value = sMainSub["sMainSub"].ToString();
                string msg1 = _value.ToString();
                oCN.BeginTran();
                //保存主表
                objJsonResult = AddBillMain(msg1);
                if (objJsonResult.code == "0")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = objJsonResult.Message;
                    objJsonResult.data = null;
                    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 = "保存失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        public json AddBillMain(string msg1)
        {
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString(); //主表数据
            string msg3 = sArray[1].ToString(); //子表数据
            int OperationType = int.Parse(sArray[2].ToString()); // æ•°æ®ç±»åž‹ 1添加 3修改
            string user = sArray[3].ToString();
            try
            {
                msg2 = "[" + msg2.ToString() + "]";
                List<ClsSc_MouldLifeUseBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldLifeUseBillMain>>(msg2);
                long HInterID = mainList[0].HInterID;//递入type得到的单据ID
                string HBillNo = mainList[0].HBillNo;//递入type得到的单据号
                long HBillStatus = 1;//单据状态
                DateTime HDate = mainList[0].HDate;//日期
                string HRemark = mainList[0].HRemark;//备注
                long HMangerID = mainList[0].HMangerID;//负责人
                long HDeptID = mainList[0].HDeptID;//部门
                string HReason = mainList[0].HReason;//变更原因
                string HExplanation = mainList[0].HExplanation;//摘要
                string HMaker = user;//制单人
                DateTime dt = DateTime.Now;
                //ds = oCN.RunProcReturn("select * from h_v_IF_POOrderBillList where hmainid=" + HInterID + " and å•据号='" + HBillNo + "'", "h_v_IF_POOrderBillList");
                if ((OperationType == 1 || OperationType == 2))//新增   && ds.Tables[0].Rows.Count == 0
                {
                    //DataSet Ds;
                    //Int64 NewHInterID = 1;
                    //Ds = oCN.RunProcReturn("select MAX(HInterID)HInterID from Cg_POOrderBillMain", "Cg_POOrderBillMain");
                    //if (Ds.Tables[0].Rows.Count != 0 && ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString()) != 0)
                    //{
                    //    NewHInterID = ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString());
                    //    NewHInterID += 1;
                    //}
                    //主表
                    oCN.RunProc(@"Insert Into Sc_MouldLifeUseBillMain
                        (HInterID,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillNo,HBillStatus
                        ,HRemark,HBackRemark,HMaker,HMakeDate,HMainSourceBillType,HMainSourceInterID
                        ,HMainSourceEntryID,HMainSourceBillNo,HPrintQty,HMangerID,HDeptID,HReason,HExplanation,HInnerBillNo)
                        values(" + HInterID + "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + 3845 + "','" +
                    mainList[0].HBillSubType + "','" + HDate + "','" + HBillNo + "','" + HBillStatus + "','" + mainList[0].HRemark +
                    "','" + mainList[0].HBackRemark + "','" + mainList[0].HMaker + "','" + dt + "','" + mainList[0].HMainSourceBillType + "'," + mainList[0].HMainSourceInterID +
                    "," + mainList[0].HMainSourceEntryID + ",'" + mainList[0].HMainSourceBillNo + "'," + mainList[0].HPrintQty + "," + mainList[0].HMangerID + "," + mainList[0].HDeptID + ",'" + HReason + "','" + HExplanation + "','" + mainList[0].HInnerBillNo + "'" + ")");
                }
                else if (OperationType == 3)//|| ds.Tables[0].Rows.Count != 0
                { //修改
                    oCN.RunProc("update Sc_MouldLifeUseBillMain  set " +
                                "HRemark='" + HRemark + "', HChecker='" + HMaker + "', HCheckDate=getdate()" + ",HReason='" + HReason +
                                "',HExplanation='" + HExplanation + "',HMangerID=" + HMangerID + ",HDeptID=" + HDeptID + " where HInterID=" + HInterID);
                    //删除子表
                    oCN.RunProc("delete from Sc_MouldLifeUseBillSub where HInterID='" + HInterID + "'");
                }
                //保存子表
                objJsonResult = AddBillSub(msg3, HInterID, OperationType, HBillNo);
                if (objJsonResult.code == "0")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = objJsonResult.Message;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = null;
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        public json AddBillSub(string msg3, long HInterID, int OperationType, string HBillNo)
        {
            List<ClsSc_MouldLifeUseBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldLifeUseBillSub>>(msg3);
            int i = 0;
            foreach (ClsSc_MouldLifeUseBillSub oSub in DetailColl)
            {
                i++;
                DataSet Cs;
                Int64 NewHEntryID = 1;
                Cs = oCN.RunProcReturn("select MAX(HEntryID)HEntryID from Sc_MouldLifeUseBillSub", "Sc_MouldLifeUseBillSub");
                if (Cs.Tables[0].Rows.Count != 0 && ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString()) != 0)
                {
                    NewHEntryID = ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString());
                    NewHEntryID += 1;
                }
                oCN.RunProc($@"Insert into Sc_MouldLifeUseBillSub
                (HInterID,HEntryID,HBillNo_bak,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty
                ,HRelationMoney,HMaterID,HUnitID,HDesignLife,HLeaveLife,HUseLife,HNewLeaveLife)
                 values({HInterID},{NewHEntryID},'{ HBillNo }','{oSub.HRemark}',{oSub.HSourceInterID}
                ,{oSub.HSourceEntryID},'{oSub.HSourceBillNo}','{oSub.HSourceBillType}',{oSub.HRelationQty},{oSub.HRelationMoney},{oSub.HMaterID},{oSub.HUnitID},{oSub.HDesignLife},{oSub.HLeaveLife},{oSub.HUseLife},{oSub.HNewLeaveLife})");
            }
            objJsonResult.code = "1";
            objJsonResult.count = 1;
            objJsonResult.Message = null;
            objJsonResult.data = null;
            return objJsonResult;
        }
        #endregion
        #region [删除]
        [Route("Sc_MouldLifeUseBill/Delete")]
        [HttpGet]
        public object Delete(string HInterID, string user)
        {
            try
            {
                oCN.BeginTran();
                oCN.RunProc("Delete From Sc_MouldLifeUseBillMain where HInterID = " + HInterID);
                oCN.RunProc("Delete From Sc_MouldLifeUseBillSub where HInterID = " + HInterID);
                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
    }
}
WebAPI/Controllers/MJGL/Sc_MouldScrapRequestBillController.cs
New file
@@ -0,0 +1,293 @@
using DBUtility;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebAPI.Models;
namespace WebAPI.Controllers.MJGL
{
    public class Sc_MouldScrapRequestBillController : ApiController
    {
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        DataSet ds;
        #region [器具报废申请单列表]
        [Route("Sc_MouldScrapRequestBill/list")]
        [HttpGet]
        public object list(string sWhere, string user)
        {
            try
            {
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Sc_MouldScrapRequestBillList order by HMainID asc", "h_v_Sc_MouldScrapRequestBillList");
                }
                else
                {
                    string sql1 = "select * from h_v_Sc_MouldScrapRequestBillList where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by HMainID asc";
                    ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldScrapRequestBillList");
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region [根据ID查找记录]
        [Route("Sc_MouldScrapRequestBill/cx")]
        [HttpGet]
        public object cx(long HInterID)
        {
            try
            {
                ds = oCN.RunProcReturn("select * from h_v_Sc_MouldScrapRequestBillList where hmainid =" + HInterID, "h_v_Sc_MouldScrapRequestBillList");
                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 = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å™¨å…·æŠ¥åºŸç”³è¯·å• ä¿å­˜/编辑功能
        [Route("Sc_MouldScrapRequestBill/MouldScrapRequestBillEdit")]
        [HttpPost]
        public object MouldScrapRequestBillEdit([FromBody] JObject sMainSub)
        {
            try
            {
                var _value = sMainSub["sMainSub"].ToString();
                string msg1 = _value.ToString();
                oCN.BeginTran();
                //保存主表
                objJsonResult = AddBillMain(msg1);
                if (objJsonResult.code == "0")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = objJsonResult.Message;
                    objJsonResult.data = null;
                    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 = "保存失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        public json AddBillMain(string msg1)
        {
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString(); //主表数据
            string msg3 = sArray[1].ToString(); //子表数据
            int OperationType = int.Parse(sArray[2].ToString()); // æ•°æ®ç±»åž‹ 1添加 3修改
            string user = sArray[3].ToString();
            try
            {
                msg2 = "[" + msg2.ToString() + "]";
                List<ClsSc_MouldScrapRequestBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldScrapRequestBillMain>>(msg2);
                long HInterID = mainList[0].HInterID;//递入type得到的单据ID
                string HBillNo = mainList[0].HBillNo;//递入type得到的单据号
                long HBillStatus = 1;//单据号
                long HPRDORGID = mainList[0].HPRDORGID;//组织
                DateTime HDate = mainList[0].HDate;//日期
                string HRemark = mainList[0].HRemark;//备注
                long HEmpID = mainList[0].HEmpID;//申请人
                long HDeptID = mainList[0].HDeptID;//部门
                long HMangerID = mainList[0].HMangerID;//负责人
                long HWHID = mainList[0].HWHID;//报废仓库
                string HReason = mainList[0].HReason;//报废原因
                string HMaker = user;//制单人
                DateTime dt = DateTime.Now;
                //ds = oCN.RunProcReturn("select * from h_v_IF_POOrderBillList where hmainid=" + HInterID + " and å•据号='" + HBillNo + "'", "h_v_IF_POOrderBillList");
                if ((OperationType == 1 || OperationType == 2))//新增   && ds.Tables[0].Rows.Count == 0
                {
                    //DataSet Ds;
                    //Int64 NewHInterID = 1;
                    //Ds = oCN.RunProcReturn("select MAX(HInterID)HInterID from Cg_POOrderBillMain", "Cg_POOrderBillMain");
                    //if (Ds.Tables[0].Rows.Count != 0 && ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString()) != 0)
                    //{
                    //    NewHInterID = ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString());
                    //    NewHInterID += 1;
                    //}
                    //主表
                    oCN.RunProc(@"Insert Into Sc_MouldScrapRequestBillMain
                        (HInterID,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillNo,HBillStatus
                        ,HReason,HExplanation,HRemark,HBackRemark,HMaker,HMakeDate,HMainSourceInterID
                        ,HMainSourceEntryID,HMainSourceBillNo,HEmpID,HDeptID,HMangerID,HWHID,HCheckItemNowID
                        ,HCheckItemNextID,HCheckFlowID,HBacker,HChecker,HUpDater,HCloseMan,HCloseType,HDeleteMan,HInnerBillNo)
                        values(" + HInterID + "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + 3823 + "','" +
                    3823 + "','" + HDate + "','" + HBillNo + "','" + HBillStatus + "','" + HReason + "','" + mainList[0].HExplanation + "','" + mainList[0].HRemark +
                    "','" + mainList[0].HBackRemark + "','" + mainList[0].HMaker + "','" + dt + "',"  + mainList[0].HMainSourceInterID +
                    "," + mainList[0].HMainSourceEntryID + ",'" + mainList[0].HMainSourceBillNo + "'," + mainList[0].HEmpID + "," + mainList[0].HDeptID + "," + mainList[0].HMangerID + "," + mainList[0].HWHID + ",0,0,0" + ",'" + mainList[0].HBacker + "','" + mainList[0].HChecker + "','" + mainList[0].HUpDater + "','" + mainList[0].HCloseMan + "'," + 0 + ",'" + mainList[0].HDeleteMan + "','" + mainList[0].HInnerBillNo + "'" + ")");
                }
                else if (OperationType == 3)//|| ds.Tables[0].Rows.Count != 0
                { //修改
                    oCN.RunProc("update Sc_MouldScrapRequestBillMain  set " +
                                "HRemark='" + HRemark + "', HUpDater='" + HMaker + "', HUpDateDate=getdate()" +
                                ",HEmpID=" + HEmpID + ",HDeptID=" + HDeptID + ",HMangerID=" + HMangerID +
                                ",HReason='" + HReason + "'" +
                                ",HWHID=" + HWHID + " where HInterID=" + HInterID);
                    //删除子表
                    oCN.RunProc("delete from Sc_MouldScrapRequestBillSub where HInterID='" + HInterID + "'");
                }
                //保存子表
                objJsonResult = AddBillSub(msg3, HInterID, OperationType);
                if (objJsonResult.code == "0")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = objJsonResult.Message;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = null;
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        public json AddBillSub(string msg3, long HInterID, int OperationType)
        {
            List<ClsSc_MouldScrapRequestBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldScrapRequestBillSub>>(msg3);
            int i = 0;
            foreach (ClsSc_MouldScrapRequestBillSub oSub in DetailColl)
            {
                i++;
                DataSet Cs;
                Int64 NewHEntryID = 1;
                Cs = oCN.RunProcReturn("select MAX(HEntryID)HEntryID from Sc_MouldScrapRequestBillSub", "Sc_MouldScrapRequestBillSub");
                if (Cs.Tables[0].Rows.Count != 0 && ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString()) != 0)
                {
                    NewHEntryID = ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString());
                    NewHEntryID += 1;
                }
                oCN.RunProc($@"Insert into Sc_MouldScrapRequestBillSub
                (HInterID,HEntryID,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty
                ,HRelationMoney,HMaterID,HPropertyID,HSecUnitID,HSecUnitRate,HUnitID,HQtyMust,HQty,HPrice,HMoney,HDesignLife,HLeaveLife,HWHID)
                 values({HInterID},{NewHEntryID},'{oSub.HRemark}',{oSub.HSourceInterID}
                ,{oSub.HSourceEntryID},'{oSub.HSourceBillNo}','{oSub.HSourceBillType}',{oSub.HRelationQty},{oSub.HRelationMoney},{oSub.HMaterID}
                ,{oSub.HPropertyID},{oSub.HSecUnitID},{oSub.HSecUnitRate},{oSub.HUnitID},0,{oSub.HQty},{oSub.HPrice},{oSub.HMoney},{oSub.HDesignLife}
                ,{oSub.HLeaveLife},{oSub.HWHID})");
            }
            objJsonResult.code = "1";
            objJsonResult.count = 1;
            objJsonResult.Message = null;
            objJsonResult.data = null;
            return objJsonResult;
        }
        #endregion
        #region [删除]
        [Route("Sc_MouldScrapRequestBill/Delete")]
        [HttpGet]
        public object Delete(string HInterID, string user)
        {
            try
            {
                oCN.BeginTran();
                oCN.RunProc("Delete From Sc_MouldScrapRequestBillMain where HInterID = " + HInterID);
                oCN.RunProc("Delete From Sc_MouldScrapRequestBillSub where HInterID = " + HInterID);
                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
    }
}
WebAPI/Controllers/MJGL/Sc_MouldStatusChangeBillController.cs
New file
@@ -0,0 +1,286 @@
using DBUtility;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebAPI.Models;
namespace WebAPI.Controllers.MJGL
{
    public class Sc_MouldStatusChangeBillController : ApiController
    {
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        DataSet ds;
        #region [器具状态变更单列表]
        [Route("Sc_MouldStatusChangeBill/list")]
        [HttpGet]
        public object list(string sWhere, string user)
        {
            try
            {
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Sc_MouldStatusChangeBillList order by HMainID asc", "h_v_Sc_MouldStatusChangeBillList");
                }
                else
                {
                    string sql1 = "select * from h_v_Sc_MouldStatusChangeBillList where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by HMainID asc";
                    ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldStatusChangeBillList");
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region [根据ID查找记录]
        [Route("Sc_MouldStatusChangeBill/cx")]
        [HttpGet]
        public object cx(long HInterID)
        {
            try
            {
                ds = oCN.RunProcReturn("select * from h_v_Sc_MouldStatusChangeBillList where HMainID =" + HInterID, "h_v_Sc_MouldStatusChangeBillList");
                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 = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å™¨å…·çŠ¶æ€å˜æ›´å• ä¿å­˜/编辑功能
        [Route("Sc_MouldStatusChangeBill/MouldStatusChangeBillEdit")]
        [HttpPost]
        public object BarCodeStatusChangeBillEdit([FromBody] JObject sMainSub)
        {
            try
            {
                var _value = sMainSub["sMainSub"].ToString();
                string msg1 = _value.ToString();
                oCN.BeginTran();
                //保存主表
                objJsonResult = AddBillMain(msg1);
                if (objJsonResult.code == "0")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = objJsonResult.Message;
                    objJsonResult.data = null;
                    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 = "保存失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        public json AddBillMain(string msg1)
        {
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString(); //主表数据
            string msg3 = sArray[1].ToString(); //子表数据
            int OperationType = int.Parse(sArray[2].ToString()); // æ•°æ®ç±»åž‹ 1添加 3修改
            string user = sArray[3].ToString();
            try
            {
                msg2 = "[" + msg2.ToString() + "]";
                List<ClsSc_MouldStatusChangeBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldStatusChangeBillMain>>(msg2);
                long HInterID = mainList[0].HInterID;//递入type得到的单据ID
                string HBillNo = mainList[0].HBillNo;//递入type得到的单据号
                long HBillStatus = 1;//单据状态
                DateTime HDate = mainList[0].HDate;//日期
                string HRemark = mainList[0].HRemark;//备注
                long HEmpID = mainList[0].HEmpID;//负责人
                long HDeptID = mainList[0].HDeptID;//部门
                string HReason = mainList[0].HReason;//变更原因
                string HExplanation = mainList[0].HExplanation;//摘要
                string HMaker = user;//制单人
                DateTime dt = DateTime.Now;
                //ds = oCN.RunProcReturn("select * from h_v_IF_POOrderBillList where hmainid=" + HInterID + " and å•据号='" + HBillNo + "'", "h_v_IF_POOrderBillList");
                if ((OperationType == 1 || OperationType == 2))//新增   && ds.Tables[0].Rows.Count == 0
                {
                    //DataSet Ds;
                    //Int64 NewHInterID = 1;
                    //Ds = oCN.RunProcReturn("select MAX(HInterID)HInterID from Cg_POOrderBillMain", "Cg_POOrderBillMain");
                    //if (Ds.Tables[0].Rows.Count != 0 && ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString()) != 0)
                    //{
                    //    NewHInterID = ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString());
                    //    NewHInterID += 1;
                    //}
                    //主表
                    oCN.RunProc(@"Insert Into Sc_MouldStatusChangeBillMain
                        (HInterID,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillNo,HBillStatus
                        ,HRemark,HBackRemark,HMaker,HMakeDate,HMainSourceBillType,HMainSourceInterID
                        ,HMainSourceEntryID,HMainSourceBillNo,HPrintQty,HEmpID,HDeptID,HReason,HExplanation,HInnerBillNo)
                        values(" + HInterID + "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + 3844 + "','" +
                    mainList[0].HBillSubType + "','" + HDate + "','" + HBillNo + "','" + HBillStatus + "','" + mainList[0].HRemark +
                    "','" + mainList[0].HBackRemark + "','" + mainList[0].HMaker + "','" + dt + "','" + mainList[0].HMainSourceBillType + "'," + mainList[0].HMainSourceInterID +
                    "," + mainList[0].HMainSourceEntryID + ",'" + mainList[0].HMainSourceBillNo + "'," + mainList[0].HPrintQty + "," + mainList[0].HEmpID + "," + mainList[0].HDeptID + ",'" + HReason + "','" + HExplanation + "','" + mainList[0].HInnerBillNo + "'" + ")");
                }
                else if (OperationType == 3)//|| ds.Tables[0].Rows.Count != 0
                { //修改
                    oCN.RunProc("update Sc_MouldStatusChangeBillMain  set " +
                                "HRemark='" + HRemark + "', HChecker='" + HMaker + "', HCheckDate=getdate()" + ",HReason='" + HReason +
                                "',HExplanation='" + HExplanation + "',HEmpID=" + HEmpID + ",HDeptID=" + HDeptID + " where HInterID=" + HInterID);
                    //删除子表
                    oCN.RunProc("delete from Sc_MouldStatusChangeBillSub where HInterID='" + HInterID + "'");
                }
                //保存子表
                objJsonResult = AddBillSub(msg3, HInterID, OperationType, HBillNo);
                if (objJsonResult.code == "0")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = objJsonResult.Message;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = null;
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        public json AddBillSub(string msg3, long HInterID, int OperationType,string HBillNo)
        {
            List<ClsSc_MouldStatusChangeBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldStatusChangeBillSub>>(msg3);
            int i = 0;
            foreach (ClsSc_MouldStatusChangeBillSub oSub in DetailColl)
            {
                i++;
                DataSet Cs;
                Int64 NewHEntryID = 1;
                Cs = oCN.RunProcReturn("select MAX(HEntryID)HEntryID from Sc_MouldStatusChangeBillSub", "Sc_MouldStatusChangeBillSub");
                if (Cs.Tables[0].Rows.Count != 0 && ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString()) != 0)
                {
                    NewHEntryID = ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString());
                    NewHEntryID += 1;
                }
                oCN.RunProc($@"Insert into Sc_MouldStatusChangeBillSub
                (HInterID,HEntryID,HBillNo_bak,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty
                ,HRelationMoney,HMaterID,HUnitID,HQtyMust,HQty,HStatusID_Old,HStatusID_New)
                 values({HInterID},{NewHEntryID},'{ HBillNo }','{oSub.HRemark}',{oSub.HSourceInterID}
                ,{oSub.HSourceEntryID},'{oSub.HSourceBillNo}','{oSub.HSourceBillType}',{oSub.HRelationQty},{oSub.HRelationMoney},{oSub.HMaterID},{oSub.HUnitID},{0},{oSub.HQty},{oSub.HStatusID_Old},{oSub.HStatusID_New})");
            }
            objJsonResult.code = "1";
            objJsonResult.count = 1;
            objJsonResult.Message = null;
            objJsonResult.data = null;
            return objJsonResult;
        }
        #endregion
        #region [删除]
        [Route("Sc_MouldStatusChangeBill/Delete")]
        [HttpGet]
        public object Delete(string HInterID, string user)
        {
            try
            {
                oCN.BeginTran();
                oCN.RunProc("Delete From Sc_MouldStatusChangeBillMain where HInterID = " + HInterID);
                oCN.RunProc("Delete From Sc_MouldStatusChangeBillSub where HInterID = " + HInterID);
                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
    }
}
WebAPI/Controllers/SBGL/Sb_EquipStatusChangeBillController.cs
New file
@@ -0,0 +1,287 @@
using DBUtility;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebAPI.Models;
namespace WebAPI.Controllers.SBGL
{
    public class Sb_EquipStatusChangeBillController : ApiController
    {
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        DataSet ds;
        #region [设备状态变更单列表]
        [Route("Sb_EquipStatusChangeBill/list")]
        [HttpGet]
        public object list(string sWhere, string user)
        {
            try
            {
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Sb_EquipStatusChangeBillList order by HMainID asc", "h_v_Sb_EquipStatusChangeBillList");
                }
                else
                {
                    string sql1 = "select * from h_v_Sb_EquipStatusChangeBillList where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by HMainID asc";
                    ds = oCN.RunProcReturn(sql, "h_v_Sb_EquipStatusChangeBillList");
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region [根据ID查找记录]
        [Route("Sb_EquipStatusChangeBill/cx")]
        [HttpGet]
        public object cx(long HInterID)
        {
            try
            {
                ds = oCN.RunProcReturn("select * from h_v_Sb_EquipStatusChangeBillList where HMainID =" + HInterID, "h_v_Sb_EquipStatusChangeBillList");
                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 = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region è®¾å¤‡çŠ¶æ€å˜æ›´å• ä¿å­˜/编辑功能
        [Route("Sb_EquipStatusChangeBill/EquipStatusChangeBillEdit")]
        [HttpPost]
        public object BarCodeStatusChangeBillEdit([FromBody] JObject sMainSub)
        {
            try
            {
                var _value = sMainSub["sMainSub"].ToString();
                string msg1 = _value.ToString();
                oCN.BeginTran();
                //保存主表
                objJsonResult = AddBillMain(msg1);
                if (objJsonResult.code == "0")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = objJsonResult.Message;
                    objJsonResult.data = null;
                    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 = "保存失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        public json AddBillMain(string msg1)
        {
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString(); //主表数据
            string msg3 = sArray[1].ToString(); //子表数据
            int OperationType = int.Parse(sArray[2].ToString()); // æ•°æ®ç±»åž‹ 1添加 3修改
            string user = sArray[3].ToString();
            try
            {
                msg2 = "[" + msg2.ToString() + "]";
                List<ClsSb_EquipStatusChangeBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSb_EquipStatusChangeBillMain>>(msg2);
                long HInterID = mainList[0].HInterID;//递入type得到的单据ID
                string HBillNo = mainList[0].HBillNo;//递入type得到的单据号
                long HBillStatus = 1;//单据状态
                DateTime HDate = mainList[0].HDate;//日期
                string HRemark = mainList[0].HRemark;//备注
                long HEmpID = mainList[0].HEmpID;//申请人
                long HDeptID = mainList[0].HDeptID;//部门
                string HReason = mainList[0].HReason;//变更原因
                string HExplanation = mainList[0].HExplanation;//摘要
                string HMaker = user;//制单人
                DateTime dt = DateTime.Now;
                //ds = oCN.RunProcReturn("select * from h_v_IF_POOrderBillList where hmainid=" + HInterID + " and å•据号='" + HBillNo + "'", "h_v_IF_POOrderBillList");
                if ((OperationType == 1 || OperationType == 2))//新增   && ds.Tables[0].Rows.Count == 0
                {
                    //DataSet Ds;
                    //Int64 NewHInterID = 1;
                    //Ds = oCN.RunProcReturn("select MAX(HInterID)HInterID from Cg_POOrderBillMain", "Cg_POOrderBillMain");
                    //if (Ds.Tables[0].Rows.Count != 0 && ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString()) != 0)
                    //{
                    //    NewHInterID = ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString());
                    //    NewHInterID += 1;
                    //}
                    //主表
                    oCN.RunProc(@"Insert Into Sb_EquipStatusChangeBillMain
                        (HInterID,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillNo,HBillStatus
                        ,HRemark,HBackRemark,HMaker,HMakeDate,HMainSourceBillType,HMainSourceInterID
                        ,HMainSourceEntryID,HMainSourceBillNo,HPrintQty,HEmpID,HDeptID,HReason,HExplanation,HInnerBillNo)
                        values(" + HInterID + "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + 3844 + "','" +
                    mainList[0].HBillSubType + "','" + HDate + "','" + HBillNo + "','" + HBillStatus + "','" + mainList[0].HRemark +
                    "','" + mainList[0].HBackRemark + "','" + mainList[0].HMaker + "','" + dt + "','" + mainList[0].HMainSourceBillType + "'," + mainList[0].HMainSourceInterID +
                    "," + mainList[0].HMainSourceEntryID + ",'" + mainList[0].HMainSourceBillNo + "'," + mainList[0].HPrintQty + "," + mainList[0].HEmpID + "," + mainList[0].HDeptID + ",'" + HReason + "','" + HExplanation + "','" + mainList[0].HInnerBillNo + "'" + ")");
                }
                else if (OperationType == 3)//|| ds.Tables[0].Rows.Count != 0
                { //修改
                    oCN.RunProc("update Sb_EquipStatusChangeBillMain  set " +
                                "HRemark='" + HRemark + "', HChecker='" + HMaker + "', HCheckDate=getdate()" + ",HReason='" + HReason +
                                "',HExplanation='" + HExplanation + "',HEmpID=" + HEmpID + ",HDeptID=" + HDeptID + " where HInterID=" + HInterID);
                    //删除子表
                    oCN.RunProc("delete from Sb_EquipStatusChangeBillSub where HInterID='" + HInterID + "'");
                }
                //保存子表
                objJsonResult = AddBillSub(msg3, HInterID, OperationType, HBillNo);
                if (objJsonResult.code == "0")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = objJsonResult.Message;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = null;
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        public json AddBillSub(string msg3, long HInterID, int OperationType, string HBillNo)
        {
            List<ClsSb_EquipStatusChangeBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSb_EquipStatusChangeBillSub>>(msg3);
            int i = 0;
            foreach (ClsSb_EquipStatusChangeBillSub oSub in DetailColl)
            {
                i++;
                DataSet Cs;
                Int64 NewHEntryID = 1;
                Cs = oCN.RunProcReturn("select MAX(HEntryID)HEntryID from Sb_EquipStatusChangeBillSub", "Sb_EquipStatusChangeBillSub");
                if (Cs.Tables[0].Rows.Count != 0 && ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString()) != 0)
                {
                    NewHEntryID = ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString());
                    NewHEntryID += 1;
                }
                oCN.RunProc($@"Insert into Sb_EquipStatusChangeBillSub
                (HInterID,HEntryID,HBillNo_bak,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty
                ,HRelationMoney,HEquipID,HUnitID,HQtyMust,HQty,HStatusID_Old,HStatusID_New)
                 values({HInterID},{NewHEntryID},'{ HBillNo }','{oSub.HRemark}',{oSub.HSourceInterID}
                ,{oSub.HSourceEntryID},'{oSub.HSourceBillNo}','{oSub.HSourceBillType}',{oSub.HRelationQty},{oSub.HRelationMoney},{oSub.HEquipID},{oSub.HUnitID},{0},{oSub.HQty},{oSub.HStatusID_Old},{oSub.HStatusID_New})");
            }
            objJsonResult.code = "1";
            objJsonResult.count = 1;
            objJsonResult.Message = null;
            objJsonResult.data = null;
            return objJsonResult;
        }
        #endregion
        #region [删除]
        [Route("Sb_EquipStatusChangeBill/Delete")]
        [HttpGet]
        public object Delete(string HInterID, string user)
        {
            try
            {
                oCN.BeginTran();
                oCN.RunProc("Delete From Sb_EquipStatusChangeBillMain where HInterID = " + HInterID);
                oCN.RunProc("Delete From Sb_EquipStatusChangeBillSub where HInterID = " + HInterID);
                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
    }
}
WebAPI/Controllers/»ù´¡×ÊÁÏ/»ù´¡×ÊÁÏ/Gy_EquipStatusController.cs
New file
@@ -0,0 +1,311 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebAPI.Models;
namespace WebAPI.Controllers.基础资料.基础资料
{
    public class Gy_EquipStatusController : ApiController
    {
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        DataSet ds;
        #region  è®¾å¤‡çŠ¶æ€ åˆ—表
        [Route("Gy_EquipStatus/Gy_EquipStatusList")]
        [HttpGet]
        public object Gy_EquipStatusList(string sWhere, string user, string Organization)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                string sql1 = string.Format(@"select * from h_v_Gy_EquipStatus where ä½¿ç”¨ç»„织='" + Organization + "'");
                string sql = sql1 + sWhere;
                ds = oCN.RunProcReturn(sql, "h_v_Gy_EquipStatus");
                //添加列名
                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.list = columnNameList;
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region  è®¾å¤‡çŠ¶æ€ ç¼–辑
        [Route("Gy_EquipStatus/Gy_EquipStatusEdit")]
        [HttpPost]
        public object Gy_EquipStatusEdit([FromBody] JObject msg)
        {
            DataSet ds;
            var _value = msg["msg"].ToString();
            string msg3 = _value.ToString();
            string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg1 = sArray[0].ToString();
            string msg2 = sArray[1].ToString();
            //string msg_HUSEORGID = sArray[2].ToString();
            Int64 HItemID = 0;
            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
            ListModels oListModels = new ListModels();
            try
            {
                DAL.ClsGy_EquipStatus_Ctl oBill = new DAL.ClsGy_EquipStatus_Ctl();
                List<Model.ClsGy_EquipStatus_Model> lsmain = new List<Model.ClsGy_EquipStatus_Model>();
                msg1 = msg1.Replace("\\", "");
                msg1 = msg1.Replace("\n", "");  //\n
                lsmain = oListModels.getObjectByJson_Gy_EquipStatus(msg1);
                foreach (Model.ClsGy_EquipStatus_Model oItem in lsmain)
                {
                    if (oItem.HNumber.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "保存失败!代码不能为空!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    if (oItem.HName.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "保存失败!名称不能为空!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    //查询数据中是否存在重复代码
                    ds = oCN.RunProcReturn("select * from  Gy_EquipStatus where HStopflag=0 and HNumber='" + oItem.HNumber.Trim() + "'", "Gy_EquipStatus");
                    if (oItem.HItemID == 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "保存失败!代码重复!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    else
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            if (ds.Tables[0].Rows[0]["HItemID"].ToString() != oItem.HItemID.ToString())
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "保存失败!代码重复!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                        }
                    }
                    //新增时判断
                    #region çˆ¶çº§æ ¡éªŒæ–¹æ³•(api调用先注释掉,)
                    /*
                    if (oItem.HItemID == 0)
                    {
                        if (ds == null || ds.Tables[0].Rows.Count > 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "保存失败!代码重复!";
                            objJsonResult.data = 1;
                            return objJsonResult;
                        }
                        //检查父级是否存在
                        string sParent;
                        sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim());
                        if (sParent.Trim() == "")
                        {
                            oBill.oModel.HParentID = 0;
                        }
                        else
                        {
                            if (oBill.HavParentCode(sParent.Trim(), HItemID))
                            {
                                oBill.oModel.HParentID = oBill.oModel.HItemID;
                            }
                            else
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "保存失败!上级代码不存在或被禁用!";
                                objJsonResult.data = 1;
                                return objJsonResult;
                            }
                        }
                    }
                    else//编辑时判断
                    {
                        //检查父级是否存在
                        string sParent;
                        sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim());
                        if (sParent.Trim() == "")
                        {
                            oBill.oModel.HParentID = 0;
                        }
                        else
                        {
                            if (oBill.HavParentCode(sParent.Trim(), oItem.HItemID))
                            {
                                oBill.oModel.HParentID = oBill.oModel.HItemID;
                            }
                            else
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "保存失败!上级代码不存在或被禁用!";
                                objJsonResult.data = 1;
                                return objJsonResult;
                            }
                        }
                    }
                    */
                    #endregion
                    //得到短代码
                    string sShortNumber;
                    sShortNumber = DBUtility.ClsPub.GetShortNumber(oItem.HNumber.Trim());
                    if (sShortNumber.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "保存失败!短代码为空!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    //oItem.HUSEORGID = Convert.ToInt32(msg_HUSEORGID); //组织id
                    oItem.HShortNumber = sShortNumber;//短代码
                    oItem.HEndFlag = true;//末级标志
                    oItem.HLevel = 1; //等级 DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim())
                    oBill.oModel = oItem;
                }
                //保存
                //保存完毕后处理
                bool bResult;
                if (oBill.oModel.HItemID == 0)
                {
                    bResult = oBill.AddNew();
                }
                else
                {
                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
                }
                if (bResult)
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
                    //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单");
                    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("Gy_EquipStatus/Delete")]
        [HttpGet]
        public object Delete(string HItemID, string user)
        {
            DataSet ds;
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (string.IsNullOrWhiteSpace(HItemID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HItemID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();//开始事务
                ds = oCN.RunProcReturn("select * from Gy_EquipStatus where HItemID=" + HItemID, "Gy_EquipStatus");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有数据,无法删除!";
                    objJsonResult.data = null;
                    return objJsonResult; ;
                }
                var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]);
                if (HStopflag)
                {
                    oCN.RollBack();//回滚事务
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "数据已禁用无法删除!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.RunProc("delete from Gy_EquipStatus where HItemID=" + HItemID);
                oCN.Commit();//提交事务
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "* æ•°æ®åˆ é™¤æˆåŠŸï¼";
                objJsonResult.data = null;
                return objJsonResult; ;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "删除失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}
WebAPI/Controllers/»ù´¡×ÊÁÏ/»ù´¡×ÊÁÏ/Gy_MouldStatusController.cs
New file
@@ -0,0 +1,313 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebAPI.Models;
namespace WebAPI.Controllers.基础资料.基础资料
{
    public class Gy_MouldStatusController : ApiController
    {
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        DataSet ds;
        #region  å™¨å…·çŠ¶æ€ åˆ—表
        [Route("Gy_MouldStatus/Gy_MouldStatusList")]
        [HttpGet]
        public object Gy_MouldStatusList(string sWhere, string user, string Organization)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                string sql1 = string.Format(@"select * from h_v_Gy_MouldStatus where ä½¿ç”¨ç»„织='" + Organization + "'");
                string sql = sql1 + sWhere;
                ds = oCN.RunProcReturn(sql, "h_v_Gy_MouldStatus");
                //添加列名
                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.list = columnNameList;
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region  å™¨å…·çŠ¶æ€ ç¼–辑
        [Route("Gy_MouldStatus/Gy_MouldStatusEdit")]
        [HttpPost]
        public object Gy_MouldStatusEdit([FromBody] JObject msg)
        {
            DataSet ds;
            var _value = msg["msg"].ToString();
            string msg3 = _value.ToString();
            string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg1 = sArray[0].ToString();
            string msg2 = sArray[1].ToString();
            //string msg_HUSEORGID = sArray[2].ToString();
            Int64 HItemID = 0;
            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
            ListModels oListModels = new ListModels();
            try
            {
                DAL.ClsGy_MouldStatus_Ctl oBill = new DAL.ClsGy_MouldStatus_Ctl();
                List<Model.ClsGy_MouldStatus_Model> lsmain = new List<Model.ClsGy_MouldStatus_Model>();
                msg1 = msg1.Replace("\\", "");
                msg1 = msg1.Replace("\n", "");  //\n
                lsmain = oListModels.getObjectByJson_Gy_MouldStatus(msg1);
                foreach (Model.ClsGy_MouldStatus_Model oItem in lsmain)
                {
                    if (oItem.HNumber.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "保存失败!代码不能为空!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    if (oItem.HName.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "保存失败!名称不能为空!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    //查询数据中是否存在重复代码
                    ds = oCN.RunProcReturn("select * from  Gy_MouldStatus where HStopflag=0 and HNumber='" + oItem.HNumber.Trim() + "'", "Gy_MouldStatus");
                    if (oItem.HItemID == 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "保存失败!代码重复!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    else
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            if (ds.Tables[0].Rows[0]["HItemID"].ToString() != oItem.HItemID.ToString())
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "保存失败!代码重复!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                        }
                    }
                    //新增时判断
                    #region çˆ¶çº§æ ¡éªŒæ–¹æ³•(api调用先注释掉,)
                    /*
                    if (oItem.HItemID == 0)
                    {
                        if (ds == null || ds.Tables[0].Rows.Count > 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "保存失败!代码重复!";
                            objJsonResult.data = 1;
                            return objJsonResult;
                        }
                        //检查父级是否存在
                        string sParent;
                        sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim());
                        if (sParent.Trim() == "")
                        {
                            oBill.oModel.HParentID = 0;
                        }
                        else
                        {
                            if (oBill.HavParentCode(sParent.Trim(), HItemID))
                            {
                                oBill.oModel.HParentID = oBill.oModel.HItemID;
                            }
                            else
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "保存失败!上级代码不存在或被禁用!";
                                objJsonResult.data = 1;
                                return objJsonResult;
                            }
                        }
                    }
                    else//编辑时判断
                    {
                        //检查父级是否存在
                        string sParent;
                        sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim());
                        if (sParent.Trim() == "")
                        {
                            oBill.oModel.HParentID = 0;
                        }
                        else
                        {
                            if (oBill.HavParentCode(sParent.Trim(), oItem.HItemID))
                            {
                                oBill.oModel.HParentID = oBill.oModel.HItemID;
                            }
                            else
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "保存失败!上级代码不存在或被禁用!";
                                objJsonResult.data = 1;
                                return objJsonResult;
                            }
                        }
                    }
                    */
                    #endregion
                    //得到短代码
                    string sShortNumber;
                    sShortNumber = DBUtility.ClsPub.GetShortNumber(oItem.HNumber.Trim());
                    if (sShortNumber.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "保存失败!短代码为空!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    //oItem.HUSEORGID = Convert.ToInt32(msg_HUSEORGID); //组织id
                    oItem.HShortNumber = sShortNumber;//短代码
                    oItem.HEndFlag = true;//末级标志
                    oItem.HLevel = 1; //等级 DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim())
                    oBill.oModel = oItem;
                }
                //保存
                //保存完毕后处理
                bool bResult;
                if (oBill.oModel.HItemID == 0)
                {
                    bResult = oBill.AddNew();
                }
                else
                {
                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
                }
                if (bResult)
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
                    //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单");
                    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("Gy_MouldStatus/Delete")]
        [HttpGet]
        public object Delete(string HItemID, string user)
        {
            DataSet ds;
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (string.IsNullOrWhiteSpace(HItemID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HItemID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();//开始事务
                ds = oCN.RunProcReturn("select * from Gy_MouldStatus where HItemID=" + HItemID, "Gy_MouldStatus");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有数据,无法删除!";
                    objJsonResult.data = null;
                    return objJsonResult; ;
                }
                var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]);
                if (HStopflag)
                {
                    oCN.RollBack();//回滚事务
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "数据已禁用无法删除!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.RunProc("delete from Gy_MouldStatus where HItemID=" + HItemID);
                oCN.Commit();//提交事务
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "* æ•°æ®åˆ é™¤æˆåŠŸï¼";
                objJsonResult.data = null;
                return objJsonResult; ;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "删除失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}
WebAPI/ListModels.cs
@@ -1016,6 +1016,30 @@
        }
        /// <summary>
        /// å¤„理器具状态表的json
        /// </summary>
        /// <param name="jsonString"></param>
        /// <returns></returns>
        public List<Model.ClsGy_MouldStatus_Model> getObjectByJson_Gy_MouldStatus(string jsonString)
        {
            jsonString = "[" + jsonString.ToString() + "]";
            List<Model.ClsGy_MouldStatus_Model> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsGy_MouldStatus_Model>>(jsonString);
            return list;
        }
        /// <summary>
        /// å¤„理设备状态表的json
        /// </summary>
        /// <param name="jsonString"></param>
        /// <returns></returns>
        public List<Model.ClsGy_EquipStatus_Model> getObjectByJson_Gy_EquipStatus(string jsonString)
        {
            jsonString = "[" + jsonString.ToString() + "]";
            List<Model.ClsGy_EquipStatus_Model> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsGy_EquipStatus_Model>>(jsonString);
            return list;
        }
        /// <summary>
        /// å¤„理单据类型表的json
        /// </summary>
        /// <param name="jsonString"></param>
WebAPI/WebAPI.csproj
@@ -392,9 +392,13 @@
    <Compile Include="Controllers\CJGL\Cj_StationEntrustOutBillController.cs" />
    <Compile Include="Controllers\CJGL\Sc_WorkBillAutoSortBillMainController.cs" />
    <Compile Include="Controllers\Gy_MateMouldController.cs" />
    <Compile Include="Controllers\MJGL\Sc_MouldLifeUseBillController.cs" />
    <Compile Include="Controllers\MJGL\Sc_MouldScrapRequestBillController.cs" />
    <Compile Include="Controllers\MJGL\Sc_MouldStatusChangeBillController.cs" />
    <Compile Include="Controllers\Pay_ReportController.cs" />
    <Compile Include="Controllers\SBGL\Sb_EquipSparepartsBillController.cs" />
    <Compile Include="Controllers\SBGL\Sb_EquipSparepartsChangeBillController.cs" />
    <Compile Include="Controllers\SBGL\Sb_EquipStatusChangeBillController.cs" />
    <Compile Include="Controllers\SCGL\Sc_ComplementGoodBill_ZXBZController.cs" />
    <Compile Include="Controllers\SCGL\日计划管理\DataHelper.cs" />
    <Compile Include="Controllers\SCGL\日计划管理\JIT_Cg_PODemandPlanBillController.cs" />
@@ -452,7 +456,9 @@
    <Compile Include="Controllers\基础资料\基础资料\Gy_COMMONCONTACTBillController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Gy_CustLocationController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Gy_DutyBillController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Gy_EquipStatusController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Gy_MatePriceSupController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Gy_MouldStatusController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Gy_OperatorController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Gy_PaymentConditionListBillController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Gy_RateTypeController.cs" />
@@ -902,10 +908,12 @@
    <Folder Include="Views\Gy_ConkType\" />
    <Folder Include="Views\Gy_CustLocation\" />
    <Folder Include="Views\Gy_DutyBill\" />
    <Folder Include="Views\Gy_EquipStatus\" />
    <Folder Include="Views\Gy_EquipType\" />
    <Folder Include="Views\Gy_ICBomBill\" />
    <Folder Include="Views\Gy_MateMould\" />
    <Folder Include="Views\Gy_MatePriceSup\" />
    <Folder Include="Views\Gy_MouldStatus\" />
    <Folder Include="Views\Gy_Operator\" />
    <Folder Include="Views\Gy_PackType\" />
    <Folder Include="Views\Gy_PaymentConditionListBill\" />
@@ -942,13 +950,17 @@
    <Folder Include="Views\Sb_EquipRepairSendWorkBill\" />
    <Folder Include="Views\Sb_EquipSparepartsBill\" />
    <Folder Include="Views\Sb_EquipSparepartsChangeBill\" />
    <Folder Include="Views\Sb_EquipStatusChangeBill\" />
    <Folder Include="Views\Sc_CallGoodsBackRequestBill\" />
    <Folder Include="Views\Sc_ComplementGoodBill\" />
    <Folder Include="Views\Sc_ComplementGoodBill_ZXBZ\" />
    <Folder Include="Views\Sc_ComplementGoods\" />
    <Folder Include="Views\Sc_JIT_ComplementGoodBill\" />
    <Folder Include="Views\Sc_MouldLifeUseBill\" />
    <Folder Include="Views\Sc_MouldRepairOutBill\" />
    <Folder Include="Views\Sc_MouldRepairSendWorkBill\" />
    <Folder Include="Views\Sc_MouldScrapRequestBill\" />
    <Folder Include="Views\Sc_MouldStatusChangeBill\" />
    <Folder Include="Views\Sc_WorkBillAutoSortBillMain\" />
    <Folder Include="Views\Sc_WorkBillSortBill\" />
    <Folder Include="Views\Sc_WorkDemandPlanBill\" />