using DBUtility;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Net;
|
using System.Net.Http;
|
using System.Web.Http;
|
using WebAPI.Models;
|
using SyntacticSugar.constant;
|
namespace WebAPI.Controllers
|
{
|
public class PM_WorkTaskWeekBillController : 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.ClsPM_WorkTaskWeekBill BillNew0 = new DAL.ClsPM_WorkTaskWeekBill(); //工作周计划对应单据类
|
public DAL.ClsPM_WorkTaskWeekBill BillOld0 = new DAL.ClsPM_WorkTaskWeekBill(); //工作周计划对应单据类
|
public DAL.ClsPM_WorkReportWeekBillMain BillNew = new DAL.ClsPM_WorkReportWeekBillMain(); //工作周总结对应单据类
|
public DAL.ClsPM_WorkReportWeekBillMain BillOld = new DAL.ClsPM_WorkReportWeekBillMain(); //工作周总结对应单据类
|
|
|
#region 工作周计划 子表2-待排计划 数据获取
|
[Route("PM_WorkTaskWeekBill/getSub2Data")]
|
[HttpGet]
|
public object getSub2Data(string user)
|
{
|
try
|
{
|
string sql = @"select
|
HProjectID
|
,项目代码 AS HProNumber
|
,项目名称 AS HProName
|
,HProjectStageID
|
,项目阶段 AS HProjectStageName
|
,任务名称 AS HName
|
,任务描述 AS HTaskNote
|
,评估工时 AS HPlanTimes
|
,已耗用工时 AS HReportTimes
|
,HInterID AS HSourceInterID
|
,HEntryID AS HSourceEntryID
|
,单据号 AS HSourceBillNo
|
,单据类型 AS HSourceBillType
|
from h_v_PM_WorkTaskBillList
|
where 单据状态 = '已审核'
|
and 接单人 = '" + user + "'";
|
|
ds = oCn.RunProcReturn(sql, "h_v_PM_WorkTaskBillList");
|
|
//if (ds.Tables[0].Rows.Count != 0 || ds != null)
|
//{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
//}
|
//else
|
//{
|
//objJsonResult.code = "0";
|
//objJsonResult.count = 0;
|
//objJsonResult.Message = "无数据";
|
//objJsonResult.data = null;
|
//return objJsonResult;
|
//}
|
}
|
catch (Exception ex)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 工作周计划保存/编辑
|
/// <summary>
|
/// 保存生产领料单
|
/// </summary>
|
/// <param name="msg"></param>
|
/// <returns></returns>
|
[Route("PM_WorkTaskWeekBill/SavePM_WorkTaskWeekBill")]
|
[HttpPost]
|
public object SavePM_WorkTaskWeekBill([FromBody] JObject msg)
|
{
|
var _value = msg["msg"].ToString();
|
string msg1 = _value.ToString();
|
string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
string msg2 = sArray[0].ToString(); //表头数据
|
string msg3 = sArray[1].ToString(); //子表1数据
|
string refSav = sArray[2].ToString(); //操作方式
|
string msg4 = sArray[3].ToString(); //用户
|
|
DBUtility.ClsPub.CurUserName = msg4;
|
|
string UserName = "";
|
string s = "";
|
ListModels oListModels = new ListModels();
|
try
|
{
|
//编辑权限
|
if (!DBUtility.ClsPub.Security_Log_second("PM_WorkTaskWeekBill_Edit", 1, false, msg4))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无保存权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
DAL.ClsPM_WorkTaskWeekBill oBill = new DAL.ClsPM_WorkTaskWeekBill();
|
List<Model.ClsPM_WorkTaskWeekBillMain> lsmain = new List<Model.ClsPM_WorkTaskWeekBillMain>();
|
msg2 = msg2.Replace("\\", "");
|
msg2 = msg2.Replace("\n", ""); //\n
|
lsmain = oListModels.getObjectByJson_PM_WorkTaskWeekBillMain(msg2);
|
foreach (Model.ClsPM_WorkTaskWeekBillMain oItem in lsmain)
|
{
|
if (refSav == "Add")
|
{
|
//单据号是否重复
|
if (BillNew0.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld0.omodel.HInterID))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据号重复!不允许保存!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
}
|
if (refSav == "Update")
|
{
|
if (BillOld0.ShowBill(oItem.HInterID, ref s) == false)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "此单据有误!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
//判断是否可编辑
|
if (BillOld0.omodel.HChecker != "" && BillOld0.omodel.HChecker != null)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "此单据已经被审核,不允许修改!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
if (BillOld0.omodel.HBillStatus > 1)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "此单据处于不可编辑状态,不允许修改!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld0, ref s))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = s + ",不允许修改";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
}
|
UserName = oItem.HMaker; //制单人
|
oItem.HBillType = "4756";
|
oItem.HBillSubType = "4756";
|
|
//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
|
//msg2 = msg2.Replace("'", "’");
|
List<Model.ClsPM_WorkTaskWeekBillSub> ls = new List<Model.ClsPM_WorkTaskWeekBillSub>();
|
ls = oListModels.getObjectByJson_PM_WorkTaskWeekBillSub(msg3);
|
int i = 0;
|
foreach (Model.ClsPM_WorkTaskWeekBillSub oItemSub in ls)
|
{
|
i++;
|
oItemSub.HEntryID = i;
|
|
//oItemSub.HCloseMan = ""; //行关闭
|
oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
|
oItemSub.HCloseType = false; //关闭类型
|
//oItemSub.HRemark = ""; //备注
|
|
//oItemSub.HSourceInterID = 0; // 源单主内码
|
//oItemSub.HSourceEntryID = 0; //源单子内码
|
//oItemSub.HSourceBillNo = ""; //源单单号
|
//oItemSub.HSourceBillType = ""; //源单类型
|
//oItemSub.HRelationQty = 0; //关联数量
|
//oItemSub.HRelationMoney = 0; //关联金额
|
oBill.DetailColl.Add(oItemSub);
|
|
}
|
//保存
|
//保存完毕后处理
|
bool bResult;
|
if (refSav == "Add")
|
{
|
// bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
|
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 = "保存成功!";
|
//WebAPIController.Add_Log("送货单下推", UserName, "生成送货单");
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!" + e.ToString();
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 工作周计划编辑时获取表头数据
|
[Route("PM_WorkTaskWeekBill/PM_WorkTaskWeekBillgetEditMainData")]
|
[HttpGet]
|
public object PM_WorkTaskWeekBillgetEditMainData(Int64 HInterID)
|
{
|
try
|
{
|
string sql = @" select
|
a.HInterID,a.HBillNo,a.HYear,a.HWeek,a.HBeginDate,a.HEndDate,a.HPlanEmpID,e1.HName HPlanEmpName,a.HDate,a.HRemark,a.HOrgID,a.HMaker
|
,a.HMakeDate,a.HUpDater,a.HUpDateDate,a.HChecker,a.HCheckDate,a.HCloseMan,a.HCloseDate,a.HDeleteMan,a.HDeleteDate,a.HBacker,a.HBackDate
|
from PM_WorkTaskWeekBillMain AS a
|
LEFT OUTER JOIN Gy_Employee AS e1 on a.HPlanEmpID = e1.HItemID
|
where HInterID = " + HInterID;
|
ds = oCn.RunProcReturn(sql, "PM_WorkTaskWeekBillMain");
|
|
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "未获取到相关数据!";
|
objJsonResult.data = null;
|
}
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "查询成功!";
|
objJsonResult.data = ds.Tables[0];
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + e.ToString();
|
objJsonResult.data = null;
|
}
|
return objJsonResult;
|
}
|
#endregion
|
|
#region 工作周计划获取表体数据
|
[Route("PM_WorkTaskWeekBill/PM_WorkTaskWeekBillgetEditSubData")]
|
[HttpGet]
|
public object PM_WorkTaskWeekBillgetEditSubData(Int64 HInterID)
|
{
|
try
|
{
|
string sql = @"select a.HInterID,a.HEntryID,a.HSno,a.HProjectID,p1.HProNumber,p1.HProName,a.HProjectStageID,g1.HName HProjectStageName,p2.HName,p2.HTaskNote
|
,a.HPlanTimes,p3.已耗用工时 HReportTimes,a.HWeekDay,a.HSourceInterID,a.HSourceEntryID,a.HSourceBillNo,a.HSourceBillType
|
from PM_WorkTaskWeekBillSub AS a
|
LEFT OUTER JOIN PM_ProjectBillMain AS p1 on a.HProjectID = p1.HInterID
|
LEFT OUTER JOIN Gy_ProjectStage AS g1 on a.HProjectStageID = g1.HItemID
|
LEFT OUTER JOIN PM_WorkTaskBillMain AS p2 on a.HSourceInterID = p2.HInterID
|
LEFT OUTER JOIN h_v_PM_WorkTaskBillList AS p3 on a.HSourceInterID = p3.HInterID and a.HSourceEntryID = p3.HEntryID
|
where a.HInterID = " + HInterID +
|
" order by a.HEntryID asc";
|
ds = oCn.RunProcReturn(sql, "PM_WorkTaskWeekBillSub");
|
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "未获取到周计划相关数据!";
|
objJsonResult.data = null;
|
}
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "查询成功!";
|
objJsonResult.data = ds.Tables[0];
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + e.ToString();
|
objJsonResult.data = null;
|
}
|
return objJsonResult;
|
}
|
#endregion
|
|
#region 工作周计划列表 查询
|
/// <summary>
|
/// 返回项目阶段列表
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("PM_WorkTaskWeekBill/list")]
|
[HttpGet]
|
public object getWorkTaskWeekBill(string sWhere, string user)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
//查看权限
|
//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_WorkTaskWeekBillList order by 单据号 desc,HEntryID asc", "h_v_PM_WorkTaskWeekBillList");
|
}
|
else
|
{
|
string sql1 = "select * from h_v_PM_WorkTaskWeekBillList where 1 = 1 ";
|
string sql = sql1 + sWhere + " order by 单据号 desc,HEntryID asc";
|
ds = oCn.RunProcReturn(sql, "h_v_PM_WorkTaskWeekBillList");
|
}
|
|
//添加列名
|
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_WorkTaskWeekBill/page")]
|
[HttpGet]
|
public object PM_WorkTaskWeekBillPage(string sWhere, string user, int page, int size)
|
{
|
DataSet ds;
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
//判断权限
|
//if (!DBUtility.ClsPub.Security_Log("Cg_POInStockBillQuery", 1, false, user))
|
//{
|
// objJsonResult.code = CodeConstant.FAIL;
|
// objJsonResult.count = CountConstant.FAIL;
|
// objJsonResult.Message = "您没有该模块权限,请与管理员联系!";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
ds = oCn.RunProcReturn("exec h_p_PM_WorkTaskWeekBillList " + page + "," + size + ",''", "h_p_PM_ProjectBillList");
|
}
|
else
|
{
|
sWhere = sWhere.Replace("'", "''");
|
ds = oCn.RunProcReturn("exec h_p_PM_WorkTaskWeekBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_PM_ProjectBillList");
|
}
|
|
//添加列名
|
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 = CodeConstant.SUCCEED;
|
objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.list = columnNameList;
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = CodeConstant.FAIL;
|
objJsonResult.count = CountConstant.FAIL;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
|
#region 工作周计划 删除
|
/// <summary>
|
///参数:string HInterID。
|
///返回值:object。
|
/// </summary>
|
[Route("PM_WorkTaskWeekBill/delete")]
|
[HttpGet]
|
public object deleteWorkTaskWeekBill(string HInterID, string user)
|
{
|
try
|
{
|
//查看权限
|
if (!DBUtility.ClsPub.Security_Log("Pm_WorkTaskWeekBill_Drop", 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_WorkTaskWeekBillMain where HInterID = " + HInterID);
|
oCn.RunProc("delete from PM_WorkTaskWeekBillSub where HInterID='" + HInterID + "'");
|
|
oCn.Commit();
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 工作周计划 审核/反审核
|
/// <summary>
|
/// </summary>
|
/// <param name="HInterID">单据ID</param>
|
/// <param name="IsAudit">审核(0),反审核(1)</param>
|
/// <param name="CurUserName">审核人</param>
|
/// <returns></returns>
|
[Route("PM_WorkTaskWeekBill/AuditPM_WorkTaskWeekBill")]
|
[HttpGet]
|
public object AuditPM_WorkTaskWeekBill(int HInterID, int IsAudit, string CurUserName)
|
{
|
string ModRightNameCheck = "Pm_WorkTaskWeekBill_Check";
|
DBUtility.ClsPub.CurUserName = CurUserName;
|
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.ClsPM_WorkTaskWeekBill oBill = new DAL.ClsPM_WorkTaskWeekBill(); //实例化单据操作类,用于进行相关操作
|
|
//针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作
|
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) //审核提交
|
{
|
|
//审核前控制=========================================
|
string sql1 = "exec h_p_PM_WorkTaskWeekBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
|
ds = oCn.RunProcReturn(sql1, "h_p_PM_WorkTaskWeekBill_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(lngBillKey, oBill.omodel.HBillNo, "h_p_PM_WorkTaskWeekBill_AfterCheckCtrl", 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 == 1) //反审核提交
|
{
|
|
//反审核前控制=========================================
|
string sql1 = "exec h_p_PM_WorkTaskWeekBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
|
ds = oCn.RunProcReturn(sql1, "h_p_PM_WorkTaskWeekBill_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(lngBillKey, oBill.omodel.HBillNo, "h_p_PM_WorkTaskWeekBill_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)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 工作周计划 关闭/反关闭
|
/// <summary>
|
/// </summary>
|
/// <param name="HInterID">单据ID</param>
|
/// <param name="IsAudit">关闭(0),反关闭(1)</param>
|
/// <param name="CurUserName">关闭人</param>
|
/// <returns></returns>
|
[Route("PM_WorkTaskWeekBill/ClosePM_WorkTaskWeekBill")]
|
[HttpGet]
|
public object ClosePM_WorkTaskWeekBill(int HInterID, int IsAudit, string CurUserName)
|
{
|
string ModRightNameCheck = "Pm_WorkTaskWeekBill_Close";
|
DBUtility.ClsPub.CurUserName = CurUserName;
|
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.ClsPM_WorkTaskWeekBill oBill = new DAL.ClsPM_WorkTaskWeekBill(); //实例化单据操作类,用于进行相关操作
|
|
//针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作
|
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.HChecker.Trim() == "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据未审核!不能进行关闭!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (IsAudit == 0) //关闭判断
|
{
|
if (oBill.omodel.HCloseMan.Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已关闭!不能再次关闭!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
if (IsAudit == 1) //反关闭判断
|
{
|
if (oBill.omodel.HCloseMan.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) //关闭提交
|
{
|
//关闭提交
|
if (oBill.CloseBill(lngBillKey, 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 == 1) //反关闭提交
|
{
|
//反关闭提交
|
if (oBill.CancelClose(lngBillKey, 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
|
|
#region 工作周计划 作废/反作废
|
/// <summary>
|
/// </summary>
|
/// <param name="HInterID">单据ID</param>
|
/// <param name="IsAudit">作废(0),反作废(1)</param>
|
/// <param name="CurUserName">作废人</param>
|
/// <returns></returns>
|
[Route("PM_WorkTaskWeekBill/DeletePM_WorkTaskWeekBill")]
|
[HttpGet]
|
public object DeletePM_WorkTaskWeekBill(int HInterID, int IsAudit, string CurUserName)
|
{
|
string ModRightNameCheck = "Pm_WorkTaskWeekBill_Delete";
|
DBUtility.ClsPub.CurUserName = CurUserName;
|
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.ClsPM_WorkTaskWeekBill oBill = new DAL.ClsPM_WorkTaskWeekBill(); //实例化单据操作类,用于进行相关操作
|
|
//针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作
|
if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //根据HInterID获取该单据的数据
|
{
|
if (oBill.omodel.HChecker.Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已审核!不能进行作废!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (IsAudit == 0) //作废判断
|
{
|
if (oBill.omodel.HDeleteMan.Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已作废!不能再作废!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
if (IsAudit == 1) //反作废判断
|
{
|
if (oBill.omodel.HDeleteMan.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) //作废提交
|
{
|
//作废提交
|
if (oBill.Cancelltion(lngBillKey, 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 == 1) //反关闭提交
|
{
|
//反关闭提交
|
if (oBill.AbandonCancelltion(lngBillKey, 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
|
|
#region 工作周总结 获取列表数据
|
[Route("PM_WorkTaskWeekBill/PM_WorkReportWeekBillList")]
|
[HttpGet]
|
public object PM_WorkReportWeekBillList(string sWhere, string user)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
ds = oCn.RunProcReturn("select * from h_v_PM_WorkReportWeekBillMainList order by 单据号 desc", "h_v_PM_WorkReportWeekBillMainList");
|
}
|
else
|
{
|
string sql1 = "select * from h_v_PM_WorkReportWeekBillMainList where 1 = 1 ";
|
string sql = sql1 + sWhere + " order by 单据号 desc";
|
ds = oCn.RunProcReturn(sql, "h_v_PM_WorkReportWeekBillMainList");
|
}
|
|
//添加列名
|
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列对象的列名
|
}
|
|
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "未获取到周总结相关数据!";
|
objJsonResult.data = null;
|
}
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "查询成功!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + e.ToString();
|
objJsonResult.data = null;
|
}
|
return objJsonResult;
|
}
|
#endregion
|
|
#region 工作周总结 分页列表
|
[Route("PM_WorkTaskWeekBill/PM_WorkReportWeekBillpage")]
|
[HttpGet]
|
public object PM_WorkReportWeekBillPage(string sWhere, string user, int page, int size)
|
{
|
DataSet ds;
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
//判断权限
|
//if (!DBUtility.ClsPub.Security_Log("Cg_POInStockBillQuery", 1, false, user))
|
//{
|
// objJsonResult.code = CodeConstant.FAIL;
|
// objJsonResult.count = CountConstant.FAIL;
|
// objJsonResult.Message = "您没有该模块权限,请与管理员联系!";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
ds = oCn.RunProcReturn("exec h_p_PM_WorkReportWeekBillMainList " + page + "," + size + ",''", "h_p_PM_ProjectBillList");
|
}
|
else
|
{
|
sWhere = sWhere.Replace("'", "''");
|
ds = oCn.RunProcReturn("exec h_p_PM_WorkReportWeekBillMainList " + page + "," + size + ",'" + sWhere + "'", "h_p_PM_ProjectBillList");
|
}
|
|
//添加列名
|
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 = CodeConstant.SUCCEED;
|
objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.list = columnNameList;
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = CodeConstant.FAIL;
|
objJsonResult.count = CountConstant.FAIL;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
|
#region 工作周总结 获取编辑列表数据
|
[Route("PM_WorkTaskWeekBill/PM_WorkReportWeekBillMainEditList")]
|
[HttpGet]
|
public object PM_WorkReportWeekBillMainEditList(string HInterID)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
ds = oCn.RunProcReturn("select * from h_v_PM_WorkReportWeekBillMainList where HInterID='" + HInterID + "'", "h_v_PM_WorkReportWeekBillMainList");
|
//添加列名
|
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列对象的列名
|
}
|
|
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "未获取到周总结相关数据!";
|
objJsonResult.data = null;
|
}
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "查询成功!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + e.ToString();
|
objJsonResult.data = null;
|
}
|
return objJsonResult;
|
}
|
#endregion
|
|
#region 工作周总结 选择总结人带出工时
|
[Route("PM_WorkTaskWeekBill/PM_WorkReportWeekBillMainList")]
|
[HttpGet]
|
public object PM_WorkReportWeekBillMainList(string HOrgID,string user,string HYear,string HWeek,string HBeginDate,string HEndDate)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
//查看权限
|
if (!DBUtility.ClsPub.Security_Log("PM_WorkReportWeekBillMain_Query", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无查看权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
|
|
string sql = "exec h_p_PM_WorkReportWeekBillMain "+ HOrgID+","+ user+","+ HYear+","+ HWeek+",'"+ HBeginDate + "','"+ HEndDate + "'";
|
ds = oCn.RunProcReturn(sql, "h_p_PM_WorkReportWeekBillMain");
|
|
|
//添加列名
|
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列对象的列名
|
}
|
|
|
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "未获取到相关数据!";
|
objJsonResult.data = null;
|
}
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "查询成功!";
|
objJsonResult.data = ds.Tables[0];
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + e.ToString();
|
objJsonResult.data = null;
|
}
|
return objJsonResult;
|
}
|
#endregion
|
|
|
#region 工作周总结保存/编辑
|
/// <summary>
|
/// 保存工作周总结
|
/// </summary>
|
/// <param name="msg"></param>
|
/// <returns></returns>
|
[Route("PM_WorkTaskWeekBill/SavePM_WorkReportWeekBillMain")]
|
[HttpPost]
|
public object SavePM_WorkReportWeekBillMain([FromBody] JObject msg)
|
{
|
var _value = msg["msg"].ToString();
|
string msg1 = _value.ToString();
|
string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
string msg2 = sArray[0].ToString();
|
string refSav = sArray[1].ToString(); //操作方式数据类型 1添加 3修改 2 复制
|
string user = sArray[2].ToString();//用户名
|
|
string UserName = "";
|
string s = "";
|
ListModels oListModels = new ListModels();
|
try
|
{
|
//保存权限
|
if (!DBUtility.ClsPub.Security_Log_second("PM_WorkReportWeekBillMain_Add", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无保存权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
DAL.ClsPM_WorkReportWeekBillMain oBill = new DAL.ClsPM_WorkReportWeekBillMain();
|
List<Model.ClsPM_WorkReportWeekBillMain> lsmain = new List<Model.ClsPM_WorkReportWeekBillMain>();
|
msg2 = msg2.Replace("\\", "");
|
msg2 = msg2.Replace("\n", ""); //\n
|
lsmain = oListModels.getObjectByJson_PM_WorkReportWeekBillMain(msg2);
|
foreach (Model.ClsPM_WorkReportWeekBillMain oItem in lsmain)
|
{
|
if (refSav == "Add")
|
{
|
//单据号是否重复
|
if (BillNew.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 (BillOld.ShowBill(oItem.HInterID, ref s) == false)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "此单据有误!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
//判断是否可编辑
|
if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "此单据已经被审核,不允许修改!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
if (BillOld.omodel.HBillStatus > 1)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "此单据处于不可编辑状态,不允许修改!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld, ref s))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = s + ",不允许修改";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
}
|
UserName = oItem.HMaker; //制单人
|
oItem.HBillType = "4757";
|
oItem.HBillSubType = "4757";
|
|
|
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;
|
}
|
|
//保存
|
//保存完毕后处理
|
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 = "保存成功!";
|
//WebAPIController.Add_Log("送货单下推", UserName, "生成送货单");
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!" + e.ToString();
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 工作周总结 审核/反审核功能
|
[Route("PM_WorkTaskWeekBill/CheckPM_WorkReportWeekBillMain")]
|
[HttpGet]
|
public object CheckPM_WorkReportWeekBillMain(int HInterID, int IsAudit, string CurUserName)
|
{
|
DBUtility.ClsPub.CurUserName = CurUserName;
|
try
|
{
|
//审核权限
|
if (!DBUtility.ClsPub.Security_Log_second("PM_WorkReportWeekBillMain_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_WorkReportWeekBillMain oBill = new DAL.ClsPM_WorkReportWeekBillMain(); //实例化单据操作类,用于进行相关操作
|
|
//针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作
|
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_WorkReportWeekBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
|
ds = oCn.RunProcReturn(sql1, "h_p_PM_WorkReportWeekBill_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_WorkReportWeekBill_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_WorkReportWeekBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
|
ds = oCn.RunProcReturn(sql1, "h_p_PM_WorkReportWeekBill_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_WorkReportWeekBill_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_WorkTaskWeekBill/ClosePM_WorkReportWeekBillMain")]
|
[HttpGet]
|
public object ClosePM_WorkReportWeekBillMain(string HInterID, int IsAudit, string user)
|
{
|
try
|
{
|
//判断是否有关闭权限
|
if (!DBUtility.ClsPub.Security_Log("PM_WorkReportWeekBillMain_Close", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无权限关闭!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
|
var ds = oCn.RunProcReturn("select * from PM_WorkReportWeekBillMain where HInterID=" + HInterID, "PM_WorkReportWeekBillMain");
|
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_WorkReportWeekBillMain set HCloseMan='" + user + "',HCloseDate=getdate() where HInterID=" + HInterID);
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "关闭成功";
|
objJsonResult.data = null;
|
}
|
if (IsAudit == 1) //反审核判断
|
{
|
oCn.RunProc("update PM_WorkReportWeekBillMain set HCloseMan='',HCloseDate=null 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 工作周总结 删除
|
/// <summary>
|
///参数:string HInterID。
|
///返回值:object。
|
/// </summary>
|
[Route("PM_WorkTaskWeekBill/PM_WorkReportWeekBillMainDelete")]
|
[HttpGet]
|
public object PM_WorkReportWeekBillMainDelete(string HInterID, string user)
|
{
|
try
|
{
|
//查看权限
|
if (!DBUtility.ClsPub.Security_Log("PM_WorkReportWeekBillMain_Drop", 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_WorkReportWeekBillMain where HInterID = " + HInterID);
|
//oCn.RunProc("delete from PM_WorkTaskWeekBillSub 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
|
}
|
}
|