1
zrg
2024-06-25 4bfab3d9173fcced07cea4afb71227b83b47c469
WebAPI/Controllers/¹¤×ʹÜÀí/Pay_SingleBalBillController.cs
@@ -592,7 +592,231 @@
        }
        #endregion
        #region å·¥èµ„结算单(个人)模块   ä»Žåˆ—表选中打开单据,返回单据信息时调用
        /// <summary>
        /// å·¥èµ„结算单(个人)编辑时,根据单据ID获取单据信息
        /// </summary>
        /// <returns></returns>
        [Route("Pay_SingleBalBillController/GetPay_SingleBalBill_Json")]
        [HttpGet]
        public object GetPay_SingleBalBill_Json(Int64 HInterID, string HMaker)
        {
            try
            {
                //判断权限
                if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 3, false, HMaker))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "您没有该模块编辑权限,请与管理员联系!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //返回列表信息
                ds = oCn.RunProcReturn("exec h_p_Pay_SingleBalBill_EditInit " + HInterID, "h_p_Pay_SingleBalBill_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 = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "返回工资结算单(个人)信息失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region å·¥èµ„结算单(个人)保存
        /// <summary>
        /// å·¥èµ„结算单(个人)保存
        /// </summary>
        [Route("Pay_SingleBalBillController/GetPay_SingleBalBill_Save_Json")]
        [HttpPost]
        public object GetPay_SingleBalBill_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_SingleBalBillMain> lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsPay_SingleBalBillMain>>(sMainStr);
                foreach (Model.ClsPay_SingleBalBillMain 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_SingleBalBillSub> ls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsPay_SingleBalBillSub>>(sSubStr);
                int i = 0;
                foreach (Model.ClsPay_SingleBalBillSub 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
        #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
        //---------------------------------------------------------------------------------------------旧方法
        #region å·¥èµ„结算单个人-查询
        /// <summary>
@@ -1375,33 +1599,6 @@
                    objJsonResult.data = null;
                    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