zzr99
2021-12-08 c0ea121256e4c23dba0efda571269c706766126a
WebAPI/Controllers/¹¤×ʹÜÀí/Pay_GroupBalBillController.cs
@@ -94,13 +94,13 @@
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                string sql = @"SELECT HMaterID,HMaterCode,HMaterName,规格型号 HMaterSpec,HUnitID,HUnitNumber,HUnitName
                string sql = @"SELECT HMaterID,HMaterCode,HMaterName,规格型号 HMaterSpec,HUnitID,HUnitNumber,HUnitName,
                    HProcID,HProcNumber,HProcName,HSourceID,HSourceNumber,HSourceName,工时 HTimes,数量 HQty,工价 HPrice,金额 HMoney, HSumMoney,HOtherSubsidy,HOtherDeduct,HPayMoney FROM h_v_Pay_GroupBalBillList where 1 = 1 " + sqlWhere;
                ds = oCN.RunProcReturn(sql, "h_v_Pay_GroupBalBillList");
                string sql1 = @"select 
 HEmpID ,b.HNumber HEmpNumber, b.HName HEmpName, b.HEmpRate HEmpRate, HBaseTimes, HMoney, HOtherSubsidy, HOtherSubsidy, HYF,'' HISZF ,'' HISFT , a.HRemark
from Pay_GroupBalBillEmp a
 left join Gy_Employee b on a.HEmpID = b.HItemID " + sqlWhere.Replace("hmainid", "HInterID");
 left join Gy_Employee b on a.HEmpID = b.HItemID  where 1 = 1  " + sqlWhere.Replace("hmainid", "HInterID");
                ds1 = oCN.RunProcReturn(sql1, "Pay_GroupBalBillEmp");
                list.Add(ds.Tables[0]);
                list.Add(ds1.Tables[0]);
@@ -120,6 +120,146 @@
        }
        #endregion
        #region è®¾å¤‡ä¿å…»è®¡åˆ’表 ä¿å­˜/编辑
        /// <summary>
        /// ä¿å­˜æ¨¡å…·ç»´ä¿®å•
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        [Route("Pay_GroupBalBill/AddBill")]
        [HttpPost]
        public object AddBill([FromBody] JObject sMainSub)
        {
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string msg3 = sArray[1].ToString();
            string msg4 = sArray[2].ToString();
            string UserName = "";
            ListModels oListModels = new ListModels();
            try
            {
                DLL.ClsPay_GroupBalBill oBill = new DLL.ClsPay_GroupBalBill();
                List<Models.ClsPay_GroupBalBillMain> lsmain = new List<Models.ClsPay_GroupBalBillMain>();
                msg2 = msg2.Replace("\\", "");
                msg2 = msg2.Replace("\n", "");  //\n
                lsmain = oListModels.getObjectByJson_Pay_GroupBalBillMain(msg2);
                foreach (Models.ClsPay_GroupBalBillMain oItem in lsmain)
                {
                    UserName = oItem.HMaker;  //制单人
                    oItem.HBillType = "2202";
                    oItem.HBillSubType = "2202";
                    //oItem.HInterID =0;
                    //oItem.HBillNo = "";
                    oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));//  --日期
                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
                    //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo);
                    if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "保存失败!没有单据日期,无法保存!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    oBill.omodel = oItem;
                }
                //保养项表体数据
                //按 },{来拆分数组 //去掉【和】
                msg3 = msg3.Substring(1, msg3.Length - 2);
                msg3 = msg3.Replace("\\", "");
                msg3 = msg3.Replace("\n", "");  //\n
                //msg2 = msg2.Replace("'", "’");
                List<Models.ClsPay_GroupBalBillSub> ls = new List<Models.ClsPay_GroupBalBillSub>();
                ls = oListModels.getObjectByJson_Pay_GroupBalBillSub(msg3);
                int i = 0;
                foreach (Models.ClsPay_GroupBalBillSub item in ls)
                {
                    i++;
                    item.HEntryID = i;
                    //oItemSub.HCloseMan = "";       //行关闭
                    item.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                    item.HCloseType = false;   //关闭类型
                    //oItemSub.HRemark = "";         //备注
                    item.HSourceInterID = 0;     // æºå•主内码
                    item.HSourceEntryID = 0;   //源单子内码
                    //oItemSub.HSourceBillNo = "";  //源单单号
                    //oItemSub.HSourceBillType = ""; //源单类型
                    item.HRelationQty = 0;     //关联数量
                    oBill.DetailColl.Add(item);
                }
                //配件项表体数据
                //按 },{来拆分数组 //去掉【和】
                msg4 = msg4.Substring(1, msg4.Length - 2);
                msg4 = msg4.Replace("\\", "");
                msg4 = msg4.Replace("\n", "");  //\n
                                                //msg2 = msg2.Replace("'", "’");
                List<Models.ClsPay_GroupBalBillEmp> ls1 = new List<Models.ClsPay_GroupBalBillEmp>();
                ls1 = oListModels.getObjectByJson_Pay_GroupBalBillEmp(msg4);
                int j = 0;
                foreach (Models.ClsPay_GroupBalBillEmp oItemSub in ls1)
                {
                    j++;
                    oItemSub.HEntryID = j;
                    //oItemSub.HCloseMan = "";       //行关闭
                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                    oItemSub.HCloseType = false;   //关闭类型
                                                   //oItemSub.HRemark = "";         //备注
                    oItemSub.HSourceInterID = 0;     // æºå•主内码
                    oItemSub.HSourceEntryID = 0;   //源单子内码
                                                   //oItemSub.HSourceBillNo = "";  //源单单号
                                                   //oItemSub.HSourceBillType = ""; //源单类型
                    oItemSub.HRelationQty = 0;     //关联数量
                    oBill.DetailEmpColl.Add(oItemSub);
                }
                //保存
                //保存完毕后处理
                bool bResult;
                if (oBill.omodel.HInterID == 0)
                {
                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    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 = "保存成功!";
                    //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单");
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
                objJsonResult.data = 1;
                return objJsonResult;
            }
        }
        #endregion
        /// <summary>
        ///工资结算个人单删除功能
        /// </summary>