yusijie
2023-08-07 3d0568d206f913ddcbc9cb8df956af8619df2242
Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API
5个文件已修改
8个文件已添加
6931 ■■■■■ 已修改文件
WebAPI/Controllers/人事管理/职员异动单/HR_EmpChangeBillController.cs 810 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/工资管理/Pay_DuSubsidyItemBillController.cs 802 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/工资管理/Pay_ErrWorkTimesRequestBillController.cs 865 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/工资管理/Pay_GroupBalBillController.cs 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/工资管理/Pay_OutApplyBillController.cs 838 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/工资管理/Pay_OverApplyBillController.cs 825 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/工资管理/Pay_PayMentBillController.cs 877 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/工资管理/Pay_ProcPriceRequestBillController.cs 841 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/工资管理/Pay_SalaryCalculateController.cs 939 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/工资管理/Pay_SingleBalBillController.cs 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/工资管理/Pay_WorkTimesBillController.cs 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Properties/PublishProfiles/FolderProfile.pubxml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/WebAPI.csproj 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/ÈËʹÜÀí/Ö°Ô±Ò춯µ¥/HR_EmpChangeBillController.cs
New file
@@ -0,0 +1,810 @@
using DBUtility;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Windows.Forms;
using WebAPI.Models;
namespace WebAPI.Controllers.项目管理.工作任务
{
    public class HR_EmpChangeBillController : ApiController
    {
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更)
        private json objJsonResult = new json();
        public DataSet ds = new DataSet();
        public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill();
        string user_LongShan = "";
        string HName_LongShan = "";
        #region èŒå‘˜å¼‚动单 æ–°å¢ž/编辑
        #region èŒå‘˜å¼‚动单 è¡¨å¤´æ•°æ®
        public class HR_EmpChangeBillMain
        {
            public int HInterID;
            public string HBillNo;
            public string HDate;
            public string HInnerBillNo;
            public int HDeptID;
            public string HDeptName;
            public string HExplanation;
            public string HRemark;
            public string HMaker;
            public string HMakerDate;
            public string HUpdater;
            public string HUpdaterDate;
            public string HChecker;
            public string HCheckerDate;
            public string HCloseMan;
            public string HCloseManDate;
            public string HDeleteMan;
            public string HDeleteManDate;
            public string HBacker;
            public string HBackerDate;
            public string HBackRemark;
        }
        #endregion
        #region èŒå‘˜å¼‚动单 å­è¡¨æ•°æ®
        public class HR_EmpChangeBillSub
        {
            public int HEmpID;
            public string HEmpNumber;
            public string HEmpName;
            public int HOldDeptID;
            public string HOldDeptNumber;
            public string HOldDeptName;
            public int HDeptID;
            public string HDeptNumber;
            public string HDeptName;
            public int HOldGroupID;
            public string HOldGroupNumber;
            public string HOldGroupName;
            public int HGroupID;
            public string HGroupNumber;
            public string HGroupName;
            public int HOldPostID;
            public string HOldPostNumber;
            public string HOldPostName;
            public int HPostID;
            public string HPostNumber;
            public string HPostName;
            public string HReason;
        }
        #endregion
        #region èŒå‘˜å¼‚动单 æ–°å¢ž/编辑
        /// <summary>
        /// æ–°å¢žå•据-保存按钮
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("HR_EmpChangeBill/AddEmpChangeBill")]
        [HttpPost]
        public object AddBill_HR_EmpChangeBilll([FromBody] JObject sMainSub)
        {
            //获取参数
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            //开始事务
            oCN.BeginTran();
            //保存主表
            objJsonResult = AddBillMain_HR_EmpChangeBill(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 = ds.Tables[0];
            return objJsonResult;
        }
        #endregion
        #region æ·»åŠ  èŒå‘˜å¼‚动单 ä¸»è¡¨
        public json AddBillMain_HR_EmpChangeBill(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修改 2 å¤åˆ¶
            string user = sArray[3].ToString();//用户名
            string HComputerName = SystemInformation.ComputerName; //设备名称
            try
            {
                if (OperationType == 1)
                {
                    //判断是否有编辑权限
                    if (!DBUtility.ClsPub.Security_Log("HR_EmpChangeBill_Edit", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "无新增权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else if (OperationType == 3)
                {
                    //判断是否有编辑权限
                    if (!DBUtility.ClsPub.Security_Log("HR_EmpChangeBill_Edit", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "无编辑权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                msg2 = "[" + msg2.ToString() + "]";
                List<HR_EmpChangeBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HR_EmpChangeBillMain>>(msg2);
                int HYear = int.Parse(mainList[0].HDate.Split('-')[0]);
                int HPeriod = int.Parse(mainList[0].HDate.Split('-')[1]);
                string HBillType = "2310";
                string HBillSubType = "";
                int HBillStatus = 1;
                int HInterID = mainList[0].HInterID;
                string HBillNo = mainList[0].HBillNo;
                string HDate = mainList[0].HDate;
                string HInnerBillNo = mainList[0].HInnerBillNo;
                int HDeptID = mainList[0].HDeptID;
                string HExplanation = mainList[0].HExplanation;
                string HRemark = mainList[0].HRemark;
                string HMaker = mainList[0].HMaker;
                string HMakerDate = mainList[0].HMakerDate;
                string HUpdater = mainList[0].HUpdater;
                string HUpdaterDate = mainList[0].HUpdaterDate;
                string HChecker = mainList[0].HChecker;
                string HCheckerDate = mainList[0].HCheckerDate;
                string HCloseMan = mainList[0].HCloseMan;
                string HCloseManDate = mainList[0].HCloseManDate;
                string HDeleteMan = mainList[0].HDeleteMan;
                string HDeleteManDate = mainList[0].HDeleteManDate;
                string HBacker = mainList[0].HBacker;
                string HBackerDate = mainList[0].HBackerDate;
                string HBackRemark = mainList[0].HBackRemark;
                //if (OperationType == 2)
                //{
                //    ds = oCN.RunProcReturn("select * from PM_ProjectBillMain where HBillNo ='" + HBillNo + "'", "PM_ProjectBillMain");
                //    if (ds.Tables[0].Rows.Count > 0)
                //    {
                //        objJsonResult.code = "0";
                //        objJsonResult.count = 0;
                //        objJsonResult.Message = "单据号重复,请重新输入!";
                //        objJsonResult.data = null;
                //        return objJsonResult;
                //    }
                //}
                ds = oCN.RunProcReturn("select * from HR_EmpChangeBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "HR_EmpChangeBillMain");
                if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//新增
                {
                    string sql = "insert into HR_EmpChangeBillMain" +
                        "(HYear,HPeriod,HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate,HInnerBillNo,HDeptID,HExplanation,HRemark, HMaker,HMakeDate) " +
                        "values(" +
                        "" + HYear +
                        "," + HPeriod +
                        ",'" + HBillType +
                        "','" + HBillSubType +
                        "'," + HBillStatus +
                        "," + HInterID +
                        ",'" + HBillNo +
                        "','" + HDate +
                        "','" + HInnerBillNo +
                        "'," + HDeptID +
                        ",'" + HExplanation +
                        "','" + HRemark +
                        "','" + HMaker +
                        "','" + HMakerDate +
                        "')";
                    //主表
                    oCN.RunProc(sql);
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",新增职员异动单:" + HBillNo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "新增职员异动单:" + HBillNo + "','LMES-职员异动单模块','" + DBUtility.ClsPub.IPAddress + "','新增单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)                    //编辑
                {
                    string sql = "update HR_EmpChangeBillMain set " +
                        "HYear = " + HYear +
                        ", HPeriod = " + HPeriod +
                        ", HBillNo = '" + HBillNo +
                        "', HDate = '" + HDate +
                        "', HInnerBillNo = '" + HInnerBillNo +
                        "', HDeptID = " + HDeptID +
                        ", HExplanation = '" + HExplanation +
                        "', HRemark = '" + HRemark +
                        "', HUpdater = '" + HUpdater +
                        "', HUpdateDate = '" + HUpdaterDate +
                        "' where HInterID = " + HInterID;
                    oCN.RunProc(sql);
                    //删除子表
                    oCN.RunProc("delete from HR_EmpChangeBillSub where HInterID= " + HInterID);
                    //记录日志
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",修改职员异动单:" + HBillNo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "修改职员异动单:" + HBillNo + "','LMES-职员异动单模块','" + DBUtility.ClsPub.IPAddress + "','修改单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                //保存子表
                objJsonResult = AddBillSub1_HR_EmpChangeBill(msg3, HInterID, HBillNo, 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;
            }
        }
        #endregion
        #region æ·»åŠ  èŒå‘˜å¼‚动表 å­è¡¨
        public json AddBillSub1_HR_EmpChangeBill(string msg3, long HInterID, string HBillNo, int OperationType)
        {
            List<HR_EmpChangeBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HR_EmpChangeBillSub>>(msg3);
            int i = 0;                                          //作为子表内码
            foreach (HR_EmpChangeBillSub oSub in DetailColl)
            {
                i++;                                            //同一个主表下的子表的内码自增
                int HEntryID = i;
                int HEmpID = oSub.HEmpID;
                int HOldDeptID = oSub.HOldDeptID;
                int HDeptID = oSub.HDeptID;
                int HOldGroupID = oSub.HOldGroupID;
                int HGroupID = oSub.HGroupID;
                int HOldPostID = oSub.HOldPostID;
                int HPostID = oSub.HPostID;
                string HReason = oSub.HReason;
                string sql = "insert into HR_EmpChangeBillSub" +
                    "(HInterID,HEntryID,HEmpID,HOldDeptID,HDeptID,HOldGroupID,HGroupID,HOldPostID,HPostID,HReason) " +
                    "values(" +
                    "" + HInterID +
                    "," + HEntryID +
                    "," + HEmpID +
                    "," + HOldDeptID +
                    "," + HDeptID +
                    "," + HOldGroupID +
                    "," + HGroupID +
                    "," + HOldPostID +
                    "," + HPostID +
                    ",'" + HReason +
                    "')";
                oCN.RunProc(sql);
            }
            objJsonResult.code = "1";
            objJsonResult.count = 1;
            objJsonResult.Message = null;
            objJsonResult.data = null;
            return objJsonResult;
        }
        #endregion
        #endregion
        #region èŒå‘˜å¼‚动单 ç¼–辑-页面赋值
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("HR_EmpChangeBill/editInit")]
        [HttpGet]
        public object getEmpChangeBilleditInit(string HInterID, string user)
        {
            try
            {
                List<DataTable> tableList = new List<DataTable>();
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("HR_EmpChangeBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无编辑权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (HInterID == null || HInterID.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID不能为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("exec h_p_HR_EmpChangeBill_EditInit " + HInterID, "h_p_HR_EmpChangeBill_EditInit");
                tableList.Add(ds.Tables[0]);
                tableList.Add(ds.Tables[1]);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = tableList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region èŒå‘˜å¼‚动单 æŸ¥è¯¢
        [Route("HR_EmpChangeBill/list")]
        [HttpGet]
        public object getEmpChangeBillList(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("HR_EmpChangeBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_HR_EmpChangeBillList order by hmainid desc", "h_v_HR_EmpChangeBillList");
                }
                else
                {
                    string sql1 = "select * from h_v_HR_EmpChangeBillList where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by hmainid desc";
                    ds = oCN.RunProcReturn(sql, "h_v_HR_EmpChangeBillList");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region èŒå‘˜å¼‚动单 åˆ é™¤
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("HR_EmpChangeBill/delete")]
        [HttpGet]
        public object deleteEmpChangeBill(string HInterID, string user)
        {
            try
            {
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("HR_EmpChangeBill_Drop", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无删除权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (HInterID == null || HInterID.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID不能为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();
                oCN.RunProc("delete from HR_EmpChangeBillMain where HInterID = " + HInterID);
                oCN.RunProc("delete from HR_EmpChangeBillSub where HInterID= " + HInterID);
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region èŒå‘˜å¼‚动单 å®¡æ ¸/反审核
        /// <summary>
        ///
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">审核(0),反审核(1)</param>
        /// <param name="CurUserName">审核人</param>
        /// <returns></returns>
        [Route("HR_EmpChangeBill/AuditHR_EmpChangeBill")]
        [HttpGet]
        public object AuditHR_EmpChangeBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有审核权限
                if (!DBUtility.ClsPub.Security_Log("HR_EmpChangeBill_Check", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限审核!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "HR_EmpChangeBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 å®¡æ ¸  2  åå®¡æ ¸
                if (Type == 1)
                {
                    //判断单据是否已经审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已审核!不需要再审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //审核单据
                    if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反审核!不需要再反审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反审核单据
                    if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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
        #region èŒå‘˜å¼‚动单 å…³é—­/反关闭功能
        [Route("HR_EmpChangeBill/CloseHR_EmpChangeBill")]
        [HttpGet]
        public object CloseHR_EmpChangeBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("HR_EmpChangeBill_Close", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限关闭!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "HR_EmpChangeBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 å…³é—­  2  åå…³é—­
                if (Type == 1)
                {
                    //判断单据是否已经关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已关闭!不需要再关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //关闭单据
                    if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反关闭!不需要再反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反关闭单据
                    if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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
        #region èŒå‘˜å¼‚动单 ä½œåºŸ/反作废功能
        [Route("HR_EmpChangeBill/DropHR_EmpChangeBill")]
        [HttpGet]
        public object DropHR_EmpChangeBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有作废权限
                if (!DBUtility.ClsPub.Security_Log("HR_EmpChangeBill_Delete", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限作废!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "HR_EmpChangeBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 ä½œåºŸ  2  åä½œåºŸ
                if (Type == 1)
                {
                    //判断单据是否已经作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已作废!不需要再作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //作废单据
                    if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "作废失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] == null || ds.Tables[0].Rows[0]["HDeleteMan"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反作废!不需要再反作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反作废单据
                    if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反作废失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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/¹¤×ʹÜÀí/Pay_DuSubsidyItemBillController.cs
New file
@@ -0,0 +1,802 @@
using DBUtility;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Windows.Forms;
using WebAPI.Models;
namespace WebAPI.Controllers.项目管理.工作任务
{
    public class Pay_DuSubsidyItemBillController : ApiController
    {
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更)
        private json objJsonResult = new json();
        public DataSet ds = new DataSet();
        public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill();
        string user_LongShan = "";
        string HName_LongShan = "";
        #region æ‰£è¡¥é¡¹ç›®è´¹ç”¨å• æ–°å¢ž/编辑
        #region æ‰£è¡¥é¡¹ç›®è´¹ç”¨å• è¡¨å¤´æ•°æ®
        public class Pay_DuSubsidyItemBillMain
        {
            public int HInterID;
            public string HBillNo;
            public string HDate;
            public string HInnerBillNo;
            public int HGroupID;
            public string HGroupName;
            public int HDeptID;
            public string HDeptName;
            public string HExplanation;
            public string HRemark;
            public string HMaker;
            public string HMakerDate;
            public string HUpdater;
            public string HUpdaterDate;
            public string HChecker;
            public string HCheckerDate;
            public string HCloseMan;
            public string HCloseManDate;
            public string HDeleteMan;
            public string HDeleteManDate;
            public string HBacker;
            public string HBackerDate;
            public string HBackRemark;
        }
        #endregion
        #region æ‰£è¡¥é¡¹ç›®è´¹ç”¨å• å­è¡¨æ•°æ®
        public class Pay_DuSubsidyItemBillSub
        {
            public int HEmpID;
            public string HEmpNumber;
            public string HEmpName;
            public int HDuSubsidyItemID;
            public string HDuSubsidyItemNumber;
            public string HDuSubsidyItemName;
            public double HQty;
            public double HPrice;
            public double HMoney;
            public string HRemark;
        }
        #endregion
        #region æ‰£è¡¥é¡¹ç›®è´¹ç”¨å• æ–°å¢ž/编辑
        /// <summary>
        /// æ–°å¢žå•据-保存按钮
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Pay_DuSubsidyItemBill/AddDuSubsidyItemBill")]
        [HttpPost]
        public object AddBill_Pay_DuSubsidyItemBill([FromBody] JObject sMainSub)
        {
            //获取参数
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            //开始事务
            oCN.BeginTran();
            //保存主表
            objJsonResult = AddBillMain_Pay_DuSubsidyItemBill(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 = ds.Tables[0];
            return objJsonResult;
        }
        #endregion
        #region æ·»åŠ  æ‰£è¡¥é¡¹ç›®è´¹ç”¨å• ä¸»è¡¨
        public json AddBillMain_Pay_DuSubsidyItemBill(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修改 2 å¤åˆ¶
            string user = sArray[3].ToString();//用户名
            string HComputerName = SystemInformation.ComputerName; //设备名称
            try
            {
                if (OperationType == 1)
                {
                    //判断是否有编辑权限
                    if (!DBUtility.ClsPub.Security_Log("Pay_DuSubsidyItemBill_Edit", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "无新增权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else if (OperationType == 3)
                {
                    //判断是否有编辑权限
                    if (!DBUtility.ClsPub.Security_Log("Pay_DuSubsidyItemBill_Edit", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "无编辑权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                msg2 = "[" + msg2.ToString() + "]";
                List<Pay_DuSubsidyItemBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Pay_DuSubsidyItemBillMain>>(msg2);
                int HYear = int.Parse(mainList[0].HDate.Split('-')[0]);
                int HPeriod = int.Parse(mainList[0].HDate.Split('-')[1]);
                string HBillType = "2233";
                string HBillSubType = "";
                int HBillStatus = 1;
                int HAutoSaveFlag = 0;
                int HInterID = mainList[0].HInterID;
                string HBillNo = mainList[0].HBillNo;
                string HDate = mainList[0].HDate;
                string HInnerBillNo = mainList[0].HInnerBillNo;
                int HGroupID = mainList[0].HGroupID;
                int HDeptID = mainList[0].HDeptID;
                string HExplanation = mainList[0].HExplanation;
                string HRemark = mainList[0].HRemark;
                string HMaker = mainList[0].HMaker;
                string HMakerDate = mainList[0].HMakerDate;
                string HUpdater = mainList[0].HUpdater;
                string HUpdaterDate = mainList[0].HUpdaterDate;
                string HChecker = mainList[0].HChecker;
                string HCheckerDate = mainList[0].HCheckerDate;
                string HCloseMan = mainList[0].HCloseMan;
                string HCloseManDate = mainList[0].HCloseManDate;
                string HDeleteMan = mainList[0].HDeleteMan;
                string HDeleteManDate = mainList[0].HDeleteManDate;
                string HBacker = mainList[0].HBacker;
                string HBackerDate = mainList[0].HBackerDate;
                string HBackRemark = mainList[0].HBackRemark;
                //if (OperationType == 2)
                //{
                //    ds = oCN.RunProcReturn("select * from PM_ProjectBillMain where HBillNo ='" + HBillNo + "'", "PM_ProjectBillMain");
                //    if (ds.Tables[0].Rows.Count > 0)
                //    {
                //        objJsonResult.code = "0";
                //        objJsonResult.count = 0;
                //        objJsonResult.Message = "单据号重复,请重新输入!";
                //        objJsonResult.data = null;
                //        return objJsonResult;
                //    }
                //}
                ds = oCN.RunProcReturn("select * from Pay_DuSubsidyItemBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "Pay_DuSubsidyItemBillMain");
                if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//新增
                {
                    string sql = "insert into Pay_DuSubsidyItemBillMain" +
                        "(HYear,HPeriod,HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate,HInnerBillNo,HGroupID,HDeptID,HExplanation,HAutoSaveFlag,HRemark,HMaker,HMakeDate) " +
                        "values(" +
                        "" + HYear +
                        "," + HPeriod +
                        ",'" + HBillType +
                        "','" + HBillSubType +
                        "'," + HBillStatus +
                        "," + HInterID +
                        ",'" + HBillNo +
                        "','" + HDate +
                        "','" + HInnerBillNo +
                        "'," + HGroupID +
                        "," + HDeptID +
                        ",'" + HExplanation +
                        "'," + HAutoSaveFlag +
                        ",'" + HRemark +
                        "','" + HMaker +
                        "','" + HMakerDate +
                        "')";
                    //主表
                    oCN.RunProc(sql);
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",新增扣补项目费用单:" + HBillNo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "新增扣补项目费用单:" + HBillNo + "','LMES-扣补项目费用单模块','" + DBUtility.ClsPub.IPAddress + "','新增单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)                    //编辑
                {
                    string sql = "update Pay_DuSubsidyItemBillMain set " +
                        "HYear = " + HYear +
                        ", HPeriod = " + HPeriod +
                        ", HBillNo = '" + HBillNo +
                        "', HDate = '" + HDate +
                        "', HInnerBillNo = '" + HInnerBillNo +
                        "', HGroupID = " + HGroupID +
                        ", HDeptID = " + HDeptID +
                        ", HExplanation = '" + HExplanation +
                        "', HRemark = '" + HRemark +
                        "', HUpdater = '" + HUpdater +
                        "', HUpdateDate = '" + HUpdaterDate +
                        "' where HInterID = " + HInterID;
                    oCN.RunProc(sql);
                    //删除子表
                    oCN.RunProc("delete from Pay_DuSubsidyItemBillSub where HInterID= " + HInterID);
                    //记录日志
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",修改扣补项目费用单:" + HBillNo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "修改扣补项目费用单:" + HBillNo + "','LMES-扣补项目费用单模块','" + DBUtility.ClsPub.IPAddress + "','修改单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                //保存子表
                objJsonResult = AddBillSub1_Pay_DuSubsidyItemBill(msg3, HInterID, HBillNo, 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;
            }
        }
        #endregion
        #region æ·»åŠ  æ‰£è¡¥é¡¹ç›®è´¹ç”¨å• å­è¡¨
        public json AddBillSub1_Pay_DuSubsidyItemBill(string msg3, long HInterID, string HBillNo, int OperationType)
        {
            List<Pay_DuSubsidyItemBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Pay_DuSubsidyItemBillSub>>(msg3);
            int i = 0;                                          //作为子表内码
            foreach (Pay_DuSubsidyItemBillSub oSub in DetailColl)
            {
                i++;                                            //同一个主表下的子表的内码自增
                int HEntryID = i;
                int HEmpID = oSub.HEmpID;
                int HDuSubsidyItemID = oSub.HDuSubsidyItemID;
                double HQty = oSub.HQty;
                double HPrice = oSub.HPrice;
                double HMoney = oSub.HMoney;
                string HRemark = oSub.HRemark;
                string sql = "insert into Pay_DuSubsidyItemBillSub" +
                    "(HInterID,HEntryID,HEmpID,HDuSubsidyItemID,HQty,HPrice,HMoney,HRemark) " +
                    "values(" +
                    "" + HInterID +
                    "," + HEntryID +
                    "," + HEmpID +
                    "," + HDuSubsidyItemID +
                    "," + HQty +
                    "," + HPrice +
                    "," + HMoney +
                    ",'" + HRemark +
                    "')";
                oCN.RunProc(sql);
            }
            objJsonResult.code = "1";
            objJsonResult.count = 1;
            objJsonResult.Message = null;
            objJsonResult.data = null;
            return objJsonResult;
        }
        #endregion
        #endregion
        #region æ‰£è¡¥é¡¹ç›®è´¹ç”¨å• ç¼–辑-页面赋值
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("Pay_DuSubsidyItemBill/editInit")]
        [HttpGet]
        public object getDuSubsidyItemBilleditInit(string HInterID, string user)
        {
            try
            {
                List<DataTable> tableList = new List<DataTable>();
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Pay_DuSubsidyItemBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无编辑权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (HInterID == null || HInterID.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID不能为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("exec h_p_Pay_DuSubsidyItemBill_EditInit " + HInterID, "h_p_Pay_DuSubsidyItemBill_EditInit");
                tableList.Add(ds.Tables[0]);
                tableList.Add(ds.Tables[1]);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = tableList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region æ‰£è¡¥é¡¹ç›®è´¹ç”¨å• æŸ¥è¯¢
        [Route("Pay_DuSubsidyItemBill/list")]
        [HttpGet]
        public object getDuSubsidyItemBillList(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Pay_DuSubsidyItemBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Pay_DuSubsidyItemBillList order by hmainid desc", "h_v_Pay_DuSubsidyItemBillList");
                }
                else
                {
                    string sql1 = "select * from h_v_Pay_DuSubsidyItemBillList where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by hmainid desc";
                    ds = oCN.RunProcReturn(sql, "h_v_Pay_DuSubsidyItemBillList");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region æ‰£è¡¥é¡¹ç›®è´¹ç”¨å• åˆ é™¤
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("Pay_DuSubsidyItemBill/delete")]
        [HttpGet]
        public object deleteDuSubsidyItemBill(string HInterID, string user)
        {
            try
            {
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Pay_DuSubsidyItemBill_Delete", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无删除权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (HInterID == null || HInterID.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID不能为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();
                oCN.RunProc("delete from Pay_DuSubsidyItemBillMain where HInterID = " + HInterID);
                oCN.RunProc("delete from Pay_DuSubsidyItemBillSub where HInterID= " + HInterID);
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region æ‰£è¡¥é¡¹ç›®è´¹ç”¨å• å®¡æ ¸/反审核
        /// <summary>
        ///
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">审核(0),反审核(1)</param>
        /// <param name="CurUserName">审核人</param>
        /// <returns></returns>
        [Route("Pay_DuSubsidyItemBill/AuditPay_DuSubsidyItemBill")]
        [HttpGet]
        public object AuditPay_DuSubsidyItemBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有审核权限
                if (!DBUtility.ClsPub.Security_Log("Pay_DuSubsidyItemBill_Check", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限审核!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_DuSubsidyItemBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 å®¡æ ¸  2  åå®¡æ ¸
                if (Type == 1)
                {
                    //判断单据是否已经审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已审核!不需要再审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //审核单据
                    if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反审核!不需要再反审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反审核单据
                    if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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
        #region æ‰£è¡¥é¡¹ç›®è´¹ç”¨å• å…³é—­/反关闭功能
        [Route("Pay_DuSubsidyItemBill/ClosePay_DuSubsidyItemBill")]
        [HttpGet]
        public object ClosePay_DuSubsidyItemBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Pay_DuSubsidyItemBill_Close", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限关闭!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_DuSubsidyItemBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 å…³é—­  2  åå…³é—­
                if (Type == 1)
                {
                    //判断单据是否已经关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已关闭!不需要再关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //关闭单据
                    if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反关闭!不需要再反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反关闭单据
                    if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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
        #region æ‰£è¡¥é¡¹ç›®è´¹ç”¨å• ä½œåºŸ/反作废功能
        [Route("Pay_DuSubsidyItemBill/DropPay_DuSubsidyItemBill")]
        [HttpGet]
        public object DropPay_DuSubsidyItemBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有作废权限
                if (!DBUtility.ClsPub.Security_Log("Pay_DuSubsidyItemBill_Drop", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限作废!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_DuSubsidyItemBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 ä½œåºŸ  2  åä½œåºŸ
                if (Type == 1)
                {
                    //判断单据是否已经作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已作废!不需要再作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //作废单据
                    if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "作废失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] == null || ds.Tables[0].Rows[0]["HDeleteMan"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反作废!不需要再反作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反作废单据
                    if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反作废失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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/¹¤×ʹÜÀí/Pay_ErrWorkTimesRequestBillController.cs
New file
@@ -0,0 +1,865 @@
using DBUtility;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Windows.Forms;
using WebAPI.Models;
namespace WebAPI.Controllers.项目管理.工作任务
{
    public class Pay_ErrWorkTimesRequestBillController : ApiController
    {
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更)
        private json objJsonResult = new json();
        public DataSet ds = new DataSet();
        public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill();
        string user_LongShan = "";
        string HName_LongShan = "";
        #region å¼‚常工时申请单
        #region è¡¨å¤´
        public class Pay_ErrWorkTimesRequestBillMain
        {
            public int HInterID;
            public string HBillNo;
            public string HDate;
            public string HInnerBillNo;
            public int HDeptID;
            public string HDeptName;
            public int HGroupID;
            public string HGroupName;
            public int HMangerID;
            public string HManagerName;
            public int HICMOInterID;
            public string HICMOBillNo;
            public string HExplanation;
            public double HSumRequestTimes;
            public int HMaterID;
            public string HMaterName;
            public int HUnitID;
            public string HUnitName;
            public double HPlanQty;
            public string HBatchNo;
            public string HRemark;
            public string HMaker;
            public string HMakerDate;
            public string HUpdater;
            public string HUpdaterDate;
            public string HChecker;
            public string HCheckerDate;
            public string HCloseMan;
            public string HCloseManDate;
            public string HDeleteMan;
            public string HDeleteManDate;
            public string HBacker;
            public string HBackerDate;
            public string HBackRemark;
        }
        #endregion
        #region å­è¡¨
        public class Pay_ErrWorkTimesRequestBillSub
        {
            public int HEmpID;
            public string HEmpNumber;
            public string HEmpName;
            public int HWorkTypeID;
            public string HWorkTypeNumber;
            public string HWorkTypeName;
            public double HPayMoney;
            public string HBTimes;
            public string HETimes;
            public double HTimes;
            public double HRelTimes;
            public double HRelPay;
            public string HRemark;
            public int HSourceInterID;
            public int HSourceEntryID;
            public string HSourceBillNo;
            public string HSourceBillType;
            public double HRelationQty;
            public double HRelationMoney;
            public string HCloseMan;
            public string HEntryCloseDate;
        }
        #endregion
        #region å¼‚常工时申请单 æ–°å¢ž/编辑
        /// <summary>
        /// æ–°å¢žå•据-保存按钮
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Pay_ErrWorkTimesRequestBill/AddErrWorkTimesRequestBill")]
        [HttpPost]
        public object AddBill_Pay_ErrWorkTimesRequestBill([FromBody] JObject sMainSub)
        {
            //获取参数
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            //开始事务
            oCN.BeginTran();
            //保存主表
            objJsonResult = AddBillMain_Pay_ErrWorkTimesRequestBill(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 = ds.Tables[0];
            return objJsonResult;
        }
        #endregion
        #region æ·»åŠ  å¼‚常工时申请单 ä¸»è¡¨
        public json AddBillMain_Pay_ErrWorkTimesRequestBill(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修改 2 å¤åˆ¶
            string user = sArray[3].ToString();//用户名
            string HComputerName = SystemInformation.ComputerName; //设备名称
            try
            {
                if (OperationType == 1)
                {
                    //判断是否有编辑权限
                    if (!DBUtility.ClsPub.Security_Log("Pay_ErrWorkTimesRequestBill_Edit", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "无新增权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else if (OperationType == 3)
                {
                    //判断是否有编辑权限
                    if (!DBUtility.ClsPub.Security_Log("Pay_ErrWorkTimesRequestBill_Edit", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "无编辑权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                msg2 = "[" + msg2.ToString() + "]";
                List<Pay_ErrWorkTimesRequestBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Pay_ErrWorkTimesRequestBillMain>>(msg2);
                int HYear = int.Parse(mainList[0].HDate.Split('-')[0]);
                int HPeriod = int.Parse(mainList[0].HDate.Split('-')[1]);
                string HBillType = "2231";
                string HBillSubType = "";
                int HBillStatus = 1;
                int HInterID = mainList[0].HInterID;
                string HBillNo = mainList[0].HBillNo;
                string HDate = mainList[0].HDate;
                string HInnerBillNo = mainList[0].HInnerBillNo;
                int HDeptID = mainList[0].HDeptID;
                int HGroupID = mainList[0].HGroupID;
                int HMangerID = mainList[0].HMangerID;
                int HICMOInterID = mainList[0].HICMOInterID;
                string HICMOBillNo = mainList[0].HICMOBillNo;
                string HExplanation = mainList[0].HExplanation;
                double HSumRequestTimes = mainList[0].HSumRequestTimes;
                int HMaterID = mainList[0].HMaterID;
                int HUnitID = mainList[0].HUnitID;
                double HPlanQty = mainList[0].HPlanQty;
                string HBatchNo = mainList[0].HBatchNo;
                string HRemark = mainList[0].HRemark;
                string HMaker = mainList[0].HMaker;
                string HMakerDate = mainList[0].HMakerDate;
                string HUpdater = mainList[0].HUpdater;
                string HUpdaterDate = mainList[0].HUpdaterDate;
                string HChecker = mainList[0].HChecker;
                string HCheckerDate = mainList[0].HCheckerDate;
                string HCloseMan = mainList[0].HCloseMan;
                string HCloseManDate = mainList[0].HCloseManDate;
                string HDeleteMan = mainList[0].HDeleteMan;
                string HDeleteManDate = mainList[0].HDeleteManDate;
                string HBacker = mainList[0].HBacker;
                string HBackerDate = mainList[0].HBackerDate;
                string HBackRemark = mainList[0].HBackRemark;
                //if (OperationType == 2)
                //{
                //    ds = oCN.RunProcReturn("select * from PM_ProjectBillMain where HBillNo ='" + HBillNo + "'", "PM_ProjectBillMain");
                //    if (ds.Tables[0].Rows.Count > 0)
                //    {
                //        objJsonResult.code = "0";
                //        objJsonResult.count = 0;
                //        objJsonResult.Message = "单据号重复,请重新输入!";
                //        objJsonResult.data = null;
                //        return objJsonResult;
                //    }
                //}
                ds = oCN.RunProcReturn("select * from Pay_ErrWorkTimesRequestBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "Pay_ErrWorkTimesRequestBillMain");
                if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//新增
                {
                    string sql = "insert into Pay_ErrWorkTimesRequestBillMain" +
                        "(HYear,HPeriod,HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate,HInnerBillNo,HDeptID,HGroupID,HMangerID,HICMOInterID,HICMOBillNo,HExplanation,HSumRequestTimes,HMaterID,HUnitID,HPlanQty,HBatchNo,HRemark, HMaker,HMakeDate) " +
                        "values(" +
                        "" + HYear +
                        "," + HPeriod +
                        ",'" + HBillType +
                        "','" + HBillSubType +
                        "'," + HBillStatus +
                        "," + HInterID +
                        ",'" + HBillNo +
                        "','" + HDate +
                        "','" + HInnerBillNo +
                        "'," + HDeptID +
                        "," + HGroupID +
                        "," + HMangerID +
                        "," + HICMOInterID +
                        ",'" + HICMOBillNo +
                        "','" + HExplanation +
                        "'," + HSumRequestTimes +
                        "," + HMaterID +
                        "," + HUnitID +
                        "," + HPlanQty +
                        ",'" + HBatchNo +
                        "','" + HRemark +
                        "','" + HMaker +
                        "','" + HMakerDate +
                        "')";
                    //主表
                    oCN.RunProc(sql);
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",新增异常工时申请单:" + HBillNo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "新增异常工时申请单:" + HBillNo + "','LMES-异常工时申请单模块','" + DBUtility.ClsPub.IPAddress + "','新增单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)                    //编辑
                {
                    string sql = "update Pay_ErrWorkTimesRequestBillMain set " +
                        "HYear = " + HYear +
                        ", HPeriod = " + HPeriod +
                        ", HBillNo = '" + HBillNo +
                        "', HDate = '" + HDate +
                        "', HInnerBillNo = '" + HInnerBillNo +
                        "', HDeptID = " + HDeptID +
                        ", HGroupID = " + HGroupID +
                        ", HMangerID = " + HMangerID +
                        ", HICMOInterID = " + HICMOInterID +
                        ", HICMOBillNo = '" + HICMOBillNo +
                        "', HExplanation = '" + HExplanation +
                        "', HSumRequestTimes = " + HSumRequestTimes +
                        ", HMaterID = " + HMaterID +
                        ", HUnitID = " + HUnitID +
                        ", HPlanQty = " + HPlanQty +
                        ", HBatchNo = '" + HBatchNo +
                        "', HRemark = '" + HRemark +
                        "', HUpdater = '" + HUpdater +
                        "', HUpdateDate = '" + HUpdaterDate +
                        "' where HInterID = " + HInterID;
                    oCN.RunProc(sql);
                    //删除子表
                    oCN.RunProc("delete from Pay_ErrWorkTimesRequestBillSub where HInterID= " + HInterID);
                    //记录日志
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",修改异常工时申请单:" + HBillNo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "修改异常工时申请单:" + HBillNo + "','LMES-异常工时申请单模块','" + DBUtility.ClsPub.IPAddress + "','修改单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                //保存子表
                objJsonResult = AddBillSub1_Pay_ErrWorkTimesRequestBill(msg3, HInterID, HBillNo, 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;
            }
        }
        #endregion
        #region æ·»åŠ  å¼‚常工时申请单 å­è¡¨
        public json AddBillSub1_Pay_ErrWorkTimesRequestBill(string msg3, long HInterID, string HBillNo, int OperationType)
        {
            List<Pay_ErrWorkTimesRequestBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Pay_ErrWorkTimesRequestBillSub>>(msg3);
            int i = 0;                                          //作为子表内码
            foreach (Pay_ErrWorkTimesRequestBillSub oSub in DetailColl)
            {
                i++;                                            //同一个主表下的子表的内码自增
                int HEntryID = i;
                int HEmpID = oSub.HEmpID;
                int HWorkTypeID = oSub.HWorkTypeID;
                double HPayMoney = oSub.HPayMoney;
                string HBTimes = oSub.HBTimes;
                string HETimes = oSub.HETimes;
                double HTimes = oSub.HTimes;
                double HRelTimes = oSub.HRelTimes;
                double HRelPay = oSub.HRelPay;
                string HRemark = oSub.HRemark;
                int HSourceInterID = oSub.HSourceInterID;
                int HSourceEntryID = oSub.HSourceEntryID;
                string HSourceBillNo = oSub.HSourceBillNo;
                string HSourceBillType = oSub.HSourceBillType;
                double HRelationQty = oSub.HRelationQty;
                double HRelationMoney = oSub.HRelationMoney;
                string sql = "insert into Pay_ErrWorkTimesRequestBillSub" +
                    "(HInterID,HEntryID,HEmpID,HWorkTypeID,HPayMoney,HBTimes,HETimes,HTimes,HRelTimes,HRelPay,HRemark, HSourceInterID,HSourceEntryID,HSourceBillNo" +
                    ",HSourceBillType,HRelationQty,HRelationMoney) " +
                    "values(" +
                    "" + HInterID +
                    "," + HEntryID +
                    "," + HEmpID +
                    "," + HWorkTypeID +
                    "," + HPayMoney +
                    ",'" + HBTimes +
                    "','" + HETimes +
                    "'," + HTimes +
                    "," + HRelTimes +
                    "," + HRelPay +
                    ",'" + HRemark +
                    "'," + HSourceInterID +
                    "," + HSourceEntryID +
                    ",'" + HSourceBillNo +
                    "','" + HSourceBillType +
                    "'," + HRelationQty +
                    "," + HRelationMoney +
                    ")";
                oCN.RunProc(sql);
            }
            objJsonResult.code = "1";
            objJsonResult.count = 1;
            objJsonResult.Message = null;
            objJsonResult.data = null;
            return objJsonResult;
        }
        #endregion
        #endregion
        #region å¼‚常工时申请单 ç¼–辑-页面赋值
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("Pay_ErrWorkTimesRequestBill/editInit")]
        [HttpGet]
        public object getErrWorkTimesRequestBilleditInit(string HInterID, string user)
        {
            try
            {
                List<DataTable> tableList = new List<DataTable>();
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Pay_ErrWorkTimesRequestBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无编辑权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (HInterID == null || HInterID.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID不能为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("exec h_p_Pay_ErrWorkTimesRequestBill_EditInit " + HInterID, "h_p_Pay_ErrWorkTimesRequestBill_EditInit");
                tableList.Add(ds.Tables[0]);
                tableList.Add(ds.Tables[1]);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = tableList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å¼‚常工时申请单 æŸ¥è¯¢
        [Route("Pay_ErrWorkTimesRequestBill/list")]
        [HttpGet]
        public object getErrWorkTimesRequestBillList(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Pay_ErrWorkTimesRequestBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Pay_ErrWorkTimesRequestBillList_New order by hmainid desc", "h_v_Pay_ErrWorkTimesRequestBillList_New");
                }
                else
                {
                    string sql1 = "select * from h_v_Pay_ErrWorkTimesRequestBillList_New where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by hmainid desc";
                    ds = oCN.RunProcReturn(sql, "h_v_Pay_ErrWorkTimesRequestBillList_New");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å¼‚常工时申请单 åˆ é™¤
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("Pay_ErrWorkTimesRequestBill/delete")]
        [HttpGet]
        public object deleteErrWorkTimesRequestBill(string HInterID, string user)
        {
            try
            {
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Pay_ErrWorkTimesRequestBill_Delete", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无删除权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (HInterID == null || HInterID.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID不能为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();
                oCN.RunProc("delete from Pay_ErrWorkTimesRequestBillMain where HInterID = " + HInterID);
                oCN.RunProc("delete from Pay_ErrWorkTimesRequestBillSub where HInterID= " + HInterID);
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å¼‚常工时申请单 å®¡æ ¸/反审核
        /// <summary>
        ///
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">审核(0),反审核(1)</param>
        /// <param name="CurUserName">审核人</param>
        /// <returns></returns>
        [Route("Pay_ErrWorkTimesRequestBill/AuditPay_ErrWorkTimesRequestBill")]
        [HttpGet]
        public object AuditPay_ErrWorkTimesRequestBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有审核权限
                if (!DBUtility.ClsPub.Security_Log("Pay_ErrWorkTimesRequestBill_Check", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限审核!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_ErrWorkTimesRequestBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 å®¡æ ¸  2  åå®¡æ ¸
                if (Type == 1)
                {
                    //判断单据是否已经审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已审核!不需要再审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //审核单据
                    if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反审核!不需要再反审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反审核单据
                    if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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
        #region å¼‚常工时申请单 å…³é—­/反关闭功能
        [Route("Pay_ErrWorkTimesRequestBill/ClosePay_ErrWorkTimesRequestBill")]
        [HttpGet]
        public object ClosePay_ErrWorkTimesRequestBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Pay_ErrWorkTimesRequestBill_Close", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限关闭!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_ErrWorkTimesRequestBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 å…³é—­  2  åå…³é—­
                if (Type == 1)
                {
                    //判断单据是否已经关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已关闭!不需要再关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //关闭单据
                    if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反关闭!不需要再反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反关闭单据
                    if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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
        #region å¼‚常工时申请单 ä½œåºŸ/反作废功能
        [Route("Pay_ErrWorkTimesRequestBill/DropPay_ErrWorkTimesRequestBill")]
        [HttpGet]
        public object DropPay_ErrWorkTimesRequestBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有作废权限
                if (!DBUtility.ClsPub.Security_Log("Pay_ErrWorkTimesRequestBill_Drop", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限作废!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_ErrWorkTimesRequestBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 ä½œåºŸ  2  åä½œåºŸ
                if (Type == 1)
                {
                    //判断单据是否已经作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已作废!不需要再作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //作废单据
                    if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "作废失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] == null || ds.Tables[0].Rows[0]["HDeleteMan"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反作废!不需要再反作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反作废单据
                    if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反作废失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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/¹¤×ʹÜÀí/Pay_GroupBalBillController.cs
@@ -1288,5 +1288,52 @@
            }
        }
        #endregion
        #region æ ¹æ®ç­ç»„获得职员列表
        [Route("Pay_GroupBalBill/getEmpListBasedGroupID")]
        [HttpGet]
        public object getEmpListBasedGroupID(int HGroupID)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                string sql = "select * from Gy_Employee where HGroupID = " + HGroupID;
                ds = oCN.RunProcReturn(sql, "EmpList");
                if (ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "未找到该班组对应的职员列表!!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}
WebAPI/Controllers/¹¤×ʹÜÀí/Pay_OutApplyBillController.cs
New file
@@ -0,0 +1,838 @@
using DBUtility;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Windows.Forms;
using WebAPI.Models;
namespace WebAPI.Controllers.工资管理.请假申请
{
    public class Pay_OutApplyBillController : ApiController
    {
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更)
        private json objJsonResult = new json();
        public DataSet ds = new DataSet();
        public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        public DAL.ClsPay_OutApplyBill BillOld = new DAL.ClsPay_OutApplyBill();
        string user_LongShan = "";
        string HName_LongShan = "";
        #region è¯·å‡ç”³è¯·å• æ–°å¢ž/编辑
        #region è¯·å‡ç”³è¯·å• è¡¨å¤´æ•°æ®
        public class Pay_OutApplyBillMain
        {
            public int HInterID;
            public string HBillNo;
            public string HDate;
            public string HInnerBillNo;
            public int HGroupID;
            public string HGroupName;
            public int HDeptID;
            public string HDeptName;
            public int HMangerID;
            public string HMangerName;
            public int HLeaveID;
            public string HLeaveName;
            public string HExplanation;
            public string HRemark;
            public string HMaker;
            public string HMakerDate;
            public string HUpdater;
            public string HUpdaterDate;
            public string HChecker;
            public string HCheckerDate;
            public string HCloseMan;
            public string HCloseManDate;
            public string HDeleteMan;
            public string HDeleteManDate;
            public string HBacker;
            public string HBackerDate;
            public string HBackRemark;
        }
        #endregion
        #region è¯·å‡ç”³è¯·å• å­è¡¨æ•°æ®
        public class Pay_OutApplyBillSub
        {
            public int HEmpID;
            public string HEmpNumber;
            public string HEmpName;
            public int HShiftsID;
            public string HShiftsNumber;
            public string HShiftsName;
            public string HBTimes;
            public string HETimes;
            public bool HRestFlag;
            public double HRestTimes;
            public double HTimes;
            public double HRelTimes;
            public string HRemark;
        }
        #endregion
        #region è¯·å‡ç”³è¯·å• æ–°å¢ž/编辑
        /// <summary>
        /// æ–°å¢žå•据-保存按钮
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Pay_OutApplyBill/AddPay_OutApplyBill")]
        [HttpPost]
        public object AddBill_Pay_OutApplyBill([FromBody] JObject sMainSub)
        {
            //获取参数
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            //开始事务
            oCN.BeginTran();
            //保存主表
            objJsonResult = AddBillMain_Pay_OutApplyBill(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 = ds.Tables[0];
            return objJsonResult;
        }
        #endregion
        #region æ·»åŠ  è¯·å‡ç”³è¯·å• ä¸»è¡¨
        public json AddBillMain_Pay_OutApplyBill(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修改 2 å¤åˆ¶
            string user = sArray[3].ToString();//用户名
            string HComputerName = SystemInformation.ComputerName; //设备名称
            try
            {
                if (OperationType == 1)
                {
                    //判断是否有编辑权限
                    if (!DBUtility.ClsPub.Security_Log("Pay_OutApplyBill_Edit", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "无新增权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else if (OperationType == 3)
                {
                    //判断是否有编辑权限
                    if (!DBUtility.ClsPub.Security_Log("Pay_OutApplyBill_Edit", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "无编辑权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                msg2 = "[" + msg2.ToString() + "]";
                List<Pay_OutApplyBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Pay_OutApplyBillMain>>(msg2);
                int HYear = int.Parse(mainList[0].HDate.Split('-')[0]);
                int HPeriod = int.Parse(mainList[0].HDate.Split('-')[1]);
                string HBillType = "2221";
                string HBillSubType = "";
                int HBillStatus = 1;
                int HInterID = mainList[0].HInterID;
                string HBillNo = mainList[0].HBillNo;
                string HDate = mainList[0].HDate;
                string HInnerBillNo = mainList[0].HInnerBillNo;
                int HDeptID = mainList[0].HDeptID;
                string HDeptName = mainList[0].HDeptName;
                int HGroupID = mainList[0].HGroupID;
                string HGroupName = mainList[0].HGroupName;
                int HMangerID = mainList[0].HMangerID;
                string HMangerName = mainList[0].HMangerName;
                int HLeaveID = mainList[0].HLeaveID;
                string HLeaveName = mainList[0].HLeaveName;
                string HExplanation = mainList[0].HExplanation;
                string HRemark = mainList[0].HRemark;
                string HMaker = mainList[0].HMaker;
                string HMakerDate = mainList[0].HMakerDate;
                string HUpdater = mainList[0].HUpdater;
                string HUpdaterDate = mainList[0].HUpdaterDate;
                string HChecker = mainList[0].HChecker;
                string HCheckerDate = mainList[0].HCheckerDate;
                string HCloseMan = mainList[0].HCloseMan;
                string HCloseManDate = mainList[0].HCloseManDate;
                string HDeleteMan = mainList[0].HDeleteMan;
                string HDeleteManDate = mainList[0].HDeleteManDate;
                string HBacker = mainList[0].HBacker;
                string HBackerDate = mainList[0].HBackerDate;
                string HBackRemark = mainList[0].HBackRemark;
                //if (OperationType == 2)
                //{
                //    ds = oCN.RunProcReturn("select * from PM_ProjectBillMain where HBillNo ='" + HBillNo + "'", "PM_ProjectBillMain");
                //    if (ds.Tables[0].Rows.Count > 0)
                //    {
                //        objJsonResult.code = "0";
                //        objJsonResult.count = 0;
                //        objJsonResult.Message = "单据号重复,请重新输入!";
                //        objJsonResult.data = null;
                //        return objJsonResult;
                //    }
                //}
                ds = oCN.RunProcReturn("select * from Pay_OutApplyBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "Pay_OutApplyBillMain");
                if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//新增
                {
                    string sql = "insert into Pay_OutApplyBillMain" +
                        "(HYear,HPeriod,HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate,HInnerBillNo,HDeptID,HGroupID,HMangerID,HLeaveID,HExplanation,HRemark, HMaker,HMakeDate) " +
                        "values(" +
                        "" + HYear +
                        "," + HPeriod +
                        ",'" + HBillType +
                        "','" + HBillSubType +
                        "'," + HBillStatus +
                        "," + HInterID +
                        ",'" + HBillNo +
                        "','" + HDate +
                        "','" + HInnerBillNo +
                        "'," + HDeptID +
                        "," + HGroupID +
                        "," + HMangerID +
                        "," + HLeaveID +
                        ",'" + HExplanation +
                        "','" + HRemark +
                        "','" + HMaker +
                        "','" + HMakerDate +
                        "')";
                    //主表
                    oCN.RunProc(sql);
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",新增请假申请单:" + HBillNo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "新增请假申请单:" + HBillNo + "','LMES-请假申请单模块','" + DBUtility.ClsPub.IPAddress + "','新增单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)                    //编辑
                {
                    string sql = "update Pay_OutApplyBillMain set " +
                        "HYear = " + HYear +
                        ", HPeriod = " + HPeriod +
                        ", HBillNo = '" + HBillNo +
                        "', HDate = '" + HDate +
                        "', HInnerBillNo = '" + HInnerBillNo +
                        "', HGroupID = " + HGroupID +
                        ", HDeptID = " + HDeptID +
                        ", HMangerID = " + HMangerID +
                        ", HLeaveID = " + HLeaveID +
                        ", HExplanation = '" + HExplanation +
                        "', HRemark = '" + HRemark +
                        "', HUpdater = '" + HUpdater +
                        "', HUpdateDate = '" + HUpdaterDate +
                        "' where HInterID = " + HInterID;
                    oCN.RunProc(sql);
                    //删除子表
                    oCN.RunProc("delete from Pay_OutApplyBillSub where HInterID= " + HInterID);
                    //记录日志
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",修改请假申请单:" + HBillNo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "修改请假申请单:" + HBillNo + "','LMES-请假申请单模块','" + DBUtility.ClsPub.IPAddress + "','修改单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                //保存子表
                objJsonResult = AddBillSub1_Pay_OutApplyBill(msg3, HInterID, HBillNo, 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;
            }
        }
        #endregion
        #region æ·»åŠ  è¯·å‡ç”³è¯·å• å­è¡¨
        public json AddBillSub1_Pay_OutApplyBill(string msg3, long HInterID, string HBillNo, int OperationType)
        {
            List<Pay_OutApplyBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Pay_OutApplyBillSub>>(msg3);
            int i = 0;                                          //作为子表内码
            foreach (Pay_OutApplyBillSub oSub in DetailColl)
            {
                i++;                                            //同一个主表下的子表的内码自增
                int HEntryID = i;
                int HEmpID = oSub.HEmpID;
                string HEmpName = oSub.HEmpName;
                int HShiftsID = oSub.HShiftsID;
                string HShiftsName = oSub.HShiftsName;
                string HBTimes = oSub.HBTimes;
                string HETimes = oSub.HETimes;
                int HRestFlag = oSub.HRestFlag ? 1 : 0;
                double HRestTimes = oSub.HRestTimes;
                double HTimes = oSub.HTimes;
                double HRelTimes = oSub.HRelTimes;
                string HRemark = oSub.HRemark;
                string sql = "insert into Pay_OutApplyBillSub" +
                            "(HInterID,HEntryID,HEmpID,HShiftsID,HBTimes,HETimes,HRestFlag,HRestTimes,HTimes,HRelTimes,HRemark) " +
                            "values(" +
                            "" + HInterID +
                            "," + HEntryID +
                            "," + HEmpID +
                            "," + HShiftsID +
                            ",'" + HBTimes +
                            "','" + HETimes +
                            "'," + HRestFlag +
                            "," + HRestTimes +
                            "," + HTimes +
                            "," + HRelTimes +
                            ",'" + HRemark +
                            "')";
                oCN.RunProc(sql);
            }
            objJsonResult.code = "1";
            objJsonResult.count = 1;
            objJsonResult.Message = null;
            objJsonResult.data = null;
            return objJsonResult;
        }
        #endregion
        #endregion
        #region è¯·å‡å·¥èµ„单 ç¼–辑-页面赋值
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("Pay_OutApplyBill/editInit")]
        [HttpGet]
        public object getOutApplyBilleditInit(string HInterID, string user)
        {
            try
            {
                List<DataTable> tableList = new List<DataTable>();
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Pay_OutApplyBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无编辑权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (HInterID == null || HInterID.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID不能为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("select * from Pay_OutApplyBillMain where HInterID = " + HInterID, "Pay_OutApplyBillMain");
                string[] HBillStatusList = { "", "未审", "审核通过", "关闭", "作废", "审核退回", "审核中", "已阅", "已回复", "结案", "验证", "下达", "开工", "申请审批", "", "申请检验", "判定合格", "判定不合格" };
                if (ds.Tables[0].Rows.Count > 0 && int.Parse(ds.Tables[0].Rows[0]["HBillStatus"].ToString()) > 1)
                {
                    int HBillStatus = int.Parse(ds.Tables[0].Rows[0]["HBillStatus"].ToString());
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "编辑失败,单据当前状态为\"" + HBillStatusList[HBillStatus] + "\"!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("exec h_p_Pay_OutApplyBill_EditInit " + HInterID, "h_p_Pay_OutApplyBill_EditInit");
                tableList.Add(ds.Tables[0]);
                tableList.Add(ds.Tables[1]);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = tableList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region è¯·å‡ç”³è¯·å• æŸ¥è¯¢
        [Route("Pay_OutApplyBill/list")]
        [HttpGet]
        public object getOutApplyBillList(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Pay_OutApplyBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Pay_OutApplyBillList order by hmainid desc", "h_v_Pay_OutApplyBillList");
                }
                else
                {
                    string sql1 = "select * from h_v_Pay_OutApplyBillList where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by hmainid desc";
                    ds = oCN.RunProcReturn(sql, "h_v_Pay_OutApplyBillList");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region è¯·å‡ç”³è¯·å• åˆ é™¤
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("Pay_OutApplyBill/delete")]
        [HttpGet]
        public object deleteOutApplyBill(string HInterID, string user)
        {
            try
            {
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Pay_OutApplyBill_Drop", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无删除权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (HInterID == null || HInterID.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID不能为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();
                oCN.RunProc("delete from Pay_OutApplyBillMain where HInterID = " + HInterID);
                oCN.RunProc("delete from Pay_OutApplyBillSub where HInterID= " + HInterID);
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region è¯·å‡ç”³è¯·å• å®¡æ ¸/反审核
        /// <summary>
        ///
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">审核(0),反审核(1)</param>
        /// <param name="CurUserName">审核人</param>
        /// <returns></returns>
        [Route("Pay_OutApplyBill/AuditPay_OutApplyBill")]
        [HttpGet]
        public object AuditPay_OutApplyBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有审核权限
                if (!DBUtility.ClsPub.Security_Log("Pay_OutApplyBill_Check", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限审核!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_OutApplyBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 å®¡æ ¸  2  åå®¡æ ¸
                if (Type == 1)
                {
                    //判断单据是否已经审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已审核!不需要再审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //审核单据
                    if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反审核!不需要再反审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反审核单据
                    if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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
        #region è¯·å‡ç”³è¯·å• å…³é—­/反关闭功能
        [Route("Pay_OutApplyBill/ClosePay_OutApplyBill")]
        [HttpGet]
        public object ClosePay_OutApplyBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Pay_OutApplyBill_Close", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限关闭!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_OutApplyBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 å…³é—­  2  åå…³é—­
                if (Type == 1)
                {
                    //判断单据是否已经关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已关闭!不需要再关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //关闭单据
                    if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反关闭!不需要再反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反关闭单据
                    if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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
        #region è¯·å‡ç”³è¯·å• ä½œåºŸ/反作废功能
        [Route("Pay_OutApplyBill/DropPay_OutApplyBill")]
        [HttpGet]
        public object DropPay_OutApplyBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有作废权限
                if (!DBUtility.ClsPub.Security_Log("Pay_OutApplyBill_Delete", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限作废!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_OutApplyBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 ä½œåºŸ  2  åä½œåºŸ
                if (Type == 1)
                {
                    //判断单据是否已经作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已作废!不需要再作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //作废单据
                    if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "作废失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] == null || ds.Tables[0].Rows[0]["HDeleteMan"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反作废!不需要再反作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反作废单据
                    if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反作废失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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/¹¤×ʹÜÀí/Pay_OverApplyBillController.cs
New file
@@ -0,0 +1,825 @@
using DBUtility;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Windows.Forms;
using WebAPI.Models;
namespace WebAPI.Controllers.工资管理.加班申请
{
    public class Pay_OverApplyBillController : ApiController
    {
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更)
        private json objJsonResult = new json();
        public DataSet ds = new DataSet();
        public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        public DAL.ClsPay_OverApplyBill BillOld = new DAL.ClsPay_OverApplyBill();
        string user_LongShan = "";
        string HName_LongShan = "";
        #region åŠ ç­ç”³è¯·å• æ–°å¢ž/编辑
        #region åŠ ç­ç”³è¯·å• è¡¨å¤´æ•°æ®
        public class Pay_OverApplyBillMain
        {
            public int HInterID;
            public string HBillNo;
            public string HDate;
            public string HInnerBillNo;
            public int HGroupID;
            public string HGroupName;
            public int HDeptID;
            public string HDeptName;
            public int HMangerID;
            public string HMangerName;
            public string HExplanation;
            public string HRemark;
            public string HMaker;
            public string HMakerDate;
            public string HUpdater;
            public string HUpdaterDate;
            public string HChecker;
            public string HCheckerDate;
            public string HCloseMan;
            public string HCloseManDate;
            public string HDeleteMan;
            public string HDeleteManDate;
            public string HBacker;
            public string HBackerDate;
            public string HBackRemark;
        }
        #endregion
        #region åŠ ç­ç”³è¯·å• å­è¡¨æ•°æ®
        public class Pay_OverApplyBillSub
        {
            public int HEmpID;
            public string HEmpNumber;
            public string HEmpName;
            public string HBTimes;
            public string HETimes;
            public bool HRestFlag;
            public double HRestTimes;
            public double HTimes;
            public double HRelTimes;
            public string HRemark;
        }
        #endregion
        #region åŠ ç­ç”³è¯·å• æ–°å¢ž/编辑
        /// <summary>
        /// æ–°å¢žå•据-保存按钮
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Pay_OverApplyBill/AddPay_OverApplyBill")]
        [HttpPost]
        public object AddBill_Pay_OverApplyBill([FromBody] JObject sMainSub)
        {
            //获取参数
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            //开始事务
            oCN.BeginTran();
            //保存主表
            objJsonResult = AddBillMain_Pay_OverApplyBill(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 = ds.Tables[0];
            return objJsonResult;
        }
        #endregion
        #region æ·»åŠ  åŠ ç­ç”³è¯·å• ä¸»è¡¨
        public json AddBillMain_Pay_OverApplyBill(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修改 2 å¤åˆ¶
            string user = sArray[3].ToString();//用户名
            string HComputerName = SystemInformation.ComputerName; //设备名称
            try
            {
                if (OperationType == 1)
                {
                    //判断是否有编辑权限
                    if (!DBUtility.ClsPub.Security_Log("Pay_OverApplyBill_Edit", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "无新增权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else if (OperationType == 3)
                {
                    //判断是否有编辑权限
                    if (!DBUtility.ClsPub.Security_Log("Pay_OverApplyBill_Edit", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "无编辑权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                msg2 = "[" + msg2.ToString() + "]";
                List<Pay_OverApplyBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Pay_OverApplyBillMain>>(msg2);
                int HYear = int.Parse(mainList[0].HDate.Split('-')[0]);
                int HPeriod = int.Parse(mainList[0].HDate.Split('-')[1]);
                string HBillType = "2209";
                string HBillSubType = "";
                int HBillStatus = 1;
                int HInterID = mainList[0].HInterID;
                string HBillNo = mainList[0].HBillNo;
                string HDate = mainList[0].HDate;
                string HInnerBillNo = mainList[0].HInnerBillNo;
                int HDeptID = mainList[0].HDeptID;
                string HDeptName = mainList[0].HDeptName;
                int HGroupID = mainList[0].HGroupID;
                string HGroupName = mainList[0].HGroupName;
                int HMangerID = mainList[0].HMangerID;
                string HMangerName = mainList[0].HMangerName;
                string HExplanation = mainList[0].HExplanation;
                string HRemark = mainList[0].HRemark;
                string HMaker = mainList[0].HMaker;
                string HMakerDate = mainList[0].HMakerDate;
                string HUpdater = mainList[0].HUpdater;
                string HUpdaterDate = mainList[0].HUpdaterDate;
                string HChecker = mainList[0].HChecker;
                string HCheckerDate = mainList[0].HCheckerDate;
                string HCloseMan = mainList[0].HCloseMan;
                string HCloseManDate = mainList[0].HCloseManDate;
                string HDeleteMan = mainList[0].HDeleteMan;
                string HDeleteManDate = mainList[0].HDeleteManDate;
                string HBacker = mainList[0].HBacker;
                string HBackerDate = mainList[0].HBackerDate;
                string HBackRemark = mainList[0].HBackRemark;
                //if (OperationType == 2)
                //{
                //    ds = oCN.RunProcReturn("select * from PM_ProjectBillMain where HBillNo ='" + HBillNo + "'", "PM_ProjectBillMain");
                //    if (ds.Tables[0].Rows.Count > 0)
                //    {
                //        objJsonResult.code = "0";
                //        objJsonResult.count = 0;
                //        objJsonResult.Message = "单据号重复,请重新输入!";
                //        objJsonResult.data = null;
                //        return objJsonResult;
                //    }
                //}
                ds = oCN.RunProcReturn("select * from Pay_OverApplyBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "Pay_PayMentBillMain");
                if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//新增
                {
                    string sql = "insert into Pay_OverApplyBillMain" +
                        "(HYear,HPeriod,HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate,HInnerBillNo,HDeptID,HGroupID,HMangerID,HExplanation,HRemark, HMaker,HMakeDate) " +
                        "values(" +
                        "" + HYear +
                        "," + HPeriod +
                        ",'" + HBillType +
                        "','" + HBillSubType +
                        "'," + HBillStatus +
                        "," + HInterID +
                        ",'" + HBillNo +
                        "','" + HDate +
                        "','" + HInnerBillNo +
                        "'," + HDeptID +
                        "," + HGroupID +
                        "," + HMangerID +
                        ",'" + HExplanation +
                        "','" + HRemark +
                        "','" + HMaker +
                        "','" + HMakerDate +
                        "')";
                    //主表
                    oCN.RunProc(sql);
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",新增加班申请单:" + HBillNo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "新增加班申请单:" + HBillNo + "','LMES-加班申请单模块','" + DBUtility.ClsPub.IPAddress + "','新增单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)                    //编辑
                {
                    string sql = "update Pay_OverApplyBillMain set " +
                        "HYear = " + HYear +
                        ", HPeriod = " + HPeriod +
                        ", HBillNo = '" + HBillNo +
                        "', HDate = '" + HDate +
                        "', HInnerBillNo = '" + HInnerBillNo +
                        "', HGroupID = " + HGroupID +
                        ", HDeptID = " + HDeptID +
                        ", HMangerID = " + HMangerID +
                        ", HExplanation = '" + HExplanation +
                        "', HRemark = '" + HRemark +
                        "', HUpdater = '" + HUpdater +
                        "', HUpdateDate = '" + HUpdaterDate +
                        "' where HInterID = " + HInterID;
                    oCN.RunProc(sql);
                    //删除子表
                    oCN.RunProc("delete from Pay_OverApplyBillSub where HInterID= " + HInterID);
                    //记录日志
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",修改加班申请单:" + HBillNo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "修改加班申请单:" + HBillNo + "','LMES-加班申请单模块','" + DBUtility.ClsPub.IPAddress + "','修改单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                //保存子表
                objJsonResult = AddBillSub1_Pay_OverApplyBill(msg3, HInterID, HBillNo, 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;
            }
        }
        #endregion
        #region æ·»åŠ  åŠ ç­ç”³è¯·å• å­è¡¨
        public json AddBillSub1_Pay_OverApplyBill(string msg3, long HInterID, string HBillNo, int OperationType)
        {
            List<Pay_OverApplyBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Pay_OverApplyBillSub>>(msg3);
            int i = 0;                                          //作为子表内码
            foreach (Pay_OverApplyBillSub oSub in DetailColl)
            {
                i++;                                            //同一个主表下的子表的内码自增
                int HEntryID = i;
                int HEmpID = oSub.HEmpID;
                string HEmpName = oSub.HEmpName;
                string HBTimes = oSub.HBTimes;
                string HETimes = oSub.HETimes;
                int HRestFlag = oSub.HRestFlag ? 1 : 0;
                double HRestTimes = oSub.HRestTimes;
                double HTimes = oSub.HTimes;
                double HRelTimes = oSub.HRelTimes;
                string HRemark = oSub.HRemark;
        string sql = "insert into Pay_OverApplyBillSub" +
                    "(HInterID,HEntryID,HEmpID,HBTimes,HETimes,HRestFlag,HRestTimes,HTimes,HRelTimes,HRemark) " +
                    "values(" +
                    "" + HInterID +
                    "," + HEntryID +
                    "," + HEmpID +
                    ",'" + HBTimes +
                    "','" + HETimes +
                    "'," + HRestFlag +
                    "," + HRestTimes +
                    "," + HTimes +
                    "," + HRelTimes +
                    ",'" + HRemark +
                    "')";
                oCN.RunProc(sql);
            }
            objJsonResult.code = "1";
            objJsonResult.count = 1;
            objJsonResult.Message = null;
            objJsonResult.data = null;
            return objJsonResult;
        }
        #endregion
        #endregion
        #region åŠ ç­å·¥èµ„å• ç¼–辑-页面赋值
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("Pay_OverApplyBill/editInit")]
        [HttpGet]
        public object getOverApplyBilleditInit(string HInterID, string user)
        {
            try
            {
                List<DataTable> tableList = new List<DataTable>();
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Pay_OverApplyBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无编辑权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (HInterID == null || HInterID.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID不能为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("select * from Pay_OverApplyBillMain where HInterID = " + HInterID, "Pay_PayMentBillMain");
                string[] HBillStatusList = { "", "未审", "审核通过", "关闭", "作废", "审核退回", "审核中", "已阅", "已回复", "结案", "验证", "下达", "开工", "申请审批", "", "申请检验", "判定合格", "判定不合格" };
                if (ds.Tables[0].Rows.Count > 0 && int.Parse(ds.Tables[0].Rows[0]["HBillStatus"].ToString())>1)
                {
                    int HBillStatus = int.Parse(ds.Tables[0].Rows[0]["HBillStatus"].ToString());
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "编辑失败,单据当前状态为\"" + HBillStatusList[HBillStatus] + "\"!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("exec h_p_Pay_OverApplyBill_EditInit " + HInterID, "h_p_Pay_OverApplyBill_EditInit");
                tableList.Add(ds.Tables[0]);
                tableList.Add(ds.Tables[1]);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = tableList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region åŠ ç­ç”³è¯·å• æŸ¥è¯¢
        [Route("Pay_OverApplyBill/list")]
        [HttpGet]
        public object getOverApplyBillList(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Pay_OverApplyBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Pay_OverApplyBillList order by hmainid desc", "h_v_Pay_OverApplyBillList");
                }
                else
                {
                    string sql1 = "select * from h_v_Pay_OverApplyBillList where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by hmainid desc";
                    ds = oCN.RunProcReturn(sql, "h_v_Pay_OverApplyBillList");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region åŠ ç­ç”³è¯·å• åˆ é™¤
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("Pay_OverApplyBill/delete")]
        [HttpGet]
        public object deleteOverApplyBill(string HInterID, string user)
        {
            try
            {
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Pay_OverApplyBill_Drop", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无删除权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (HInterID == null || HInterID.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID不能为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();
                oCN.RunProc("delete from Pay_OverApplyBillMain where HInterID = " + HInterID);
                oCN.RunProc("delete from Pay_OverApplyBillSub where HInterID= " + HInterID);
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region åŠ ç­ç”³è¯·å• å®¡æ ¸/反审核
        /// <summary>
        ///
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">审核(0),反审核(1)</param>
        /// <param name="CurUserName">审核人</param>
        /// <returns></returns>
        [Route("Pay_OverApplyBill/AuditPay_OverApplyBill")]
        [HttpGet]
        public object AuditPay_OverApplyBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有审核权限
                if (!DBUtility.ClsPub.Security_Log("Pay_OverApplyBill_Check", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限审核!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_OverApplyBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 å®¡æ ¸  2  åå®¡æ ¸
                if (Type == 1)
                {
                    //判断单据是否已经审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已审核!不需要再审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //审核单据
                    if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反审核!不需要再反审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反审核单据
                    if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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
        #region åŠ ç­ç”³è¯·å• å…³é—­/反关闭功能
        [Route("Pay_OverApplyBill/ClosePay_OverApplyBill")]
        [HttpGet]
        public object ClosePay_OverApplyBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Pay_OverApplyBill_Close", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限关闭!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_OverApplyBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 å…³é—­  2  åå…³é—­
                if (Type == 1)
                {
                    //判断单据是否已经关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已关闭!不需要再关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //关闭单据
                    if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反关闭!不需要再反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反关闭单据
                    if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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
        #region åŠ ç­ç”³è¯·å• ä½œåºŸ/反作废功能
        [Route("Pay_OverApplyBill/DropPay_OverApplyBill")]
        [HttpGet]
        public object DropPay_OverApplyBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有作废权限
                if (!DBUtility.ClsPub.Security_Log("Pay_OverApplyBill_Delete", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限作废!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_OverApplyBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 ä½œåºŸ  2  åä½œåºŸ
                if (Type == 1)
                {
                    //判断单据是否已经作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已作废!不需要再作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //作废单据
                    if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "作废失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] == null || ds.Tables[0].Rows[0]["HDeleteMan"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反作废!不需要再反作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反作废单据
                    if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反作废失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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/¹¤×ʹÜÀí/Pay_PayMentBillController.cs
New file
@@ -0,0 +1,877 @@
using DBUtility;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Windows.Forms;
using WebAPI.Models;
namespace WebAPI.Controllers.工资管理.工资单
{
    public class Pay_PayMentBillController : ApiController
    {
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更)
        private json objJsonResult = new json();
        public DataSet ds = new DataSet();
        public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        public DAL.ClsPay_PayMentBill BillOld = new DAL.ClsPay_PayMentBill();
        string user_LongShan = "";
        string HName_LongShan = "";
        #region å·¥èµ„单 æ–°å¢ž/编辑
        #region å·¥èµ„单 è¡¨å¤´æ•°æ®
        public class Pay_PayMentBillMain
        {
            public int HInterID;
            public string HBillNo;
            public string HDate;
            public string HInnerBillNo;
            public int HGroupID;
            public string HGroupName;
            public int HDeptID;
            public string HDeptName;
            public string HExplanation;
            public string HRemark;
            public string HMaker;
            public string HMakerDate;
            public string HUpdater;
            public string HUpdaterDate;
            public string HChecker;
            public string HCheckerDate;
            public string HCloseMan;
            public string HCloseManDate;
            public string HDeleteMan;
            public string HDeleteManDate;
            public string HBacker;
            public string HBackerDate;
            public string HBackRemark;
        }
        #endregion
        #region å·¥èµ„单 å­è¡¨æ•°æ®
        public class Pay_PayMentBillSub
        {
            public int HEmpID;
            public string HEmpNumber;
            public string HEmpName;
            public string HEmpType;
            public int HPostID;
            public string HPostNumber;
            public string HPostName;
            public double HPiecePay;
            public double HTimesPay;
            public double HFixPay;
            public double HBasePay;
            public double HWorkTimes;
            public double HPayTotal;
            public double HSubsidyTotal;
            public double HDeuctTotal;
            public double HShoudPay;
            public double HInsurance;
            public double HTaxBefore;
            public double HTax;
            public double HRelPay;
            public string HRemark;
        }
        #endregion
        #region å·¥èµ„单 æ–°å¢ž/编辑
        /// <summary>
        /// æ–°å¢žå•据-保存按钮
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Pay_PayMentBill/AddPayMentBill")]
        [HttpPost]
        public object AddBill_Pay_PayMentBill([FromBody] JObject sMainSub)
        {
            //获取参数
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            //开始事务
            oCN.BeginTran();
            //保存主表
            objJsonResult = AddBillMain_Pay_PayMentBill(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 = ds.Tables[0];
            return objJsonResult;
        }
        #endregion
        #region æ·»åŠ  å·¥èµ„单 ä¸»è¡¨
        public json AddBillMain_Pay_PayMentBill(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修改 2 å¤åˆ¶
            string user = sArray[3].ToString();//用户名
            string HComputerName = SystemInformation.ComputerName; //设备名称
            try
            {
                if (OperationType == 1)
                {
                    //判断是否有编辑权限
                    if (!DBUtility.ClsPub.Security_Log("Pay_PayMentBill_Edit", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "无新增权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else if (OperationType == 3)
                {
                    //判断是否有编辑权限
                    if (!DBUtility.ClsPub.Security_Log("Pay_PayMentBill_Edit", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "无编辑权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                msg2 = "[" + msg2.ToString() + "]";
                List<Pay_PayMentBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Pay_PayMentBillMain>>(msg2);
                int HYear = int.Parse(mainList[0].HDate.Split('-')[0]);
                int HPeriod = int.Parse(mainList[0].HDate.Split('-')[1]);
                string HBillType = "2202";
                string HBillSubType = "";
                int HBillStatus = 1;
                int HInterID = mainList[0].HInterID;
                string HBillNo = mainList[0].HBillNo;
                string HDate = mainList[0].HDate;
                string HInnerBillNo = mainList[0].HInnerBillNo;
                int HDeptID = mainList[0].HDeptID;
                string HDeptName = mainList[0].HDeptName;
                int HGroupID = mainList[0].HGroupID;
                string HGroupName = mainList[0].HGroupName;
                string HExplanation = mainList[0].HExplanation;
                string HRemark = mainList[0].HRemark;
                string HMaker = mainList[0].HMaker;
                string HMakerDate = mainList[0].HMakerDate;
                string HUpdater = mainList[0].HUpdater;
                string HUpdaterDate = mainList[0].HUpdaterDate;
                string HChecker = mainList[0].HChecker;
                string HCheckerDate = mainList[0].HCheckerDate;
                string HCloseMan = mainList[0].HCloseMan;
                string HCloseManDate = mainList[0].HCloseManDate;
                string HDeleteMan = mainList[0].HDeleteMan;
                string HDeleteManDate = mainList[0].HDeleteManDate;
                string HBacker = mainList[0].HBacker;
                string HBackerDate = mainList[0].HBackerDate;
                string HBackRemark = mainList[0].HBackRemark;
                //if (OperationType == 2)
                //{
                //    ds = oCN.RunProcReturn("select * from PM_ProjectBillMain where HBillNo ='" + HBillNo + "'", "PM_ProjectBillMain");
                //    if (ds.Tables[0].Rows.Count > 0)
                //    {
                //        objJsonResult.code = "0";
                //        objJsonResult.count = 0;
                //        objJsonResult.Message = "单据号重复,请重新输入!";
                //        objJsonResult.data = null;
                //        return objJsonResult;
                //    }
                //}
                ds = oCN.RunProcReturn("select * from Pay_PayMentBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "Pay_PayMentBillMain");
                if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//新增
                {
                    string sql = "insert into Pay_PayMentBillMain" +
                        "(HYear,HPeriod,HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate,HInnerBillNo,HDeptID,HDeptName,HGroupID,HGroupName,HExplanation,HRemark, HMaker,HMakeDate) " +
                        "values(" +
                        "" + HYear +
                        "," + HPeriod +
                        ",'" + HBillType +
                        "','" + HBillSubType +
                        "'," + HBillStatus +
                        "," + HInterID +
                        ",'" + HBillNo +
                        "','" + HDate +
                        "','" + HInnerBillNo +
                        "'," + HDeptID +
                        ",'" + HDeptName +
                        "'," + HGroupID +
                        ",'" + HGroupName +
                        "','" + HExplanation +
                        "','" + HRemark +
                        "','" + HMaker +
                        "','" + HMakerDate +
                        "')";
                    //主表
                    oCN.RunProc(sql);
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",新增工资单:" + HBillNo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "新增工资单:" + HBillNo + "','LMES-工资单模块','" + DBUtility.ClsPub.IPAddress + "','新增单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)                    //编辑
                {
                    string sql = "update Pay_PayMentBillMain set " +
                        "HYear = " + HYear +
                        ", HPeriod = " + HPeriod +
                        ", HBillNo = '" + HBillNo +
                        "', HDate = '" + HDate +
                        "', HInnerBillNo = '" + HInnerBillNo +
                        "', HGroupID = " + HGroupID +
                        ", HGroupName = '" + HGroupName +
                        "', HDeptID = " + HDeptID +
                        ", HDeptName = '" + HDeptName +
                        "', HExplanation = '" + HExplanation +
                        "', HRemark = '" + HRemark +
                        "', HUpdater = '" + HUpdater +
                        "', HUpdateDate = '" + HUpdaterDate +
                        "' where HInterID = " + HInterID;
                    oCN.RunProc(sql);
                    //删除子表
                    oCN.RunProc("delete from Pay_PayMentBillSub where HInterID= " + HInterID);
                    //记录日志
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",修改工资单:" + HBillNo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "修改工资单:" + HBillNo + "','LMES-工资单模块','" + DBUtility.ClsPub.IPAddress + "','修改单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                //保存子表
                objJsonResult = AddBillSub1_Pay_PayMentBill(msg3, HInterID, HBillNo, 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;
            }
        }
        #endregion
        #region æ·»åŠ  å·¥èµ„单 å­è¡¨
        public json AddBillSub1_Pay_PayMentBill(string msg3, long HInterID, string HBillNo, int OperationType)
        {
            List<Pay_PayMentBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Pay_PayMentBillSub>>(msg3);
            int i = 0;                                          //作为子表内码
            foreach (Pay_PayMentBillSub oSub in DetailColl)
            {
                i++;                                            //同一个主表下的子表的内码自增
                int HEntryID = i;
                int HEmpID = oSub.HEmpID;
                string HEmpName = oSub.HEmpName;
                string HEmpType = oSub.HEmpType;
                int HPostID = oSub.HPostID;
                double HPiecePay = oSub.HPiecePay;
                double HTimesPay = oSub.HTimesPay;
                double HFixPay = oSub.HFixPay;
                double HBasePay = oSub.HBasePay;
                double HWorkTimes = oSub.HWorkTimes;
                double HPayTotal = oSub.HPayTotal;
                double HSubsidyTotal = oSub.HSubsidyTotal;
                double HDeuctTotal = oSub.HDeuctTotal;
                double HShoudPay = oSub.HShoudPay;
                double HInsurance = oSub.HInsurance;
                double HTaxBefore = oSub.HTaxBefore;
                double HTax = oSub.HTax;
                double HRelPay = oSub.HRelPay;
                string HRemark = oSub.HRemark;
        string sql = "insert into Pay_PayMentBillSub" +
                    "(HInterID,HEntryID,HEmpID,HEmpName,HEmpType,HPostID,HPiecePay,HTimesPay,HFixPay,HBasePay,HWorkTimes,HPayTotal,HSubsidyTotal,HDeuctTotal,HShoudPay,HInsurance,HTaxBefore,HTax,HRelPay,HRemark) " +
                    "values(" +
                    "" + HInterID +
                    "," + HEntryID +
                    "," + HEmpID +
                    ",'" + HEmpName +
                    "','" + HEmpType +
                    "'," + HPostID +
                    "," + HPiecePay +
                    "," + HTimesPay +
                    "," + HFixPay +
                    "," + HBasePay +
                    "," + HWorkTimes +
                    "," + HPayTotal +
                    "," + HSubsidyTotal +
                    "," + HDeuctTotal +
                    "," + HShoudPay +
                    "," + HInsurance +
                    "," + HTaxBefore +
                    "," + HTax +
                    "," + HRelPay +
                    ",'" + HRemark +
                    "')";
                oCN.RunProc(sql);
            }
            objJsonResult.code = "1";
            objJsonResult.count = 1;
            objJsonResult.Message = null;
            objJsonResult.data = null;
            return objJsonResult;
        }
        #endregion
        #endregion
        #region å·¥èµ„单 ç¼–辑-页面赋值
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("Pay_PayMentBill/editInit")]
        [HttpGet]
        public object getPayMentBilleditInit(string HInterID, string user)
        {
            try
            {
                List<DataTable> tableList = new List<DataTable>();
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Pay_PayMentBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无编辑权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (HInterID == null || HInterID.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID不能为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("exec h_p_Pay_PayMentBill_EditInit " + HInterID, "h_p_Pay_PayMentBill_EditInit");
                tableList.Add(ds.Tables[0]);
                tableList.Add(ds.Tables[1]);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = tableList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å·¥èµ„单 æŸ¥è¯¢
        [Route("Pay_PayMentBill/list")]
        [HttpGet]
        public object getPayMentBillList(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Pay_PayMentBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Pay_PayMentBillList order by hmainid desc", "h_v_Pay_PayMentBillList");
                }
                else
                {
                    string sql1 = "select * from h_v_Pay_PayMentBillList where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by hmainid desc";
                    ds = oCN.RunProcReturn(sql, "h_v_Pay_PayMentBillList");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å·¥èµ„单 åˆ é™¤
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("Pay_PayMentBill/delete")]
        [HttpGet]
        public object deletePayMentBill(string HInterID, string user)
        {
            try
            {
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Pay_PayMentBill_Delete", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无删除权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (HInterID == null || HInterID.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID不能为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();
                oCN.RunProc("delete from Pay_PayMentBillMain where HInterID = " + HInterID);
                oCN.RunProc("delete from Pay_PayMentBillSub where HInterID= " + HInterID);
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å·¥èµ„单 å®¡æ ¸/反审核
        /// <summary>
        ///
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">审核(0),反审核(1)</param>
        /// <param name="CurUserName">审核人</param>
        /// <returns></returns>
        [Route("Pay_PayMentBill/AuditPay_PayMentBill")]
        [HttpGet]
        public object AuditPay_PayMentBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有审核权限
                if (!DBUtility.ClsPub.Security_Log("Pay_PayMentBill_Check", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限审核!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_PayMentBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 å®¡æ ¸  2  åå®¡æ ¸
                if (Type == 1)
                {
                    //判断单据是否已经审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已审核!不需要再审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //审核单据
                    if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反审核!不需要再反审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反审核单据
                    if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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
        #region å·¥èµ„单 å…³é—­/反关闭功能
        [Route("Pay_PayMentBill/ClosePay_PayMentBill")]
        [HttpGet]
        public object ClosePay_PayMentBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Pay_PayMentBill_Close", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限关闭!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_PayMentBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 å…³é—­  2  åå…³é—­
                if (Type == 1)
                {
                    //判断单据是否已经关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已关闭!不需要再关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //关闭单据
                    if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反关闭!不需要再反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反关闭单据
                    if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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
        #region å·¥èµ„单 ä½œåºŸ/反作废功能
        [Route("Pay_PayMentBill/DropPay_PayMentBill")]
        [HttpGet]
        public object DropPay_PayMentBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有作废权限
                if (!DBUtility.ClsPub.Security_Log("Pay_PayMentBill_Drop", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限作废!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_PayMentBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 ä½œåºŸ  2  åä½œåºŸ
                if (Type == 1)
                {
                    //判断单据是否已经作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已作废!不需要再作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //作废单据
                    if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "作废失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] == null || ds.Tables[0].Rows[0]["HDeleteMan"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反作废!不需要再反作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反作废单据
                    if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反作废失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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
        #region æ ¹æ®ç­ç»„获取工资单子表数据
        [Route("Pay_PayMentBill/getPayMentBillSub")]
        [HttpGet]
        public object getPayMentBillSub(int HGroupID, int HYear, int HMonth, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                string sql = "exec h_v_Pay_PayMentBill_getSubDataBasedGroupID " + HGroupID + "," + HYear + "," + HMonth;
                ds = oCN.RunProcReturn(sql, "h_v_Pay_PayMentBill_getSubDataBasedGroupID");
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}
WebAPI/Controllers/¹¤×ʹÜÀí/Pay_ProcPriceRequestBillController.cs
New file
@@ -0,0 +1,841 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Pub_Class;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web.Http;
using System.Windows.Forms;
using WebAPI.Models;
namespace WebAPI.Controllers
{
    //班组Controller
    public class Pay_ProcPriceRequestBillController : ApiController
    {
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill();
        DataSet ds;
        #region å®šé¢ç”³è¯·å• æ–°å¢ž
        #region ä¸»è¡¨
        public class Pay_ProcPriceRequestBillMain
        {
            public int HInterID;
            public string HBillNo;
            public string HDate;
            public string HInnerBillNo;
            public int HDeptID;
            public string HDeptName;
            public string HExplanation;
            public string HRemark;
            public string HMaker;
            public string HMakerDate;
            public string HUpdater;
            public string HUpdaterDate;
            public string HChecker;
            public string HCheckerDate;
            public string HCloseMan;
            public string HCloseManDate;
            public string HDeleteMan;
            public string HDeleteManDate;
            public string HBacker;
            public string HBackerDate;
            public string HBackRemark;
        }
        #endregion
        #region å­è¡¨
        public class Pay_ProcPriceRequestBillSub
        {
            public int HMaterID;
            public string HMaterNumber;
            public string HMaterName;
            public string HMaterModel;
            public int HProcID;
            public string HProcNumber;
            public string HProcName;
            public int HSourceID;
            public string HSourceNumber;
            public string HSourceName;
            public double HOldPrice;
            public double HPrice;
            public double HOldFixPrice;
            public double HFixPrice;
            public string HBeginDate;
            public string HEndDate;
            public bool HCostFlag;
            public string HRemark;
            public int HSourceInterID;
            public int HSourceEntryID;
            public string HSourceBillNo;
            public string HSourceBillType;
            public double HRelationQty;
            public double HRelationMoney;
            public string HCloseMan;
            public string HEntryCloseDate;
        }
        #endregion
        #region å®šé¢ç”³è¯·å• æ–°å¢ž/编辑
        /// <summary>
        /// æ–°å¢žå•据-保存按钮
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Pay_ProcPriceRequestBill/AddProcPriceRequestBill")]
        [HttpPost]
        public object AddBill_Pay_ProcPriceRequestBill([FromBody] JObject sMainSub)
        {
            //获取参数
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            //开始事务
            oCN.BeginTran();
            //保存主表
            objJsonResult = AddBillMain_Pay_ProcPriceRequestBill(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 = ds.Tables[0];
            return objJsonResult;
        }
        #endregion
        #region æ·»åŠ  å®šé¢ç”³è¯·å• ä¸»è¡¨
        public json AddBillMain_Pay_ProcPriceRequestBill(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修改 2 å¤åˆ¶
            string user = sArray[3].ToString();//用户名
            string HComputerName = SystemInformation.ComputerName; //设备名称
            try
            {
                if (OperationType == 1)
                {
                    //判断是否有编辑权限
                    if (!DBUtility.ClsPub.Security_Log("Pay_ProcPriceRequestBill_Edit", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "无新增权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else if (OperationType == 3)
                {
                    //判断是否有编辑权限
                    if (!DBUtility.ClsPub.Security_Log("Pay_ProcPriceRequestBill_Edit", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "无编辑权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                msg2 = "[" + msg2.ToString() + "]";
                List<Pay_ProcPriceRequestBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Pay_ProcPriceRequestBillMain>>(msg2);
                int HYear = int.Parse(mainList[0].HDate.Split('-')[0]);
                int HPeriod = int.Parse(mainList[0].HDate.Split('-')[1]);
                string HBillType = "2219";
                string HBillSubType = "";
                int HBillStatus = 1;
                int HInterID = mainList[0].HInterID;
                string HBillNo = mainList[0].HBillNo;
                string HDate = mainList[0].HDate;
                string HInnerBillNo = mainList[0].HInnerBillNo;
                int HDeptID = mainList[0].HDeptID;
                string HDeptName = mainList[0].HDeptName;
                string HExplanation = mainList[0].HExplanation;
                string HRemark = mainList[0].HRemark;
                string HMaker = mainList[0].HMaker;
                string HMakerDate = mainList[0].HMakerDate;
                string HUpdater = mainList[0].HUpdater;
                string HUpdaterDate = mainList[0].HUpdaterDate;
                string HChecker = mainList[0].HChecker;
                string HCheckerDate = mainList[0].HCheckerDate;
                string HCloseMan = mainList[0].HCloseMan;
                string HCloseManDate = mainList[0].HCloseManDate;
                string HDeleteMan = mainList[0].HDeleteMan;
                string HDeleteManDate = mainList[0].HDeleteManDate;
                string HBacker = mainList[0].HBacker;
                string HBackerDate = mainList[0].HBackerDate;
                string HBackRemark = mainList[0].HBackRemark;
                //if (OperationType == 2)
                //{
                //    ds = oCN.RunProcReturn("select * from PM_ProjectBillMain where HBillNo ='" + HBillNo + "'", "PM_ProjectBillMain");
                //    if (ds.Tables[0].Rows.Count > 0)
                //    {
                //        objJsonResult.code = "0";
                //        objJsonResult.count = 0;
                //        objJsonResult.Message = "单据号重复,请重新输入!";
                //        objJsonResult.data = null;
                //        return objJsonResult;
                //    }
                //}
                ds = oCN.RunProcReturn("select * from Pay_ProcPriceRequestBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "Pay_ProcPriceRequestBillMain");
                if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//新增
                {
                    string sql = "insert into Pay_ProcPriceRequestBillMain" +
                        "(HYear,HPeriod,HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate,HInnerBillNo,HDeptID" +
                        ",HExplanation,HRemark,HMaker,HMakeDate) " +
                        "values(" +
                        "" + HYear +
                        "," + HPeriod +
                        ",'" + HBillType +
                        "','" + HBillSubType +
                        "'," + HBillStatus +
                        "," + HInterID +
                        ",'" + HBillNo +
                        "','" + HDate +
                        "','" + HInnerBillNo +
                        "'," + HDeptID +
                        ",'" + HExplanation +
                        "','" + HRemark +
                        "','" + HMaker +
                        "','" + HMakerDate +
                        "')";
                    //主表
                    oCN.RunProc(sql);
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",新增定额申请单:" + HBillNo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "新增定额申请单:" + HBillNo + "','LMES-定额申请单模块','" + DBUtility.ClsPub.IPAddress + "','新增单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)                    //编辑
                {
                    string sql = "update Pay_ProcPriceRequestBillMain set " +
                        "HYear = " + HYear +
                        ", HPeriod = " + HPeriod +
                        ", HBillNo = '" + HBillNo +
                        "', HDate = '" + HDate +
                        "', HInnerBillNo = '" + HInnerBillNo +
                        "', HDeptID = " + HDeptID +
                        ", HExplanation = '" + HExplanation +
                        "', HRemark = '" + HRemark +
                        "', HUpdater = '" + HUpdater +
                        "', HUpdateDate = '" + HUpdaterDate +
                        "' where HInterID = " + HInterID;
                    oCN.RunProc(sql);
                    //删除子表
                    oCN.RunProc("delete from Pay_ProcPriceRequestBillSub where HInterID= " + HInterID);
                    //记录日志
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",修改定额申请单:" + HBillNo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "修改定额申请单:" + HBillNo + "','LMES-定额申请单模块','" + DBUtility.ClsPub.IPAddress + "','修改单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                //保存子表
                objJsonResult = AddBillSub1_Pay_ProcPriceRequestBill(msg3, HInterID, HBillNo, 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;
            }
        }
        #endregion
        #region æ·»åŠ  å®šé¢ç”³è¯·å• å­è¡¨
        public json AddBillSub1_Pay_ProcPriceRequestBill(string msg3, long HInterID, string HBillNo, int OperationType)
        {
            List<Pay_ProcPriceRequestBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Pay_ProcPriceRequestBillSub>>(msg3);
            int i = 0;                                          //作为子表内码
            foreach (Pay_ProcPriceRequestBillSub oSub in DetailColl)
            {
                i++;                                            //同一个主表下的子表的内码自增
                int HEntryID = i;
                int HMaterID = oSub.HMaterID;
                int HProcID = oSub.HProcID;
                int HSourceID = oSub.HSourceID;
                double HOldPrice = oSub.HOldPrice;
                double HPrice = oSub.HPrice;
                double HOldFixPrice = oSub.HOldFixPrice;
                double HFixPrice = oSub.HFixPrice;
                string HBeginDate = oSub.HBeginDate;
                string HEndDate = oSub.HEndDate;
                int HCostFlag = oSub.HCostFlag?1:0;
                string HRemark = oSub.HRemark;
                int HSourceInterID = oSub.HSourceInterID;
                int HSourceEntryID = oSub.HSourceEntryID;
                string HSourceBillNo = oSub.HSourceBillNo;
                string HSourceBillType = oSub.HSourceBillType;
                double HRelationQty = oSub.HRelationQty;
                double HRelationMoney = oSub.HRelationMoney;
                string sql = "insert into Pay_ProcPriceRequestBillSub" +
                    "(HInterID,HEntryID,HMaterID,HProcID,HSourceID,HOldPrice,HPrice,HOldFixPrice,HFixPrice,HBeginDate,HEndDate,HCostFlag,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo" +
                    ",HSourceBillType,HRelationQty,HRelationMoney) " +
                    "values(" +
                    "" + HInterID +
                    "," + HEntryID +
                    "," + HMaterID +
                    "," + HProcID +
                    "," + HSourceID +
                    "," + HOldPrice +
                    "," + HPrice +
                    "," + HOldFixPrice +
                    "," + HFixPrice +
                    ",'" + HBeginDate +
                    "','" + HEndDate +
                    "'," + HCostFlag +
                    ",'" + HRemark +
                    "'," + HSourceInterID +
                    "," + HSourceEntryID +
                    ",'" + HSourceBillNo +
                    "','" + HSourceBillType +
                    "'," + HRelationQty +
                    "," + HRelationMoney +
                    ")";
                oCN.RunProc(sql);
            }
            objJsonResult.code = "1";
            objJsonResult.count = 1;
            objJsonResult.Message = null;
            objJsonResult.data = null;
            return objJsonResult;
        }
        #endregion
        #endregion
        #region å®šé¢ç”³è¯·å• ç¼–辑-页面赋值
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("Pay_ProcPriceRequestBill/editInit")]
        [HttpGet]
        public object getProcPriceRequestBilleditInit(string HInterID, string user)
        {
            try
            {
                List<DataTable> tableList = new List<DataTable>();
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Pay_ProcPriceRequestBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无编辑权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (HInterID == null || HInterID.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID不能为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("exec h_p_Pay_ProcPriceRequestBill_EditInit " + HInterID, "h_p_Pay_ProcPriceRequestBill_EditInit");
                tableList.Add(ds.Tables[0]);
                tableList.Add(ds.Tables[1]);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = tableList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å®šé¢ç”³è¯·å•-查询
        /// <summary>
        /// è¿”回项目阶段列表
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Pay_ProcPriceRequestBill/list")]
        [HttpGet]
        public object getProcPriceRequestBillList(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Pay_ProcPriceRequestBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Pay_ProcPriceRequestBillList order by hmainid desc", "h_v_Pay_ProcPriceRequestBillList");
                }
                else
                {
                    string sql1 = "select * from h_v_Pay_ProcPriceRequestBillList where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by hmainid desc";
                    ds = oCN.RunProcReturn(sql, "h_v_Pay_ProcPriceRequestBillList");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å®šé¢ç”³è¯·å• åˆ é™¤
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("Pay_ProcPriceRequestBill/delete")]
        [HttpGet]
        public object deleteProcPriceRequestBill(string HInterID, string user)
        {
            try
            {
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Pay_ProcPriceRequestBill_Drop", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无删除权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (HInterID == null || HInterID.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID不能为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();
                oCN.RunProc("delete from Pay_ProcPriceRequestBillMain where HInterID = " + HInterID);
                oCN.RunProc("delete from Pay_ProcPriceRequestBillSub where HInterID= " + HInterID);
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å®šé¢ç”³è¯·å• å®¡æ ¸/反审核
        /// <summary>
        ///
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">审核(0),反审核(1)</param>
        /// <param name="CurUserName">审核人</param>
        /// <returns></returns>
        [Route("Pay_ProcPriceRequestBill/AuditPay_ProcPriceRequestBill")]
        [HttpGet]
        public object AuditPay_ProcPriceRequestBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有审核权限
                if (!DBUtility.ClsPub.Security_Log("Pay_ProcPriceRequestBill_Check", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限审核!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_ProcPriceRequestBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 å®¡æ ¸  2  åå®¡æ ¸
                if (Type == 1)
                {
                    //判断单据是否已经审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已审核!不需要再审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //审核单据
                    if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反审核!不需要再反审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反审核单据
                    if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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
        #region å®šé¢ç”³è¯·å• å…³é—­/反关闭功能
        [Route("Pay_ProcPriceRequestBill/ClosePay_ProcPriceRequestBill")]
        [HttpGet]
        public object ClosePay_ProcPriceRequestBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Pay_ProcPriceRequestBill_Close", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限关闭!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_ProcPriceRequestBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 å…³é—­  2  åå…³é—­
                if (Type == 1)
                {
                    //判断单据是否已经关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已关闭!不需要再关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //关闭单据
                    if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反关闭!不需要再反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反关闭单据
                    if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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
        #region å®šé¢ç”³è¯·å• ä½œåºŸ/反作废功能
        [Route("Pay_ProcPriceRequestBill/DropPay_ProcPriceRequestBill")]
        [HttpGet]
        public object DropPay_ProcPriceRequestBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有作废权限
                if (!DBUtility.ClsPub.Security_Log("Pay_ProcPriceRequestBill_Delete", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限作废!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Pay_ProcPriceRequestBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 ä½œåºŸ  2  åä½œåºŸ
                if (Type == 1)
                {
                    //判断单据是否已经作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已作废!不需要再作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //作废单据
                    if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "作废失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] == null || ds.Tables[0].Rows[0]["HDeleteMan"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反作废!不需要再反作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反作废单据
                    if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反作废失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                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/¹¤×ʹÜÀí/Pay_SalaryCalculateController.cs
New file
@@ -0,0 +1,939 @@
using DBUtility;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Windows.Forms;
using WebAPI.Models;
using static WebAPI.Controllers.Pay_SingleBalBillController;
using static WebAPI.Controllers.Pay_GroupBalBillController;
namespace WebAPI.Controllers.工资管理.工资计算
{
    public class Pay_SalaryCulateController : ApiController
    {
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更)
        private json objJsonResult = new json();
        public DataSet ds = new DataSet();
        public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill();
        string user_LongShan = "";
        string HName_LongShan = "";
        #region å·¥èµ„计算-数据查询
        /// <summary>
        /// è¿”回项目阶段列表
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Pay_SalaryCalculate/list")]
        [HttpGet]
        public object getSalaryCalculateData(string HBeginDate, string HEndDate, int HOperatorType,string HBillType,string user)
        {
            try
            {
                string sql = "exec h_p_Pay_SalaryCalculate_getData " + HOperatorType + ",'" + HBeginDate + "','" + HEndDate + "'";
                ds = oCN.RunProcReturn(sql, "h_p_Pay_SalaryCalculate_getData");
                if (HOperatorType == 1)
                {
                    oCN.BeginTran();
                    objJsonResult = getSalaryCalculateData_SingleBalBill(HBeginDate, HEndDate, HOperatorType, HBillType, user);
                    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 = ds.Tables[0];
                    return objJsonResult;
                }else if(HOperatorType == 2)
                {
                    oCN.BeginTran();
                    objJsonResult = getSalaryCalculateData_GroupBalBill(HBeginDate, HEndDate, HOperatorType, HBillType, user);
                    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 = ds.Tables[0];
                    return objJsonResult;
                }
                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 å·¥èµ„计算-个人工资结算单
        #region å·¥èµ„计算-批量计算-个人工资结算单
        public json getSalaryCalculateData_SingleBalBill(string HBeginDate, string HEndDate, int HOperatorType, string HBillType, string user)
        {
            try
            {
                //判断是否有编辑权限
                if (!DBUtility.ClsPub.Security_Log("Pay_SingleBalBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无新增权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("select * from Pay_SingleBalBillMain where HAutoCreate = 1 and CONVERT(varchar(100),HDate, 23) >= '" + HBeginDate + "' and CONVERT(varchar(100),HDate, 23) <= '" + HEndDate + "'", "Pay_SingleBalBillMain");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    for(int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        int HInterID = int.Parse(ds.Tables[0].Rows[i]["HInterID"].ToString());
                        oCN.RunProc("delete from Pay_SingleBalBillMain where HInterID = " + HInterID);
                        oCN.RunProc("delete from Pay_SingleBalBillSub where HInterID = " + HInterID);
                    }
                }
                //获取工序出站汇报单数据
                string sql = "exec h_p_Pay_SalaryCalculate_getData " + HOperatorType + ",'" + HBeginDate + "','" + HEndDate + "'";
                ds = oCN.RunProcReturn(sql, "h_p_Pay_SalaryCalculate_getData");
                DataTable data = ds.Tables[0];
                //整理工序出站汇报单数据,并分别生成个人工资结算单
                if (data.Rows.Count > 0)
                {
                    int HEmpIDBar = -100;               //当前个人工资结算单-职员ID标记
                    Pay_SingleBalBillMain mainTable = new Pay_SingleBalBillMain();
                    List<Pay_SingleBalBillController.Pay_SingleBalBillSub> subTable = new List<Pay_SingleBalBillController.Pay_SingleBalBillSub>();
                    for(int i = 0; i < data.Rows.Count; i++)
                    {
                        int HEmpID = data.Rows[i]["HEmpID"] == null ? 0 : (int)data.Rows[i]["HEmpID"];
                        if (HEmpIDBar != HEmpID)
                        {
                            if (subTable.Count > 0)
                            {
                                //新增单据
                                objJsonResult = AddBillMain_Pay_SingleBalBillMain(mainTable, user,subTable);
                                if (objJsonResult.code == "0")
                                {
                                    objJsonResult.code = "0";
                                    objJsonResult.count = 0;
                                    objJsonResult.Message = objJsonResult.Message;
                                    objJsonResult.data = null;
                                    return objJsonResult;
                                }
                                //清空表头信息和子表信息,加载新单据的数据
                                mainTable = new Pay_SingleBalBillMain();
                                subTable.Clear();
                            }
                            //生成单据后,更新当前个人工资结算单-职员ID标记
                            HEmpIDBar = HEmpID;
                            //填充表头信息
                            mainTable.HInterID = (int)DBUtility.ClsPub.CreateBillID(HBillType, ref DBUtility.ClsPub.sExeReturnInfo);
                            mainTable.HBillNo = DBUtility.ClsPub.CreateBillCode(HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
                            mainTable.HDate = DateTime.Now.ToString("yyyy-MM-dd");
                            mainTable.HInnerBillNo = mainTable.HBillNo;
                            mainTable.HDeptID = data.Rows[i]["HDeptID"] == null ? 0 : (int)data.Rows[i]["HDeptID"];
                            mainTable.HGroupID = data.Rows[i]["HGroupID"] == null ? 0 :(int)data.Rows[i]["HGroupID"];
                            mainTable.HEmpID = data.Rows[i]["HEmpID"] == null ? 0 : (int)data.Rows[i]["HEmpID"];
                            mainTable.HPayTypeID = 0;
                            mainTable.HSourceBillID = 0;
                            mainTable.HSourceBillNo = "";
                            mainTable.HSourceBillType = "";
                            mainTable.HExplanation = "";
                            mainTable.HRemark = "";
                            mainTable.HMaker = user;
                            mainTable.HMakerDate = DateTime.Now.ToString("yyyy-MM-dd");
                        }
                        //填充并添加子表记录信息
                        Pay_SingleBalBillController.Pay_SingleBalBillSub oSub = new Pay_SingleBalBillController.Pay_SingleBalBillSub();
                        oSub.HMaterID = data.Rows[i]["HMaterID"] == null ? 0 : (int)data.Rows[i]["HMaterID"];
                        oSub.HProcID = data.Rows[i]["HProcID"] == null ? 0 : (int)data.Rows[i]["HProcID"];
                        oSub.HEmpID = data.Rows[i]["HEmpID"] == null ? 0 : (int)data.Rows[i]["HEmpID"];
                        oSub.HTimes = data.Rows[i]["HTimes"] == null ? 0 : double.Parse(data.Rows[i]["HTimes"].ToString());
                        oSub.HQty = data.Rows[i]["HQty"] == null ? 0 : double.Parse(data.Rows[i]["HQty"].ToString());
                        oSub.HPrice = data.Rows[i]["HPrice"] == null ? 0 : double.Parse(data.Rows[i]["HPrice"].ToString());
                        oSub.HPriceRate = 1;
                        oSub.HSubsidyQty = 0;
                        oSub.HSubsidyMoney = 0;
                        oSub.HSubsidyTotal = 0;
                        oSub.HDeuctTotal = 0;
                        oSub.HPackQty = 0;
                        oSub.HPackPrice = 0;
                        oSub.HPackMoney = 0;
                        oSub.HPackMaterID = 0;
                        oSub.HMoney = data.Rows[i]["HMoney"] == null ? 0 : double.Parse(data.Rows[i]["HMoney"].ToString());
                        oSub.HRemark = "";
                        oSub.HICMOInterID = data.Rows[i]["HICMOInterID"] == null ? 0 : (int)data.Rows[i]["HICMOInterID"];
                        oSub.HICMOBillNo = data.Rows[i]["HICMOBillNo"] == null ? "" : data.Rows[i]["HICMOBillNo"].ToString();
                        oSub.HProcReportInterID = 0;
                        oSub.HProcReportEntryID = 0;
                        oSub.HProcReportBillNo = "";
                        oSub.HProcPlanInterID = data.Rows[i]["HProcPlanInterID"] == null ? 0 : (int)data.Rows[i]["HProcPlanInterID"];
                        oSub.HProcPlanEntryID = data.Rows[i]["HProcPlanEntryID"] == null ? 0 : (int)data.Rows[i]["HProcPlanEntryID"];
                        oSub.HProcPlanBillNo = data.Rows[i]["HProcPlanBillNo"] == null ? "" : data.Rows[i]["HProcPlanBillNo"].ToString();
                        oSub.HSourceInterID = 0; //data.Rows[i]["HSourceInterID"] == null ? 0 : (int)data.Rows[i]["HSourceInterID"];
                        oSub.HSourceEntryID = 0; //data.Rows[i]["HSourceEntryID "] == null ? 0 : (int)data.Rows[i]["HSourceEntryID "];
                        oSub.HSourceBillNo = ""; //data.Rows[i]["HSourceBillNo"] == null ? "" : data.Rows[i]["HSourceBillNo"].ToString();
                        oSub.HSourceBillType = "";
                        oSub.HRelationQty = 0;
                        oSub.HRelationMoney = 0;
                        oSub.HCloseMan = "";
                        oSub.HEntryCloseDate = "";
                        subTable.Add(oSub);
                    }
                    //生成最后一条记录:最后一条记录因为无法再与data.Rows[data.Rows.Count]["HEmpID"]比较,所以不会添加,需要最后另外添加
                    objJsonResult = AddBillMain_Pay_SingleBalBillMain(mainTable, user, subTable);
                    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 = "Sucess!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "生成失败,指定时间段内无数据!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å·¥èµ„计算-工资结算单(个人) ä¸»è¡¨
        public json AddBillMain_Pay_SingleBalBillMain(Pay_SingleBalBillMain oMain,string user,List<Pay_SingleBalBillController.Pay_SingleBalBillSub> subTable)
        {
            int OperationType = 1;//数据类型 1添加 3修改 2 å¤åˆ¶
            string HComputerName = SystemInformation.ComputerName; //设备名称
            try
            {
                List<Pay_SingleBalBillMain> mainList = new List<Pay_SingleBalBillMain>();
                mainList.Add(oMain);
                int HYear = int.Parse(mainList[0].HDate.Split('-')[0]);
                int HPeriod = int.Parse(mainList[0].HDate.Split('-')[1]);
                string HBillType = "2205";
                string HBillSubType = "";
                int HBillStatus = 1;
                int HInterID = mainList[0].HInterID;
                string HBillNo = mainList[0].HBillNo;
                string HDate = mainList[0].HDate;
                string HInnerBillNo = mainList[0].HInnerBillNo;
                int HGroupID = mainList[0].HGroupID;
                int HDeptID = mainList[0].HDeptID;
                int HEmpID = mainList[0].HEmpID;
                int HPayType = mainList[0].HPayTypeID;
                int HMainSourceInterID = mainList[0].HSourceBillID;
                string HMainSourceBillNo = mainList[0].HSourceBillNo;
                string HMainSourceBillType = mainList[0].HSourceBillType;
                string HExplanation = mainList[0].HExplanation;
                string HRemark = mainList[0].HRemark;
                //制单、修改
                string HMaker = mainList[0].HMaker;
                string HMakerDate = mainList[0].HMakerDate;
                ds = oCN.RunProcReturn("select * from Pay_SingleBalBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "Pay_SingleBalBillMain");
                if (OperationType == 1  && ds.Tables[0].Rows.Count == 0)//新增
                {
                    string sql = "insert into Pay_SingleBalBillMain" +
                        "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate,HBillNo,HBillStatus,HGroupID,HDeptID,HEmpID,HPayType,HExplanation,HInnerBillNo,HRemark,HMaker,HMakeDate,HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HAutoCreate) " +
                        "values(" +
                        "" + HYear +
                        "," + HPeriod +
                        ",'" + HBillType +
                        "','" + HBillSubType +
                        "'," + HInterID +
                        ",'" + HDate +
                        "','" + HBillNo +
                        "'," + HBillStatus +
                        "," + HGroupID +
                        "," + HDeptID +
                        "," + HEmpID +
                        "," + HPayType +
                        ",'" + HExplanation +
                        "','" + HInnerBillNo +
                        "','" + HRemark +
                        "','" + HMaker +
                        "','" + HMakerDate +
                        "'," + HMainSourceInterID +
                        ",'" + HMainSourceBillNo +
                        "','" + HMainSourceBillType +
                        "'," + 1 +
                        ")";
                    //主表
                    oCN.RunProc(sql);
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",新增工资结算单(个人):" + HBillNo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "新增工资结算单(个人):" + HBillNo + "','LMES-工资结算单(个人)模块','" + DBUtility.ClsPub.IPAddress + "','新增单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                //保存子表
                objJsonResult = AddBillSub_Pay_SingleBalBillMain(subTable, HInterID, HBillNo, 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;
            }
        }
        #endregion
        #region å·¥èµ„计算-工资结算单(个人) å­è¡¨
        public json AddBillSub_Pay_SingleBalBillMain(List<Pay_SingleBalBillController.Pay_SingleBalBillSub> DetailColl, long HInterID, string HBillNo, int OperationType)
        {
            try
            {
                int i = 0;                                          //作为子表内码
                foreach (Pay_SingleBalBillController.Pay_SingleBalBillSub oSub in DetailColl)
                {
                    i++;                                            //同一个主表下的子表的内码自增
                    int HEntryID = i;
                    int HMaterID = oSub.HMaterID;
                    int HProcID = oSub.HProcID;
                    int HEmpID = oSub.HEmpID;
                    double HTimes = oSub.HTimes;
                    double HQty = oSub.HQty;
                    double HPrice = oSub.HPrice;
                    double HPriceRate = oSub.HPriceRate;
                    double HSubsidyQty = oSub.HSubsidyQty;
                    double HSubsidyMoney = oSub.HSubsidyMoney;
                    double HSubsidyTotal = oSub.HSubsidyTotal;
                    double HDeuctTotal = oSub.HDeuctTotal;
                    double HPackQty = oSub.HPackQty;
                    double HPackPrice = oSub.HPackPrice;
                    double HPackMoney = oSub.HPackMoney;
                    int HPackMaterID = oSub.HPackMaterID;
                    double HMoney = oSub.HMoney;
                    int HICMOInterID = oSub.HICMOInterID;
                    string HICMOBillNo = oSub.HICMOBillNo;
                    int HProcReportInterID = oSub.HProcReportInterID;
                    int HProcReportEntryID = oSub.HProcReportEntryID;
                    string HProcReportBillNo = oSub.HProcReportBillNo;
                    int HProcPlanInterID = oSub.HProcPlanInterID;
                    int HProcPlanEntryID = oSub.HProcPlanEntryID;
                    string HProcPlanBillNo = oSub.HProcPlanBillNo;
                    string HRemark = oSub.HRemark;
                    int HSourceInterID = oSub.HSourceInterID;
                    int HSourceEntryID = oSub.HSourceEntryID;
                    string HSourceBillNo = oSub.HSourceBillNo;
                    string HSourceBillType = oSub.HSourceBillType;
                    double HRelationQty = oSub.HRelationQty;
                    double HRelationMoney = oSub.HRelationMoney;
                    string HCloseMan = oSub.HCloseMan;
                    string HEntryCloseDate = oSub.HEntryCloseDate;
                    string sql = "insert into Pay_SingleBalBillSub" +
                        "(HInterID,HEntryID,HMaterID,HProcID,HEmpID,HTimes,HQty,HPrice,HPriceRate,HSubsidyQty,HSubsidyMoney,HSubsidyTotal,HDeuctTotal" +
                        ",HPackQty,HPackPrice,HPackMoney,HPackMaterID,HMoney,HICMOInterID,HICMOBillNo,HProcReportInterID,HProcReportEntryID,HProcReportBillNo" +
                        ",HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
                        ",HCloseMan,HEntryCloseDate) " +
                        "values(" +
                        "" + HInterID +
                        "," + HEntryID +
                        "," + HMaterID +
                        "," + HProcID +
                        "," + HEmpID +
                        "," + HTimes +
                        "," + HQty +
                        "," + HPrice +
                        "," + HPriceRate +
                        "," + HSubsidyQty +
                        "," + HSubsidyMoney +
                        "," + HSubsidyTotal +
                        "," + HDeuctTotal +
                        "," + HPackQty +
                        "," + HPackPrice +
                        "," + HPackMoney +
                        "," + HPackMaterID +
                        "," + HMoney +
                        "," + HICMOInterID +
                        ",'" + HICMOBillNo +
                        "'," + HProcReportInterID +
                        "," + HProcReportEntryID +
                        ",'" + HProcReportBillNo +
                        "'," + HProcPlanInterID +
                        "," + HProcPlanEntryID +
                        ",'" + HProcPlanBillNo +
                        "','" + HRemark +
                        "'," + HSourceInterID +
                        "," + HSourceEntryID +
                        ",'" + HSourceBillNo +
                        "','" + HSourceBillType +
                        "'," + HRelationQty +
                        "," + HRelationMoney +
                        ",'" + HCloseMan +
                        "','" + HEntryCloseDate +
                        "')";
                    oCN.RunProc(sql);
                }
                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;
            }
        }
        #endregion
        #endregion
        #region å·¥èµ„计算-集体工资结算单
        #region å·¥èµ„计算-批量计算-集体工资结算单
        public json getSalaryCalculateData_GroupBalBill(string HBeginDate, string HEndDate, int HOperatorType, string HBillType, string user)
        {
            try
            {
                //判断是否有编辑权限
                if (!DBUtility.ClsPub.Security_Log("Pay_GroupBalBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无新增权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("select * from Pay_GroupBalBillMain where HAutoCreate = 1 and CONVERT(varchar(100),HDate, 23) >= '" + HBeginDate + "' and CONVERT(varchar(100),HDate, 23) <= '" + HEndDate + "'", "Pay_GroupBalBillMain");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        int HInterID = int.Parse(ds.Tables[0].Rows[i]["HInterID"].ToString());
                        oCN.RunProc("delete from Pay_GroupBalBillMain where HInterID = " + HInterID);
                        oCN.RunProc("delete from Pay_GroupBalBillSub where HInterID = " + HInterID);
                        oCN.RunProc("delete from Pay_GroupBalBillEmp where HInterID = " + HInterID);
                    }
                }
                //获取工序出站汇报单数据
                string sql = "exec h_p_Pay_SalaryCalculate_getData " + HOperatorType + ",'" + HBeginDate + "','" + HEndDate + "'";
                ds = oCN.RunProcReturn(sql, "h_p_Pay_SalaryCalculate_getData");
                DataTable data = ds.Tables[0];
                //查询子表2所需变量
                DataSet ds1;
                string sql1;
                //整理工序出站汇报单数据,并分别生成个人工资结算单
                if (data.Rows.Count > 0)
                {
                    int HDeptIDBar = -100;
                    int HGroupIDBar = -100;
                    Pay_GroupBalBillMain mainTable = new Pay_GroupBalBillMain();
                    List<Pay_GroupBalBillController.Pay_GroupBalBillSub> subTable = new List<Pay_GroupBalBillController.Pay_GroupBalBillSub>();
                    List<Pay_GroupBalBillController.Pay_GroupBalBillEmp> subEmpTable = new List<Pay_GroupBalBillController.Pay_GroupBalBillEmp>();
                    for (int i = 0; i < data.Rows.Count; i++)
                    {
                        int HDeptID = data.Rows[i]["HDeptID"] == null ? 0 : (int)data.Rows[i]["HDeptID"];
                        int HGroupID = data.Rows[i]["HGroupID"] == null ? 0 : (int)data.Rows[i]["HGroupID"];
                        if (HDeptIDBar != HDeptID  ||  HGroupIDBar != HGroupID)
                        {
                            if (subTable.Count > 0)
                            {
                                //获取子表2数据
                                sql1 = "select * from h_v_Gy_Employee_ForWeb where HDeptID ='" + HDeptIDBar + "' and HGroupID = '" + HGroupIDBar + "'";
                                ds1 = oCN.RunProcReturn(sql1, "h_v_Gy_Employee_ForWeb");
                                if (ds1.Tables[0].Rows.Count > 0)
                                {
                                    for(int j = 0; j < ds1.Tables[0].Rows.Count; j++)
                                    {
                                        Pay_GroupBalBillController.Pay_GroupBalBillEmp oSubEmp = new Pay_GroupBalBillController.Pay_GroupBalBillEmp();
                                        oSubEmp.HEmpID = ds1.Tables[0].Rows[j]["HItemID"] == null ? 0 : int.Parse(ds1.Tables[0].Rows[j]["HItemID"].ToString());
                                        oSubEmp.HEmpRate = ds1.Tables[0].Rows[j]["HEmpRate"] == null ? 0 : double.Parse(ds1.Tables[0].Rows[j]["HEmpRate"].ToString());
                                        oSubEmp.HBaseTimes = 0;
                                        oSubEmp.HMoney = 0;
                                        oSubEmp.HOtherSubsidy = 0;
                                        oSubEmp.HOtherDeduct = 0;
                                        oSubEmp.HYF = 0;
                                        oSubEmp.HIsPay = false;
                                        oSubEmp.HAvgFlag = false;
                                        oSubEmp.HRemark = "";
                                        subEmpTable.Add(oSubEmp);
                                    }
                                }
                                //新增单据
                                objJsonResult = AddBillMain_Pay_GroupBalBill(mainTable, user, subTable, subEmpTable);
                                if (objJsonResult.code == "0")
                                {
                                    objJsonResult.code = "0";
                                    objJsonResult.count = 0;
                                    objJsonResult.Message = objJsonResult.Message;
                                    objJsonResult.data = null;
                                    return objJsonResult;
                                }
                                //清空表头信息和子表信息,加载新单据的数据
                                mainTable = new Pay_GroupBalBillMain();
                                subTable.Clear();
                                subEmpTable.Clear();
                            }
                            //生成单据后,更新当前集体工资结算单-部门ID,班组ID
                            HDeptIDBar = HDeptID;
                            HGroupIDBar = HGroupID;
                            //填充表头信息
                            mainTable.HInterID = (int)DBUtility.ClsPub.CreateBillID(HBillType, ref DBUtility.ClsPub.sExeReturnInfo);
                            mainTable.HBillNo = DBUtility.ClsPub.CreateBillCode(HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
                            mainTable.HDate = DateTime.Now.ToString("yyyy-MM-dd");
                            mainTable.HInnerBillNo = mainTable.HBillNo;
                            mainTable.HDeptID = data.Rows[i]["HDeptID"] == null ? 0 : (int)data.Rows[i]["HDeptID"];
                            mainTable.HGroupID = data.Rows[i]["HGroupID"] == null ? 0 : (int)data.Rows[i]["HGroupID"];
                            mainTable.HSumMoney = 0;
                            mainTable.HOtherSubsidy = 0;
                            mainTable.HPayMoney = 0;
                            mainTable.HOtherDeduct = 0;
                            mainTable.HSourceBillID = 0;
                            mainTable.HSourceBillNo = "";
                            mainTable.HSourceBillType = "";
                            mainTable.HExplanation = "";
                            mainTable.HRemark = "";
                            mainTable.HMaker = user;
                            mainTable.HMakerDate = DateTime.Now.ToString("yyyy-MM-dd");
                        }
                        //填充并添加子表记录信息
                        Pay_GroupBalBillController.Pay_GroupBalBillSub oSub = new Pay_GroupBalBillController.Pay_GroupBalBillSub();
                        oSub.HMaterID = data.Rows[i]["HMaterID"] == null ? 0 : (int)data.Rows[i]["HMaterID"];
                        oSub.HUnitID = data.Rows[i]["HUnitID"] == null ? 0 : (int)data.Rows[i]["HUnitID"];
                        oSub.HProcID = data.Rows[i]["HProcID"] == null ? 0 : (int)data.Rows[i]["HProcID"];
                        oSub.HSourceID = data.Rows[i]["HSourceID"] == null ? 0 : (int)data.Rows[i]["HSourceID"];
                        oSub.HTimes = data.Rows[i]["HTimes"] == null ? 0 : double.Parse(data.Rows[i]["HTimes"].ToString());
                        oSub.HQty = data.Rows[i]["HQty"] == null ? 0 : double.Parse(data.Rows[i]["HQty"].ToString());
                        oSub.HPrice = data.Rows[i]["HPrice"] == null ? 0 : double.Parse(data.Rows[i]["HPrice"].ToString());
                        oSub.HMoney = data.Rows[i]["HMoney"] == null ? 0 : double.Parse(data.Rows[i]["HMoney"].ToString());
                        oSub.HRemark = "";
                        oSub.HICMOInterID = 0; // data.Rows[i]["HICMOInterID"] == null ? 0 : (int)data.Rows[i]["HICMOInterID"];
                        oSub.HICMOBillNo = ""; // data.Rows[i]["HICMOBillNo"] == null ? "" : data.Rows[i]["HICMOBillNo"].ToString();
                        oSub.HProcReportInterID = 0;
                        oSub.HProcReportEntryID = 0;
                        oSub.HProcReportBillNo = "";
                        oSub.HProcPlanInterID = 0; // data.Rows[i]["HProcPlanInterID"] == null ? 0 : (int)data.Rows[i]["HProcPlanInterID"];
                        oSub.HProcPlanEntryID = 0; // data.Rows[i]["HProcPlanEntryID"] == null ? 0 : (int)data.Rows[i]["HProcPlanEntryID"];
                        oSub.HProcPlanBillNo = ""; // data.Rows[i]["HProcPlanBillNo"] == null ? "" : data.Rows[i]["HProcPlanBillNo"].ToString();
                        oSub.HSourceInterID = data.Rows[i]["HSourceInterID"] == null ? 0 : (int)data.Rows[i]["HSourceInterID"];
                        oSub.HSourceEntryID = data.Rows[i]["HSourceEntryID"] == null ? 0 : (int)data.Rows[i]["HSourceEntryID"];
                        oSub.HSourceBillNo = data.Rows[i]["HSourceBillNo"] == null ? "" : data.Rows[i]["HSourceBillNo"].ToString();
                        oSub.HSourceBillType = data.Rows[i]["HSourceBillType"] == null ? "" : data.Rows[i]["HSourceBillType"].ToString();
                        oSub.HRelationQty = data.Rows[i]["HQty"] == null ? 0 : double.Parse(data.Rows[i]["HQty"].ToString());
                        oSub.HRelationMoney = data.Rows[i]["HMoney"] == null ? 0 : double.Parse(data.Rows[i]["HMoney"].ToString());
                        subTable.Add(oSub);
                    }
                    //生成最后一条记录:最后一条记录因为无法再与data.Rows[data.Rows.Count]["HEmpID"]比较,所以不会添加,需要最后另外添加
                    sql1 = "select * from h_v_Gy_Employee_ForWeb where HDeptID ='" + HDeptIDBar + "' and HGroupID = '" + HGroupIDBar + "'";
                    ds1 = oCN.RunProcReturn(sql1, "h_v_Gy_Employee_ForWeb");
                    if (ds1.Tables[0].Rows.Count > 0)
                    {
                        for (int j = 0; j < ds1.Tables[0].Rows.Count; j++)
                        {
                            Pay_GroupBalBillController.Pay_GroupBalBillEmp oSubEmp = new Pay_GroupBalBillController.Pay_GroupBalBillEmp();
                            oSubEmp.HEmpID = ds1.Tables[0].Rows[j]["HItemID"] == null ? 0 : int.Parse(ds1.Tables[0].Rows[j]["HItemID"].ToString());
                            oSubEmp.HEmpRate = ds1.Tables[0].Rows[j]["HEmpRate"] == null ? 0 : double.Parse(ds1.Tables[0].Rows[j]["HEmpRate"].ToString());
                            oSubEmp.HBaseTimes = 0;
                            oSubEmp.HMoney = 0;
                            oSubEmp.HOtherSubsidy = 0;
                            oSubEmp.HOtherDeduct = 0;
                            oSubEmp.HYF = 0;
                            oSubEmp.HIsPay = false;
                            oSubEmp.HAvgFlag = false;
                            oSubEmp.HRemark = "";
                            subEmpTable.Add(oSubEmp);
                        }
                    }
                    objJsonResult = AddBillMain_Pay_GroupBalBill(mainTable, user, subTable,subEmpTable);
                    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 = "Sucess!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "生成失败,指定时间段内无数据!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å·¥èµ„计算-工资结算单(集体) ä¸»è¡¨
        public json AddBillMain_Pay_GroupBalBill(Pay_GroupBalBillMain oMain, string user, List<Pay_GroupBalBillController.Pay_GroupBalBillSub> subTable, List<Pay_GroupBalBillController.Pay_GroupBalBillEmp> subEmpTable)
        {
            int OperationType = 1;//数据类型 1添加 3修改 2 å¤åˆ¶
            string HComputerName = SystemInformation.ComputerName; //设备名称
            try
            {
                List<Pay_GroupBalBillMain> mainList = new List<Pay_GroupBalBillMain>();
                mainList.Add(oMain);
                int HYear = int.Parse(mainList[0].HDate.Split('-')[0]);
                int HPeriod = int.Parse(mainList[0].HDate.Split('-')[1]);
                string HBillType = "2201";
                string HBillSubType = "";
                int HBillStatus = 1;
                int HInterID = mainList[0].HInterID;
                string HBillNo = mainList[0].HBillNo;
                string HDate = mainList[0].HDate;
                string HInnerBillNo = mainList[0].HInnerBillNo;
                int HGroupID = mainList[0].HGroupID;
                string HGroupName = mainList[0].HGroupName;
                double HSumMoney = mainList[0].HSumMoney;
                double HOtherSubsidy = mainList[0].HOtherSubsidy;
                int HDeptID = mainList[0].HDeptID;
                string HDeptName = mainList[0].HDeptName;
                double HPayMoney = mainList[0].HPayMoney;
                double HOtherDeduct = mainList[0].HOtherDeduct;
                string HSourceBillType = mainList[0].HSourceBillType;
                int HSourceBillID = mainList[0].HSourceBillID;
                string HSourceBillNo = mainList[0].HSourceBillNo;
                string HExplanation = mainList[0].HExplanation;
                string HRemark = mainList[0].HRemark;
                string HMaker = mainList[0].HMaker;
                string HMakerDate = mainList[0].HMakerDate;
                string HUpdater = mainList[0].HUpdater;
                string HUpdaterDate = mainList[0].HUpdaterDate;
                string HChecker = mainList[0].HChecker;
                string HCheckerDate = mainList[0].HCheckerDate;
                string HCloseMan = mainList[0].HCloseMan;
                string HCloseManDate = mainList[0].HCloseManDate;
                string HDeleteMan = mainList[0].HDeleteMan;
                string HDeleteManDate = mainList[0].HDeleteManDate;
                string HBacker = mainList[0].HBacker;
                string HBackerDate = mainList[0].HBackerDate;
                string HBackRemark = mainList[0].HBackRemark;
                ds = oCN.RunProcReturn("select * from Pay_GroupBalBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "Pay_GroupBalBillMain");
                if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//新增
                {
                    string sql = "insert into Pay_GroupBalBillMain" +
                        "(HYear,HPeriod,HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate,HInnerBillNo,HGroupID,HSumMoney,HOtherSubsidy,HDeptID" +
                        ",HPayMoney,HOtherDeduct,HMainSourceBillType,HMainSourceInterID,HMainSourceBillNo,HExplanation,HRemark,HMaker,HMakeDate) " +
                        "values(" +
                        "" + HYear +
                        "," + HPeriod +
                        ",'" + HBillType +
                        "','" + HBillSubType +
                        "','" + HBillStatus +
                        "'," + HInterID +
                        ",'" + HBillNo +
                        "','" + HDate +
                        "','" + HInnerBillNo +
                        "'," + HGroupID +
                        ",'" + HSumMoney +
                        "','" + HOtherSubsidy +
                        "'," + HDeptID +
                        "," + HPayMoney +
                        "," + HOtherDeduct +
                        ",'" + HSourceBillType +
                        "'," + HSourceBillID +
                        ",'" + HSourceBillNo +
                        "','" + HExplanation +
                        "','" + HRemark +
                        "','" + HMaker +
                        "','" + HMakerDate +
                        "')";
                    //主表
                    oCN.RunProc(sql);
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",新增工资结算单(集体):" + HBillNo);
                    oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "新增工资结算单(集体):" + HBillNo + "','LMES-工资结算单(集体)模块','" + DBUtility.ClsPub.IPAddress + "','新增单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                }
                //保存子表
                objJsonResult = AddBillSub1_Pay_GroupBalBill(subTable, HInterID, HBillNo, OperationType);
                objJsonResult = AddBillSub2_Pay_GroupBalBill(subEmpTable, HInterID, HBillNo, 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;
            }
        }
        #endregion
        #region æ·»åŠ  å·¥èµ„结算单(集体) å­è¡¨1
        public json AddBillSub1_Pay_GroupBalBill(List<Pay_GroupBalBillController.Pay_GroupBalBillSub> DetailColl, long HInterID, string HBillNo, int OperationType)
        {
            try
            {
                int i = 0;                                          //作为子表内码
                foreach (Pay_GroupBalBillController.Pay_GroupBalBillSub oSub in DetailColl)
                {
                    i++;                                            //同一个主表下的子表的内码自增
                    int HEntryID = i;
                    int HMaterID = oSub.HMaterID;
                    int HUnitID = oSub.HUnitID;
                    int HProcID = oSub.HProcID;
                    int HSourceID = oSub.HSourceID;
                    double HTimes = oSub.HTimes;
                    double HQty = oSub.HQty;
                    double HPrice = oSub.HPrice;
                    double HMoney = oSub.HMoney;
                    string HRemark = oSub.HRemark;
                    int HICMOInterID = oSub.HICMOInterID;
                    string HICMOBillNo = oSub.HICMOBillNo;
                    int HProcReportInterID = oSub.HProcReportInterID;
                    int HProcReportEntryID = oSub.HProcReportEntryID;
                    string HProcReportBillNo = oSub.HProcReportBillNo;
                    int HProcPlanInterID = oSub.HProcPlanInterID;
                    int HProcPlanEntryID = oSub.HProcPlanEntryID;
                    string HProcPlanBillNo = oSub.HProcPlanBillNo;
                    int HSourceInterID = oSub.HSourceInterID;
                    int HSourceEntryID = oSub.HSourceEntryID;
                    string HSourceBillNo = oSub.HSourceBillNo;
                    string HSourceBillType = oSub.HSourceBillType;
                    double HRelationQty = oSub.HRelationQty;
                    double HRelationMoney = oSub.HRelationMoney;
                    string sql = "insert into Pay_GroupBalBillSub" +
                        "(HInterID,HEntryID,HMaterID,HUnitID,HProcID,HSourceID,HTimes,HQty,HPrice,HMoney,HRemark,HICMOInterID,HICMOBillNo,HProcReportInterID" +
                        ",HProcReportEntryID,HProcReportBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HSourceInterID,HSourceEntryID,HSourceBillNo" +
                        ",HSourceBillType,HRelationQty,HRelationMoney) " +
                        "values(" +
                        "" + HInterID +
                        "," + HEntryID +
                        "," + HMaterID +
                        "," + HUnitID +
                        "," + HProcID +
                        "," + HSourceID +
                        "," + HTimes +
                        "," + HQty +
                        "," + HPrice +
                        "," + HMoney +
                        ",'" + HRemark +
                        "'," + HICMOInterID +
                        ",'" + HICMOBillNo +
                        "'," + HProcReportInterID +
                        "," + HProcReportEntryID +
                        ",'" + HProcReportBillNo +
                        "'," + HProcPlanInterID +
                        "," + HProcPlanEntryID +
                        ",'" + HProcPlanBillNo +
                        "'," + HSourceInterID +
                        "," + HSourceEntryID +
                        ",'" + HSourceBillNo +
                        "','" + HSourceBillType +
                        "'," + HRelationQty +
                        "," + HRelationMoney +
                        ")";
                    oCN.RunProc(sql);
                }
                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;
            }
        }
        #endregion
        #region æ·»åŠ  å·¥èµ„结算单(集体) å­è¡¨2
        public json AddBillSub2_Pay_GroupBalBill(List<Pay_GroupBalBillController.Pay_GroupBalBillEmp> DetailColl, long HInterID, string HBillNo, int OperationType)
        {
            try
            {
                int i = 0;                                          //作为子表内码
                foreach (Pay_GroupBalBillEmp oSub in DetailColl)
                {
                    i++;                                            //同一个主表下的子表的内码自增
                    int HEntryID = i;
                    int HEmpID = oSub.HEmpID;
                    string HEmpNumber = oSub.HEmpNumber;
                    string HEmpName = oSub.HEmpName;
                    double HEmpRate = oSub.HEmpRate;
                    double HBaseTimes = oSub.HBaseTimes;
                    double HMoney = oSub.HMoney;
                    double HOtherSubsidy = oSub.HOtherSubsidy;
                    double HOtherDeduct = oSub.HOtherDeduct;
                    double HYF = oSub.HYF;
                    int HIsPay = oSub.HIsPay ? 1 : 0;
                    int HAvgFlag = oSub.HAvgFlag ? 1 : 0;
                    string HRemark = oSub.HRemark;
                    string sql = "insert into Pay_GroupBalBillEmp" +
                        "(HInterID,HEntryID,HEmpID,HEmpRate,HBaseTimes,HMoney,HOtherSubsidy,HOtherDeduct,HYF,HIsPay,HAvgFlag,HRemark) " +
                        "values(" +
                        "" + HInterID +
                        "," + HEntryID +
                        "," + HEmpID +
                        "," + HEmpRate +
                        "," + HBaseTimes +
                        "," + HMoney +
                        "," + HOtherSubsidy +
                        "," + HOtherDeduct +
                        "," + HYF +
                        "," + HIsPay +
                        "," + HAvgFlag +
                        ",'" + HRemark +
                        "')";
                    oCN.RunProc(sql);
                }
                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;
            }
        }
        #endregion
        #endregion
    }
}
WebAPI/Controllers/¹¤×ʹÜÀí/Pay_SingleBalBillController.cs
@@ -818,6 +818,33 @@
            return objJsonResult;
        }
        #endregion
        #region æ ¹æ®ç‰©æ–™ID、工序ID、资源ID获取工价
        [Route("Pay_SingleBalBill/get_HPrice_BaseMaterHProcHSource")]
        [HttpGet]
        public object get_HPrice_BaseMaterHProcHSource(Int64 HMaterID, Int64 HProcID, Int64 HSourceID)
        {
            try
            {
                DAL.ClsGy_ProcPrice_Ctl oProcPrice = new DAL.ClsGy_ProcPrice_Ctl();
                double HPrice = oProcPrice.LoadProcPrice(HMaterID, HProcID, HSourceID, true);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = HPrice;
                return objJsonResult;
            }
            catch(Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
        #region å·¥èµ„结算单(个人)-查询
WebAPI/Controllers/¹¤×ʹÜÀí/Pay_WorkTimesBillController.cs
@@ -1,4 +1,5 @@
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Pub_Class;
using System;
using System.Collections;
@@ -396,5 +397,52 @@
                return objJsonResult;
            }
        }
        #region è€ƒå‹¤æ±‡æ€»æ•°æ®å¤„理表查询
        [Route("Pay_WorkTimesSumQueryBill/list")]
        [HttpGet]
        public object getWorkTimesSumQueryBillList(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Pay_WorkTimesSumQueryBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("exec h_p_Pay_WorkTimesSumQueryBillList " + sWhere, "Pay_WorkTimesSumQueryBillList");
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}
WebAPI/Properties/PublishProfiles/FolderProfile.pubxml
@@ -10,7 +10,7 @@
    <LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
    <LastUsedPlatform>x86</LastUsedPlatform>
    <PublishProvider>FileSystem</PublishProvider>
    <PublishUrl>E:\网站发布\API</PublishUrl>
    <PublishUrl>D:\网站发布\智云MESWMS\API</PublishUrl>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <SiteUrlToLaunchAfterPublish />
  </PropertyGroup>
WebAPI/WebAPI.csproj
@@ -463,6 +463,7 @@
    <Compile Include="Controllers\Sc_ProcessReportController.cs" />
    <Compile Include="Controllers\人事管理\入职申请\HR_EmpEngageRequestBillController.cs" />
    <Compile Include="Controllers\人事管理\离职申请\HR_EmpDimissionBillController.cs" />
    <Compile Include="Controllers\人事管理\职员异动单\HR_EmpChangeBillController.cs" />
    <Compile Include="Controllers\仓存管理\委外用料\WW_PPBomBillController.cs" />
    <Compile Include="Controllers\仓存管理\扫码异常记录\KF_PonderationBillController.cs" />
    <Compile Include="Controllers\仓存管理\条码出入库记录\Kf_ICStockInOutBillController.cs" />
@@ -504,6 +505,13 @@
    <Compile Include="Controllers\基础资料\基础资料\Xt_CheckFlowBillController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Xt_CheckItemBillController.cs" />
    <Compile Include="Controllers\基础资料\工资基础资料\Gy_ProcCommPriceController.cs" />
    <Compile Include="Controllers\工资管理\Pay_OutApplyBillController.cs" />
    <Compile Include="Controllers\工资管理\Pay_OverApplyBillController.cs" />
    <Compile Include="Controllers\工资管理\Pay_PayMentBillController.cs" />
    <Compile Include="Controllers\工资管理\Pay_SalaryCalculateController.cs" />
    <Compile Include="Controllers\工资管理\Pay_DuSubsidyItemBillController.cs" />
    <Compile Include="Controllers\工资管理\Pay_ErrWorkTimesRequestBillController.cs" />
    <Compile Include="Controllers\工资管理\Pay_ProcPriceRequestBillController.cs" />
    <Compile Include="Controllers\工资管理\Pay_MonthlySalaryReportController.cs" />
    <Compile Include="Controllers\工资管理\Pay_PieceRateWageReportController.cs" />
    <Compile Include="Controllers\工资管理\Gy_ClassTimePrjBillController.cs" />