zrg
2024-04-02 7eec29ace1b0fd5e8e9671c7b13120b36d14b596
WebAPI/Controllers/¹¤×ʹÜÀí/Pay_WorkTimesBillController.cs
@@ -30,11 +30,11 @@
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        public DAL.ClsPay_WorkTimesBill oBill = new DAL.ClsPay_WorkTimesBill();
        public DAL.ClsPay_WorkTimesBill BillNew = new DAL.ClsPay_WorkTimesBill();   //对应单据类
        public DAL.ClsPay_WorkTimesBill BillOld = new DAL.ClsPay_WorkTimesBill();   //对应单据类
        public DLL.ClsPay_WorkTimesBill BillNew0 = new DLL.ClsPay_WorkTimesBill();   //
        public DLL.ClsPay_WorkTimesBill BillOld0 = new DLL.ClsPay_WorkTimesBill();   //
        #region è€ƒå‹¤æ±‡æŠ¥å•列表
        #region è€ƒå‹¤æ±‡æŠ¥å•列表信息
        /// <summary>
        /// èŽ·å–è€ƒå‹¤æ±‡æŠ¥å•åˆ—è¡¨ä¿¡æ¯
        /// </summary>
@@ -591,7 +591,7 @@
        }
        #endregion
        #region è€ƒå‹¤æ±‡æŠ¥å•编辑
        #region è€ƒå‹¤æ±‡æŠ¥å•模块   ä»Žåˆ—表选中打开单据,返回单据信息时调用
        /// <summary>
        /// è€ƒå‹¤æ±‡æŠ¥å•编辑时,根据单据ID获取单据信息
        /// </summary>
@@ -624,7 +624,7 @@
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "成功!";
                    objJsonResult.data = ds.Tables[0];
@@ -642,6 +642,201 @@
        }
        #endregion
        #region è€ƒå‹¤æ±‡æŠ¥å•保存
        /// <summary>
        /// è€ƒå‹¤æ±‡æŠ¥å•保存
        /// </summary>
        [Route("Pay_WorkTimesBillController/GetPay_WorkTimesBill_Save_Json")]
        [HttpPost]
        public object GetPay_WorkTimesBill_Save_Json([FromBody] JObject sMainSub)
        {
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string sMainStr = sArray[0].ToString();         //主表数据
            string sSubStr = sArray[1].ToString();          //子表数据
            string OperationType = sArray[2].ToString();    //操作类型(1新增、2编辑)
            string HMaker = sArray[3].ToString();           //制单人
            try
            {
                //判断权限
                if (OperationType == "1")
                {
                    BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
                    //判断新增权限
                    if (!DBUtility.ClsPub.Security_Log(ModRightName, 1, false, HMaker))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "您没有该模块新增权限,请与管理员联系!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify;
                    //判断编辑权限
                    if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 1, false, HMaker))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "您没有该模块编辑权限,请与管理员联系!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                //表头赋值
                sMainStr = sMainStr.Replace("\\", "");
                sMainStr = sMainStr.Replace("\n", "");
                sMainStr = "[" + sMainStr.ToString() + "]";
                List<Model.ClsPay_WorkTimesBillMain> lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsPay_WorkTimesBillMain>>(sMainStr);
                foreach (Model.ClsPay_WorkTimesBillMain oItem in lsmain)
                {
                    //单据号是否重复
                    if (oBill.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, oItem.HInterID))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据号重复!不允许保存!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //判断会计期是否合理
                    string s = "";
                    int sYear = 0;
                    int sPeriod = 0;
                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod_Pay(oItem.HDate, ref sYear, ref sPeriod, ref s) == false)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = s;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    oItem.HYear = sYear;
                    oItem.HPeriod = sPeriod;
                    DBUtility.ClsPub.CurUserName = oItem.HMaker;
                    oBill.omodel = oItem;
                }
                //表体赋值
                //按 },{来拆分数组 //去掉【和】
                sSubStr = sSubStr.Substring(1, sSubStr.Length - 2);
                sSubStr = sSubStr.Replace("\\", "");
                sSubStr = sSubStr.Replace("\n", "");
                sSubStr = "[" + sSubStr.ToString() + "]";
                List<Model.ClsPay_WorkTimesBillSub> ls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsPay_WorkTimesBillSub>>(sSubStr);
                int i = 0;
                foreach (Model.ClsPay_WorkTimesBillSub oItemSub in ls)
                {
                    i++;
                    oItemSub.HEntryID = i;
                    oBill.DetailColl.Add(oItemSub);
                }
                //保存
                bool bResult;
                if (OperationType == "1")   //新增保存
                {
                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                }
                else                        //编辑保存
                {
                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                }
                if (bResult)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;  //成功!
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.Message;
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        //---------------------------------------------------------------------------------------------旧方法
        /// <summary>
        /// è¿”回考勤汇报单列表
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Pay_WorkTimesBill/GetWorkTimesBill")]
        [HttpGet]
        public object GetWorkTimesBill(string sWhere, string user)
        {
            try
            {
                if (!DBUtility.ClsPub.Security_Log("Pay_WorkTimesBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = Sc_GetWorkTimesBill(sWhere);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "返回记录成功!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        public static DataSet Sc_GetWorkTimesBill(string sWhere)
        {
            if (sWhere == null || sWhere.Equals(""))
            {
                return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Pay_WorkTimesBillList order by hmainid desc", "h_v_Pay_WorkTimesBillList");
            }
            else
            {
                string sql1 = "select * from h_v_Pay_WorkTimesBillList where 1 = 1 ";
                string sql = sql1 + sWhere + " order by hmainid desc";
                return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Pay_WorkTimesBillList");
            }
        }
        #region[考勤汇报单编辑时获取表头数据]
@@ -664,38 +859,34 @@
        #region[考勤汇报单编辑时获取表体数据]
        [Route("Pay_WorkTimesBill/Pay_WorkTimesBillListProjectDetai")]
        [HttpGet]
        public object Pay_WorkTimesBillListProjectDetai(Int64 HInterID)
        public object Pay_WorkTimesBillListProjectDetai(string sqlWhere)
        {
            DataSet ds;
            try
            {
                ds = oCn.RunProcReturn("exec h_p_Pay_WorkTimesBill_EditInit " + HInterID, "h_p_Pay_WorkTimesBill_EditInit");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "未查询到该考勤汇报单,请刷新数据后重新选择!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                string sql1 = "SELECT  HDeptID,部门代码,部门,HGroupID" +
                    ",班组代码,班组,表头备注,制单人,制单日期,审核人" +
                    ",审核日期,修改人,修改日期,关闭人, å…³é—­æ—¥æœŸ,HEmpID" +
                    ",HEmpNumber,HEmpName,职员系数 HEmpRate,基本天数 HBaseDays,基本工时 HBaseTimes,加班工时 HOverTimes,请假工时 HLeaveTimes,加班天数 HOverDays,请假天数 HLeaveDays,迟到次数 HLateQty" +
                    ",公出 HOutForComQty,私出 HOutForEmpQty,公出时间 HOutForComTimes,私出时间 HOutForEmpTimes,迟到时间 HLateTimes,早退次数 HEarlyQty,早退时间 HEarlyTimes" +
                    ",旷工天数 HAbsentDays,上午 HAMTimes,下午 HPMTimes,HCTPrjID,HCTPrjNumber,HCTPrjName,HWorkTypeID,HWorkTypeNumber,HWorkTypeName,HPayMoney,HMoney" +
                    ",表体备注 HRemark,HRestFlag,HSchClassID FROM h_v_Pay_WorkTimesBillList where 1 = 1 ";
                string sql = sql1 + sqlWhere;
                ds = oCN.RunProcReturn(sql, "h_v_Pay_WorkTimesBillList");
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "获取信息成功!";
                objJsonResult.data = ds.Tables[0];
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "返回考勤汇报单信息失败!" + e.ToString();
                objJsonResult.Message = "没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
            return objJsonResult;
        }
        #endregion
@@ -742,7 +933,7 @@
                    if (refSav == "Add")
                    {
                        //单据号是否重复
                        if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID))
                        if (BillNew0.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld0.omodel.HInterID))
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
@@ -753,7 +944,7 @@
                    }
                    if (refSav == "Update")
                    {
                        if (BillOld.ShowBill(oItem.HInterID, ref s) == false)
                        if (BillOld0.ShowBill(oItem.HInterID, ref s) == false)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
@@ -762,7 +953,7 @@
                            return objJsonResult;
                        }
                        //判断是否可编辑
                        if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null)
                        if (BillOld0.omodel.HChecker != "" && BillOld0.omodel.HChecker != null)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
@@ -770,7 +961,7 @@
                            objJsonResult.data = 1;
                            return objJsonResult;
                        }
                        if (BillOld.omodel.HBillStatus > 1)
                        if (BillOld0.omodel.HBillStatus > 1)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
@@ -778,7 +969,7 @@
                            objJsonResult.data = 1;
                            return objJsonResult;
                        }
                        if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld, ref s))
                        if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld0, ref s))
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
@@ -864,6 +1055,45 @@
        }
        /// <summary>
        ///工资结算个人单删除功能
        /// </summary>
        /// <returns></returns>
        [Route("Pay_WorkTimesBill/DeltetWorkTimesBill")]
        [HttpGet]
        public object DeltetWorkTimesBill(string HInterID, string user)
        {
            try
            {
                if (!DBUtility.ClsPub.Security_Log("Pay_WorkTimesBill_Drop", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无删除权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCn.BeginTran();
                oCn.RunProc("Delete From Pay_WorkTimesBillMain where HInterID = " + HInterID);
                oCn.RunProc("Delete From Pay_WorkTimesBillSub where HInterID = " + HInterID);
                oCn.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "删除成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCn.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        /// <summary>
        /// é€šè¿‡ç­ç»„查询职员信息
        ///参数:string sql。
        ///返回值:object。