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;
|
using System.Windows.Forms;
|
|
namespace WebAPI.Controllers
|
{
|
public class WMS_CusBarCodeCheckBillController : ApiController
|
{
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
|
public const string ModName = "1282"; //单据类型
|
public const string ModCaption = "三点照合扫码记录单"; //单据名称
|
public const string ModRightName = "WMS_CusBarCodeCheckBill";
|
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.ClsWMS_CusBarCodeCheckBill oBill = new DAL.ClsWMS_CusBarCodeCheckBill();
|
|
#region 三点照合扫码记录单列表
|
/// <summary>
|
/// 获取三点照合扫码记录单列表信息
|
/// </summary>
|
/// <returns></returns>
|
[Route("WMS_CusBarCodeCheckBillController/GetWMS_CusBarCodeCheckBillList_Json")]
|
[HttpGet]
|
public object GetWMS_CusBarCodeCheckBillList_Json(string sWhere, string HMaker, string OperationType, string ViewName)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
//判断权限
|
if (OperationType == "1")
|
{
|
//判断权限
|
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 " + ViewName + " where 1=1 " + sWhere + " order by hmainid desc", ViewName);
|
|
//添加列名
|
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("WMS_CusBarCodeCheckBillController/GetWMS_CusBarCodeCheckBill_Delete_Json")]
|
[HttpGet]
|
public object GetWMS_CusBarCodeCheckBill_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;
|
}
|
|
//判断存在性
|
ds = oCn.RunProcReturn("select HBillNo from WMS_CusBarCodeCheckBillMain with(nolock) where HInterID=" + HInterID.ToString(), "WMS_CusBarCodeCheckBillMain");
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "未查询到该三点照合扫码记录单,请刷新数据后重新选择!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
//删除前控制
|
DataSet BeforeDs = oCn.RunProcReturn("Exec h_p_WMS_CusBarCodeCheckBill_BeforeDelCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_WMS_CusBarCodeCheckBill_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(HInterID, DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBillNo"]), "h_p_WMS_CusBarCodeCheckBill_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;
|
}
|
}
|
}
|
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("WMS_CusBarCodeCheckBillController/GetWMS_CusBarCodeCheckBill_Check_Json")]
|
[HttpGet]
|
public object GetWMS_CusBarCodeCheckBill_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;
|
}
|
|
//判断存在性
|
ds = oCn.RunProcReturn("select HBillNo,HChecker,HCloseMan,HDeleteMan from WMS_CusBarCodeCheckBillMain with(nolock) where HInterID=" + HInterID.ToString(), "WMS_CusBarCodeCheckBillMain");
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "未查询到该三点照合扫码记录单,请刷新数据后重新选择!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
//Type 1 审核 2 反审核
|
if (Type == 1)
|
{
|
if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HChecker"]).Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已审核,不能再次审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HCloseMan"]).Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已关闭,不能再次审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HDeleteMan"]).Trim() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已作废,不能再次审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//审核前控制
|
DataSet BeforeDs = oCn.RunProcReturn("Exec h_p_WMS_CusBarCodeCheckBill_BeforeCheckCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_WMS_CusBarCodeCheckBill_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, DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBillNo"]), "h_p_WMS_CusBarCodeCheckBill_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 = "单据号:" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBillNo"]) + " 审核成功!";
|
objJsonResult.data = null;
|
return objJsonResult; ;
|
}
|
}
|
else
|
{
|
if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HChecker"]).Trim() == "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据未审核,不需要反审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//反审核前控制
|
DataSet BeforeDs = oCn.RunProcReturn("Exec h_p_WMS_CusBarCodeCheckBill_BeforeUnCheckCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_WMS_CusBarCodeCheckBill_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, DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBillNo"]), "h_p_WMS_CusBarCodeCheckBill_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 = "单据号:" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBillNo"]) + " 反审核成功!";
|
objJsonResult.data = null;
|
return objJsonResult; ;
|
}
|
}
|
}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核或反审核三点照合扫码记录单失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
|
|
}
|
}
|