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 System.Threading.Tasks; using DLL; namespace WebAPI.Controllers.项目管理.工作任务 { public class PM_WorkTaskBillController : 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 = ""; public DAL.ClsPM_WorkTaskMoneyBillMain BillNew0 = new DAL.ClsPM_WorkTaskMoneyBillMain(); //任务费用单对应单据类 public DAL.ClsGy_WorkTaskMoneyBOMBill BillNew1 = new DAL.ClsGy_WorkTaskMoneyBOMBill(); //任务费用清单对应单据类 public DAL.ClsGy_WorkTaskMoneyBOMBill BillOld1 = new DAL.ClsGy_WorkTaskMoneyBOMBill(); #region 工作任务 新增/编辑 #region 工作任务 表头数据 public class PM_WorkTaskBill_Main { public int HInterID; public string HBillNo; public int HProjectID; public string HProNumber; public string HProName; public int HProjectStageID; public string HProjectStageName; public string HName; public string HDate; public string HTaskNote; public double HPlanTimes; public double HSelfTimes; public string HLastDate; public string HSendEmp; public string HReceiveEmp; public string HType; public string HCopyEmp; public string HRemark; public int HOrgID; public string HMaker; public string HUpdater; public string HChecker; public string HMakerDate; public string HUpdaterDate; public string HCheckerDate; public string HCloseMan; public string HDeleteMan; public string HBacker; public string HCloseManDate; public string HDeleteManDate; public string HBackerDate; public string HBackRemark; public int HMainSourceInterID; public int HMainSourceEntryID; public string HMainSourceBillNo; public string HMainSourceBillType; public int HOrderLevID; public int HTaskClassID; } #endregion #region 工作任务 新增/编辑 /// /// 新增单据-保存按钮 ///参数:string sql。 ///返回值:object。 /// [Route("PM_WorkTaskBill/AddBill")] [HttpPost] public object AddBill([FromBody] JObject sMainSub) { //获取参数 var _value = sMainSub["sMainSub"].ToString(); string msg1 = _value.ToString(); //开始事务 oCN.BeginTran(); //保存主表 objJsonResult = AddBillMain(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(string msg1) { string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); int OperationType = int.Parse(sArray[1].ToString());//数据类型 1添加 3修改 2 复制 string user = sArray[2].ToString();//用户名 string HComputerName = SystemInformation.ComputerName; //设备名称 user_LongShan = sArray[2].ToString();//用户名 try { if(OperationType == 1) { //判断是否有新增权限 if (!DBUtility.ClsPub.Security_Log("Pm_WorkTaskBill_add", 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("Pm_WorkTaskBill_edit", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无编辑权限!"; objJsonResult.data = null; return objJsonResult; } } msg2 = "[" + msg2.ToString() + "]"; List mainList = Newtonsoft.Json.JsonConvert.DeserializeObject>(msg2); int HYear = int.Parse(mainList[0].HDate.Split('-')[0]); int HPeriod = int.Parse(mainList[0].HDate.Split('-')[1]); string HBillType = "4753"; string HBillSubType = ""; int HInterID = mainList[0].HInterID; string HBillNo = mainList[0].HBillNo; int HProjectID = mainList[0].HProjectID; string HProNumber = mainList[0].HProNumber; string HProName = mainList[0].HProName; int HProjectStageID = mainList[0].HProjectStageID; string HProjectStageName = mainList[0].HProjectStageName; string HName = mainList[0].HName; string HDate = mainList[0].HDate; string HTaskNote = mainList[0].HTaskNote; double HPlanTimes = mainList[0].HPlanTimes; double HSelfTimes = mainList[0].HSelfTimes; string HLastDate = mainList[0].HLastDate; string HSendEmp = mainList[0].HSendEmp; string HReceiveEmp = mainList[0].HReceiveEmp; string HType = mainList[0].HType; string HCopyEmp = mainList[0].HCopyEmp; string HRemark = mainList[0].HRemark; int HOrgID = mainList[0].HOrgID; string HMaker = mainList[0].HMaker; string HUpdater = mainList[0].HUpdater; string HChecker = mainList[0].HChecker; string HMakerDate = mainList[0].HMakerDate; string HUpdaterDate = mainList[0].HUpdaterDate; string HCheckerDate = mainList[0].HCheckerDate; string HCloseMan = mainList[0].HCloseMan; string HDeleteMan = mainList[0].HDeleteMan; string HBacker = mainList[0].HBacker; string HCloseManDate = mainList[0].HCloseManDate; string HDeleteManDate = mainList[0].HDeleteManDate; string HBackerDate = mainList[0].HBackerDate; string HBackRemark = mainList[0].HBackRemark; int HMainSourceInterID = mainList[0].HMainSourceInterID; int HMainSourceEntryID = mainList[0].HMainSourceEntryID; string HMainSourceBillNo = mainList[0].HMainSourceBillNo; string HMainSourceBillType = mainList[0].HMainSourceBillType; int HOrderLevID = mainList[0].HOrderLevID; int HTaskClassID = mainList[0].HTaskClassID; if (OperationType == 2) { ds = oCN.RunProcReturn("select * from PM_WorkTaskBillMain where HBillNo ='" + HBillNo + "'", "PM_WorkTaskBillMain"); 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 PM_WorkTaskBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "PM_WorkTaskBill"); if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//新增 { string sql = "insert into PM_WorkTaskBillMain" + "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HBillNo,HProjectID,HProNumber,HProjectStageID,HName,HDate,HTaskNote,HPlanTimes" + ",HSelfTimes,HLastDate,HSendEmp,HReceiveEmp,HType,HCopyEmp,HRemark,HOrgID,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType,HOrderLevID,HTaskClassID)" + "values(" + "" + HYear + "," + HPeriod + ",'" + HBillType + "','" + HBillSubType + "'," + HInterID + ",'" + HBillNo + "'," + HProjectID + ",'" + HProNumber + "'," + HProjectStageID + ",'" + HName + "','" + HDate + "','" + HTaskNote + "'," + HPlanTimes + "," + HSelfTimes + ",'" + HLastDate + "','" + HSendEmp + "','" + HReceiveEmp + "','" + HType + "','" + HCopyEmp + "','" + HRemark + "'," + HOrgID + ",'" + HMaker + "','" + HMakerDate + "'," + HMainSourceInterID + "," + HMainSourceEntryID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "','" + HOrderLevID + "','"+ HTaskClassID+ "')"; //主表 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 PM_WorkTaskBillMain set " + "HYear = " + HYear + ",HPeriod = " + HPeriod + ",HBillType = '" + HBillType + "',HBillSubType = '" + HBillSubType + "',HBillNo = '" + HBillNo + "',HProjectID = " + HProjectID + ",HProNumber = '" + HProNumber + "',HProjectStageID = " + HProjectStageID + ",HName = '" + HName + "',HDate = '" + HDate + "',HTaskNote = '" + HTaskNote + "',HPlanTimes = " + HPlanTimes + ",HSelfTimes = " + HSelfTimes + ",HLastDate = '" + HLastDate + "',HSendEmp = '" + HSendEmp + "',HReceiveEmp = '" + HReceiveEmp + "',HType = '" + HType + "',HCopyEmp = '" + HCopyEmp + "',HRemark = '" + HRemark + "',HOrgID = " + HOrgID + ",HUpdater = '" + HUpdater + "',HUpdateDate = '" + HUpdaterDate + "',HMainSourceInterID = " + HMainSourceInterID + ",HMainSourceEntryID = " + HMainSourceEntryID + ",HMainSourceBillNo = '" + HMainSourceBillNo + "',HMainSourceBillType = '" + HMainSourceBillType + "',HOrderLevID = '" + HOrderLevID + "',HTaskClassID = '" + HTaskClassID + "' where HInterID = " + HInterID; oCN.RunProc(sql); //删除子表 oCN.RunProc("delete from PM_WorkTaskBillSub 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); } else if (OperationType == 4 && ds.Tables[0].Rows.Count == 0) //下推 { string sql = "insert into PM_WorkTaskBillMain" + "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HBillNo,HProjectID,HProNumber,HProjectStageID,HName,HDate,HTaskNote,HPlanTimes" + ",HSelfTimes,HLastDate,HSendEmp,HReceiveEmp,HType,HCopyEmp,HRemark,HOrgID,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType,HOrderLevID )" + "values(" + "" + HYear + "," + HPeriod + ",'" + HBillType + "','" + HBillSubType + "'," + HInterID + ",'" + HBillNo + "'," + HProjectID + ",'" + HProNumber + "'," + HProjectStageID + ",'" + HName + "','" + HDate + "','" + HTaskNote + "'," + HPlanTimes + "," + HSelfTimes + ",'" + HLastDate + "','" + HSendEmp + "','" + HReceiveEmp + "','" + HType + "','" + HCopyEmp + "','" + HRemark + "'," + HOrgID + ",'" + HMaker + "','" + HMakerDate + "'," + HMainSourceInterID + "," + HMainSourceEntryID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "','" + HOrderLevID + "')"; //主表 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(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(long HInterID, string HBillNo, int OperationType) { string sql = "insert into PM_WorkTaskBillSub" + "(HInterID,HEntryID,HBillNo_bak,HRemark) " + "values(" + "" + HInterID + "," + 1 + ",'" + HBillNo + "','" + "" + "')"; oCN.RunProc(sql); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = null; objJsonResult.data = null; return objJsonResult; } #endregion #endregion #region 工作任务列表 查询 /// /// 返回项目阶段列表 ///参数:string sql。 ///返回值:object。 /// [Route("PM_WorkTaskBill/list")] [HttpGet] public object getWorkTaskBill(string sWhere, string user) { try { List columnNameList = new List(); //查看权限 //if (!DBUtility.ClsPub.Security_Log("Gy_ProjectStage_Query", 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_PM_WorkTaskBillList order by 单据号 desc", "h_v_PM_WorkTaskBillList"); } else { string sql1 = "select * from h_v_PM_WorkTaskBillList where 1 = 1 "; string sql = sql1 + sWhere + " order by 单据号 desc"; ds = oCN.RunProcReturn(sql, "h_v_PM_WorkTaskBillList"); } //添加列名 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 工作任务列表 下推数据查询 /// /// 返回项目阶段列表 ///参数:string sql。 ///返回值:object。 /// [Route("PM_WorkTaskBill/XTList")] [HttpGet] public object XTList(string HInterID,string user) { try { List columnNameList = new List(); ds = oCN.RunProcReturn("select * from h_v_PM_WorkTaskBillMyList where HInterID ='"+ HInterID + "' and 接单人='"+user+"'", "h_v_PM_WorkTaskBillMyList"); //添加列名 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 订单等级列表 查询 /// /// 返回项目阶段列表 ///参数:string sql。 ///返回值:object。 /// [Route("PM_WorkTaskBill/getOrder")] [HttpGet] public object getOrder() { try { List columnNameList = new List(); //if (HItemID == null || HItemID.Equals("")) //{ //ds = oCN.RunProcReturn("select * from Gy_OrderLev ", "Gy_OrderLev"); //} //else //{ // string sql = "select * from Gy_OrderLev where HItemID='"+ HItemID + "'"; // ds = oCN.RunProcReturn(sql, "Gy_OrderLev"); //} ds = oCN.RunProcReturn("select * from Gy_OrderLev ", "Gy_OrderLev"); //添加列名 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 工作任务 编辑-页面赋值 /// ///参数:string HInterID。 ///返回值:object。 /// [Route("PM_WorkTaskBill/editInit")] [HttpGet] public object getWorkTaskBilleditInit(string HInterID, string user) { try { //查看权限 if (!DBUtility.ClsPub.Security_Log("Pm_WorkTaskBill_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_PM_WorkTaskBill_EditInit " + HInterID, "h_p_PM_WorkTaskBill_EditInit"); 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 工作任务 删除 /// ///参数:string HInterID。 ///返回值:object。 /// [Route("PM_WorkTaskBill/delete")] [HttpGet] public object deleteWorkTaskBill(string HInterID, string user) { try { //查看权限 if (!DBUtility.ClsPub.Security_Log("Pm_WorkTaskBill_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 PM_WorkTaskBillMain where HInterID = " + HInterID); oCN.RunProc("delete from PM_WorkTaskBillSub 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 工作任务 审核/反审核 /// /// /// /// 单据ID /// 审核(0),反审核(1) /// 审核人 /// [Route("PM_WorkTaskBill/AuditPM_WorkTaskBill")] [HttpGet] public object AuditPM_WorkTaskBill(string HInterID, int Type, string user) { try { //判断是否有审核权限 if (!DBUtility.ClsPub.Security_Log("Pm_WorkTaskBill_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 = "PM_WorkTaskBillMain"; 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 == 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; } //审核单据 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]["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; } //反审核单据 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("PM_WorkTaskBill/ClosePM_WorkTaskBill")] [HttpGet] public object ClosePM_WorkTaskBill(string HInterID, int Type, string user) { try { //判断是否有删除权限 if (!DBUtility.ClsPub.Security_Log("Pm_WorkTaskBill_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 = "PM_WorkTaskBillMain"; 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 == 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]["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; } 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]["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; } 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("PM_WorkTaskBill/DropPM_WorkTaskBill")] [HttpGet] public object DropPM_WorkTaskBill(string HInterID, int Type, string user) { try { //判断是否有作废权限 if (!DBUtility.ClsPub.Security_Log("Pm_WorkTaskBill_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 = "PM_WorkTaskBillMain"; 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 == 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]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].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 (!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]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].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 (!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("PM_WorkTaskBill/BeginPM_WorkTaskBill")] [HttpGet] public object BeginPM_WorkTaskBill(string HInterID, int Type, string user) { try { if (string.IsNullOrWhiteSpace(HInterID)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "HInterID为空!"; objJsonResult.data = null; return objJsonResult; } ClsPub.CurUserName = user; BillOld.MvarItemKey = "PM_WorkTaskBillMain"; oCN.BeginTran();//开始事务 //Type 0 开始任务 1 撤销任务 2结束任务 if (Type == 0) { //判断单据是否存在 DataSet ds; string sql = "select * from PM_WorkTaskBillMain where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, "PM_WorkTaskBillMain"); 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 (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HMainSourceBillType"])== "4759") { var lInterID = ds.Tables[0].Rows[0]["HMainSourceInterID"]; string sql1 = "update PM_WorkTaskBillMain set HTaskStatus='已开始' where HinterID = " + HInterID; oCN.RunProc(sql1); string sql2 = "update PM_CustomerTaskBillMain set HTaskStatus='已开始' where HinterID = " + lInterID; oCN.RunProc(sql2); } else { string sql2 = "update PM_WorkTaskBillMain set HTaskStatus='已开始' where HinterID = " + HInterID; oCN.RunProc(sql2); } } } else if(Type==1) { //判断单据是否存在 DataSet ds; string sql = "select * from PM_WorkTaskBillMain where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, "PM_WorkTaskBillMain"); 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) { var lInterID = ds.Tables[0].Rows[0]["HMainSourceInterID"]; string sql1 = "update PM_WorkTaskBillMain set HTaskStatus='未开始' where HinterID = " + HInterID; oCN.RunProc(sql1); string sql2 = "update PM_CustomerTaskBillMain set HTaskStatus='未开始' where HinterID = " + lInterID; oCN.RunProc(sql2); } } oCN.Commit();//提交事务 objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "执行成功!"; objJsonResult.data = null; return objJsonResult; ; } catch (Exception e) { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "执行失败!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 工作任务 催促次数功能 [Route("PM_WorkTaskBill/UpdateHHasten")] [HttpGet] public object UpdateHHasten(string HInterID, int HHasten, string user) { try { if (string.IsNullOrWhiteSpace(HInterID)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "HInterID为空!"; objJsonResult.data = null; return objJsonResult; } ClsPub.CurUserName = user; BillOld.MvarItemKey = "PM_WorkTaskBillMain"; oCN.BeginTran();//开始事务 DataSet ds; string sql = "select * from PM_WorkTaskBillMain where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, "PM_WorkTaskBillMain"); 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) { string sql1 = "update PM_WorkTaskBillMain set HHasten='"+ HHasten+ "' where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql1, "PM_WorkTaskBillMain"); } 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 任务汇报 新增/编辑-保存 #region 任务汇报 表头数据 string reportMan; public class PM_WorkTaskReportBill_Main { public int HInterID; public int HProID; public int HProjectStageID; public string HMainSourceBillNo; public string HMainSourceBillType; public string HBillNo; public string HDate; public string HRemark; public int HOrgID; public string HMaker; public string HUpdater; public string HChecker; public string HMakerDate; public string HUpdaterDate; public string HCheckerDate; public string HCloseMan; public string HDeleteMan; public string HBacker; public string HCloseManDate; public string HDeleteManDate; public string HBackerDate; public string HBackRemark; public int HReportEmpID; public string HReportEmpName; } #endregion #region 任务汇报 子表数据 public class PM_WorkTaskReportBill_Sub { public int RowID; public int HProjectID; public string HProNumber; public int HProjectStageID; public string HProjectStageName; public string HName; public string HTaskNote; public string HType; public double HRelTimes; public string HReportNote; public string HAdv; public string HRemarkSub; public int HSourceInterID; public int HSourceEntryID; public string HSourceBillNo; public string HSourceBillType; public bool HFinishFlag; } #endregion #region 任务汇报 新增/编辑-保存 /// /// 新增单据-保存按钮 ///参数:string sql。 ///返回值:object。 /// [Route("PM_WorkTaskReportBill/AddBill")] [HttpPost] public object AddBill_WorkTaskReportBill([FromBody] JObject sMainSub) { //获取参数 var _value = sMainSub["sMainSub"].ToString(); string msg1 = _value.ToString(); //开始事务 oCN.BeginTran(); //保存主表 objJsonResult = AddBillMain_WorkTaskReportBill(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_WorkTaskReportBill(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; //设备名称 user_LongShan = sArray[3].ToString();//用户名 try { if (OperationType == 1) { //判断是否有编辑权限 if (!DBUtility.ClsPub.Security_Log("Pm_WorkTaskReportBill_add", 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("Pm_WorkTaskReportBill_edit", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无编辑权限!"; objJsonResult.data = null; return objJsonResult; } } msg2 = "[" + msg2.ToString() + "]"; List mainList = Newtonsoft.Json.JsonConvert.DeserializeObject>(msg2); int HYear = int.Parse(mainList[0].HDate.Split('-')[0]); int HPeriod = int.Parse(mainList[0].HDate.Split('-')[1]); string HBillType = "4754"; string HBillSubType = ""; int HBillStatus = 1; int HInterID = mainList[0].HInterID; int HProID = mainList[0].HProID; int HProjectStageID = mainList[0].HProjectStageID; string HMainSourceBillNo = mainList[0].HMainSourceBillNo; string HMainSourceBillType = mainList[0].HMainSourceBillType; string HBillNo = mainList[0].HBillNo; string HDate = mainList[0].HDate; string HRemark = mainList[0].HRemark; int HOrgID = mainList[0].HOrgID; string HMaker = mainList[0].HMaker; string HMakerDate = mainList[0].HMakerDate; int HReportEmpID = mainList[0].HReportEmpID; string HReportEmpName = mainList[0].HReportEmpName; string HUpdater = mainList[0].HUpdater; string HUpdaterDate = mainList[0].HUpdaterDate; reportMan = HReportEmpName;//获取汇报人名称 //保存前控制 DataSet BeforeDs = oCN.RunProcReturn("Exec h_p_PM_WorkTaskReportBill_BeforeSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_PM_WorkTaskReportBill_BeforeSaveCtrl"); if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存前判断失败!"; objJsonResult.data = null; return objJsonResult; } else { if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]); objJsonResult.data = null; return objJsonResult; } } ds = oCN.RunProcReturn("select * from PM_WorkTaskReportBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "PM_WorkTaskReportBillMain"); if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//新增 { string sql = "insert into PM_WorkTaskReportBillMain" + "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate,HBillNo,HBillStatus,HRemark,HMaker,HMakeDate,HOrgID,HReportEmpID) " + "values(" + "" + HYear + "," + HPeriod + ",'" + HBillType + "','" + HBillSubType + "'," + HInterID + ",'" + HDate + "','" + HBillNo + "'," + HBillStatus + ",'" + HRemark + "','" + HMaker + "','" + HMakerDate + "'," + HOrgID + "," + HReportEmpID + ")"; //主表 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 PM_WorkTaskReportBillMain set " + "HYear = " + HYear + ",HPeriod = " + HPeriod + ",HBillType = '" + HBillType + "',HBillSubType = '" + HBillSubType + "',HDate = '" + HDate + "',HBillNo = '" + HBillNo + "',HBillStatus = " + HBillStatus + ",HRemark = '" + HRemark + "',HUpdater = '" + HUpdater + "',HUpdateDate = '" + HUpdaterDate + "',HOrgID = " + HOrgID + ",HReportEmpID = " + HReportEmpID + " where HInterID = " + HInterID; oCN.RunProc(sql); //删除子表时 回填工作任务单关联数量、单据状态 oCN.RunProc("exec h_p_PM_UpDateRelation_WorkTaskToWorkTaskReport_Delete " + HInterID.ToString()); //删除子表 oCN.RunProc("delete from PM_WorkTaskReportBillSub 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); } else if(OperationType == 4 && ds.Tables[0].Rows.Count == 0) //下推 { string sql = "insert into PM_WorkTaskReportBillMain" + "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate,HBillNo,HBillStatus,HRemark,HMaker,HMakeDate,HOrgID,HReportEmpID,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillType,HMainSourceBillNo) " + "values(" + "" + HYear + "," + HPeriod + ",'" + HBillType + "','" + HBillSubType + "'," + HInterID + ",'" + HDate + "','" + HBillNo + "'," + HBillStatus + ",'" + HRemark + "','" + HMaker + "','" + HMakerDate + "'," + HOrgID + "," + HReportEmpID + "," + HProID + "," + HProjectStageID + ",'" + HMainSourceBillType + "','" + HMainSourceBillNo + "')"; //主表 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_WorkTaskReportBill(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 AddBillSub_WorkTaskReportBill(string msg3, long HInterID, string HBillNo, int OperationType) { List DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject>(msg3); int i = 0; //作为子表内码 foreach (PM_WorkTaskReportBill_Sub oSub in DetailColl) { i++; //同一个主表下的子表的内码自增 int HEntryID = i; int HProjectID = oSub.HProjectID; string HProNumber = oSub.HProNumber; int HProjectStageID = oSub.HProjectStageID; string HName = oSub.HName; string HTaskNote = oSub.HTaskNote; string HType = oSub.HType; double HRelTimes = oSub.HRelTimes; string HReportNote = oSub.HReportNote; string HAdv = oSub.HAdv; string HRemark = oSub.HRemarkSub; int HSourceInterID = oSub.HSourceInterID; int HSourceEntryID = oSub.HSourceEntryID; string HSourceBillNo = oSub.HSourceBillNo; string HSourceBillType = oSub.HSourceBillType; bool HFinishFlag = oSub.HFinishFlag; if (HFinishFlag==true) { //判断单据是否存在 DataSet ds; string sqls = "select * from PM_WorkTaskBillMain where HinterID = " + HSourceInterID; ds = oCN.RunProcReturn(sqls, "PM_WorkTaskBillMain"); 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) { var lInterID = ds.Tables[0].Rows[0]["HMainSourceInterID"]; string sql1 = "update PM_WorkTaskBillMain set HTaskStatus='已完成' where HinterID = " + HSourceInterID; oCN.RunProc(sql1); string sql2 = "update PM_CustomerTaskBillMain set HTaskStatus='已完成' where HinterID = " + lInterID; oCN.RunProc(sql2); } } //查找工作任务获取派单人和抄送人 string sqlz = "select * from h_v_PM_WorkTaskBillList where HInterID = " + HSourceInterID; ds = oCN.RunProcReturn(sqlz, "h_v_PM_WorkTaskBillList"); if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据不存在!"; objJsonResult.data = null; return objJsonResult; } string HSendEmp = ds.Tables[0].Rows[0]["派单人"].ToString();//派单人 string HCopyEmp = ds.Tables[0].Rows[0]["抄送人"].ToString();//抄送人 string HWorkTaskDate = DateTime.Parse(ds.Tables[0].Rows[0]["日期"].ToString()).ToString("yyyy-MM-dd");//工作任务单据时间 string HSelfTimes = ds.Tables[0].Rows[0]["自评工时"].ToString();//自评工时 string HProjectName = ds.Tables[0].Rows[0]["项目名称"].ToString();//项目名称 string HTaskDescription = ds.Tables[0].Rows[0]["任务描述"].ToString(); //插入子表sql string sql = "insert into PM_WorkTaskReportBillSub" + "(HInterID,HBillNo_bak,HEntryID,HRemark,HProjectID,HProNumber,HProjectStageID,HName,HTaskNote,HType,HRelTimes,HReportNote,HAdv,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo,HFinishFlag) " + "values(" + "" + HInterID + ",'" + HBillNo + "'," + HEntryID + ",'" + HRemark + "'," + HProjectID + ",'" + HProNumber + "'," + HProjectStageID + ",'" + HName + "','" + HTaskNote + "','" + HType + "'," + HRelTimes + ",'" + HReportNote + "','" + HAdv + "'," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillType + "','" + HSourceBillNo + "'," + DBUtility.ClsPub.BoolToString(HFinishFlag) + ")"; oCN.RunProc(sql); string messageContext = "单据日期= " + HWorkTaskDate + ",汇报人=" + reportMan + ",汇报内容=" + HReportNote +",任务描述 ="+ HTaskDescription +",完成标记="+ (HFinishFlag?"是":"否") + ",自评工时=" + HSelfTimes + "小时,耗用工时=" + HRelTimes + "小时,任务名称=" + HName + ",项目名称=" + HProjectName; ; _ = SendDingDingAsync(HSendEmp, messageContext, HCopyEmp); } //保存后控制 DataSet AfterDs = oCN.RunProcReturn("Exec h_p_PM_WorkTaskReportBill_AfterSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_PM_WorkTaskReportBill_AfterSaveCtrl"); if (AfterDs == null || AfterDs.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存后判断失败!"; objJsonResult.data = null; return objJsonResult; } else { if (DBUtility.ClsPub.isLong(AfterDs.Tables[0].Rows[0]["HBack"]) == 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.isStrNull(AfterDs.Tables[0].Rows[0]["HRemark"]); objJsonResult.data = null; return objJsonResult; } else { //回填工作任务单关联数量、单据状态 oCN.RunProc("exec h_p_PM_UpDateRelation_WorkTaskToWorkTaskReport_Add " + HInterID.ToString()); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = null; objJsonResult.data = null; return objJsonResult; } } } #endregion #endregion #region 任务汇报 查询 /// /// 返回项目阶段列表 ///参数:string sql。 ///返回值:object。 /// [Route("PM_WorkTaskReportBill/list")] [HttpGet] public object getWorkTaskReportBill(string sWhere, string user) { try { List columnNameList = new List(); //查看权限 //if (!DBUtility.ClsPub.Security_Log("Gy_ProjectStage_Query", 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_PM_WorkTaskReportBillList order by 单据号 desc", "h_v_PM_ProjectStageBillList"); } else { string sql1 = "select * from h_v_PM_WorkTaskReportBillList where 1 = 1 "; string sql = sql1 + sWhere + " order by 单据号 desc"; ds = oCN.RunProcReturn(sql, "h_v_PM_WorkTaskReportBillList"); } //添加列名 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 任务汇报 编辑-页面赋值 /// ///参数:string HInterID。 ///返回值:object。 /// [Route("PM_WorkTaskReportBill/editInit")] [HttpGet] public object getWorkTaskReportBilleditInit(string HInterID, string user) { try { List tableList = new List(); //查看权限 //if (!DBUtility.ClsPub.Security_Log("Pm_ProjectStageBill_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_PM_WorkTaskReportBill_EditInit " + HInterID, "h_p_PM_WorkTaskReportBill_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 任务汇报 删除 /// ///参数:string HInterID。 ///返回值:object。 /// [Route("PM_WorkTaskReportBill/delete")] [HttpGet] public object deleteWorkTaskReportBill(string HInterID, string user) { try { //查看权限 if (!DBUtility.ClsPub.Security_Log("Pm_WorkTaskReportBill_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("exec h_p_PM_UpDateRelation_WorkTaskToWorkTaskReport_Delete " + HInterID.ToString()); oCN.RunProc("delete from PM_WorkTaskReportBillMain where HInterID = " + HInterID); oCN.RunProc("delete from PM_WorkTaskReportBillSub where HInterID='" + HInterID + "'"); oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; 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 任务汇报 审核/反审核 /// /// /// /// 单据ID /// 审核(0),反审核(1) /// 审核人 /// [Route("PM_WorkTaskReportBill/AuditPM_WorkTaskReportBill")] [HttpGet] public object AuditPM_WorkTaskReportBill(string HInterID, int Type, string user) { try { //判断是否有审核权限 if (!DBUtility.ClsPub.Security_Log("Pm_WorkTaskReportBill_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 = "PM_WorkTaskReportBillMain"; 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 == 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; } //审核单据 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]["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; } //反审核单据 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("PM_WorkTaskReportBill/ClosePM_WorkTaskReportBill")] [HttpGet] public object ClosePM_WorkTaskReportBill(string HInterID, int Type, string user) { try { //判断是否有删除权限 if (!DBUtility.ClsPub.Security_Log("Pm_WorkTaskReportBill_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 = "PM_WorkTaskReportBillMain"; 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 == 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]["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; } 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]["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; } 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("PM_WorkTaskReportBill/DropPM_WorkTaskReportBill")] [HttpGet] public object DropPM_WorkTaskReportBill(string HInterID, int Type, string user) { try { //判断是否有作废权限 if (!DBUtility.ClsPub.Security_Log("Pm_WorkTaskReportBill_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 = "PM_WorkTaskReportBillMain"; 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 == 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]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].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 (!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]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].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 (!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("PM_WorkTaskReportBill/getHEmpByHUserName")] [HttpGet] public object getHEmpByHUserName(string Czybm, string user) { try { List columnNameList = new List(); //查看权限 //if (!DBUtility.ClsPub.Security_Log("Gy_ProjectStage_Query", 1, false, user)) //{ // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "无查看权限!"; // objJsonResult.data = null; // return objJsonResult; //} string sql = @"select a.HEmpID,b.HName HEmpName from Gy_Czygl AS a LEFT OUTER JOIN Gy_Employee AS b on a.HEmpID = b.HItemID where a.Czybm = '" + Czybm + "'"; ds = oCN.RunProcReturn(sql, "Gy_Czygl"); if (ds == null || 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 #region 我的任务列表(未完成,已完成,正在进行) /// /// 返回我的任务列表 ///参数:string sql。 ///返回值:object。 /// [Route("PM_WorkTaskBill/PM_WorkTaskBillMainList")] [HttpGet] public object PM_WorkTaskBillMainList( string user) { try { List columnNameList = new List(); ds = oCN.RunProcReturn("exec h_p_PM_WorkTaskBillMyList " + user, "h_p_PM_WorkTaskBillMyList"); if (ds.Tables[0].Rows.Count != 0 || ds != null) { //添加列名 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; objJsonResult.list = columnNameList; 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 任务费用 保存/编辑 /// /// 任务费用 /// /// /// [Route("PM_WorkTaskBill/SavePM_WorkTaskMoneyBillMain")] [HttpPost] public object SavePM_WorkTaskMoneyBillMain([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 refSav = sArray[2].ToString();//操作方式数据类型 1添加 3修改 2 复制 string user = sArray[3].ToString();//用户名 string UserName = ""; string s = ""; ListModels oListModels = new ListModels(); try { //保存权限 if (!DBUtility.ClsPub.Security_Log_second("PM_WorkTaskMoneyBillMain_Edit", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!无权限!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsPM_WorkTaskMoneyBillMain oBill = new DAL.ClsPM_WorkTaskMoneyBillMain(); List lsmain = new List(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); //\n lsmain = oListModels.getObjectByJson_PM_WorkTaskMoneyBillMain(msg2); foreach (Model.ClsPM_WorkTaskMoneyBillMain oItem in lsmain) { if (refSav == "Add") { //单据号是否重复 if (BillNew0.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据号重复!不允许保存!"; objJsonResult.data = 1; return objJsonResult; } } if (refSav == "Update") { if (BillNew0.ShowBill(oItem.HInterID, ref s) == false) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据有误!"; objJsonResult.data = 1; return objJsonResult; } //判断是否可编辑 if (BillNew0.omodel.HChecker != "" && BillNew0.omodel.HChecker != null) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据已经被审核,不允许修改!"; objJsonResult.data = 1; return objJsonResult; } if (BillNew0.omodel.HBillStatus > 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据处于不可编辑状态,不允许修改!"; objJsonResult.data = 1; return objJsonResult; } } UserName = oItem.HMaker; //制单人 oItem.HBillType = "4763"; oItem.HBillSubType = "4763"; //oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month); oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); 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 List ls = new List(); ls = oListModels.getObjectByJson_PM_WorkTaskMoneyBillSub(msg3); int i = 0; foreach (Model.ClsPM_WorkTaskMoneyBillSub oItemSub in ls) { i++; oItemSub.HEntryID = i; oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); oItemSub.HCloseType = false; //关闭类型 oBill.DetailColl.Add(oItemSub); } //保存 //保存完毕后处理 bool bResult; if (refSav == "Add") { bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else if (refSav == "Update") { bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); } else { bResult = false; } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "保存成功!"; 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 #region 任务费用列表 查询 /// /// 返回任务费用列表 ///参数:string sql。 ///返回值:object。 /// [Route("PM_WorkTaskBill/getPM_WorkTaskMoneyBillMainList")] [HttpGet] public object getPM_WorkTaskMoneyBillMainList(string sWhere, string user) { try { List columnNameList = new List(); //查看权限 if (!DBUtility.ClsPub.Security_Log_second("PM_WorkTaskMoneyBillMain_Check", 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_PM_WorkTaskMoneyBillMainList order by 单据号 desc", "h_v_PM_WorkTaskMoneyBillMainList"); } else { string sql1 = "select * from h_v_h_v_PM_WorkTaskMoneyBillMainList where 1 = 1 "; string sql = sql1 + sWhere + " order by 单据号 desc"; ds = oCN.RunProcReturn(sql, "h_v_PM_WorkTaskMoneyBillMainList"); } //添加列名 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 任务费用列表 获取编辑列表数据 [Route("PM_WorkTaskBill/PM_WorkTaskMoneyBillMainEditList")] [HttpGet] public object PM_WorkTaskMoneyBillMainEditList(string HInterID, string User) { try { List tableList = new List(); //查看权限 if (!DBUtility.ClsPub.Security_Log("PM_WorkTaskMoneyBillMain_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_PM_WorkTaskMoneyBill_EditInit " + HInterID, "h_p_PM_WorkTaskMoneyBill_EditInit"); tableList.Add(ds.Tables[0]); tableList.Add(ds.Tables[1]); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "查询成功!"; 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("PM_WorkTaskBill/CheckPM_WorkTaskMoneyBillMain")] [HttpGet] public object CheckPM_ProjectBeginBillMain(int HInterID, int IsAudit, string CurUserName) { DBUtility.ClsPub.CurUserName = CurUserName; try { //审核权限 if (!DBUtility.ClsPub.Security_Log_second("PM_WorkTaskMoneyBillMain_Check", 1, false, CurUserName)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "审核失败!无权限!"; objJsonResult.data = null; return objJsonResult; } //HInterID数据判断 if (HInterID <= 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "HInterID小于0!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); //对HInterID进行类型的转换 DAL.ClsPM_WorkTaskMoneyBillMain oBill = new DAL.ClsPM_WorkTaskMoneyBillMain(); //实例化单据操作类,用于进行相关操作 //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作 if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //根据HInterID获取该单据的数据 { if (oBill.omodel.HCloseMan.Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已关闭!不能再次审核!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HDeleteMan.Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已作废!不能再次审核!"; objJsonResult.data = null; return objJsonResult; } if (IsAudit == 0) //审核判断 { if (oBill.omodel.HChecker.Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已审核!不能再次审核!"; objJsonResult.data = null; return objJsonResult; } } if (IsAudit == 1) //反审核判断 { if (oBill.omodel.HChecker.Trim() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未审核!不需要反审核!"; objJsonResult.data = null; return objJsonResult; } } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } //进行需要进行的审核/反审核操作 if (IsAudit == 0) //审核提交 { oCN.BeginTran(); //记录返回信息 string msg = ""; //审核前控制========================================= string sql1 = "exec h_p_PM_WorkTaskMoneyBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'"; ds = oCN.RunProcReturn(sql1, "h_p_PM_WorkTaskMoneyBill_BeforeCheckCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系"; objJsonResult.data = null; oCN.RollBack(); return objJsonResult; } if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; objJsonResult.data = null; oCN.RollBack(); return objJsonResult; } //================================================================================== //审核提交 if (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_PM_WorkTaskMoneyBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) { oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "审核成功!" + msg; objJsonResult.data = null; return objJsonResult; } else { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } if (IsAudit == 1) //反审核提交 { //反审核前控制========================================= string sql1 = "exec h_p_PM_WorkTaskMoneyBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'"; ds = oCN.RunProcReturn(sql1, "h_p_PM_WorkTaskMoneyBill_BeforeUnCheckCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "反审核失败!原因:反审核前判断失败,请与网络管理人员联系"; objJsonResult.data = null; return objJsonResult; } if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "反审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; objJsonResult.data = null; return objJsonResult; } //=========================================================== //反审核提交AbandonCheck if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_PM_WorkTaskMoneyBill_AfterUnCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "反审核成功"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } return objJsonResult; } catch (Exception e) { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 任务费用列表 关闭/反关闭功能 [Route("PM_WorkTaskBill/ClosePM_WorkTaskMoneyBillMain")] [HttpGet] public object ClosePM_WorkTaskMoneyBillMain(string HInterID, int IsAudit, string user) { try { //判断是否有关闭权限 if (!DBUtility.ClsPub.Security_Log("PM_WorkTaskMoneyBillMain_Close", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无权限关闭!"; objJsonResult.data = null; return objJsonResult; } var ds = oCN.RunProcReturn("select * from PM_WorkTaskMoneyBillMain where HInterID=" + HInterID, "PM_WorkTaskMoneyBillMain"); if (ds.Tables[0].Rows.Count > 0) { if (IsAudit == 0) //关闭判断 { if (ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已关闭!不能再次关闭!"; objJsonResult.data = null; return objJsonResult; } } if (IsAudit == 1) //反关闭判断 { if (ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未关闭!不需要反关闭!"; objJsonResult.data = null; return objJsonResult; } } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据不存在!"; objJsonResult.data = null; return objJsonResult; } oCN.BeginTran(); if (IsAudit == 0) //关闭判断 { oCN.RunProc("update PM_WorkTaskMoneyBillMain set HCloseMan='" + user + "',HCloseDate=getdate(),HBillStatus='3' where HInterID=" + HInterID); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "关闭成功"; objJsonResult.data = null; } if (IsAudit == 1) //反关闭判断 { if (ds.Tables[0].Rows[0]["HChecker"].ToString() == "") { oCN.RunProc("update PM_WorkTaskMoneyBillMain set HCloseMan='',HCloseDate=null,HBillStatus='1' where HInterID=" + HInterID); } else { oCN.RunProc("update PM_WorkTaskMoneyBillMain set HCloseMan='',HCloseDate=null,HBillStatus='2' where HInterID=" + HInterID); } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "反关闭成功"; objJsonResult.data = null; } oCN.Commit(); return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "执行失败!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 任务费用列表 作废/反作废功能 [Route("PM_WorkTaskBill/DropPM_WorkTaskMoneyBillMain")] [HttpGet] public object DropPM_WorkTaskMoneyBillMain(string HInterID, int IsAudit, string user) { try { //判断是否有关闭权限 if (!DBUtility.ClsPub.Security_Log("PM_WorkTaskMoneyBillMain_Drop", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无权限关闭!"; objJsonResult.data = null; return objJsonResult; } var ds = oCN.RunProcReturn("select * from PM_WorkTaskMoneyBillMain where HInterID=" + HInterID, "PM_WorkTaskMoneyBillMain"); if (ds.Tables[0].Rows.Count > 0) { if (IsAudit == 0) //关闭判断 { if (ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已作废!不能再次作废!"; objJsonResult.data = null; return objJsonResult; } } if (IsAudit == 1) //反关闭判断 { if (ds.Tables[0].Rows[0]["HDeleteMan"].ToString() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未作废!不需要反作废!"; objJsonResult.data = null; return objJsonResult; } } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据不存在!"; objJsonResult.data = null; return objJsonResult; } oCN.BeginTran(); if (IsAudit == 0) //作废判断 { oCN.RunProc("update PM_WorkTaskMoneyBillMain set HDeleteMan='" + user + "',HDeleteDate=getdate(),HBillStatus='4' where HInterID=" + HInterID); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "关闭成功"; objJsonResult.data = null; } if (IsAudit == 1) //反作废判断 { if (ds.Tables[0].Rows[0]["HChecker"].ToString() == "" && ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "") { oCN.RunProc("update PM_WorkTaskMoneyBillMain set HDeleteMan='',HDeleteDate=null,HBillStatus='1' where HInterID=" + HInterID); } else if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "" && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") { oCN.RunProc("update PM_WorkTaskMoneyBillMain set HDeleteMan='',HDeleteDate=null,HBillStatus='3' where HInterID=" + HInterID); } else if (ds.Tables[0].Rows[0]["HChecker"].ToString() == "" && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") { oCN.RunProc("update PM_WorkTaskMoneyBillMain set HDeleteMan='',HDeleteDate=null,HBillStatus='3' where HInterID=" + HInterID); } else if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "" && ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "") { oCN.RunProc("update PM_WorkTaskMoneyBillMain set HDeleteMan='',HDeleteDate=null,HBillStatus='2' where HInterID=" + HInterID); } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "反关闭成功"; objJsonResult.data = null; } oCN.Commit(); return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "执行失败!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 任务费用列表 删除 /// ///参数:string HInterID。 ///返回值:object。 /// [Route("PM_WorkTaskBill/DeletePM_WorkTaskMoneyBillMain")] [HttpGet] public object DeletePM_WorkTaskMoneyBillMain(string HInterID, string user) { try { //查看权限 if (!DBUtility.ClsPub.Security_Log("PM_WorkTaskMoneyBillMain_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 Gy_WorkTaskMoneyBOMBillMain where HInterID = " + HInterID); oCN.RunProc("delete from Gy_WorkTaskMoneyBOMBillSub where HInterID = " + HInterID); oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; 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 任务费用清单 #region 任务费用清单 保存/编辑 /// /// 任务费用清单 /// /// /// [Route("PM_WorkTaskBill/SaveGy_WorkTaskMoneyBOMBill")] [HttpPost] public object SaveGy_WorkTaskMoneyBOMBill([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 refSav = sArray[2].ToString();//操作方式数据类型 1添加 3修改 2 复制 string user = sArray[3].ToString();//用户名 string UserName = ""; string s = ""; ListModels oListModels = new ListModels(); try { //保存权限 if (!DBUtility.ClsPub.Security_Log_second("PM_WorkTaskMoneyBOMBill_Edit", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!无权限!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsGy_WorkTaskMoneyBOMBill oBill = new DAL.ClsGy_WorkTaskMoneyBOMBill(); List lsmain = new List(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); //\n //序列化主表数据 var jsonString = "[" + msg2.ToString() + "]"; lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject>(jsonString); foreach (Model.ClsGy_WorkTaskMoneyBOMBillMain oItem in lsmain) { if (refSav == "Add") { //单据号是否重复 if (BillNew1.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据号重复!不允许保存!"; objJsonResult.data = 1; return objJsonResult; } } if (refSav == "Update") { if (BillNew1.ShowBill(oItem.HInterID, ref s) == false) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据有误!"; objJsonResult.data = 1; return objJsonResult; } //判断是否可编辑 if (BillNew1.omodel.HChecker != "" && BillNew1.omodel.HChecker != null) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据已经被审核,不允许修改!"; objJsonResult.data = 1; return objJsonResult; } if (BillNew1.omodel.HBillStatus > 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据处于不可编辑状态,不允许修改!"; objJsonResult.data = 1; return objJsonResult; } } UserName = oItem.HMaker; //制单人 oItem.HBillType = "3339"; oItem.HBillSubType = "3339"; //oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month); oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); 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 List ls = new List(); jsonString = "[" + msg3.ToString() + "]"; ls = Newtonsoft.Json.JsonConvert.DeserializeObject>(jsonString); int i = 0; foreach (Model.ClsGy_WorkTaskMoneyBOMBillSub oItemSub in ls) { i++; oItemSub.HEntryID = i; oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); oItemSub.HCloseType = false; //关闭类型 oBill.DetailColl.Add(oItemSub); } //保存 //保存完毕后处理 bool bResult; if (refSav == "Add") { bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else if (refSav == "Update") { bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); } else { bResult = false; } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "保存成功!"; 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 #region 任务费用清单列表 查询 /// /// 返回任务费用清单列表 ///参数:string sql。 ///返回值:object。 /// [Route("PM_WorkTaskBill/getGy_WorkTaskMoneyBOMBillList")] [HttpGet] public object getGy_WorkTaskMoneyBOMBillList(string sWhere, string user) { try { List columnNameList = new List(); //查看权限 if (!DBUtility.ClsPub.Security_Log_second("PM_WorkTaskMoneyBOMBill_Query", 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_Gy_WorkTaskMoneyBOMBillList order by 单据号 desc", "h_v_Gy_WorkTaskMoneyBOMBillList"); } else { string sql1 = "select * from h_v_Gy_WorkTaskMoneyBOMBillList where 1 = 1 "; string sql = sql1 + sWhere + " order by 单据号 desc"; ds = oCN.RunProcReturn(sql, "h_v_Gy_WorkTaskMoneyBOMBillList"); } //添加列名 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 任务费用清单列表 获取编辑列表数据 /// /// 获取编辑列表数据 /// /// /// /// [Route("PM_WorkTaskBill/Gy_WorkTaskMoneyBOMBillEditList")] [HttpGet] public object Gy_WorkTaskMoneyBOMBillMainEditList(string HInterID, string User) { try { List tableList = new List(); //查看权限 if (!DBUtility.ClsPub.Security_Log("PM_WorkTaskMoneyBOMBill_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 h_v_Gy_WorkTaskMoneyBOMBillList where HInterID =" + HInterID, "h_v_Gy_WorkTaskMoneyBOMBillList"); if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "false!"; objJsonResult.data = null; return objJsonResult; } else { 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 任务费用清单列表 审核/反审核功能 [Route("PM_WorkTaskBill/CheckGy_WorkTaskMoneyBOMBill")] [HttpGet] public object CheckGy_WorkTaskMoneyBOMBill(string HInterID, int Type, string user) { try { //判断是否有审核权限 if (!DBUtility.ClsPub.Security_Log("PM_WorkTaskMoneyBOMBill_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; BillOld1.MvarItemKey = "Gy_WorkTaskMoneyBOMBillMain"; oCN.BeginTran();//开始事务 //Type 1 审核 2 反审核 if (Type == 1) { //判断单据是否已经审核 DataSet ds; string sql = "select * from " + BillOld1.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld1.MvarItemKey); 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; } //审核单据 if (!BillOld1.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 " + BillOld1.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld1.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 (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; } //反审核单据 if (!BillOld1.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("PM_WorkTaskBill/CloseGy_WorkTaskMoneyBOMBill")] [HttpGet] public object CloseGy_WorkTaskMoneyBOMBill(string HInterID, int Type, string user) { try { //判断是否有删除权限 if (!DBUtility.ClsPub.Security_Log("PM_WorkTaskMoneyBOMBill_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; BillOld1.MvarItemKey = "Gy_WorkTaskMoneyBOMBillMain"; oCN.BeginTran();//开始事务 //Type 1 关闭 2 反关闭 if (Type == 1) { //判断单据是否已经关闭 DataSet ds; string sql = "select * from " + BillOld1.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld1.MvarItemKey); 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]["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; } 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 (!BillOld1.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 " + BillOld1.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld1.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 (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 (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 (!BillOld1.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("PM_WorkTaskBill/DropGy_WorkTaskMoneyBOMBill")] [HttpGet] public object DropGy_WorkTaskMoneyBOMBillMain(string HInterID, int Type, string user) { try { //判断是否有作废权限 if (!DBUtility.ClsPub.Security_Log("PM_WorkTaskMoneyBOMBill_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; BillOld1.MvarItemKey = "Gy_WorkTaskMoneyBOMBillMain"; oCN.BeginTran();//开始事务 //Type 1 作废 2 反作废 if (Type == 1) { //判断单据是否已经作废 DataSet ds; string sql = "select * from " + BillOld1.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld1.MvarItemKey); 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]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].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 (!BillOld1.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 " + BillOld1.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld1.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 (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 (!BillOld1.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 任务费用清单列表 删除 /// ///参数:string HInterID。 ///返回值:object。 /// [Route("PM_WorkTaskBill/DeleteGy_WorkTaskMoneyBOMBill")] [HttpGet] public object DeleteGy_WorkTaskMoneyBOMBillMain(string HInterID, string user) { try { //查看权限 if (!DBUtility.ClsPub.Security_Log("PM_WorkTaskMoneyBOMBill_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 Gy_WorkTaskMoneyBOMBillMain where HInterID = " + HInterID); oCN.RunProc("delete from Gy_WorkTaskMoneyBOMBillSub where HInterID = " + HInterID); oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; 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 项目费用清单 行关闭/行反关闭 /// /// /// 单据ID /// 关闭(1),反关闭(2) /// 关闭人 /// [Route("PM_WorkTaskBill/CloseRowGy_WorkTaskMoneyBOMBill")] [HttpGet] public object CloseRowGy_WorkTaskMoneyBOMBill(int HInterID, int HEntryID, int IsAudit, string CurUserName) { string ModRightNameCheck = "PM_ProjectMoneyBOMBill_Close"; string SubBillName = "Gy_WorkTaskMoneyBOMBillSub"; //子表表名 DBUtility.ClsPub.CurUserName = CurUserName; DataSet ds = null; try { //检查权限 if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "行关闭失败!无权限!"; objJsonResult.data = null; return objJsonResult; } //HInterID数据判断 if (HInterID <= 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "HInterID小于0!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); //对HInterID进行类型的转换 DAL.ClsGy_WorkTaskMoneyBOMBill oBill = new DAL.ClsGy_WorkTaskMoneyBOMBill(); //实例化单据操作类,用于进行相关操作 //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作 if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //根据HInterID获取该单据的数据 { if (oBill.omodel.HDeleteMan.Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已作废!不能进行行关闭!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HCloseMan.Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已关闭!不能进行行关闭!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HChecker.Trim() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未审核!不能进行行关闭!"; objJsonResult.data = null; return objJsonResult; } string sql = "select * from " + SubBillName + " where HInterID = " + HInterID + " and HEntryID = " + HEntryID; ds = oCN.RunProcReturn(sql, "Cg_POOrderBillSub"); if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "该行数据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } if (IsAudit == 1) //行关闭判断 { if (ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "行已关闭!不能再次行关闭!"; objJsonResult.data = null; return objJsonResult; } } if (IsAudit == 2) //行反关闭判断 { if (ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "行未关闭!不需要再行反关闭!"; objJsonResult.data = null; return objJsonResult; } //判断行是否为自动关闭 string temp = ds.Tables[0].Rows[0]["HCloseType"].ToString(); if (ds.Tables[0].Rows[0]["HCloseType"].ToString() == "False") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "行反关闭失败!行为自动关闭,不能进行手动反关闭!"; objJsonResult.data = null; return objJsonResult; } } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } //进行需要进行的行关闭/行反关闭操作 if (IsAudit == 1) //行关闭提交 { //行关闭提交 if (oBill.CloseRow(lngBillKey, HEntryID, oBill.omodel.HBillNo, CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "行关闭成功"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "行关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } if (IsAudit == 2) //行反关闭提交 { //行反关闭提交 if (oBill.CancelRow(lngBillKey, HEntryID, oBill.omodel.HBillNo, CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "反关闭成功"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "反关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "关闭失败或者反关闭失败!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #endregion #region 任务汇报单保存发送钉钉消息 /// /// 任务汇报单保存发送钉钉消息 /// /// /// 日期+汇报人+汇报内容+工时+ 项目名称 /// 抄送人 /// public async Task SendDingDingAsync(string HSendMan, string HDescription, string HCopyMan) { string concatenatedNames = ""; Cls_DDMsg msg = new Cls_DDMsg(); string appKey = "dingrsrzhdyn3mlaof95"; string appSecret = "RAqH6YtZnPLCpDbuqfaYQkKkVtVdS0wqfC8I26X6qiS-8eoCJCNrzx3fubGND4Sq"; //任务汇报单保存发送钉钉消息保存 将消息 发送给 接收人 //获取接送人的钉钉id string HReceiveMan = HSendMan; string[] names = HCopyMan.Split(','); string sqlNames = ""; foreach (string name in names) { sqlNames += "'" + name.Trim() + "',"; } sqlNames = sqlNames.TrimEnd(','); //获取指派处理人,发送人的钉钉id string sql1 = "select HDingDingUserID 钉钉id from Gy_Czygl where Czymc in ('" + HReceiveMan + "'," + sqlNames + ")"; ds = oCN.RunProcReturn(sql1, "Gy_Czygl"); List HNames = new List(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string HName = ds.Tables[0].Rows[i]["钉钉id"].ToString(); HNames.Add(HName); } concatenatedNames = string.Join(",", HNames);//钉钉人员的id列表 //获取企业的access_token的值 string response = msg.GetAccessToken(appKey, appSecret); JObject responseJson = JObject.Parse(response); // 获取access_token的值 string accessToken = responseJson["accessToken"].ToString(); //调用方法发送消息 string agentId = "3118119317";//钉钉后台建立的小程序id string userIdList = concatenatedNames;//钉钉人员的id string deptIdList = "0"; // 空字符串表示不指定部门 string toAllUser = "false"; string message = HDescription; response = await msg.SendTextMessage(accessToken, agentId, userIdList, deptIdList, toAllUser, message); Console.WriteLine(response); return response; } #endregion } }