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.IO;
|
using System.Web;
|
using System.Web.Http;
|
using WebAPI.Models;
|
using WebAPI.Service;
|
|
namespace WebAPI.Controllers
|
{
|
public class Cg_OrderTransportBillListController : ApiController
|
{
|
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
|
|
private json objJsonResult = new json();
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
DataSet ds;
|
|
/// <summary>
|
/// 返回运单申请列表
|
///参数:string sql。
|
///返回值:object。
|
/// </summary>
|
[Route("Cg_OrderTransportBill/list")]
|
[HttpGet]
|
public object list(string sWhere, string user)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
//判断是否有查询权限
|
if (!DBUtility.ClsPub.Security_Log("Cg_OrderTransportBill_Query", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无权限查询!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
ds = oCN.RunProcReturn("select * from h_v_Cg_OrderTransportBillList where 1=1 order by hmainid ", "h_v_Cg_OrderTransportBillList");
|
}
|
else
|
{
|
string sql1 = "select * from h_v_Cg_OrderTransportBillList where 1=1 ";
|
string sql = sql1 + sWhere + " order by hmainid";
|
ds = oCN.RunProcReturn(sql, "h_v_Cg_OrderTransportBillList");
|
}
|
|
//添加列名
|
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列对象的列名
|
}
|
|
//if (ds.Tables[0].Rows.Count != 0 || ds != null)
|
//{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
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 = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
#region 运单申请列表-分页
|
[Route("Cg_OrderTransportBill/list_byPage")]
|
[HttpGet]
|
public object GetCarList_byPage(string sWhere, string user, int page, int size)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>(); //定义声明变量 ,把通过 new List<object>()创建的 实例,赋值给变量
|
//判断是否有查询权限
|
if (!DBUtility.ClsPub.Security_Log("Cg_OrderTransportBill_Query", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无权限查询!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
ds = oCN.RunProcReturn("exec h_p_Cg_OrderTransportBillListPage " + page + "," + size + "," + "''", "h_p_Cg_OrderTransportBillList");
|
}
|
else
|
{
|
sWhere = sWhere.Replace("'", "''");
|
|
ds = oCN.RunProcReturn("exec h_p_Cg_OrderTransportBillListPage " + page + "," + size + ",'" + sWhere + "'", "h_p_Cg_OrderTransportBillList");
|
}
|
|
//添加列名
|
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列对象的列名
|
}
|
|
if (ds.Tables[0].Rows.Count > 0)
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.list = columnNameList;
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "没有返回任何记录!";
|
objJsonResult.list = columnNameList;
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 保存 运单申请信息
|
/// <summary>
|
/// 保存运单申请信息
|
/// </summary>
|
/// <param name="msg"></param>
|
/// <returns></returns>
|
[Route("Cg_OrderTransportBill/SaveCg_OrderTransportBill")]
|
[HttpPost]
|
public object SaveCg_OrderTransportBill([FromBody] JObject msg)
|
{
|
DataSet ds;
|
var _value = msg["msg"].ToString();
|
string msg3 = _value.ToString();
|
string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
string msg1 = sArray[0].ToString();
|
string msg2 = sArray[1].ToString();
|
string oprType = sArray[2].ToString();
|
|
//查看权限
|
if (!DBUtility.ClsPub.Security_Log("Cg_OrderTransportBill_Edit", 1, false, msg2))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无保存权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
Int64 HItemID = 0;
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
//获取最大ID值赋值
|
// DataSet Maxds = oCN.RunProcReturn("select MAX(HItemID) HItemID from Cg_OrderTransportBill ", "Cg_OrderTransportBill");
|
// if (Maxds != null || Maxds.Tables[0].Rows.Count > 0)
|
// {
|
// var maxid = 0;
|
// if (Maxds.Tables[0].Rows[0]["HItemID"] != DBNull.Value)
|
// {
|
// //HItemID= Maxds.Tables[0].Rows[0]["HItemID"]
|
// maxid = Convert.ToInt32(Maxds.Tables[0].Rows[0]["HItemID"]);
|
// maxid += 1;
|
// }
|
//
|
// HItemID = maxid;
|
// }
|
ListModels oListModels = new ListModels();
|
try
|
{
|
DAL.ClsCg_OrderTransportBill_Ctl oBill = new DAL.ClsCg_OrderTransportBill_Ctl();
|
List<Model.ClsCg_OrderTransportBill_Model> lsmain = new List<Model.ClsCg_OrderTransportBill_Model>();
|
msg1 = msg1.Replace("\\", "");
|
msg1 = msg1.Replace("\n", ""); //\n
|
lsmain = oListModels.getObjectByJson_Cg_OrderTransportBill(msg1);
|
foreach (Model.ClsCg_OrderTransportBill_Model oItem in lsmain)
|
{
|
//新增时判断
|
if (oprType == "1" || oprType == "2")
|
{
|
oItem.HMaker = msg2;//创建人
|
}
|
else if(oprType == "3")//编辑时判断
|
{
|
//已审核不允许修改
|
DataSet dss;
|
dss = oCN.RunProcReturn("select * from Cg_OrderTransportBill where HItemID=" + oItem.HItemID, "Cg_OrderTransportBill");
|
//判断是否可编辑
|
if (dss.Tables[0].Rows[0]["HChecker"].ToString() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "此单据状态已经审核,不允许修改!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
oBill.oModel = oItem;
|
}
|
|
//保存
|
//保存完毕后处理
|
bool bResult;
|
if (oprType == "1" || oprType == "2")
|
{
|
|
bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
|
}
|
else if(oprType == "3")
|
{
|
oBill.oModel.HModifyEmp = msg2;
|
bResult = oBill.ModifyBill(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
|
}
|
else
|
{
|
throw new Exception("该单据为浏览状态,不可保存");
|
}
|
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 运单申请审核、反审核
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="HInterID">单据ID</param>
|
/// <param name="IsAudit">审核(0),反审核(1)</param>
|
/// <param name="CurUserName">审核人</param>
|
/// <returns></returns>
|
[Route("Cg_OrderTransportBill/AuditCg_OrderTransportBill")]
|
[HttpGet]
|
public object AuditCg_OrderTransportBill(int HInterID, int IsAudit, string CurUserName)
|
{
|
DAL.ClsCg_OrderTransportBill_Ctl oBill = new DAL.ClsCg_OrderTransportBill_Ctl();
|
string sReturn = "";
|
try
|
{
|
//审核权限
|
if (!DBUtility.ClsPub.Security_Log_second("Cg_OrderTransportBill_Check", 1, false, CurUserName))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败!无权限!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
var ds = oCN.RunProcReturn("select * from Cg_OrderTransportBillMain where HItemID=" + HInterID, "Cg_OrderTransportBill");
|
if (ds.Tables[0].Rows.Count > 0)
|
{
|
if (IsAudit == 0) //审核判断
|
{
|
if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已审核!不能再次审核!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
if (IsAudit == 1) //反审核判断
|
{
|
if (ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
|
{
|
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;
|
}
|
|
oCN.BeginTran();
|
|
if (IsAudit == 0) //审核判断
|
{
|
//审核前控制=========================================
|
string sql1 = "exec h_p_Cg_OrderTransportBill_BeforeCheckCtrl " + HInterID + ",'" + CurUserName + "'";
|
ds = oCN.RunProcReturn(sql1, "h_p_Cg_OrderTransportBill_BeforeCheckCtrl");
|
if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系";
|
objJsonResult.data = null;
|
oCN.RollBack();
|
return objJsonResult;
|
}
|
|
if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
|
objJsonResult.data = null;
|
oCN.RollBack();
|
return objJsonResult;
|
}
|
//==================================================================================
|
|
|
oBill.CheckBill(HInterID, ref sReturn);
|
|
|
//审核后控制=========================================
|
string sql2 = "exec h_p_Cg_OrderTransportBill_AfterCheckCtrl " + HInterID + ",'" + CurUserName + "'";
|
ds = oCN.RunProcReturn(sql2, "h_p_Cg_OrderTransportBill_AfterCheckCtrl");
|
if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "审核失败!原因:审核后判断失败,请与网络管理人员联系";
|
objJsonResult.data = null;
|
oCN.RollBack();
|
return objJsonResult;
|
}
|
|
if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
|
objJsonResult.data = null;
|
oCN.RollBack();
|
return objJsonResult;
|
}
|
//==================================================================================
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "审核成功";
|
objJsonResult.data = null;
|
}
|
if (IsAudit == 1) //反审核判断
|
{
|
//反审核前控制=========================================
|
string sql1 = "exec h_p_Cg_OrderTransportBill_BeforeUnCheckCtrl " + HInterID + ",'" + CurUserName + "'";
|
ds = oCN.RunProcReturn(sql1, "h_p_Cg_OrderTransportBill_BeforeCheckCtrl");
|
if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "反审核失败!原因:反审核前判断失败,请与网络管理人员联系";
|
objJsonResult.data = null;
|
oCN.RollBack();
|
return objJsonResult;
|
}
|
|
if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "反审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
|
objJsonResult.data = null;
|
oCN.RollBack();
|
return objJsonResult;
|
}
|
//==================================================================================
|
|
oBill.AbandonCheck(HInterID, ref sReturn);
|
|
//反审核后控制=========================================
|
string sql2 = "exec h_p_Cg_OrderTransportBill_AfterUnCheckCtrl " + HInterID + ",'" + CurUserName + "'";
|
ds = oCN.RunProcReturn(sql2, "h_p_Cg_OrderTransportBill_AfterUnCheckCtrl");
|
if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "反审核失败!原因:反审核后判断失败,请与网络管理人员联系";
|
objJsonResult.data = null;
|
oCN.RollBack();
|
return objJsonResult;
|
}
|
|
if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "反审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
|
objJsonResult.data = null;
|
oCN.RollBack();
|
return objJsonResult;
|
}
|
//==================================================================================
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "反审核成功";
|
objJsonResult.data = null;
|
}
|
oCN.Commit();
|
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 运单申请单 作废/反作废功能
|
[Route("Cg_OrderTransportBill/DropCg_OrderTransportBill")]
|
[HttpGet]
|
public object DropCg_OrderTransportBill(string HInterID, int Type, string user)
|
{
|
DAL.ClsCg_OrderTransportBill_Ctl oBill = new DAL.ClsCg_OrderTransportBill_Ctl();
|
try
|
{
|
//判断是否有作废权限
|
if (!DBUtility.ClsPub.Security_Log("Cg_OrderTransportBill_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;
|
oCN.BeginTran();//开始事务
|
|
//Type 1 作废 2 反作废
|
if (Type == 1)
|
{
|
//判断单据是否已经作废
|
DataSet ds;
|
string sql = "select * from " + oBill.MvarItemKey + " where HinterID = " + HInterID;
|
ds = oCN.RunProcReturn(sql, oBill.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 (ds.Tables[0].Rows[0]["HBillStatus"].ToString() == "6")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据在审核中!不能进行作废!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//作废单据
|
if (!oBill.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 " + oBill.MvarItemKey + " where HinterID = " + HInterID;
|
ds = oCN.RunProcReturn(sql, oBill.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 (ds.Tables[0].Rows[0]["HBillStatus"].ToString() == "6")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据在审核中!不能进行反作废!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//反作废单据
|
if (!oBill.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
|
|
#region 收料通知单 关闭/反关闭功能
|
[Route("Cg_OrderTransportBill/CloseCg_OrderTransportBill")]
|
[HttpGet]
|
public object CloseCg_OrderTransportBill(string HInterID, int Type, string user)
|
{
|
DAL.ClsCg_OrderTransportBill_Ctl oBill = new DAL.ClsCg_OrderTransportBill_Ctl();
|
try
|
{
|
//判断是否有删除权限
|
if (!DBUtility.ClsPub.Security_Log("Cg_OrderTransportBill_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;
|
oBill.MvarItemKey = "Cg_OrderTransportBillMain";
|
oCN.BeginTran();//开始事务
|
|
//Type 1 关闭 2 反关闭
|
if (Type == 1)
|
{
|
//判断单据是否已经关闭
|
DataSet ds;
|
string sql = "select * from " + oBill.MvarItemKey + " where HinterID = " + HInterID;
|
ds = oCN.RunProcReturn(sql, oBill.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]["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]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据已关闭!不能再次关闭!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//关闭单据
|
if (!oBill.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 " + oBill.MvarItemKey + " where HinterID = " + HInterID;
|
ds = oCN.RunProcReturn(sql, oBill.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]["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]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "单据未关闭!不需要再反关闭!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
//反关闭单据
|
if (!oBill.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("Cg_OrderTransportBill/GetCg_OrderTransportBillDetail")]
|
[HttpGet]
|
public object GetCg_OrderTransportBillDetail(int HID)
|
{
|
|
try
|
{
|
List<object> columnNameList = new List<object>();
|
string sql1 = $@"select * from h_v_Cg_OrderTransportBillList where HItemID = {HID}";
|
ds = oCN.RunProcReturn(sql1, "h_v_Cg_OrderTransportBillList");
|
//添加列名
|
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("Cg_OrderTransportBill/Cg_OrderTransportBill_UploadFile")]
|
[HttpPost]
|
public object Cg_OrderTransportBill_UploadFile()
|
{
|
|
string HBillNo = HttpContext.Current.Request.Params["HBillNo"]; //车牌号
|
string HUserName = HttpContext.Current.Request.Params["HUserName"]; //创建人
|
HttpPostedFile files = HttpContext.Current.Request.Files["file"];
|
string path = HttpContext.Current.Server.MapPath("~/../Files/Cg_OrderTransportBill/" + HBillNo);
|
|
dynamic dyResult = UpLoadFile(files, path, HBillNo, HUserName);
|
if (dyResult != null && dyResult.result == 1)
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "上传成功!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = dyResult.returnval;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
}
|
#endregion
|
|
public dynamic UpLoadFile(HttpPostedFile files, string path, string HBillNo, string HUserName)
|
{
|
dynamic Result_Ob = new { result = 1, returnval = "上传成功!" };
|
string filePath = Path.GetFullPath(files.FileName);//文件上传路径
|
string fileExtension = Path.GetExtension(files.FileName);// 文件扩展名
|
string filename = files.FileName;//文件名
|
string fileSavePath = path;// 上传保存路径
|
int filesize = files.ContentLength;//获取上传文件的大小单位为字节byte
|
int Maxsize = 40000 * 1024;//定义上传文件的最大空间大小为40M
|
try
|
{
|
if (files == null || files.ContentLength <= 0)
|
{
|
Result_Ob = new { result = 0, returnval = "文件不能为空!" };
|
return Result_Ob;
|
}
|
if (filesize >= Maxsize)
|
{
|
Result_Ob = new { result = 0, returnval = "上传文件超过40M,不能上传!" };
|
return Result_Ob;
|
}
|
|
string fileurl = Path.Combine(fileSavePath, filename);
|
if (Directory.Exists(fileurl) == true) //如果存在重名文件就提示
|
{
|
Result_Ob = new { result = 0, returnval = "存在同名文件!" };
|
return Result_Ob;
|
}
|
//删除数据表数据
|
ds = oCN.RunProcReturn("delete from MES_AccessoriesList where HSourceBillNo ='" + HBillNo + "' and HFileName='" + filename + "'", "MES_AccessoriesList");
|
if (Directory.Exists(path))
|
{
|
File.Delete(fileurl); //删除指定文件
|
files.SaveAs(fileurl);
|
string StrPath = "/files/Cg_OrderTransportBill/" + HBillNo + "/" + filename;
|
if (File.Exists(fileurl))
|
{
|
//这里可以执行一些其它的操作,比如更新数据库
|
//写入数据表
|
oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
|
",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
|
",HFileClsID,HSourceBillNo" +
|
") values('"
|
+ filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
|
",'" + HUserName + "',getdate(),'','V1','" + filesize +
|
"','" + 0 + "','" + HBillNo +
|
"') ");
|
}
|
else
|
{
|
Result_Ob = new { result = 0, returnval = "上传失败!此文件为恶意文件" };
|
}
|
}
|
else
|
{
|
Directory.CreateDirectory(fileSavePath); //添加文件夹
|
files.SaveAs(fileurl);
|
string StrPath = "/files/Cg_OrderTransportBill/" + HBillNo + "/" + filename;
|
if (File.Exists(fileurl))
|
{
|
//这里可以执行一些其它的操作,比如更新数据库
|
//写入数据表
|
oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
|
",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
|
",HFileClsID,HSourceBillNo" +
|
") values('"
|
+ filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
|
",'" + HUserName + "',getdate(),'','V1','" + filesize +
|
"','" + 0 + "','" + HBillNo +
|
"') ");
|
}
|
else
|
{
|
Result_Ob = new { result = 0, returnval = "上传失败!此文件为恶意文件" };
|
}
|
}
|
|
}
|
catch (Exception e)
|
{
|
Result_Ob = new { result = 0, returnval = e.Message };
|
}
|
return Result_Ob;
|
}
|
}
|
}
|