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 QC_RequestCheckBillController : ApiController
|
{
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
|
private json objJsonResult = new json();
|
public DataSet ds = new DataSet();
|
public SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
|
public DLL.ClsQC_RequestCheckBill BillNew0 = new DLL.ClsQC_RequestCheckBill();
|
public DLL.ClsQC_RequestCheckBill BillOld0 = new DLL.ClsQC_RequestCheckBill();
|
|
#region 检验申请单列表
|
[Route("QC_RequestCheckBill/GetRequestCheckBillList")]
|
[HttpGet]
|
public object GetRequestCheckBillList(string sWhere, string user)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
|
//判断查询权限
|
if (!DBUtility.ClsPub.Security_Log("QC_RequestCheckBill_Query", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无查询权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
ds = oCn.RunProcReturn("select * from h_v_QC_RequestCheckBillList_Search " + sWhere + " order by 日期 desc, hmainid desc", "h_v_QC_RequestCheckBillList_Search");
|
|
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));
|
}
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Success!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
}
|
catch (Exception ex)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 检验申请单删除
|
[Route("QC_RequestCheckBill/set_DeleteBill")]
|
[HttpGet]
|
public object set_DeleteBill(string HInterID, string user)
|
{
|
// 编辑权限检查
|
if (!DBUtility.ClsPub.Security_Log_second("QC_RequestCheckBill_Drop", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无删除权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
Int64 lngBillKey = DBUtility.ClsPub.isLong(HInterID);
|
if (lngBillKey == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据ID为空!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
DLL.ClsQC_RequestCheckBill oBill = new DLL.ClsQC_RequestCheckBill();
|
if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
if (oBill.omodel.HBillStatus > 1)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据当前处于不能删除状态,不能删除!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (oBill.omodel.HChecker != "" && oBill.omodel.HChecker != null)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已经审核,不能删除!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
string s = "";
|
if (!DBUtility.Xt_BaseBillFun.Fun_AllowDeleteBill(oBill, ref s))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = s + ",不允许删除";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
// 会计期间判断
|
int sYear = 0;
|
int sPeriod = 0;
|
DateTime HDate = DateTime.Now;
|
if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
|
{
|
objJsonResult.Message = s;
|
return objJsonResult;
|
}
|
|
bool IsDete = oBill.DeleteBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo);
|
if (IsDete)
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据未找到";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region[检验申请单编辑时获取数据]
|
[Route("QC_RequestCheckBill/GetRequestCheckBillDetail")]
|
[HttpGet]
|
public ApiResult<DataSet> QC_RequestCheckBillListCheckDetai(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 * from h_v_IF_RequestCheckBillList where hmainid= " + HID + " ", "h_v_Sc_MouldProdInHouseBillList");
|
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("QC_RequestCheckBill/getMaterialByMaterID")]
|
[HttpGet]
|
public ApiResult<DataTable> getMaterialByMaterID(Int64 HMaterID)
|
{
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
|
string sql = "select a.HItemID HMaterID,a.HNumber HMaterNumber,a.HName HMaterName,a.HMaterRuleType,a.HModel HMaterModel,a.HUnitID, b.HNumber HUnitNumber, b.HName HUnitName, a.HMaterRuleExternType, a.HMaterRuleExternType1" +
|
" from Gy_Material AS a " +
|
" LEFT OUTER JOIN Gy_Unit AS b on a.HUnitID = b.HItemID " +
|
" where a.HItemID =" + HMaterID;
|
|
var dataSet = oCN.RunProcReturn(sql, "Gy_Material");
|
|
if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
|
return new ApiResult<DataTable> { code = -1, msg = "不存在该物料" };
|
|
return new ApiResult<DataTable> { code = 1, msg = "查询成功", data = dataSet.Tables[0] };
|
}
|
#endregion
|
|
#region 检验申请单审核/反审核
|
[Route("QC_RequestCheckBill/set_CheckBill")]
|
[HttpGet]
|
public object set_CheckBill(int HInterID, string CurUserName)
|
{
|
string ModRightNameCheck = "QC_RequestCheckBill_Check";
|
DBUtility.ClsPub.CurUserName = CurUserName;
|
DLL.ClsQC_RequestCheckBill oBill = new DLL.ClsQC_RequestCheckBill();
|
|
try
|
{
|
// 审核权限检查
|
if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败!无权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
// 审核前判断
|
string s = "";
|
if (!DBUtility.Xt_BaseBillFun.Fun_AllowCheckBill(oBill, ref s))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = s + ",不允许审核";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (HInterID <= 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "HInterID小于0!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
// 检查单据状态
|
if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
if (oBill.omodel.HCloseMan.Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已关闭!不能再次审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (oBill.omodel.HDeleteMan.Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已作废!不能再次审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (oBill.omodel.HChecker.Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已审核!不能再次审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
// 会计期间判断
|
int sYear = 0;
|
int sPeriod = 0;
|
DateTime HDate = DateTime.Now;
|
if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
|
{
|
objJsonResult.Message = s;
|
return objJsonResult;
|
}
|
|
// 执行审核
|
if (oBill.CheckBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "审核成功";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
[Route("QC_RequestCheckBill/set_AbandonCheck")]
|
[HttpGet]
|
public object set_AbandonCheck(int HInterID, string CurUserName)
|
{
|
string ModRightNameCheck = "QC_RequestCheckBill_Check";
|
DBUtility.ClsPub.CurUserName = CurUserName;
|
DLL.ClsQC_RequestCheckBill oBill = new DLL.ClsQC_RequestCheckBill();
|
|
try
|
{
|
//权限检查
|
if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "反审核失败!无权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
string s = "";
|
if (!DBUtility.Xt_BaseBillFun.Fun_AllowCheckBill(oBill, ref s))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = s + ",不允许反审核";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (HInterID <= 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "HInterID小于0!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
// 检查单据状态
|
if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
if (oBill.omodel.HCloseMan.Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已关闭!不能反审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (oBill.omodel.HDeleteMan.Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已作废!不能反审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (oBill.omodel.HChecker.Trim() == "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据未审核!不需要反审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
// 会计期间判断
|
int sYear = 0;
|
int sPeriod = 0;
|
DateTime HDate = DateTime.Now;
|
if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
|
{
|
objJsonResult.Message = s;
|
return objJsonResult;
|
}
|
|
// 执行反审核
|
if (oBill.AbandonCheck(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "反审核成功";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "反审核失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 质检申请单保存/编辑
|
[Route("QC_RequestCheckBill/SaveRequestCheckBill")]
|
[HttpPost]
|
public object SaveRequestCheckBill([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(); // 用户
|
|
DBUtility.ClsPub.CurUserName = msg4;
|
|
string UserName = "";
|
string s = "";
|
ListModels oListModels = new ListModels();
|
|
try
|
{
|
// 编辑权限检查
|
if (!DBUtility.ClsPub.Security_Log_second("QC_RequestCheckBill_Edit", 1, false, msg4))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无保存权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
DLL.ClsQC_RequestCheckBill oBill = new DLL.ClsQC_RequestCheckBill();
|
List<Models.ClsQC_RequestCheckBillMain> lsmain = new List<Models.ClsQC_RequestCheckBillMain>();
|
|
msg2 = msg2.Replace("\\", "").Replace("\n", "");
|
// 需要先实现这个方法
|
lsmain = oListModels.getObjectByJson_QC_RequestCheckBillMain1(msg2);
|
|
foreach (Models.ClsQC_RequestCheckBillMain oItem in lsmain)
|
{
|
if (refSav == "Add")
|
{
|
// 检查单据号是否重复
|
if (BillNew0.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld0.omodel.HInterID))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据号重复!不允许保存!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
}
|
|
if (refSav == "Update")
|
{
|
if (BillOld0.ShowBill(oItem.HInterID, ref s) == false)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "此单据有误!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
|
if (BillOld0.omodel.HChecker != "" && BillOld0.omodel.HChecker != null)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "此单据已经被审核,不允许修改!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
|
if (BillOld0.omodel.HBillStatus > 1)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "此单据处于不可编辑状态,不允许修改!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
|
if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld0, ref s))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = s + ",不允许修改";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
}
|
|
UserName = oItem.HMaker;
|
oItem.HBillType = "7525"; // 质检申请单类型
|
oItem.HYear = DateTime.Now.Year; // 修正:直接使用int类型
|
oItem.HPeriod = DateTime.Now.Month; // 修正:直接使用int类型
|
oItem.HMakeDate = DateTime.Now; // 修正:直接使用DateTime类型
|
|
if (oItem.HDate == DateTime.MinValue)
|
{
|
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("\\", "").Replace("\n", "");
|
|
List<Models.ClsQC_RequestCheckBillSub> ls = new List<Models.ClsQC_RequestCheckBillSub>();
|
// 需要先实现这个方法
|
ls = oListModels.getObjectByJson_QC_RequestCheckBillSub(msg3);
|
|
int i = 0;
|
foreach (Models.ClsQC_RequestCheckBillSub oItemSub in ls)
|
{
|
i++;
|
oItemSub.HEntryID = i;
|
oItemSub.HEntryCloseDate = null;
|
oItemSub.HCloseType = false;
|
oItemSub.HSourceInterID = 0;
|
oItemSub.HSourceEntryID = 0;
|
oBill.DetailColl.Add(oItemSub);
|
}
|
|
// 会计期间判断
|
int sYear = 0;
|
int sPeriod = 0;
|
DateTime HDate = DateTime.Now;
|
if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
|
{
|
objJsonResult.Message = s;
|
return objJsonResult;
|
}
|
|
// 执行保存
|
bool bResult;
|
if (refSav == "Add")
|
{
|
bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
|
}
|
else if (refSav == "Update")
|
{
|
bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
|
}
|
else
|
{
|
bResult = false;
|
}
|
|
if (bResult)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "保存成功!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!" + e.ToString();
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
|
#region 质检申请单关闭/反关闭
|
[Route("QC_RequestCheckBill/CloseRequestCheckBill")]
|
[HttpGet]
|
public object CloseRequestCheckBill(int HInterID, int IsAudit, string CurUserName)
|
{
|
string ModRightNameCheck = "QC_RequestCheckBill_Close";
|
DBUtility.ClsPub.CurUserName = CurUserName;
|
|
try
|
{
|
//权限检查
|
if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "关闭失败!无权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (HInterID <= 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "HInterID小于0!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
// 修正:使用 DLL 命名空间而不是 DAL
|
WebAPI.DLL.ClsQC_RequestCheckBill oBill = new WebAPI.DLL.ClsQC_RequestCheckBill();
|
|
// 检查单据状态
|
if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
if (oBill.omodel.HDeleteMan.Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已作废!不能进行关闭!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (oBill.omodel.HChecker.Trim() == "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据未审核!不能进行关闭!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (IsAudit == 0 && oBill.omodel.HCloseMan.Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已关闭!不能再次关闭!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (IsAudit == 1 && oBill.omodel.HCloseMan.Trim() == "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据未关闭!不需要反关闭!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
// 执行操作
|
if (IsAudit == 0)
|
{
|
if (oBill.CloseBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "关闭成功";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
else
|
{
|
if (oBill.CancelClose(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "反关闭成功";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "反关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "操作失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 质检申请单作废/反作废
|
[Route("QC_RequestCheckBill/DeleteRequestCheckBill")]
|
[HttpGet]
|
public object DeleteRequestCheckBill(int HInterID, int IsAudit, string CurUserName)
|
{
|
string ModRightNameCheck = "QC_RequestCheckBill_Delete";
|
DBUtility.ClsPub.CurUserName = CurUserName;
|
|
try
|
{
|
//权限检查
|
if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "作废失败!无权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (HInterID <= 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "HInterID小于0!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
|
WebAPI.DLL.ClsQC_RequestCheckBill oBill = new WebAPI.DLL.ClsQC_RequestCheckBill();
|
|
// 检查单据状态
|
if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
if (oBill.omodel.HChecker.Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已审核!不能进行作废!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (IsAudit == 0 && oBill.omodel.HDeleteMan.Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已作废!不能再作废!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (IsAudit == 1 && oBill.omodel.HDeleteMan.Trim() == "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据未作废!不需要反作废!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
// 执行操作
|
if (IsAudit == 0)
|
{
|
if (oBill.Cancelltion(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "作废成功";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "作废失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
else
|
{
|
if (oBill.AbandonCancelltion(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "反作废成功";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "反作废失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "操作失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
}
|
}
|