using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Web;
|
using System.Web.Http;
|
using WebAPI.Models;
|
using Newtonsoft.Json;
|
using Model;
|
using DBUtility;
|
|
namespace WebAPI.Controllers.MJGL
|
{
|
public class Sc_MouldBatchWorkCheckBillController : ApiController
|
{
|
private json objJsonResult = new json();
|
public DataSet ds = new DataSet();
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
|
public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill();
|
|
|
#region 模具投产验收单 保存前、保存后控制
|
|
//保存前控制
|
public json BeforeSave_MouldBatchWorkCheckBill(Int64 HInterID, string HBillNo, Int64 OperationType)
|
{
|
DataSet BeforeSave = oCN.RunProcReturn("Exec h_p_Sc_MouldBatchWorkCheckBill_BeforeSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_Sc_MouldBatchWorkCheckBill_BeforeSaveCtrl");
|
if (BeforeSave == null || BeforeSave.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存前判断失败!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else if (DBUtility.ClsPub.isLong(BeforeSave.Tables[0].Rows[0]["HBack"]) == 1)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0; //失败!
|
objJsonResult.Message = DBUtility.ClsPub.isStrNull(BeforeSave.Tables[0].Rows[0]["HRemark"]);
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1; //成功!
|
objJsonResult.Message = DBUtility.ClsPub.isStrNull(BeforeSave.Tables[0].Rows[0]["HRemark"]);
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
//保存后控制
|
public json AfterSave_MouldBatchWorkCheckBill(Int64 HInterID, string HBillNo, Int64 OperationType)
|
{
|
DataSet AfterSave = oCN.RunProcReturn("Exec h_p_Sc_MouldBatchWorkCheckBill_AfterSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_Sc_MouldBatchWorkCheckBill_AfterSaveCtrl");
|
if (AfterSave == null || AfterSave.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存后判断失败!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else if (DBUtility.ClsPub.isLong(AfterSave.Tables[0].Rows[0]["HBack"]) == 1)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0; //失败!
|
objJsonResult.Message = DBUtility.ClsPub.isStrNull(AfterSave.Tables[0].Rows[0]["HRemark"]);
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1; //成功!
|
objJsonResult.Message = DBUtility.ClsPub.isStrNull(AfterSave.Tables[0].Rows[0]["HRemark"]);
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
#endregion
|
|
#region 模具投产验收单 列表查询
|
[Route("Sc_MouldBatchWorkCheckBill/Sc_MouldBatchWorkCheckBillList")]
|
[HttpGet]
|
public object Sc_MouldBatchWorkCheckBillList(string sWhere, string user)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
|
//查看权限
|
if (!DBUtility.ClsPub.Security_Log("Sc_MouldBatchWorkCheckBill_Query", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无查看权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
ds = oCN.RunProcReturn("select * from h_v_Sc_MouldBatchWorkCheckBillList where 1=1" + sWhere + "order by HInterID desc ", "h_v_Sc_MouldBatchWorkCheckBillList");
|
|
//添加列名
|
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 sql。
|
///返回值:object。
|
/// </summary>
|
[Route("Sc_MouldBatchWorkCheckBill/AddSc_MouldBatchWorkCheckBill")]
|
[HttpPost]
|
public object AddSc_MouldBatchWorkCheckBill([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;
|
}
|
|
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();//用户名
|
try
|
{
|
if (!DBUtility.ClsPub.Security_Log("Sc_MouldBatchWorkCheckBill_Edit", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无权限编辑!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
msg2 = "[" + msg2.ToString() + "]";
|
List<ClsSc_MouldBatchWorkCheckBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldBatchWorkCheckBillMain>>(msg2);
|
string HBillType = "3848";
|
long HInterID = mainList[0].HInterID;//递入type得到的单据ID
|
string HBillNo = mainList[0].HBillNo;//递入type得到的单据号
|
DateTime HDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));//日期
|
int HYear = DateTime.Now.Year;
|
double HPeriod = DateTime.Now.Month;
|
string HRemark = mainList[0].HRemark;//备注
|
string HMaker = mainList[0].HMaker;//制单人
|
int HOrgID = mainList[0].HOrgID; //组织
|
Int64 HDeptID = mainList[0].HDeptID;
|
Int64 HEmpID = mainList[0].HEmpID;
|
Int64 HMangerID = mainList[0].HMangerID;
|
|
ds = oCN.RunProcReturn("select * from h_v_Sc_MouldBatchWorkCheckBillList where HInterID=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_Sc_MouldBatchWorkCheckBillList");
|
|
if ((OperationType == 1) && ds.Tables[0].Rows.Count == 0)//新增
|
{
|
//保存前控制
|
objJsonResult = BeforeSave_MouldBatchWorkCheckBill(HInterID, HBillNo, 1);
|
if (objJsonResult.count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = objJsonResult.Message;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//主表
|
oCN.RunProc(@"Insert Into Sc_MouldBatchWorkCheckBillMain
|
(HBillType,HBillStatus, HBillSubType, HInterID, HBillNo, HDate
|
, HYear, HPeriod, HRemark, HMaker, HMakeDate, HOrgID
|
, HDeptID, HEmpID, HMangerID)" +
|
" values('" + HBillType + "','1','" + HBillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" +
|
"," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()," + HOrgID +
|
"," + HDeptID + "," + HEmpID + "," + HMangerID + ") ");
|
|
}
|
else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)
|
{
|
//保存前控制
|
objJsonResult = BeforeSave_MouldBatchWorkCheckBill(HInterID, HBillNo, 2);
|
if (objJsonResult.count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = objJsonResult.Message;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//修改
|
oCN.RunProc("update Sc_MouldBatchWorkCheckBillMain set " +
|
"HDate='" + HDate +
|
"',HYear='" + HYear + "',HPeriod='" + HPeriod + "',HRemark='" + HRemark + "',hupdater='" + HMaker +
|
"',hupdatedate=getdate(),HDeptID=" + HDeptID + ",HEmpID=" + HEmpID + ",HMangerID=" + HMangerID + " where HInterID='" + HInterID + "'");
|
|
//删除子表
|
oCN.RunProc("delete from Sc_MouldBatchWorkCheckBillSub where HInterID='" + HInterID + "'");
|
}
|
//保存子表
|
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;
|
}
|
}
|
|
public json AddBillSub(string msg3, long HInterID, string HBillNo, Int64 OperationType)
|
{
|
List<ClsSc_MouldBatchWorkCheckBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldBatchWorkCheckBillSub>>(msg3);
|
int i = 0;
|
foreach (ClsSc_MouldBatchWorkCheckBillSub oSub in DetailColl)
|
{
|
i++;
|
|
oCN.RunProc(@"Insert Into Sc_MouldBatchWorkCheckBillSub
|
(HInterID, HBillNo_bak, HEntryID, HMaterID_Prod, HMaterID
|
, HMouldID, HMouldNum)
|
values("
|
+ HInterID + ",'" + HBillNo + "'," + i + ",'" + oSub.HMaterID_Prod.ToString() + "','" + oSub.HMaterID
|
+ "','" + oSub.HMouldID.ToString() + "','" + oSub.HMouldNum.ToString() + "') ");
|
}
|
|
if (OperationType == 1)//新增
|
{
|
//保存后控制
|
objJsonResult = AfterSave_MouldBatchWorkCheckBill(HInterID, HBillNo, 1);
|
if (objJsonResult.count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = objJsonResult.Message;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
else
|
{
|
//保存后控制
|
objJsonResult = AfterSave_MouldBatchWorkCheckBill(HInterID, HBillNo, 2);
|
if (objJsonResult.count == 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;
|
}
|
|
#endregion
|
|
#region 模具投产验收单 编辑查询
|
[Route("Sc_MouldBatchWorkCheckBill/Sc_MouldBatchWorkCheckBill_Edit")]
|
[HttpGet]
|
public object Sc_MouldBatchWorkCheckBill_Edit(string linterid, string user)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
|
//查看权限
|
if (!DBUtility.ClsPub.Security_Log("Sc_MouldBatchWorkCheckBill_Query", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无查看权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
ds = oCN.RunProcReturn("select * from h_v_Sc_MouldBatchWorkCheckBillEdit where 1=1 and HInterID=" + linterid + "order by HInterID desc ", "h_v_Sc_MouldBatchWorkCheckBillEdit");
|
|
//添加列名
|
foreach (DataColumn col in ds.Tables[0].Columns)
|
{
|
Type dataType = col.DataType;
|
string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
|
columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
|
}
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 模具投产验收单删除功能
|
[Route("Sc_MouldBatchWorkCheckBill/DeltetSc_MouldBatchWorkCheckBill")]
|
[HttpGet]
|
public object DeltetSc_MouldBatchWorkCheckBill(string HInterID,string user)
|
{
|
|
//删除权限
|
if (!DBUtility.ClsPub.Security_Log("Sc_MouldBatchWorkCheckBill_Delete", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无删除权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
oCN.BeginTran();
|
|
|
ds = oCN.RunProcReturn(@"select HMaker,HBillNo,HBillStatus,HChecker from Sc_MouldBatchWorkCheckBillMain a
|
inner join Sc_MouldBatchWorkCheckBillSub b on a.HInterID = b.HInterID
|
where a.HInterID = " + HInterID, "Sc_MouldBatchWorkCheckBillMain");
|
|
if (ds.Tables[0].Rows.Count != 0)
|
{
|
|
string sReturn = "";
|
if (oSystemParameter.ShowBill(ref sReturn))
|
{
|
if (oSystemParameter.omodel.Sc_ProcessExchangeBill_DeleterAndMakerMustSame == "Y")
|
{
|
if (ds.Tables[0].Rows[0]["HMaker"].ToString() != user && (user != "admin" && user != "Admin"))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据号:" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "只能删除本人的单据!";
|
objJsonResult.data = null;
|
oCN.RollBack();
|
return objJsonResult;
|
}
|
}
|
}
|
|
if (int.Parse(ds.Tables[0].Rows[0]["HBillStatus"].ToString()) > 1)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据号:" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "单据当前处于不能删除状态,不能删除!";
|
objJsonResult.data = null;
|
oCN.RollBack();
|
return objJsonResult;
|
}
|
|
if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据号:" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "单据已经审核,不能删除!";
|
objJsonResult.data = null;
|
oCN.RollBack();
|
return objJsonResult;
|
}
|
|
oCN.RunProc("delete from Sc_MouldBatchWorkCheckBillMain where HInterID=" + HInterID);
|
oCN.RunProc("delete from Sc_MouldBatchWorkCheckBillSub where HInterID=" + HInterID) ;
|
|
oCN.Commit();
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据未找到";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "删除成功!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
#endregion
|
|
#region 模具投产验收单审核/反审核功能
|
[Route("Sc_MouldBatchWorkCheckBill/CheckSc_MouldBatchWorkCheckBill")]
|
[HttpGet]
|
public object CheckSc_MouldBatchWorkCheckBill(string HInterID, int Type, string user)
|
{
|
try
|
{
|
//判断是否有删除权限
|
if (!DBUtility.ClsPub.Security_Log("Sc_MouldBatchWorkCheckBill_Check", 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 = "Sc_MouldBatchWorkCheckBillMain";
|
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]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已审核!不需要再审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
//审核单据
|
if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据不存在!";
|
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]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已反审核!不需要再反审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
//反审核单据
|
if (BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
|
{
|
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据不存在!";
|
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("Sc_MouldBatchWorkCheckBill/CloseSc_MouldBatchWorkCheckBill")]
|
[HttpGet]
|
public object CloseSc_MouldBatchWorkCheckBill(string HInterID, int Type, string user)
|
{
|
try
|
{
|
//判断是否有删除权限
|
if (!DBUtility.ClsPub.Security_Log("Sc_MouldBatchWorkCheckBill_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 = "Sc_MouldBatchWorkCheckBillMain";
|
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 == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据不存在!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
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 (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]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已作废!不能进行关闭!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
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("Sc_MouldBatchWorkCheckBill/DropSc_MouldBatchWorkCheckBill")]
|
[HttpGet]
|
public object DropSc_MouldBatchWorkCheckBill(string HInterID, int Type, string user)
|
{
|
try
|
{
|
//判断是否有作废权限
|
if (!DBUtility.ClsPub.Security_Log("Sc_MouldBatchWorkCheckBill_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 = "Sc_MouldBatchWorkCheckBillMain";
|
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 == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据不存在!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
|
{
|
if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已审核!不能进行作废!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
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]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已审核!不能进行作废!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
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
|
|
|
}
|
}
|