1
wtt
6 天以前 221487ffd7c7bb915b51cbd29b904aff1c9c5cf0
WebAPI/Controllers/PM_ProjectCommunicationBillListController.cs
@@ -160,7 +160,7 @@
                    [HCusID], [HPMEmpID], [HWorkEmpID], [HProSituation], [HProRisk], [HProProgramme], 
                    [HReportEmpID], [HOrgID]
                ) 
                VALUES ({DateTime.Now.Year}, {DateTime.Now.Month},  '{list[0].HBillType}',  '{list[0].HBillSubType}', {list[0].HInterID},  '{list[0].HDate}',  '{list[0].HBillNo}',  1, 0,  0, 0, '{list[0].HRemark ?? ""}',  '{list[0].HBacker ?? ""}',  '{(list[0].HBackDate)}',  '{list[0].HBackRemark ?? ""}', '{list[0].HChecker ?? ""}',  '{(list[0].HCheckDate)}',  '{list[0].HMaker ?? ""}',  '{(list[0].HMakeDate)}',  '{list[0].HUpDater ?? ""}',  '{(list[0].HUpDateDate)}',  '{list[0].HCloseMan ?? ""}',  '{(list[0].HCloseDate)}',  '{list[0].HCloseType }',  '{list[0].HDeleteMan ?? ""}',  '{(list[0].HDeleteDate)}',  '{list[0].HMainSourceBillType ?? ""}',  '{list[0].HMainSourceInterID}',  '{list[0].HMainSourceEntryID}',  '{list[0].HMainSourceBillNo ?? ""}',  '{list[0].HPrintQty}',   {list[0].HProjectID },  '{list[0].HProNumber ?? ""}',  '{list[0].HProName ?? ""}',  {list[0].HCusID },  {list[0].HPMEmpID }, {list[0].HWorkEmpID }, '{list[0].HProSituation ?? ""}', '{list[0].HProRisk ?? ""}', '{list[0].HProProgramme ?? ""}', {list[0].HReportEmpID}, {100038} );";
                VALUES ({DateTime.Now.Year}, {DateTime.Now.Month},  '{list[0].HBillType}',  '{list[0].HBillSubType}', {list[0].HInterID},  '{list[0].HDate}',  '{list[0].HBillNo}',  1, 0,  0, 0, '{list[0].HRemark ?? ""}',  '{list[0].HBacker ?? ""}',  '{(list[0].HBackDate)}',  '{list[0].HBackRemark ?? ""}', '{ ""}',  '{(list[0].HCheckDate)}',  '{list[0].HMaker ?? ""}',  '{(list[0].HMakeDate)}',  '{list[0].HUpDater ?? ""}',  '{(list[0].HUpDateDate)}',  '{list[0].HCloseMan ?? ""}',  '{(list[0].HCloseDate)}',  '{list[0].HCloseType }',  '{list[0].HDeleteMan ?? ""}',  '{(list[0].HDeleteDate)}',  '{list[0].HMainSourceBillType ?? ""}',  '{list[0].HMainSourceInterID}',  '{list[0].HMainSourceEntryID}',  '{list[0].HMainSourceBillNo ?? ""}',  '{list[0].HPrintQty}',   {list[0].HProjectID },  '{list[0].HProNumber ?? ""}',  '{list[0].HProName ?? ""}',  {list[0].HCusID },  {list[0].HPMEmpID }, {list[0].HWorkEmpID }, '{list[0].HProSituation ?? ""}', '{list[0].HProRisk ?? ""}', '{list[0].HProProgramme ?? ""}', {list[0].HReportEmpID}, {100038} );";
                    oCN.RunProc(sql);
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
@@ -173,14 +173,15 @@
                }
                else
                {
                    //若MAINDI重复则重新获取
                    oCN.BeginTran();
                    //主表
                    oCN.RunProc("Update PM_ProjectCommunicationBillMain" + " set " +
                    " HProSituation='" + list[0].HProSituation + "'" +
                    ",HProRisk='" + list[0].HProRisk + "'" +
                    ",HProProgramme='" + list[0].HProProgramme + "'" +
                    ",HReportEmpID=" + list[0].HReportEmpID +
                    ",HUpDater='" + UserName +"'"+
                    ",HUpDateDate='" + DateTime.Now +"'"+
                    " Where HInterID=" + list[0].HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
@@ -239,5 +240,206 @@
                return objJsonResult;
            }
        }
        #region  删除
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("PM_ProjectCommunicationBillList/delete")]
        [HttpGet]
        public object delete(string HInterID, string user)
        {
            try
            {
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Pm_ProjectBill_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;
                }
                DataSet ds=oCN.RunProcReturn("select HChecker from PM_ProjectCommunicationBillMain where HInterID=" + HInterID, "PM_ProjectCommunicationBillMain");
                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;
                }
                oCN.BeginTran();
                oCN.RunProc("delete from PM_ProjectCommunicationBillMain 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("PM_ProjectCommunicationBillList/AuditPM_ProjectCommunicationBillList")]
        [HttpGet]
        public object AuditPM_ProjectCommunicationBillList(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有审核权限
                if (!DBUtility.ClsPub.Security_Log("Pm_ProjectBill_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;
                oCN.BeginTran();//开始事务
                //Type 1 审核  2  反审核
                if (Type == 1)
                {
                    //判断单据是否已经审核
                    DataSet ds;
                    string sql = "select * from PM_ProjectCommunicationBillMain where HInterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, "PM_ProjectCommunicationBillMain");
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据不存在!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    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 (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 (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;
                        }
                        string sqll = $"update PM_ProjectCommunicationBillMain set HChecker ='{user}', HCheckDate=GETDATE(),HBillStatus=2 where HInterID={HInterID} ";
                        oCN.RunProc(sqll);
                    }
                }
                else
                {
                    //判断单据是否已经反审核
                    DataSet ds;
                    string sql = "select * from PM_ProjectCommunicationBillMain where HInterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, "PM_ProjectCommunicationBillMain");
                    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 (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 (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;
                        }
                        //反审核单据
                        string sqll = $"update PM_ProjectCommunicationBillMain set HChecker ='',HBillStatus=1 where HInterID={HInterID} ";
                        oCN.RunProc(sqll);
                    }
                }
                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
    }
}