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;
|
|
namespace WebAPI.Controllers
|
{
|
public class Gy_ClassTimePrjController : ApiController
|
{
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
|
const string ModCaption = "核算方式";
|
public const string ModRightName = "Gy_ClassTimePrj";
|
public const string ModRightNameAdd = ModRightName + "_Add"; //新增
|
public const string ModRightNameEdit = ModRightName + "_Edit"; //编辑
|
public const string ModRightNameCheck = ModRightName + "_Check"; //审核
|
public const string ModRightNameClose = ModRightName + "_Stop"; //禁用
|
public const string ModRightNameDelete = ModRightName + "_Delete"; //删除
|
public DataSet ds = new DataSet();
|
private json objJsonResult = new json();
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DAL.ClsGy_ClassTimePrj_Ctl oClassTimePrj = new DAL.ClsGy_ClassTimePrj_Ctl();
|
DAL.ClsGy_ClassTimePrj_View oClassTimePrjHlp = new DAL.ClsGy_ClassTimePrj_View();
|
|
|
#region 核算方式列表
|
/// <summary>
|
/// 获取核算方式列表信息
|
/// </summary>
|
/// <returns></returns>
|
[Route("Gy_ClassTimePrjController/GetGy_ClassTimePrjList_Json")]
|
[HttpGet]
|
public object GetGy_ClassTimePrjList_Json(string sWhere, string HMaker)
|
{
|
try
|
{
|
//判断权限
|
if (!DBUtility.ClsPub.Security_Log(ModRightName, 1, false, HMaker))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "您没有该模块权限,请与管理员联系!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
//返回列表信息
|
ds = oCn.RunProcReturn("select * from h_v_Gy_ClassTimePrjList where " + sWhere + " order by " + ModCaption + "代码" , "h_v_Gy_ClassTimePrjList");
|
List<object> columnNameList = new List<object>();
|
//添加列名
|
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 = "0";
|
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 核算方式删除
|
/// <summary>
|
/// 删除核算方式
|
/// </summary>
|
/// <returns></returns>
|
[Route("Gy_ClassTimePrjController/GetGy_ClassTimePrj_Delete_Json")]
|
[HttpGet]
|
public object GetGy_ClassTimePrj_Delete_Json(Int64 HItemID, string HMaker)
|
{
|
try
|
{
|
//判断权限
|
if (!DBUtility.ClsPub.Security_Log(ModRightNameDelete, 1, false, HMaker))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "您没有该模块删除功能权限,请与管理员联系!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
//判断存在性
|
if (oClassTimePrjHlp.GetInfoByID(HItemID))
|
{
|
//判断是否存在子项
|
if (oClassTimePrj.HavChildCodes(HItemID))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "此核算方式存在子项目,不能删除!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//删除数据
|
if (oClassTimePrj.DeleteByID(HItemID))
|
{
|
//写入日志
|
DBUtility.ClsPub.Add_Log("", "删除核算方式,代码:" + oClassTimePrjHlp.omodel.HNumber + ",名称:" + oClassTimePrjHlp.omodel.HName, HMaker);
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "删除核算方式成功!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
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;
|
}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "删除核算方式失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 核算方式审核、反审核
|
/// <summary>
|
/// 审核、反审核核算方式
|
/// </summary>
|
/// <param name="HItemID">内码</param>
|
/// <param name="IsAudit">审核(0),反审核(1)</param>
|
/// <param name="HMaker">操作人</param>
|
/// <returns></returns>
|
[Route("Gy_ClassTimePrjController/GetGy_ClassTimePrj_Check_Json")]
|
[HttpGet]
|
public object GetGy_ClassTimePrj_Check_Json(Int64 HItemID, int IsAudit, string HMaker)
|
{
|
string sErrMsg = "";
|
try
|
{
|
//判断权限
|
if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, HMaker))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "您没有该模块审核/反审核功能权限,请与管理员联系!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (IsAudit == 0) //审核判断
|
{
|
if (oClassTimePrj.CheckByHItemID(HItemID, HMaker, ref sErrMsg))
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "审核核算方式成功!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核核算方式失败!" + sErrMsg;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
else if (IsAudit == 1) //反审核判断
|
{
|
if (oClassTimePrj.AbandonCheckByHItemID(HItemID, HMaker, ref sErrMsg))
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "反审核核算方式成功!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "反审核核算方式失败!" + sErrMsg;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核/反审核功能判断错误!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核或反审核核算方式失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 核算方式禁用、反禁用
|
/// <summary>
|
/// 禁用、反禁用核算方式
|
/// </summary>
|
/// <param name="HItemID">内码</param>
|
/// <param name="IsStop">禁用(0),反禁用(1)</param>
|
/// <param name="HMaker">操作人</param>
|
/// <returns></returns>
|
[Route("Gy_ClassTimePrjController/GetGy_ClassTimePrj_Stop_Json")]
|
[HttpGet]
|
public object GetGy_ClassTimePrj_Stop_Json(Int64 HItemID, int IsStop, string HMaker)
|
{
|
string sErrMsg = "";
|
try
|
{
|
//判断权限
|
if (!DBUtility.ClsPub.Security_Log(ModRightNameClose, 1, false, HMaker))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "您没有该模块禁用/反禁用功能权限,请与管理员联系!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (IsStop == 0) //禁用判断
|
{
|
if (oClassTimePrj.StopByHItemID(HItemID, HMaker, ref sErrMsg))
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "禁用核算方式成功!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "禁用核算方式失败!" + sErrMsg;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
else if (IsStop == 1) //反禁用判断
|
{
|
if (oClassTimePrj.AbandonStopByHItemID(HItemID, HMaker, ref sErrMsg))
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "反禁用核算方式成功!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "反禁用核算方式失败!" + sErrMsg;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "禁用/反禁用功能判断错误!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "禁用或反禁用核算方式失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 核算方式保存
|
/// <summary>
|
/// 核算方式保存
|
/// </summary>
|
[Route("Gy_ClassTimePrjController/GetGy_ClassTimePrj_Save_Json")]
|
[HttpPost]
|
public object GetGy_ClassTimePrj_Save_Json([FromBody] JObject oMain)
|
{
|
try
|
{
|
var _value = oMain["oMain"].ToString();
|
string msg1 = _value.ToString();
|
string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
string msg2 = sArray[0].ToString();
|
string HMaker = sArray[1].ToString();
|
string OperationType = sArray[2].ToString(); //操作类型(1新增、2编辑)
|
|
//判断权限
|
if (OperationType == "1")
|
{
|
//判断新增权限
|
if (!DBUtility.ClsPub.Security_Log(ModRightNameAdd, 1, false, HMaker))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "您没有该模块新增权限,请与管理员联系!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
else
|
{
|
//判断编辑权限
|
if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 1, false, HMaker))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "您没有该模块编辑权限,请与管理员联系!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
//反序列化
|
msg2 = msg2.Replace("\\", "");
|
msg2 = msg2.Replace("\n", "");
|
msg2 = "[" + msg2.ToString() + "]";
|
List<Model.ClsGy_ClassTimePrj_Model> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsGy_ClassTimePrj_Model>>(msg2);
|
oClassTimePrj.oModel.HItemID = list[0].HItemID;
|
oClassTimePrj.oModel.HNumber = list[0].HNumber;
|
oClassTimePrj.oModel.HName = list[0].HName;
|
oClassTimePrj.oModel.HParentID = list[0].HParentID;
|
oClassTimePrj.oModel.HStopflag = list[0].HStopflag;
|
oClassTimePrj.oModel.HUseFlag = list[0].HUseFlag;
|
oClassTimePrj.oModel.HRemark = list[0].HRemark;
|
oClassTimePrj.oModel.HMakeEmp = HMaker;
|
oClassTimePrj.oModel.HModifyEmp = HMaker;
|
oClassTimePrj.oModel.HCheckEmp = list[0].HCheckEmp;
|
oClassTimePrj.oModel.HUSEORGID = list[0].HUSEORGID;
|
oClassTimePrj.oModel.HCREATEORGID = list[0].HUSEORGID;
|
//
|
oClassTimePrj.oModel.HDeptID = list[0].HDeptID;
|
oClassTimePrj.oModel.HGroupID = list[0].HGroupID;
|
|
//保存前判断
|
//审核代码是否合理
|
if (!DBUtility.ClsPub.AllowNumber(oClassTimePrj.oModel.HNumber))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "代码中不能出现连续‘.’并且首位末位不能为‘.’!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//是否重复代码
|
if (oClassTimePrj.HavSameNumber(oClassTimePrj.oModel.HItemID, oClassTimePrj.oModel.HNumber))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "代码重复!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
//保存
|
if (OperationType == "1")
|
{
|
//新增
|
if (oClassTimePrj.AddNew())
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "新增成功!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "新增失败!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
else
|
{
|
if(oClassTimePrj.oModel.HCheckEmp!="")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已审核,不允许修改!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//修改
|
if (oClassTimePrj.ModifyByID(oClassTimePrj.oModel.HItemID))
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "修改成功!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "修改失败!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!" + e.Message;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
#endregion
|
|
#region 显示核算方式信息
|
/// <summary>
|
/// 根据基础资料ID 查找记录
|
/// </summary>
|
[Route("Gy_ClassTimePrjController/GetGy_ClassTimePrj_Json")]
|
[HttpGet]
|
public object GetGy_ClassTimePrj_Json(Int64 HItemID)
|
{
|
try
|
{
|
ds = oCn.RunProcReturn("select * from h_v_Gy_ClassTimePrjListDetail where HItemID=" + HItemID, "h_v_Gy_ClassTimePrjListDetail");
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "未查询到该核算方式,请刷新数据后重新选择!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "成功!";
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "返回核算方式信息失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
#endregion
|
|
}
|
}
|