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;
|
|
namespace WebAPI.Controllers.项目管理.项目阶段
|
{
|
public class Gy_ProjectStageController : 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 = "";
|
|
|
#region 项目阶段 新增/编辑
|
#region 项目阶段 新增/编辑 信息列表
|
public class Gy_ProjectStage_eidt_add
|
{
|
public long HItemID;
|
public string HNumber;
|
public string HName;
|
public long HParentID;
|
public bool HStopflag;
|
public string HRemark;
|
public string HHelpCode;
|
public int HUSEORGID;
|
public string HStageNote;
|
public string HRelationGoods;
|
public bool HIsKey;
|
public double HRate;
|
}
|
#endregion
|
/// <summary>
|
/// 保存按钮
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("Gy_ProjectStage/AddNewProjectStage")]
|
[HttpPost]
|
public object AddNewProjectStage([FromBody] JObject oMain)
|
{
|
try
|
{
|
//DAL.ClsGy_Process_Ctl oDept = new DAL.ClsGy_Process_Ctl();
|
//DAL.ClsGy_Process_View oDeptHlp = new DAL.ClsGy_Process_View();
|
|
var _value = oMain["oMain"].ToString();
|
string msg1 = _value.ToString();
|
string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
string msg2 = sArray[0].ToString();
|
string user = sArray[1].ToString();//用户名
|
|
//判断是否有编辑权限
|
if (!DBUtility.ClsPub.Security_Log("PM_ProjectStage_edit", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无权限编辑!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
//string msg3 = sArray[1].ToString();
|
//string msg4 = sArray[2].ToString();
|
//string msg5 = sArray[3].ToString();
|
|
|
//反序列化
|
msg2 = "[" + msg2.ToString() + "]";
|
List<Gy_ProjectStage_eidt_add> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Gy_ProjectStage_eidt_add>>(msg2);
|
|
long HItemID = list[0].HItemID;
|
string HNumber = list[0].HNumber;
|
string HName = list[0].HName;
|
string HShortNumber = list[0].HNumber;
|
long HParentID = list[0].HParentID;
|
long HLevel = ClsPub.GetLevel(list[0].HNumber.Trim());
|
bool HEndFlag = true;
|
bool HStopflag = list[0].HStopflag;
|
string HRemark = list[0].HRemark;
|
string HHelpCode = list[0].HHelpCode;
|
string HMakeEmp = user;
|
string HModifyEmp = user;
|
int HUSEORGID = list[0].HUSEORGID;
|
string HStageNote = list[0].HStageNote;
|
string HRelationGoods = list[0].HRelationGoods;
|
bool HIsKey = list[0].HIsKey;
|
double HRate = list[0].HRate;
|
|
|
//保存
|
//保存完毕后处理
|
if (HItemID == 0)
|
{
|
oCN.BeginTran();
|
string sql = "Insert into Gy_ProjectStage" +
|
" (HNumber,HName,HShortNumber,HParentID,HLevel,HEndFlag,HStopflag,HRemark,HHelpCode,HMakeEmp,HUSEORGID,HStageNote,HRelationGoods,HIsKey,HRate) " +
|
" Values(" +
|
"'" + HNumber + "'" +
|
",'" + HName + "'" +
|
",'" + HShortNumber + "'" +
|
"," + HParentID.ToString() + "" +
|
"," + HLevel.ToString() + "" +
|
"," + Convert.ToString(HEndFlag ? 1 : 0) + "" +
|
"," + Convert.ToString(HStopflag ? 1 : 0) + "" +
|
",'" + HRemark + "'" +
|
",'" + HHelpCode + "'" +
|
",'" + HMakeEmp + "'" +
|
"," + HUSEORGID + "" +
|
",'" + HStageNote + "'" +
|
",'" + HRelationGoods + "'" +
|
"," + Convert.ToString(HIsKey ? 1 : 0) + "" +
|
"," + HRate + "" +
|
")";
|
|
oCN.RunProc(sql, ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改上级为非末级代码
|
oCN.RunProc("Update Gy_ProjectStage set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oCN.Commit();
|
}
|
else
|
{
|
////若MAINDI重复则重新获取
|
oCN.BeginTran();
|
string sql = "Update Gy_ProjectStage set " +
|
"HNumber='" + HNumber + "'" +
|
",HName='" + HName + "'" +
|
",HShortNumber='" + HShortNumber + "'" +
|
",HParentID=" + HParentID.ToString() + "" +
|
",HLevel=" + HLevel.ToString() + "" +
|
",HEndFlag=" + Convert.ToString(HEndFlag ? 1 : 0) + "" +
|
",HStopflag=" + Convert.ToString(HStopflag ? 1 : 0) + "" +
|
",HRemark='" + HRemark + "'" +
|
",HHelpCode='" + HHelpCode + "'" +
|
",HMakeEmp='" + HMakeEmp + "'" +
|
",HModifyEmp = '" + HModifyEmp + "'" +
|
",HModifyTime = getDate()" +
|
",HUSEORGID=" + HUSEORGID + "" +
|
",HStageNote='" + HStageNote + "'" +
|
",HRelationGoods='" + HRelationGoods + "'" +
|
",HIsKey=" + Convert.ToString(HIsKey ? 1 : 0) + "" +
|
",HRate=" + HRate + "" +
|
" where HItemID=" + HItemID;
|
oCN.RunProc(sql, ref DBUtility.ClsPub.sExeReturnInfo);
|
//修改上级为非末级代码
|
oCN.RunProc("Update Gy_ProjectStage set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
|
//
|
oCN.Commit();
|
}
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "保存成功!";
|
//WebAPIController.Add_Log("送货单下推", UserName, "生成送货单");
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.Message;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 项目阶段 查询
|
/// <summary>
|
/// 返回项目阶段列表
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("Gy_ProjectStage/list")]
|
[HttpGet]
|
public object getProjectStageList(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 Gy_ProjectStage order by HNumber ", "Gy_ProjectStage");
|
}
|
else
|
{
|
string sql1 = "select * from Gy_ProjectStage where 1 = 1 ";
|
string sql = sql1 + sWhere + " order by HNumber ";
|
ds = oCN.RunProcReturn(sql, "Gy_ProjectStage");
|
}
|
|
//添加列名
|
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 项目阶段 查询指定项目阶段记录
|
/// <summary>
|
/// 根据基础资料ID 查找记录
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("Gy_ProjectStage/cx")]
|
[HttpGet]
|
public object cx(long HInterID)
|
{
|
try
|
{
|
|
ds = oCN.RunProcReturn("select * from Gy_ProjectStage where HitemID=" + HInterID, "Gy_ProjectStage");
|
|
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 项目阶段 删除
|
/// <summary>
|
/// 项目阶段列表删除功能
|
/// </summary>
|
/// <returns></returns>
|
[Route("DeltetGy_ProjectStage")]
|
[HttpGet]
|
public object DeltetGy_ProjectStage(string HItemID, string user)
|
{
|
DataSet ds;
|
DataSet ds1;
|
try
|
{
|
//删除权限
|
if (!DBUtility.ClsPub.Security_Log("PM_ProjectStage_delete", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无删除权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
if (string.IsNullOrWhiteSpace(HItemID))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "HItemID为空!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
oCN.BeginTran();//开始事务
|
ds = oCN.RunProcReturn("select * from Gy_ProjectStage where HItemID=" + HItemID, "Gy_ProjectStage");
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有数据,无法删除!";
|
objJsonResult.data = null;
|
return objJsonResult; ;
|
}
|
//var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]);
|
//if (HStopflag)
|
//{
|
// oCN.RollBack();//回滚事务
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "数据已删除无法再次删除!";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
ds1 = oCN.RunProcReturn("Select HItemID from Gy_ProjectStage Where HParentID='" + HItemID + "'", " Gy_ProjectStage");
|
if (ds1.Tables[0].Rows.Count != 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "此项目存在子项目,不能删除!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
string HUseFlag = Convert.ToString(ds.Tables[0].Rows[0]["HUseFlag"]);
|
if (HUseFlag == "已使用")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "此项目已使用,不能删除!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
oCN.RunProc("delete from Gy_ProjectStage where HItemID=" + HItemID);
|
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 项目阶段 审核/反审核
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="HInterID">单据ID</param>
|
/// <param name="IsAudit">审核(0),反审核(1)</param>
|
/// <param name="CurUserName">审核人</param>
|
/// <returns></returns>
|
[Route("Gy_ProjectStage/AuditGy_ProjectStage")]
|
[HttpGet]
|
public object AuditGy_ProjectStage(int HInterID, int IsAudit, string CurUserName)
|
{
|
try
|
{
|
//审核权限
|
if (!DBUtility.ClsPub.Security_Log_second("Pm_ProjectStage_Check", 1, false, CurUserName))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败!无权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
var ds = oCN.RunProcReturn("select * from Gy_ProjectStage where HItemID=" + HInterID, "Gy_ProjectStage");
|
if (ds.Tables[0].Rows.Count > 0)
|
{
|
if (IsAudit == 0) //审核判断
|
{
|
if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已审核!不能再次审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
if (IsAudit == 1) //反审核判断
|
{
|
if (ds.Tables[0].Rows[0]["HCheckEmp"].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 Gy_ProjectStage set HCheckEmp='" + CurUserName + "',HCheckTime=getdate() where HItemID=" + HInterID);
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "审核成功";
|
objJsonResult.data = null;
|
}
|
if (IsAudit == 1) //反审核判断
|
{
|
oCN.RunProc("update Gy_ProjectStage set HCheckEmp='',HCheckTime=null where HItemID=" + HInterID);
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "反审核成功";
|
objJsonResult.data = null;
|
}
|
oCN.Commit();
|
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
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="IsStop">禁用(0),反禁用(1)</param>
|
/// <param name="CurUserName">审核人</param>
|
/// <returns></returns>
|
[Route("Gy_ProjectStage/StopGy_ProjectStage")]
|
[HttpGet]
|
public object StopGy_ProjectStage(int HInterID, int IsStop, string CurUserName)
|
{
|
try
|
{
|
//审核权限
|
if (!DBUtility.ClsPub.Security_Log_second("Pm_ProjectStage_Stop", 1, false, CurUserName))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "禁用失败!无权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
var ds = oCN.RunProcReturn("select * from Gy_ProjectStage where HItemID=" + HInterID, "Gy_ProjectStage");
|
if (ds.Tables[0].Rows.Count > 0)
|
{
|
if (IsStop == 0) //禁用判断
|
{
|
if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已禁用!不能再次禁用!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
if (IsStop == 1) //反禁用判断
|
{
|
if (ds.Tables[0].Rows[0]["HStopEmp"].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 (IsStop == 0) //禁用判断
|
{
|
oCN.RunProc("update Gy_ProjectStage set HStopEmp='" + CurUserName + "',HStopTime=getdate(),HStopflag=1 where HItemID=" + HInterID);
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "禁用成功";
|
objJsonResult.data = null;
|
}
|
if (IsStop == 1) //反禁用判断
|
{
|
oCN.RunProc("update Gy_ProjectStage set HStopEmp='',HStopTime=null,HStopflag=0 where HItemID=" + HInterID);
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "反禁用成功";
|
objJsonResult.data = null;
|
}
|
oCN.Commit();
|
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "禁用失败或者反禁用失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
|
|
#region 项目阶段清单 新增/编辑- 保存
|
#region 项目阶段清单 表头数据
|
public class PM_ProjectStageBill_Main
|
{
|
public int HInterID;
|
public string HBillNo;
|
public string HDate;
|
public string HRemark;
|
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;
|
}
|
#endregion
|
#region 项目阶段清单 子表数据
|
public class PM_ProjectStageBill_Sub
|
{
|
public int RowID;
|
public int HProjectStageID;
|
public string HProjectStageName;
|
public string HStageNote;
|
public int HPMGoodsID;
|
public string HPMGoodsName;
|
public bool HIsKey;
|
public double HRate;
|
//public int HEmpID;
|
//public string HEmpName;
|
//public int HCheckEmpID;
|
//public string HCheckEmpName;
|
//public string HFinishDate;
|
//public double HWorkDays;
|
public string HRemarkSub;
|
}
|
#endregion
|
#region 项目阶段清单 新增/编辑-保存
|
/// <summary>
|
/// 新增单据-保存按钮
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("PM_ProjectStageBill/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();
|
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_ProjectStageBill_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_ProjectStageBill_edit", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无编辑权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
msg2 = "[" + msg2.ToString() + "]";
|
List<PM_ProjectStageBill_Main> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PM_ProjectStageBill_Main>>(msg2);
|
|
int HYear = int.Parse(mainList[0].HDate.Split('-')[0]);
|
int HPeriod = int.Parse(mainList[0].HDate.Split('-')[1]);
|
string HBillType = "4751";
|
string HBillSubType = "";
|
int HInterID = mainList[0].HInterID;
|
string HDate = mainList[0].HDate;
|
string HBillNo = mainList[0].HBillNo;
|
int HBillStatus = 1;
|
string HRemark = mainList[0].HRemark;
|
string HMaker = mainList[0].HMaker;
|
string HMakerDate = mainList[0].HMakerDate;
|
string HUpdater = mainList[0].HUpdater;
|
string HUpdaterDate = mainList[0].HUpdaterDate;
|
|
if (OperationType == 2)
|
{
|
ds = oCN.RunProcReturn("select * from PM_ProjectStageBillMain where HBillNo ='" + HBillNo + "'", "PM_ProjectStageBill");
|
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_ProjectStageBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "PM_ProjectStageBillMain");
|
|
if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//新增
|
{
|
string sql = "insert into PM_ProjectStageBillMain" +
|
"(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate,HBillNo,HBillStatus,HRemark,HMaker,HMakeDate) " +
|
"values(" +
|
"" + HYear +
|
"," + HPeriod +
|
",'" + HBillType +
|
"','" + HBillSubType +
|
"'," + HInterID +
|
",'" + HDate +
|
"','" + HBillNo +
|
"'," + HBillStatus +
|
",'" + HRemark +
|
"','" + HMaker +
|
"','" + HMakerDate +
|
"')";
|
|
//主表
|
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_ProjectStageBillMain set " +
|
"HYear = " + HYear +
|
",HPeriod = " + HPeriod +
|
",HBillType = '" + HBillType +
|
"',HBillSubType = '" + HBillSubType +
|
"',HDate = '" + HDate +
|
"',HBillNo = '" + HBillNo +
|
"',HBillStatus = " + HBillStatus +
|
",HRemark = '" + HRemark +
|
"',HUpdater = '" + HUpdater +
|
"',HUpdateDate = '" + HUpdaterDate +
|
"' where HInterID = " + HInterID;
|
|
oCN.RunProc(sql);
|
|
//删除子表
|
oCN.RunProc("delete from PM_ProjectStageBillSub 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);
|
}
|
//保存子表
|
objJsonResult = AddBillSub(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(string msg3, long HInterID, string HBillNo, int OperationType)
|
{
|
List<PM_ProjectStageBill_Sub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PM_ProjectStageBill_Sub>>(msg3);
|
int i = 0; //作为子表内码
|
foreach (PM_ProjectStageBill_Sub oSub in DetailColl)
|
{
|
i++; //同一个主表下的子表的内码自增
|
|
int HEntryID = i;
|
int HProjectStageID = oSub.HProjectStageID;
|
string HStageNote = oSub.HStageNote;
|
int HPMGoodsID = oSub.HPMGoodsID;
|
string HRelationGoods = oSub.HPMGoodsName;
|
int HIsKey = oSub.HIsKey?1:0;
|
double HRate = oSub.HRate;
|
string HRemark = oSub.HRemarkSub;
|
|
string sql = "insert into PM_ProjectStageBillSub" +
|
"(HInterID,HBillNo_bak,HEntryID,HRemark,HProjectStageID,HStageNote,HPMGoodsID,HRelationGoods,HIsKey,HRate) " +
|
"values(" +
|
"" + HInterID +
|
",'" + HBillNo +
|
"'," + HEntryID +
|
",'" + HRemark +
|
"'," + HProjectStageID +
|
",'" + HStageNote +
|
"'," + HPMGoodsID +
|
",'" + HRelationGoods +
|
"'," + HIsKey +
|
"," + HRate +
|
")";
|
|
oCN.RunProc(sql);
|
}
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = null;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
#endregion
|
#endregion
|
|
#region 项目阶段清单 查询
|
/// <summary>
|
/// 返回项目阶段列表
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("PM_ProjectStageBill/list")]
|
[HttpGet]
|
public object getProjectStageBill(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 PM_ProjectStageBillMain order by HBillNo desc ", "PM_ProjectStageBillMain");
|
}
|
else
|
{
|
string sql1 = "select * from PM_ProjectStageBillMain where 1 = 1 ";
|
string sql = sql1 + sWhere + " order by HBillNo desc ";
|
ds = oCN.RunProcReturn(sql, "PM_ProjectStageBillMain");
|
}
|
|
//添加列名
|
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 项目阶段清单 编辑-页面赋值
|
/// <summary>
|
///参数:string HInterID。
|
///返回值:object。
|
/// </summary>
|
[Route("PM_ProjectStageBill/editInit")]
|
[HttpGet]
|
public object getProjectStageBilleditInit(string HInterID, string user)
|
{
|
try
|
{
|
List<DataTable> tableList = new List<DataTable>();
|
|
//查看权限
|
//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_ProjectStageBill_EditInit " + HInterID, "h_p_PM_ProjectStageBill_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 项目阶段清单 删除
|
/// <summary>
|
///参数:string HInterID。
|
///返回值:object。
|
/// </summary>
|
[Route("PM_ProjectStageBill/delete")]
|
[HttpGet]
|
public object deleteProjectStageBill(string HInterID, string user)
|
{
|
try
|
{
|
//查看权限
|
if (!DBUtility.ClsPub.Security_Log("Pm_ProjectStageBill_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_ProjectStageBillMain where HInterID = " + HInterID);
|
oCN.RunProc("delete from PM_ProjectStageBillSub 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_ProjectStageBill/AuditPM_ProjectStageBill")]
|
[HttpGet]
|
public object AuditPM_ProjectStageBill(int HInterID, int IsAudit, string CurUserName)
|
{
|
try
|
{
|
//审核权限
|
if (!DBUtility.ClsPub.Security_Log_second("Pm_ProjectStageBill_Check", 1, false, CurUserName))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败!无权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
var ds = oCN.RunProcReturn("select * from PM_ProjectStageBillMain where HInterID=" + HInterID, "PM_ProjectStageBillMain");
|
if (ds.Tables[0].Rows.Count > 0)
|
{
|
if (IsAudit == 0) //审核判断
|
{
|
if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已审核!不能再次审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
if (IsAudit == 1) //反审核判断
|
{
|
if (ds.Tables[0].Rows[0]["HChecker"].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_ProjectStageBillMain set HChecker='" + CurUserName + "',HCheckDate=getdate() where HInterID=" + HInterID);
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "审核成功";
|
objJsonResult.data = null;
|
}
|
if (IsAudit == 1) //反审核判断
|
{
|
oCN.RunProc("update PM_ProjectStageBillMain set HChecker='',HCheckDate=null where HInterID=" + HInterID);
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "反审核成功";
|
objJsonResult.data = null;
|
}
|
oCN.Commit();
|
|
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_ProjectStageBill/ClosePM_ProjectStageBill")]
|
[HttpGet]
|
public object ClosePM_ProjectStageBill(string HInterID, int Type, string user)
|
{
|
try
|
{
|
//判断是否有删除权限
|
if (!DBUtility.ClsPub.Security_Log("Pm_ProjectStageBill_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_ProjectStageBillMain";
|
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.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 (!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]["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_ProjectStageBill/DropPM_ProjectStageBill")]
|
[HttpGet]
|
public object DropPM_ProjectStageBill(string HInterID, int Type, string user)
|
{
|
try
|
{
|
//判断是否有作废权限
|
if (!DBUtility.ClsPub.Security_Log("Pm_ProjectStageBill_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_ProjectStageBillMain";
|
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.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 (!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]["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 项目阶段汇报 新增/编辑-保存
|
#region 项目阶段汇报 表头数据
|
public class PM_ProjectReportBill_Main
|
{
|
public int HInterID;
|
public string HBillNo;
|
public string HDate;
|
public string HProNumber;
|
public int HProjectStageID;
|
public string HProjectStageName;
|
public string HStageNote;
|
public string HRelationGoods;
|
public int HIsKey;
|
public int HReportEmpID;
|
public string HReportEmpName;
|
public string HReportNote;
|
public string HReportGoods;
|
public string HReceiveEmp;
|
public string HCopyEmp;
|
public double HRate;
|
public int HOrgID;
|
public string HRemark;
|
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;
|
}
|
#endregion
|
#region 项目阶段汇报 子表数据
|
public class PM_ProjectReportBill_Sub
|
{
|
public int RowID;
|
public int HEmpID;
|
public string HEmpName;
|
public bool HIsPM;
|
public double HRate;
|
public double HAvgMoney;
|
public double HCountMoney;
|
public string HRemarkSub;
|
}
|
#endregion
|
#region 项目阶段汇报 新增/编辑-保存
|
/// <summary>
|
/// 新增单据-保存按钮
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("PM_ProjectReportBill/AddBill")]
|
[HttpPost]
|
public object AddBill_ProjectReportBill([FromBody] JObject sMainSub)
|
{
|
//获取参数
|
var _value = sMainSub["sMainSub"].ToString();
|
string msg1 = _value.ToString();
|
//开始事务
|
oCN.BeginTran();
|
//保存主表
|
objJsonResult = AddBillMain_ProjectReportBill(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_ProjectReportBill(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_ProjectReportBill_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_ProjectReportBill_edit", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无编辑权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
msg2 = "[" + msg2.ToString() + "]";
|
List<PM_ProjectReportBill_Main> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PM_ProjectReportBill_Main>>(msg2);
|
|
int HYear = int.Parse(mainList[0].HDate.Split('-')[0]);
|
int HPeriod = int.Parse(mainList[0].HDate.Split('-')[1]);
|
string HBillType = "4752";
|
string HBillSubType = "";
|
int HBillStatus = 1;
|
|
int HInterID = mainList[0].HInterID;
|
string HBillNo = mainList[0].HBillNo;
|
string HDate = mainList[0].HDate;
|
string HProNumber = mainList[0].HProNumber;
|
int HProjectStageID = mainList[0].HProjectStageID;
|
string HStageNote = mainList[0].HStageNote;
|
string HRelationGoods = mainList[0].HRelationGoods;
|
int HIsKey = mainList[0].HIsKey;
|
int HReportEmpID = mainList[0].HReportEmpID;
|
string HReportNote = mainList[0].HReportNote;
|
string HReportGoods = mainList[0].HReportGoods;
|
string HReceiveEmp = mainList[0].HReceiveEmp;
|
string HCopyEmp = mainList[0].HCopyEmp;
|
double HRate = mainList[0].HRate;
|
int HOrgID = mainList[0].HOrgID;
|
string HRemark = mainList[0].HRemark;
|
string HMaker = mainList[0].HMaker;
|
string HMakerDate = mainList[0].HMakerDate;
|
string HUpdater = mainList[0].HUpdater;
|
string HUpdaterDate = mainList[0].HUpdaterDate;
|
|
|
if (OperationType == 2)
|
{
|
ds = oCN.RunProcReturn("select * from PM_ProjectReportBillMain where HBillNo ='" + HBillNo + "'", "PM_ProjectReportBillMain");
|
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_ProjectReportBillMain where HInterID = " + HInterID + " and HBillNo = '" + HBillNo + "'", "PM_ProjectReportBillMain");
|
|
if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//新增
|
{
|
string sql = "insert into PM_ProjectReportBillMain" +
|
"(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate,HBillNo,HBillStatus,HRemark,HMaker,HMakeDate" +
|
",HProNumber,HProjectStageID,HStageNote,HRelationGoods,HIsKey,HReportEmpID,HReportNote,HReportGoods,HReceiveEmp,HCopyEmp,HRate,HOrgID) " +
|
"values(" +
|
"" + HYear +
|
"," + HPeriod +
|
",'" + HBillType +
|
"','" + HBillSubType +
|
"'," + HInterID +
|
",'" + HDate +
|
"','" + HBillNo +
|
"'," + HBillStatus +
|
",'" + HRemark +
|
"','" + HMaker +
|
"','" + HMakerDate +
|
"','" + HProNumber +
|
"'," + HProjectStageID +
|
",'" + HStageNote +
|
"','" + HRelationGoods +
|
"'," + HIsKey +
|
"," + HReportEmpID +
|
",'" + HReportNote +
|
"','" + HReportGoods +
|
"','" + HReceiveEmp +
|
"','" + HCopyEmp +
|
"'," + HRate +
|
"," + HOrgID +
|
")";
|
|
//主表
|
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_ProjectReportBillMain set " +
|
"HYear = " + HYear +
|
",HPeriod = " + HPeriod +
|
",HBillType = '" + HBillType +
|
"',HBillSubType = '" + HBillSubType +
|
"',HDate = '" + HDate +
|
"',HBillNo = '" + HBillNo +
|
"',HBillStatus = " + HBillStatus +
|
",HRemark = '" + HRemark +
|
"',HUpdater = '" + HUpdater +
|
"',HUpdateDate = '" + HUpdaterDate +
|
"',HProNumber = '" + HProNumber +
|
"',HProjectStageID = " + HProjectStageID +
|
",HStageNote = '" + HStageNote +
|
"',HRelationGoods = '" + HRelationGoods +
|
"',HIsKey = " + HIsKey +
|
",HReportEmpID = " + HReportEmpID +
|
",HReportNote = '" + HReportNote +
|
"',HReportGoods = '" + HReportGoods +
|
"',HReceiveEmp = '" + HReceiveEmp +
|
"',HCopyEmp = '" + HCopyEmp +
|
"',HRate = " + HRate +
|
",HOrgID = " + HOrgID +
|
" where HInterID = " + HInterID;
|
|
oCN.RunProc(sql);
|
|
//删除子表
|
oCN.RunProc("delete from PM_ProjectReportBillSub 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);
|
}
|
//保存子表
|
objJsonResult = AddBillSub_ProjectReportBill(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_ProjectReportBill(string msg3, long HInterID, string HBillNo, int OperationType)
|
{
|
List<PM_ProjectReportBill_Sub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PM_ProjectReportBill_Sub>>(msg3);
|
int i = 0; //作为子表内码
|
foreach (PM_ProjectReportBill_Sub oSub in DetailColl)
|
{
|
i++; //同一个主表下的子表的内码自增
|
|
int HEntryID = i;
|
int HEmpID = oSub.HEmpID;
|
int HIsPM = oSub.HIsPM?1:0;
|
double HRate = oSub.HRate;
|
double HAvgMoney = oSub.HAvgMoney;
|
double HCountMoney = oSub.HCountMoney;
|
string HRemarkSub = oSub.HRemarkSub;
|
string sql = "insert into PM_ProjectReportBillSub" +
|
"(HInterID,HBillNo_bak,HEntryID,HRemark,HEmpID,HIsPM,HRate,HAvgMoney,HCountMoney) " +
|
"values(" +
|
"" + HInterID +
|
",'" + HBillNo +
|
"'," + HEntryID +
|
",'" + HRemarkSub +
|
"'," + HEmpID +
|
"," + HIsPM +
|
"," + HRate +
|
"," + HAvgMoney +
|
"," + HCountMoney +
|
")";
|
oCN.RunProc(sql);
|
}
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = null;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
#endregion
|
#endregion
|
|
#region 项目阶段汇报 查询
|
/// <summary>
|
/// 返回项目阶段列表
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("PM_ProjectReportBill/list")]
|
[HttpGet]
|
public object getProjectReportBill(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 PM_ProjectReportBillMain order by HBillNo desc ", "PM_ProjectReportBillMain");
|
}
|
else
|
{
|
string sql1 = "select * from PM_ProjectReportBillMain where 1 = 1 ";
|
string sql = sql1 + sWhere + " order by HBillNo desc ";
|
ds = oCN.RunProcReturn(sql, "PM_ProjectReportBillMain");
|
}
|
|
//添加列名
|
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 项目阶段清单 编辑-页面赋值
|
/// <summary>
|
///参数:string HInterID。
|
///返回值:object。
|
/// </summary>
|
[Route("PM_ProjectReportBill/editInit")]
|
[HttpGet]
|
public object getProjectReportBilleditInit(string HInterID, string user)
|
{
|
try
|
{
|
List<DataTable> tableList = new List<DataTable>();
|
|
//查看权限
|
//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_ProjectReportBill_EditInit " + HInterID, "h_p_PM_ProjectReportBill_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 项目阶段汇报 删除
|
/// <summary>
|
///参数:string HInterID。
|
///返回值:object。
|
/// </summary>
|
[Route("PM_ProjectReportBill/delete")]
|
[HttpGet]
|
public object deleteProjectReportBill(string HInterID, string user)
|
{
|
try
|
{
|
//查看权限
|
if (!DBUtility.ClsPub.Security_Log("Pm_ProjectReportBill_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_ProjectReportBillMain where HInterID = " + HInterID);
|
oCN.RunProc("delete from PM_ProjectReportBillSub 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_ProjectReportBill/AuditPM_ProjectReportBill")]
|
[HttpGet]
|
public object AuditPM_ProjectReportBill(int HInterID, int IsAudit, string CurUserName)
|
{
|
try
|
{
|
//审核权限
|
if (!DBUtility.ClsPub.Security_Log_second("Pm_ProjectReportBill_Check", 1, false, CurUserName))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败!无权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
var ds = oCN.RunProcReturn("select * from PM_ProjectReportBillMain where HInterID=" + HInterID, "PM_ProjectReportBillMain");
|
if (ds.Tables[0].Rows.Count > 0)
|
{
|
if (IsAudit == 0) //审核判断
|
{
|
if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已审核!不能再次审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
if (IsAudit == 1) //反审核判断
|
{
|
if (ds.Tables[0].Rows[0]["HChecker"].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_ProjectReportBillMain set HChecker='" + CurUserName + "',HCheckDate=getdate() where HInterID=" + HInterID);
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "审核成功";
|
objJsonResult.data = null;
|
}
|
if (IsAudit == 1) //反审核判断
|
{
|
oCN.RunProc("update PM_ProjectReportBillMain set HChecker='',HCheckDate=null where HInterID=" + HInterID);
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "反审核成功";
|
objJsonResult.data = null;
|
}
|
oCN.Commit();
|
|
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_ProjectReportBill/ClosePM_ProjectReportBill")]
|
[HttpGet]
|
public object ClosePM_ProjectReportBill(string HInterID, int Type, string user)
|
{
|
try
|
{
|
//判断是否有删除权限
|
if (!DBUtility.ClsPub.Security_Log("Pm_ProjectReportBill_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_ProjectReportBillMain";
|
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.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 (!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]["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_ProjectReportBill/DropPM_ProjectReportBill")]
|
[HttpGet]
|
public object DropPM_ProjectReportBill(string HInterID, int Type, string user)
|
{
|
try
|
{
|
//判断是否有作废权限
|
if (!DBUtility.ClsPub.Security_Log("Pm_ProjectReportBill_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_ProjectReportBillMain";
|
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.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 (!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]["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
|
}
|
}
|