using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using Pub_Class;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Data.SqlClient;
|
using System.Web.Http;
|
using WebAPI.Models;
|
|
namespace WebAPI.Controllers
|
{
|
|
public class Pay_WorkTimesBillController : ApiController
|
{
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
|
public const string ModName = "2203"; //单据类型
|
public const string ModCaption = "考勤汇报单"; //单据名称
|
public const string ModRightName = "Pay_WorkTimesBill";
|
public const string ModRightNameList = ModRightName + "List"; //列表
|
public const string ModRightNameEdit = ModRightName + "_Edit"; //编辑
|
public const string ModRightNameCheck = ModRightName + "_Check"; //审核
|
public const string ModRightNameClose = ModRightName + "_Close"; //关闭
|
public const string ModRightNameDelete = ModRightName + "_Delete"; //作废
|
public const string ModRightNameDrop = ModRightName + "_Drop"; //删除
|
public const string ModRightNameMoney = ModRightName + "_Money"; //金额
|
public const string ModRightNameQty = ModRightName + "_Qty"; //数量
|
public DataSet ds = new DataSet();
|
private json objJsonResult = new json();
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
public DAL.ClsPay_WorkTimesBill oBill = new DAL.ClsPay_WorkTimesBill();
|
public DAL.ClsPay_WorkTimesBill BillNew = new DAL.ClsPay_WorkTimesBill(); //对应单据类
|
public DAL.ClsPay_WorkTimesBill BillOld = new DAL.ClsPay_WorkTimesBill(); //对应单据类
|
|
|
#region 考勤汇报单列表
|
/// <summary>
|
/// 获取考勤汇报单列表信息
|
/// </summary>
|
/// <returns></returns>
|
[Route("Pay_WorkTimesBillController/GetPay_WorkTimesBillList_Json")]
|
[HttpGet]
|
public object GetPay_WorkTimesBillList_Json(string sWhere, string HMaker)
|
{
|
try
|
{
|
//判断权限
|
if (!DBUtility.ClsPub.Security_Log(ModRightNameList, 3, false, HMaker))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "您没有该模块权限,请与管理员联系!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
//返回列表信息
|
ds = oCn.RunProcReturn("select * from h_v_Pay_WorkTimesBillList where 1=1 " + sWhere + " order by hmainid desc", "h_v_Pay_WorkTimesBillList");
|
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("Pay_WorkTimesBillController/GetPay_WorkTimesBill_Delete_Json")]
|
[HttpGet]
|
public object GetPay_WorkTimesBill_Delete_Json(Int64 HInterID, string HMaker)
|
{
|
try
|
{
|
//判断权限
|
if (!DBUtility.ClsPub.Security_Log(ModRightNameDrop, 3, false, HMaker))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "您没有该模块删除功能权限,请与管理员联系!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
//判断存在性
|
if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
//判断会计期是否合理
|
string s = "";
|
int sYear = 0;
|
int sPeriod = 0;
|
if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod_Pay(oBill.omodel.HDate, ref sYear, ref sPeriod, ref s) == false)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = s;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//删除前控制
|
DataSet BeforeDs = oCn.RunProcReturn("Exec h_p_Pay_WorkTimesBill_BeforeDelCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_Pay_WorkTimesBill_BeforeDelCtrl");
|
if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "删除前判断失败!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "删除失败!" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]);
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
//删除单据(包含删除后控制、写入日志)
|
if (!oBill.DeleteBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Pay_WorkTimesBill_AfterDelCtrl", HMaker, ref ClsPub.sExeReturnInfo))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "删除失败!原因:" + ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
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.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 考勤汇报单审核/反审核
|
/// <summary>
|
/// 审核/反审核考勤汇报单
|
/// </summary>
|
/// <param name="HInterID">单据ID</param>
|
/// <param name="Type">审核(1),反审核(2)</param>
|
/// <param name="HMaker">审核人</param>
|
/// <returns></returns>
|
[Route("Pay_WorkTimesBillController/GetPay_WorkTimesBill_Check_Json")]
|
[HttpGet]
|
public object GetPay_WorkTimesBill_Check_Json(Int64 HInterID, int Type, string HMaker)
|
{
|
try
|
{
|
//判断权限
|
if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 3, false, HMaker))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "您没有该模块审核/反审核功能权限,请与管理员联系!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
//判断存在性
|
if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
//判断会计期是否合理
|
string s = "";
|
int sYear = 0;
|
int sPeriod = 0;
|
if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod_Pay(oBill.omodel.HDate, ref sYear, ref sPeriod, ref s) == false)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = s;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
//Type 1 审核 2 反审核
|
if (Type == 1)
|
{
|
if (oBill.omodel.HChecker.Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已审核,不能再次审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (oBill.omodel.HCloseMan.Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已关闭,不能再次审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (oBill.omodel.HDeleteMan.Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已作废,不能再次审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//审核前控制
|
DataSet BeforeDs = oCn.RunProcReturn("Exec h_p_Pay_WorkTimesBill_BeforeCheckCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_Pay_WorkTimesBill_BeforeCheckCtrl");
|
if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核前判断失败!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]);
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
//审核单据
|
if (!oBill.CheckBill(HInterID, oBill.omodel.HBillNo, "h_p_Pay_WorkTimesBill_AfterCheckCtrl", HMaker, ref ClsPub.sExeReturnInfo))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "单据号:"+ oBill.omodel.HBillNo+ " 审核成功!";
|
objJsonResult.data = null;
|
return objJsonResult; ;
|
}
|
}
|
else
|
{
|
if (oBill.omodel.HChecker.Trim() == "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据未审核,不需要反审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//反审核前控制
|
DataSet BeforeDs = oCn.RunProcReturn("Exec h_p_Pay_WorkTimesBill_BeforeUnCheckCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_Pay_WorkTimesBill_BeforeUnCheckCtrl");
|
if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "反审核前判断失败!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "反审核失败!" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]);
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
//反审核单据
|
if (!oBill.AbandonCheck(HInterID, oBill.omodel.HBillNo, "h_p_Pay_WorkTimesBill_AfterUnCheckCtrl", HMaker, ref ClsPub.sExeReturnInfo))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "反审核失败!原因:" + ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "单据号:" + oBill.omodel.HBillNo + " 反审核成功!";
|
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="HInterID">单据ID</param>
|
/// <param name="Type">关闭(1),反关闭(2)</param>
|
/// <param name="HMaker">关闭人</param>
|
/// <returns></returns>
|
[Route("Pay_WorkTimesBillController/GetPay_WorkTimesBill_Close_Json")]
|
[HttpGet]
|
public object GetPay_WorkTimesBill_Close_Json(Int64 HInterID, int Type, string HMaker)
|
{
|
try
|
{
|
//判断权限
|
if (!DBUtility.ClsPub.Security_Log(ModRightNameClose, 3, false, HMaker))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "您没有该模块关闭/反关闭功能权限,请与管理员联系!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
//判断存在性
|
if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
//判断会计期是否合理
|
string s = "";
|
int sYear = 0;
|
int sPeriod = 0;
|
if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod_Pay(oBill.omodel.HDate, ref sYear, ref sPeriod, ref s) == false)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = s;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
//Type 1 关闭 2 反关闭
|
if (Type == 1)
|
{
|
if (oBill.omodel.HCloseMan.Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已关闭,不能再次关闭!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//关闭单据
|
if (!oBill.CloseBill(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "单据号:" + oBill.omodel.HBillNo + " 关闭成功!";
|
objJsonResult.data = null;
|
return objJsonResult; ;
|
}
|
}
|
else
|
{
|
if (oBill.omodel.HCloseMan.Trim() == "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据未关闭,不需要反关闭!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//反关闭单据
|
if (!oBill.CancelClose(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "反关闭失败!原因:" + ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "单据号:" + oBill.omodel.HBillNo + " 反关闭成功!";
|
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="HInterID">单据ID</param>
|
/// <param name="Type">作废(1),反作废(2)</param>
|
/// <param name="HMaker">作废人</param>
|
/// <returns></returns>
|
[Route("Pay_WorkTimesBillController/GetPay_WorkTimesBill_Cancelltion_Json")]
|
[HttpGet]
|
public object GetPay_WorkTimesBill_Cancelltion_Json(Int64 HInterID, int Type, string HMaker)
|
{
|
try
|
{
|
//判断权限
|
if (!DBUtility.ClsPub.Security_Log(ModRightNameDelete, 3, false, HMaker))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "您没有该模块作废/反作废功能权限,请与管理员联系!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
//判断存在性
|
if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
//判断会计期是否合理
|
string s = "";
|
int sYear = 0;
|
int sPeriod = 0;
|
if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod_Pay(oBill.omodel.HDate, ref sYear, ref sPeriod, ref s) == false)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = s;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
//Type 1 作废 2 反作废
|
if (Type == 1)
|
{
|
if (oBill.omodel.HDeleteMan.Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已作废,不能再次作废!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//作废单据
|
if (!oBill.Cancelltion(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "作废失败!原因:" + ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "单据号:" + oBill.omodel.HBillNo + " 作废成功!";
|
objJsonResult.data = null;
|
return objJsonResult; ;
|
}
|
}
|
else
|
{
|
if (oBill.omodel.HDeleteMan.Trim() == "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据未作废,不需要反作废!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//反作废单据
|
if (!oBill.AbandonCancelltion(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "反作废失败!原因:" + ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "单据号:" + oBill.omodel.HBillNo + " 反作废成功!";
|
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>
|
/// 考勤汇报单编辑时,根据单据ID获取单据信息
|
/// </summary>
|
/// <returns></returns>
|
[Route("Pay_WorkTimesBillController/GetPay_WorkTimesBill_Json")]
|
[HttpGet]
|
public object GetPay_WorkTimesBill_Json(Int64 HInterID, string HMaker)
|
{
|
try
|
{
|
//判断权限
|
if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 3, false, HMaker))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "您没有该模块编辑权限,请与管理员联系!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
//返回列表信息
|
ds = oCn.RunProcReturn("exec h_p_Pay_WorkTimesBill_EditInit " + HInterID, "h_p_Pay_WorkTimesBill_EditInit");
|
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
|
|
|
|
#region[考勤汇报单编辑时获取表头数据]
|
[Route("Pay_WorkTimesBill/Pay_WorkTimesBillListCheckDetail")]
|
[HttpGet]
|
public ApiResult<DataSet> Pay_WorkTimesBillListCheckDetail(string HID)
|
{
|
if (string.IsNullOrEmpty(HID))
|
return new ApiResult<DataSet> { code = -1, msg = "ID不能为空" };
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
|
var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Pay_WorkTimesBillList where hmainid= " + HID + " ", "h_v_Pay_WorkTimesBillList");
|
if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
|
return new ApiResult<DataSet> { code = -1, msg = "不存在结算单号" };
|
|
return new ApiResult<DataSet> { code = 1, msg = "查询成功", data = dataSet };
|
}
|
#endregion
|
|
#region[考勤汇报单编辑时获取表体数据]
|
[Route("Pay_WorkTimesBill/Pay_WorkTimesBillListProjectDetai")]
|
[HttpGet]
|
public object Pay_WorkTimesBillListProjectDetai(Int64 HInterID)
|
{
|
try
|
{
|
ds = oCn.RunProcReturn("exec h_p_Pay_WorkTimesBill_EditInit " + HInterID, "h_p_Pay_WorkTimesBill_EditInit");
|
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
|
|
/// <summary>
|
/// 新增单据-保存按钮
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("Pay_WorkTimesBill/SaveGetWorkTimesBillList")]
|
[HttpPost]
|
public object SaveGetWorkTimesBillList([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();
|
string refSav = sArray[2].ToString();
|
string msg4 = sArray[3].ToString();
|
|
string UserName = "";
|
string s = "";
|
DBUtility.ClsPub.CurUserName = msg4; //操作人
|
ListModels oListModels = new ListModels();
|
try
|
{
|
//编辑权限
|
if (!DBUtility.ClsPub.Security_Log_second("Pay_WorkTimesBill_Edit", 1, false, msg4))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无保存权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
DLL.ClsPay_WorkTimesBill oBill = new DLL.ClsPay_WorkTimesBill();
|
List<Models.ClsPay_WorkTimesBillMain> lsmain = new List<Models.ClsPay_WorkTimesBillMain>();
|
msg2 = msg2.Replace("\\", "");
|
msg2 = msg2.Replace("\n", ""); //\n
|
lsmain = oListModels.getObjectByJson_Pay_WorkTimesBillMain(msg2);
|
foreach (Models.ClsPay_WorkTimesBillMain 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 = "2203";
|
oItem.HBillSubType = "2203";
|
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<Models.ClsPay_WorkTimesBillSub> ls = new List<Models.ClsPay_WorkTimesBillSub>();
|
ls = oListModels.getObjectByJson_Pay_WorkTimesBillSub(msg3);
|
int i = 0;
|
foreach (Models.ClsPay_WorkTimesBillSub oItemSub in ls)
|
{
|
i++;
|
oItemSub.HEntryID = i;
|
oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate("");
|
oItemSub.HCloseType = false; //关闭类型
|
oItemSub.HSourceInterID = 0; // 源单主内码
|
oItemSub.HSourceEntryID = 0; //源单子内码
|
oBill.DetailColl.Add(oItemSub);
|
}
|
//保存
|
//保存完毕后处理
|
bool bResult;
|
if (oBill.omodel.HInterID == 0)
|
{
|
// bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
|
bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
|
}
|
else
|
{
|
bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
|
}
|
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;
|
}
|
}
|
|
/// <summary>
|
/// 通过班组查询职员信息
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("Pay_WorkTimesBill/GetEmployeeByHGroup")]
|
[HttpGet]
|
public object GetEmployeeByHGroup(int HGroupID)
|
{
|
if (HGroupID <= 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "班组未选择";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
try
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
List<object> list = new List<object>();
|
DataSet ds1;
|
string sql1 = string.Format(@"select a.HItemID HEmpID,a.HNumber HEmpNumber,a.HName HEmpName,a.HEmpRate HEmpRate,a.HCTPrjID,b.HName HCTPrjName from Gy_Employee a
|
left join Gy_ClassTimePrjGroup b on a.HCTPrjID=b.HItemID
|
where a.HGroupID=" + HGroupID);
|
ds1 = oCN.RunProcReturn(sql1, "Gy_Employee");
|
list.Add(ds1.Tables[0]);
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "获取信息成功!";
|
objJsonResult.list = list;
|
return objJsonResult;
|
}
|
catch (Exception ex)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
[Route("Pay_WorkTimesBill/calcAvgMoney")]
|
[HttpPost]
|
public object GetEmployeeByHGroup([FromBody] JObject msg) {
|
try
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
List<object> list = new List<object>();
|
DataSet ds;
|
string sql = string.Format($"exec h_p_CalcAvgMoney '{msg["msg"]}'");
|
ds = oCN.RunProcReturn(sql, "h_p_CalcAvgMoney");
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "获取信息成功!";
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
catch (Exception ex)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
|
#region 考勤汇总数据处理表查询
|
[Route("Pay_WorkTimesSumQueryBill/list")]
|
[HttpGet]
|
public object getWorkTimesSumQueryBillList(string sWhere, string user)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
if (!DBUtility.ClsPub.Security_Log("Pay_WorkTimesSumQueryBillList", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无查看权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
|
ds = oCn.RunProcReturn("exec h_p_Pay_WorkTimesSumQueryBillList " + sWhere, "Pay_WorkTimesSumQueryBillList");
|
|
//添加列名
|
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
|
}
|
}
|