You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/Controllers/WMSController.cs

1700 lines
71 KiB
C#

2 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using DSWeb.Areas.Import.Models.Comm;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.MvcShipping.DAL.WMS;
using DSWeb.MvcShipping.Models.WMS;
using DSWeb.TruckMng.Comm.Cookie;
using DSWeb.TruckMng.Helper;
using DSWeb.TruckMng.Helper.Repository;
using DSWeb.Areas.Import.DAL.Comm;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.Areas.CommMng.Models;
using DSWeb.EntityDA;
using System.Data;
using DSWeb.DataAccess;
using System.Data.SqlClient;
using DSWeb.Areas.Import.DAL.ImportSales;
using DSWeb.MvcShipping.Models.MsChFee;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.Areas.MvcShipping.Helper;
2 years ago
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class WMSController : Controller
{
public ActionResult Index()
{
return View();
}
//
// GET: /MvcShipping/WareHouse/Edit
public ActionResult Edit()
{
return View();
}
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var dataList = WMSDAL.GetDataList(condition, sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetDataList_Import ( int start, int limit, string sort, string condition )
{
var dataList = WMSDAL.GetDataList_Import(condition, sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetWMSOUTList(int start, int limit, string sort, string condition)
{
var dataList = WMSDAL.GetWMSOUTList(condition, sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetWMSOUTList_Import ( int start, int limit, string sort, string condition )
{
var dataList = WMSDAL.GetWMSOUTList_Import(condition, sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetData(string handle, string condition)
{
WMSmb head = null;
if (handle == "edit")
{
var list = WMSDAL.GetDataList(condition, "");
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new WMSmb();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetData_Import(string handle, string condition)
{
WMSmb_ImportTrade head = null;
if (handle == "edit")
{
var list = WMSDAL.GetDataList_Import(condition, "");
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new WMSmb_ImportTrade();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetWMSOUTData(string handle, string condition)
{
WMSOUTmb head = null;
if (handle == "edit")
{
var list = WMSDAL.GetWMSOUTList(condition, "");
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new WMSOUTmb();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetWMSINList(int start, int limit, string sort, string condition)
{
var dataList = WMSDAL.GetWMSINList(condition, sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public WMSmb GetWMS(string condition)
{
WMSmb head = null;
var list = WMSDAL.GetDataList(condition, "");
if (list.Count > 0)
head = list[0];
if (head == null)
{
head = new WMSmb();
}
return head;
}
public ContentResult GetWMSOUTDetailList ( int start, int limit, string sort, string WMSOUTBSNO, string ASSOCIATEDNO, string condition, string ONLYINWMSOUT )
{
var USERID = Session["USERID"].ToString();
var _ONLYINWMSOUT = "";
if (!string.IsNullOrEmpty(ONLYINWMSOUT))
{
_ONLYINWMSOUT = ONLYINWMSOUT;
}
var dataList = WMSDAL.GetWMSOUTDetailList(USERID, WMSOUTBSNO.Trim(), ASSOCIATEDNO.Trim(), condition, sort.Trim(), _ONLYINWMSOUT);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetWMSRATE(int start, int limit, string sort, string condition)
{
var dataList = WMSDAL.GetWMSRATE(condition, sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetWMSRATEDetailList(int start, int limit, string sort, string condition)
{
var dataList = WMSDAL.GetWMSRATEDetailList(condition, sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult Save(string opstatus, string data, string WMSINBody, string WMSINBodyDel
, string WMSRATEBody, string WMSRATEBodyDel)
{
var head = JsonConvert.Deserialize<WMSmb>(data);
var WMSINBodyList = JsonConvert.Deserialize<List<WMSINmb>>(WMSINBody);
var WMSINBodyDelList = JsonConvert.Deserialize<List<WMSINmb>>(WMSINBodyDel);
var WMSRATEBodyList = JsonConvert.Deserialize<List<WMSRATEmb>>(WMSRATEBody);
var WMSRATEBodyDelList = JsonConvert.Deserialize<List<WMSRATEmb>>(WMSRATEBodyDel);
if (opstatus == "add")
{
head.DbOperationType = DbOperationType.DbotIns;
head.ModelUIStatus = "I";
head.GID = "Wms" + Guid.NewGuid().ToString().Replace("-", ""); ;//获取管理费单号
head.WMSOP = CookieConfig.GetCookie_UserName(Request);
//head.CORPID = CookieConfig.GetCookie_OrgName(Request);
head.WMSNO = getCodeRule("入库单号", "WMSNO", "WMS", head.WMSDATE);//调用编码规则
if (head.ASSOCIATEDNO == "") {
head.ASSOCIATEDNO = head.GID;
}
}
else if (opstatus == "edit")
{
head.DbOperationType = DbOperationType.DbotUpd;
head.ModelUIStatus = "E";
head.MODIFIEDTIME = DateTime.Now.ToString();
head.MODIFIEDUSER = CookieConfig.GetCookie_UserId(Request);
}
else
{
head.DbOperationType = DbOperationType.DbotDel;
}
var modb = new ModelObjectRepository();
DBResult result = modb.Save(head,
ModelObjectConvert<WMSINmb>.ToModelObjectList(WMSINBodyList),
ModelObjectConvert<WMSINmb>.ToModelObjectList(WMSINBodyDelList),
ModelObjectConvert<WMSRATEmb>.ToModelObjectList(WMSRATEBodyList),
ModelObjectConvert<WMSRATEmb>.ToModelObjectList(WMSRATEBodyDelList)
);
//刷新父窗口上的父节点
/*
if (result.Success == true && feeUnUnionList != null)
{
var _count = BaoxiaoDAL.FeeUnUnion(feeUnUnionList);
}*/
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = WMSDAL.GetData(" GID='" + head.GID + "'")
};
//p_op_gain(head.BXGID);
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
//暂时无用
public ContentResult Save_Import(string opstatus, string data, string WMSINBody, string WMSINBodyDel
, string WMSRATEBody, string WMSRATEBodyDel)
{
var head = JsonConvert.Deserialize<WMSmb_ImportTrade>(data);
var WMSINBodyList = JsonConvert.Deserialize<List<WMSINmb>>(WMSINBody);
var WMSINBodyDelList = JsonConvert.Deserialize<List<WMSINmb>>(WMSINBodyDel);
var WMSRATEBodyList = JsonConvert.Deserialize<List<WMSRATEmb>>(WMSRATEBody);
var WMSRATEBodyDelList = JsonConvert.Deserialize<List<WMSRATEmb>>(WMSRATEBodyDel);
if (opstatus == "add")
{
head.DbOperationType = DbOperationType.DbotIns;
head.ModelUIStatus = "I";
head.GID = "Wms" + Guid.NewGuid().ToString().Replace("-", ""); ;//获取管理费单号
head.WMSOP = CookieConfig.GetCookie_UserName(Request);
//head.CORPID = CookieConfig.GetCookie_OrgName(Request);
head.WMSNO = getCodeRule("入库单号", "WMSNO", "WMS", head.WMSDATE);//调用编码规则
if (head.ASSOCIATEDNO == "")
{
head.ASSOCIATEDNO = head.GID;
}
}
else if (opstatus == "edit")
{
head.DbOperationType = DbOperationType.DbotUpd;
head.ModelUIStatus = "E";
head.MODIFIEDTIME = DateTime.Now.ToString();
head.MODIFIEDUSER = CookieConfig.GetCookie_UserId(Request);
}
else
{
head.DbOperationType = DbOperationType.DbotDel;
}
var modb = new ModelObjectRepository();
DBResult result = modb.Save(head,
ModelObjectConvert<WMSINmb>.ToModelObjectList(WMSINBodyList),
ModelObjectConvert<WMSINmb>.ToModelObjectList(WMSINBodyDelList),
ModelObjectConvert<WMSRATEmb>.ToModelObjectList(WMSRATEBodyList),
ModelObjectConvert<WMSRATEmb>.ToModelObjectList(WMSRATEBodyDelList)
);
//更新跟单的 declarenumber
if (head.CUSTOMNO != "") {
BasicDataRefDAL.ExecSql(" update import_main set DeclareNumber='" + head.CUSTOMNO + "' where contractno='" + head.ASSOCIATEDNO + "' ");
}
if (head.CLIENTBSNO != "")
{
BasicDataRefDAL.ExecSql(" update WMS set CLIENTBSNO='" + head.CUSTOMNO + "' where BLNO='" + head.BLNO + "' ");
}
if (head.CREATETIME != "")
{
DateTime dt = new DateTime();
dt = Convert.ToDateTime(head.CREATETIME);
BasicDataRefDAL.ExecSql(" update WMS set CREATETIME='" + dt.ToString("d") + "' where BLNO='" + head.BLNO + "' ");
}
//刷新父窗口上的父节点
/*
if (result.Success == true && feeUnUnionList != null)
{
var _count = BaoxiaoDAL.FeeUnUnion(feeUnUnionList);
}*/
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = WMSDAL.GetData(" GID='" + head.GID + "'")
};
//p_op_gain(head.BXGID);
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveRate(string BSNONAME,string BSNO,string WMSRATEBody, string WMSRATEBodyDel)
{
var WMSRATEBodyList = JsonConvert.Deserialize<List<WMSRATEmb>>(WMSRATEBody);
var WMSRATEDelBodyList = JsonConvert.Deserialize<List<WMSRATEmb>>(WMSRATEBodyDel);
if (WMSRATEBodyList !=null )
{
foreach (var _WR in WMSRATEBodyList)
{
_WR.MODIFIEDUSER = CookieConfig.GetCookie_UserName(Request);
_WR.MODIFIEDTIME = DateTime.Now.ToString();
}
}
var modb = new ModelObjectRepository();
DBResult result = modb.SaveComm(BSNONAME,BSNO,
ModelObjectConvert<WMSRATEmb>.ToModelObjectList(WMSRATEBodyList),
ModelObjectConvert<WMSRATEmb>.ToModelObjectList(WMSRATEDelBodyList)
);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DelRate ( string BSNONAME, string BSNO, string WMSRATEBodyDel )
{
//var WMSRATEBodyList = JsonConvert.Deserialize<List<WMSRATEmb>>(WMSRATEBody);
var WMSRATEDelBodyList = JsonConvert.Deserialize<List<WMSRATEmb>>(WMSRATEBodyDel);
var modb = new ModelObjectRepository();
DBResult result = modb.SaveComm(BSNONAME, BSNO,
null,
ModelObjectConvert<WMSRATEmb>.ToModelObjectList(WMSRATEDelBodyList)
);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveWMSOUT(string opstatus, string data, string WMSOUTDetailBody, string WMSOUTDetailBodyDel)
{
var head = JsonConvert.Deserialize<WMSOUTmb>(data);
var WMSOUTDetailBodyList = JsonConvert.Deserialize<List<WMSOUTDetailmb>>(WMSOUTDetailBody);
var WMSOUTDetailBodyDelList = JsonConvert.Deserialize<List<WMSOUTDetailmb>>(WMSOUTDetailBodyDel);
return SaveWMSOUT_OWN(opstatus, head, WMSOUTDetailBodyList, WMSOUTDetailBodyDelList);
}
public ContentResult SaveWMSOUT_OWN ( string opstatus, WMSOUTmb head, List<WMSOUTDetailmb> WMSOUTDetailBodyList, List<WMSOUTDetailmb> WMSOUTDetailBodyDelList )
{
var jsonRespose = new JsonResponse
{
Success = false,
Message = ""//,
//Data = WMSDAL.GetWMSOUTData(" GID='" + head.GID + "'")
};
var result = new DBResult();
var result2 = new DBResult();
var result3 = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
//var tran = conn.BeginTransaction();//tran
SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction);
try
{
if (head.INGIDNEW != "")//如果没有下属货转入库信息(=="") 则直接进行入库信息添加
//否则先处理现有的入库信息
{
//判断现有货转入库信息是否已费用入账
//var HZWMSCount = WMSDAL.GetHZWMSCount(head.BSNO);
var HZWMSLockCount = WMSDAL.GetHZWMSLockCount(head.INGIDNEW);
if (HZWMSLockCount > 0)
{
//返回错误
var jsonRespose_0 = new JsonResponse { Success = false, Message = "下属的货转入库已经入账,不能修改" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose_0) };
}
else
{
//删除该WMS
WMSDAL.DelHZWMS(head.INGIDNEW);
}
}
if (opstatus == "add")
{
head.DbOperationType = DbOperationType.DbotIns;
head.ModelUIStatus = "I";
head.GID = "WO" + Guid.NewGuid().ToString().Replace("-", "");
//head.WMSDATE = DateTime.Now.ToShortTimeString();
head.WMSOP = CookieConfig.GetCookie_UserName(Request);
//head.CORPID = CookieConfig.GetCookie_OrgCode(Request);
//head.WMSNO = getCodeRule("入库单号", "WMSNO", "WMS", head);//调用编码规则
if (head.BSNO == "" || head.BSNO == "*")
{
head.BSNO = getCodeRule("出库单号", "BSNO", "WMS_OUT", head.DODATE);//调用编码规则
}
if (head.ASSOCIATEDNO == "")
{
head.ASSOCIATEDNO = head.GID;
}
}
else if (opstatus == "edit")
{
head.DbOperationType = DbOperationType.DbotUpd;
head.ModelUIStatus = "E";
head.MODIFIEDTIME = DateTime.Now.ToString();
head.MODIFIEDUSER = CookieConfig.GetCookie_UserId(Request);
}
else
{
head.DbOperationType = DbOperationType.DbotDel;
}
var modb = new ModelObjectRepository();
result = modb.Save(head,
ModelObjectConvert<WMSOUTDetailmb>.ToModelObjectList(WMSOUTDetailBodyList),
ModelObjectConvert<WMSOUTDetailmb>.ToModelObjectList(WMSOUTDetailBodyDelList)
);
if (result.Success == false) {
}
var WODList = WMSDAL.GetWMSOUTDetailList_0(" OUTBSNO='" + head.BSNO + "' ", "");
var GOODSOUTFEE = 0M;
var GOODSOUTFEEAP = 0M;
foreach (var WOD in WODList)
{
//using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
//{
try
{
var _r = WMSDAL.SetFee(sqlTran, WOD.STARTBILLINGDATE, WOD.ENDBILLINGDATE, WOD.INBSNO
, WOD.CUSTOMERNAME, decimal.Parse(WOD.GOODSPFSL), WOD.GID, 1
, CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserName(Request), WOD.OUTBSNO, true, false);
WOD.FEEDAYS = _r.feedays;
WOD.GOODSOUTFEE = _r.sumfee;
GOODSOUTFEE += Convert.ToDecimal(_r.sumfee);
sqlTran.Commit();
}
catch
{
}
finally
{
SqlHelper.CloseConnection();
}
// }
};
WODList.ForEach(delegate( WMSOUTDetailmb WOD )
{
//using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
//{
try
{
var _r = WMSDAL.SetFee(sqlTran, WOD.STARTBILLINGDATE, WOD.ENDBILLINGDATEAP, WOD.INBSNO
, WOD.CUSTOMERNAME, decimal.Parse(WOD.GOODSPFSL), WOD.GID, 2
, CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserName(Request), WOD.OUTBSNO, true, false);
WOD.FEEDAYSAP = _r.feedays;
WOD.GOODSOUTFEEAP = _r.sumfee;
GOODSOUTFEEAP += Convert.ToDecimal(_r.sumfee);
sqlTran.Commit();
}
catch
{
}
finally
{
SqlHelper.CloseConnection();
}
//}
});
head.GOODSOUTFEE = GOODSOUTFEE.ToString();
head.GOODSOUTFEEAP = GOODSOUTFEEAP.ToString();
/*foreach (var _s in WODList) {
_s.OUTBSNO = head.BSNO;
}*/
var modb2 = new ModelObjectRepository();
result2 = modb2.SaveComm("OUTBSNO", head.BSNO,
ModelObjectConvert<WMSOUTDetailmb>.ToModelObjectList(WODList),
null
);
//计算完成 把WMS里的剩余数量 减掉现在的
var WODList_0 = WMSDAL.GetWMSOUTDetailList_0(" inbsno in(select inbsno from wms_out_detail where OUTBSNO='" + head.BSNO + "' ) ", "");
var WMSGIDList = "";
var WMSList = new List<WMSmb>();
if (head.ASSOCIATEDNO != "")
{//在业务内 明确业务编号
WMSList = WMSDAL.GetDataList(" gid in(select inbsno from wms_out_detail where OUTBSNO='" + head.BSNO + "' )", "");
}
else
{
//独立出入库业务,应该选择即将保存的和现存的
if (WMSGIDList != "")
{
WMSList = WMSDAL.GetDataList(" GID in(" + WMSGIDList + ")", "");
}
}
foreach (var _WMS in WMSList)
{
//var GOODSSTOCK = Convert.ToDecimal(_WMS.GOODSSTOCK);
//var GOODSPACKSTOCK = Convert.ToDecimal(_WMS.GOODSPACKSTOCK);
foreach (var _WO in WODList_0)
{
if (_WO.INBSNO == _WMS.GID) //将已经存在的出库记录内的出库件数和重量 全部加回剩余量
{
//改为使用入库信息
_WMS.GOODSSTOCK = _WMS.GOODSRKSL;
_WMS.GOODSPACKSTOCK = _WMS.GOODSPACK;
}
}
}
foreach (var _WMS in WMSList)
{
var GOODSSTOCK = Convert.ToDecimal(_WMS.GOODSSTOCK);
var GOODSPACKSTOCK = Convert.ToDecimal(_WMS.GOODSPACKSTOCK);
foreach (var _WO in WODList_0)
{
if (_WO.INBSNO == _WMS.GID) //从剩余量中减去提取量
{
GOODSSTOCK -= Convert.ToDecimal(_WO.GOODSPFSL);
GOODSPACKSTOCK -= Convert.ToDecimal(_WO.GOODSPACKPFSL);
}
}
_WMS.GOODSSTOCK = GOODSSTOCK.ToString();
_WMS.GOODSPACKSTOCK = GOODSPACKSTOCK.ToString();
}
var modb3 = new ModelObjectRepository();
result3 = modb3.Save(
ModelObjectConvert<WMSmb>.ToModelObjectList(WMSList)
);
}
catch (Exception ee)
{
jsonRespose = new JsonResponse
{
Success = false,
Message = ee.Message//,
//Data = WMSDAL.GetWMSOUTData(" GID='" + head.GID + "'")
};
sqlTran.Rollback();
}
/*
if (result.Success == true && result2.Success==true && result3.Success==true)
{
//sqlTran.Commit();
}
else {
//sqlTran.Rollback();
}*/
jsonRespose = new JsonResponse
{
Success = result.Success == true && result2.Success == true && result3.Success == true,
Message = "",
Data = WMSDAL.GetWMSOUTData(" GID='" + head.GID + "'")
};
}
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 修改入库/开始计费时间。即使已经费用入账。用于修改既往的单据内的入库时间
public ContentResult SetNewWMSBillingDate(string WMSGID, string WMSDATE, string STARTBILLINGDATE, string STARTBILLINGDATEAP)
{
var _count = WMSDAL.SetNewWMSBillingDate(WMSGID, WMSDATE, STARTBILLINGDATE, STARTBILLINGDATEAP
, CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserName(Request));
var _result = SetNewWMSFee(WMSGID);
var jsonRespose = new JsonResponse
{
Success = false,
Message = _count.ToString()
};
if (_count == 0 ) {
jsonRespose.Success = true;
}
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 将一个入库单下属的出库单全部重新计算仓储费用明细
public ContentResult SetNewWMSFee(string WMSGID) {
var WODList = WMSDAL.GetWMSOUTDetailList_0(" INBSNO='" + WMSGID + "'", "");
foreach (var WOD in WODList)
{
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
var _r = WMSDAL.SetFee(sqlTran, WOD.STARTBILLINGDATE, WOD.ENDBILLINGDATE, WOD.INBSNO
, WOD.CUSTOMERNAME, decimal.Parse(WOD.GOODSPFSL), WOD.GID, 1
, CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserName(Request), WOD.OUTBSNO, true, false);
WOD.FEEDAYS = _r.feedays;
WOD.GOODSOUTFEE = _r.sumfee;
//GOODSOUTFEE += float.Parse(_r.sumfee);
sqlTran.Commit();
}
catch
{
}
finally
{
SqlHelper.CloseConnection();
}
}
};
WODList.ForEach(delegate(WMSOUTDetailmb WOD)
{
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
var _r = WMSDAL.SetFee(sqlTran, WOD.STARTBILLINGDATE, WOD.ENDBILLINGDATEAP, WOD.INBSNO
, WOD.CUSTOMERNAME, decimal.Parse(WOD.GOODSPFSL), WOD.GID, 2
, CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserName(Request), WOD.OUTBSNO, true, false);
WOD.FEEDAYSAP = _r.feedays;
WOD.GOODSOUTFEEAP = _r.sumfee;
//GOODSOUTFEEAP += float.Parse(_r.sumfee);
sqlTran.Commit();
}
catch
{
}
finally
{
SqlHelper.CloseConnection();
}
}
});
/*foreach (var _s in WODList) {
_s.OUTBSNO = head.BSNO;
}*/
var modb2 = new ModelObjectRepository();
DBResult result2 = modb2.SaveComm("INBSNO", WMSGID,
ModelObjectConvert<WMSOUTDetailmb>.ToModelObjectList(WODList),
null
);
var jsonRespose = new JsonResponse
{
Success = result2.Success,
Message = result2.Message/*,
Data = WMSDAL.GetWMSOUTData(" GID='" + head.GID + "'")*/
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 获取 锁定的 货转出库 下属的 货转入库 数量
public int GetHZWMSLockCount(string INGIDNEW) {
var _count = WMSDAL.GetHZWMSLockCount(INGIDNEW);
return _count;
}
#endregion
public ContentResult SetHZWMS(string OpStatus, string data)
{
var head = JsonConvert.Deserialize<WMSOUTmb>(data);
if (head.INGIDNEW != "")//如果没有下属货转入库信息(=="") 则直接进行入库信息添加
//否则先处理现有的入库信息
{
//判断现有货转入库信息是否已费用入账
//var HZWMSCount = WMSDAL.GetHZWMSCount(head.BSNO);
var HZWMSLockCount = WMSDAL.GetHZWMSLockCount(head.INGIDNEW);
if (HZWMSLockCount > 0)
{
//返回错误
var jsonRespose_0 = new JsonResponse { Success = false, Message = "下属的货转入库已经入账,不能修改" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose_0) };
}
else {
//删除该WMS
WMSDAL.DelHZWMS(head.INGIDNEW);
}
}
//新增入库信息
//getCodeRule("入库单号", "WMSNO", "WMS", head.WMSDATE);
//if (OpStatus != "add") { WMSDAL.DelHZWMS(head.BSNO); }
var WMSGID = "Wms" + Guid.NewGuid().ToString().Replace("-", "");
var WMSNO=getCodeRule("入库单号", "WMSNO", "WMS", head.DODATE);
Resultmb result = WMSDAL.InsertHZWMS(head,WMSGID,WMSNO,CookieConfig.GetCookie_UserId(Request));
//var GID = head.GID;
var jsonRespose = new JsonResponse {
Success = result.Success, Message = result.Message,
Data = WMSDAL.GetWMSOUTData(" GID='" + head.GID + "'")
,
DataBody = GetWMS(" WMSNO='" + WMSNO + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult Delete(string data, string USERID)
{
var head = JsonConvert.Deserialize<WMSmb>(data);
//判断该入库单下是否有出库数据
string checkSql = @"select count(*) from wms_out_detail where INBSNO = '"+head.GID+"' ";
Database db = DatabaseFactory.CreateDatabase();
int cnt = Convert.ToInt32(db.ExecuteScalar(CommandType.Text,checkSql));
if (cnt<=0)
{
var modb = new ModelObjectDB();
DBResult result = modb.Delete(head, USERID, true);
//var GID = head.GID;
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = "无法删除已存在出库数据的入库单!"};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult DeleteOUT(string data, string USERID)
{
var head = JsonConvert.Deserialize<WMSOUTmb>(data);
if (head.ISCHANGE == "True")
{
var HZWMSLockCount = WMSDAL.GetHZWMSLockCount(head.INGIDNEW);
if (HZWMSLockCount > 0)
{
//返回错误
var jsonRespose_0 = new JsonResponse { Success = false, Message = "下属的货转入库已经入账,不能修改" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose_0) };
}
else {
WMSDAL.DelHZWMS(head.INGIDNEW);
}
}
//首先记录 WMS_out_detail的 INBSNO即WMS的GID将保存前的 剩余件数和剩余量储存
var WMSGIDList = "";
var WODList_0 = WMSDAL.GetWMSOUTDetailList_0(" OUTBSNO='" + head.BSNO + "'", "");
foreach (var _WO in WODList_0)
{
if (WMSGIDList == "")
WMSGIDList = "'" + _WO.INBSNO + "'";
else WMSGIDList = WMSGIDList + ",'" + _WO.INBSNO + "'";
}
var WMSList = new List<WMSmb>();
WMSList = WMSDAL.GetDataList(" GID in (" + WMSGIDList + ")", "");
foreach (var _WMS in WMSList)
{
var GOODSSTOCK = Convert.ToDecimal(_WMS.GOODSSTOCK);
var GOODSPACKSTOCK = Convert.ToDecimal(_WMS.GOODSPACKSTOCK);
foreach (var _WO in WODList_0)
{
if (_WO.INBSNO == _WMS.GID) //将现有数字全部加回剩余量
{
GOODSSTOCK += Convert.ToDecimal(_WO.GOODSPFSL);
GOODSPACKSTOCK += Convert.ToDecimal(_WO.GOODSPACKPFSL);
}
}
_WMS.GOODSSTOCK = GOODSSTOCK.ToString();
_WMS.GOODSPACKSTOCK = GOODSPACKSTOCK.ToString();
}
var modb3 = new ModelObjectRepository();
DBResult result3 = modb3.Save(
ModelObjectConvert<WMSmb>.ToModelObjectList(WMSList)
);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(head, USERID, true);
var _count = WMSDAL.DeleteOut(head.BSNO);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteOUTByBSNO(string BSNO)
{
var dataList = WMSDAL.GetWMSOUTList(" BSNO='" + BSNO + "'", "");
var _r = new ContentResult();
foreach (var head in dataList)
{
if (head.ISCHANGE == "True")
{
var HZWMSLockCount = WMSDAL.GetHZWMSLockCount(head.INGIDNEW);
if (HZWMSLockCount > 0)
{
//返回错误
var jsonRespose_0 = new JsonResponse { Success = false, Message = "下属的货转入库已经入账,不能修改" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose_0) };
}
else
{
WMSDAL.DelHZWMS(head.INGIDNEW);
}
}
//首先记录 WMS_out_detail的 INBSNO即WMS的GID将保存前的 剩余件数和剩余量储存
var WMSGIDList = "";
var WODList_0 = WMSDAL.GetWMSOUTDetailList_0(" OUTBSNO='" + head.BSNO + "'", "");
foreach (var _WO in WODList_0)
{
if (WMSGIDList == "")
WMSGIDList = "'" + _WO.INBSNO + "'";
else WMSGIDList = WMSGIDList + ",'" + _WO.INBSNO + "'";
}
var WMSList = new List<WMSmb>();
WMSList = WMSDAL.GetDataList(" ASSOCIATEDNO ='" + head.ASSOCIATEDNO + "'", "");
foreach (var _WMS in WMSList)
{
var GOODSSTOCK = Convert.ToDecimal(_WMS.GOODSSTOCK);
var GOODSPACKSTOCK = Convert.ToDecimal(_WMS.GOODSPACKSTOCK);
foreach (var _WO in WODList_0)
{
if (_WO.INBSNO == _WMS.GID) //将现有数字全部加回剩余量
{
GOODSSTOCK += Convert.ToDecimal(_WO.GOODSPFSL);
GOODSPACKSTOCK += Convert.ToDecimal(_WO.GOODSPACKPFSL);
}
}
_WMS.GOODSSTOCK = GOODSSTOCK.ToString();
_WMS.GOODSPACKSTOCK = GOODSPACKSTOCK.ToString();
}
var modb3 = new ModelObjectRepository();
DBResult result3 = modb3.Save(
ModelObjectConvert<WMSmb>.ToModelObjectList(WMSList)
);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(head, Session["USERID"].ToString(), true);
var _count = WMSDAL.DeleteOut(head.BSNO);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
_r = new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
return _r;
}
2 years ago
public ContentResult Lock(string data, string LOCK)
{//费用入账
var WMSList = JsonConvert.Deserialize<List<WMSmb>>(data);
var WMSGID = "";
for (int i = 0; i <= WMSList.Count() - 1; i++)
{
if (WMSGID == "") { WMSGID = "" + WMSList[i].GID.ToString() + ""; }
else { WMSGID = WMSGID + "," + WMSList[i].GID.ToString() + ""; }
}
var USERID = CookieConfig.GetCookie_UserId(Request);
2 years ago
return LockWMS(WMSGID,USERID, LOCK);
2 years ago
}
public ContentResult LockWMSList ( string WMSGIDList, string LOCK )
{//费用入账
var USERID = CookieConfig.GetCookie_UserId(Request);
return LockWMS(WMSGIDList, USERID, LOCK);
}
public ContentResult LockWMS(string WMSGID,string USERID, string LOCK)
{
WmsDA _wda = new WmsDA();
var _r = 0;
Resultmb result = new Resultmb();
if (LOCK == "1")
_r = _wda.setislock(WMSGID, USERID);
else if (LOCK == "0") {
//入库解锁时先看有没有下属出库 有则返回false
var _WODList=WMSDAL.GetWMSOUTDetailList_0("INBSNO in('"+WMSGID+"')","");
if (_WODList.Count > 0) {
result.Success = false;
result.Message = "已有出库操作,不能取消入账";
var jsonRespose2 = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}else
_r = _wda.setnotlock(WMSGID, USERID);
}
/*
iResult = 1;//状态为1表示插入成功
iResult = -1;//有异常,插入失败
iResult = -2;//插入异常,事务已回滚成功*/
if (_r == 1)
{
result.Success = true;
if (LOCK == "0")
result.Message = "已经取消费用入账";
else
result.Message = "已经费用入账";
}
else if (_r == -1 || _r == -2)
{
result.Success = true;
result.Message = "操作失败";
}
//WMSDAL.Lock(WMSGID, LOCK,);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult LockOut(string data, string LOCK)
{//出库费用入账
var _WMSOUTList = JsonConvert.Deserialize<List<WMSOUTmb>>(data);
var WMSOUTGID = "";
for (int i = 0; i <= _WMSOUTList.Count() - 1; i++)
{
if (WMSOUTGID == "") { WMSOUTGID = "'" + _WMSOUTList[i].GID.ToString() + "'"; }
else { WMSOUTGID = WMSOUTGID + ",'" + _WMSOUTList[i].GID.ToString() + "'"; }
}
var condition = " GID in(" + WMSOUTGID + ") ";
if (LOCK == "1") {
condition += " and isnull(ISLOCK,0)=0";
}
if (LOCK == "0")
{
condition += " and isnull(ISLOCK,1)=1";
}
var dataList = WMSDAL.GetWMSOUTList(condition, "");
WMSOUTGID = "";
for (int i = 0; i <= dataList.Count() - 1; i++)
{
WMSOUTGID = "'" + _WMSOUTList[i].GID.ToString() + "'";
}
WmsOutDA _wda = new WmsOutDA();
var _r = 0;
if (LOCK == "1")
_r = _wda.setislock2(WMSOUTGID, CookieConfig.GetCookie_UserId(Request));
else if (LOCK == "0")
_r = _wda.setnotlock2(WMSOUTGID, CookieConfig.GetCookie_UserId(Request));
Resultmb result = new Resultmb();
/*
iResult = 1;//状态为1表示插入成功
iResult = -1;//有异常,插入失败
iResult = -2;//插入异常,事务已回滚成功*/
if (_r == 1)
{
result.Success = true;
if (LOCK == "0")
result.Message = "已经取消费用入账";
else
result.Message = "已经费用入账";
}
else if (_r == -1 || _r == -2)
{
result.Success = true;
result.Message = "操作失败";
}
//WMSDAL.Lock(WMSGID, LOCK,);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult LockOut_Import ( string data, string LOCK )
{//出库费用入账
var _WMSOUTList = JsonConvert.Deserialize<List<WMSOUTmb>>(data);
var WMSOUTGID = "";
for (int i = 0; i <= _WMSOUTList.Count() - 1; i++)
{
if (WMSOUTGID == "") { WMSOUTGID = "'" + _WMSOUTList[i].GID.ToString() + "'"; }
else { WMSOUTGID = WMSOUTGID + ",'" + _WMSOUTList[i].GID.ToString() + "'"; }
}
var condition = " wo.GID in(" + WMSOUTGID + ") ";
if (LOCK == "1")
{
condition += " and isnull(wo.ISLOCK,0)=0";
}
if (LOCK == "0")
{
condition += " and isnull(wo.ISLOCK,1)=1";
}
var dataList = WMSDAL.GetWMSOUTList_Import(condition, "");
WMSOUTGID = "";
for (int i = 0; i <= dataList.Count() - 1; i++)
{
if ((LOCK == "1" && dataList[i].BSSTATUS == "2")||(LOCK == "0"))
{
if (WMSOUTGID == "")
{
WMSOUTGID += dataList[i].GID.ToString();
}
else {
WMSOUTGID += ","+dataList[i].GID.ToString();
}
}
}
WmsOutDA _wda = new WmsOutDA();
var _r = 0;
if (LOCK == "1")
_r = _wda.setislock2(WMSOUTGID, CookieConfig.GetCookie_UserId(Request));
else if (LOCK == "0")
_r = _wda.setnotlock3(WMSOUTGID, CookieConfig.GetCookie_UserId(Request));
Resultmb result = new Resultmb();
/*
iResult = 1;//状态为1表示插入成功
iResult = -1;//有异常,插入失败
iResult = -2;//插入异常,事务已回滚成功*/
var _count = 0;
if (_r == 1)
{
result.Success = true;
if (LOCK == "0")
result.Message = "已经取消费用入账";
else
result.Message = "已经费用入账";
if (LOCK == "1")
{
foreach (var _W in _WMSOUTList)
{
_count += ImportSalesDAL.LockDelivery_2(_W.BSNO);
//产生费用
//MakeFee_ImportDelivery(_W.GID,_W.BSNO);
}
}
else {
foreach (var _W in _WMSOUTList)
{
_count += ImportSalesDAL.UnLockDelivery_2(_W.BSNO);
//删除费用
//DelFee_ImportDelivery(_W.BSNO);
}
}
}
else if (_r == -1 || _r == -2)
{
result.Success = true;
result.Message = "操作失败";
}
//WMSDAL.Lock(WMSGID, LOCK,);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
/*
private ContentResult MakeFee_ImportDelivery (string WmsOutBsNo, string DELIVERYNO ) {
var condition = " D.DELIVERYNO='" + DELIVERYNO + "'";
var deliverydetail= ImportSalesDAL.GetDeliveryDetailList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), "");
var headdata=ImportSalesDAL.GetDeliveryData("DELIVERYNO='"+DELIVERYNO+"'");
var chfeelist = new List<MsChFeeImportWMS>();
var chfeedellist = new List<MsChFeeImportWMS>();
var BSNO="";
foreach (var _dd in deliverydetail) {
var _fee = new MsChFeeImportWMS();
var salesdetaillist = ImportSalesDAL.GetDetailList(" s.GID='" + _dd.SALEDETAIL_GID + "'");
var salesdetail = salesdetaillist[0];
BSNO=salesdetail.BSNO;
_fee.GId = System.Guid.NewGuid().ToString();
_fee.BsNo = "";
_fee.FeeName = "尾款";
_fee.FeeType = 1;
_fee.FeeStatus = 0;
_fee.CustomerName = headdata.CUSTOMERNAME;
_fee.UnitPrice = Convert.ToDecimal( salesdetail.PRICERMB);
_fee.TaxUnitPrice = Convert.ToDecimal(salesdetail.PRICERMB);
_fee.Quantity = Convert.ToDecimal(_dd.WEIGHT);
_fee.Amount = _fee.UnitPrice * _fee.Quantity;
_fee.NoTaxAmount = _fee.Amount;
_fee.Currency = "RMB";
_fee.ExChangerate = 1;
if (salesdetail.CURRENCY!="RMB"){
_fee.Remark = salesdetail.CURRENCY + " 汇率" + salesdetail.EXCHANGERATE;
}
_fee.EnteroPerator = Session["USERID"].ToString();
_fee.EnterDate = System.DateTime.Now;
_fee.DebitNo="";
_fee.IsDebit="0";
_fee.IsOpen="0";
_fee.IsAdvancedpay="0";
_fee.IsInvoice="0";
_fee.FeeFrt="PP";
_fee.IsCrmOrderFee="0";
_fee.AuditStatus=0;
_fee.SALESNO=salesdetail.SALESNO;
_fee.DELIVERYNO = _dd.DELIVERYNO;
_fee.WmsOutBsNo = WmsOutBsNo;
chfeelist.Add(_fee);
}
var modb = new ModelObjectRepository();
var _r = modb.SaveComm("BsNo", BSNO,
ModelObjectConvert<MsChFeeImportWMS>.ToModelObjectList(chfeelist),
ModelObjectConvert<MsChFeeImportWMS>.ToModelObjectList(chfeedellist)
);
var jsonRespose = new JsonResponse
{
Success = _r.Success,
Message = _r.Message,
Data = null
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
private ContentResult DelFee_ImportDelivery ( string DELIVERYNO )
{
var _count = WMSDAL.DelFee_ImportDelivery(DELIVERYNO);
var modb = new ModelObjectRepository();
var _r = new DBResult();
if (_count > 0) {
_r.Success = true;
}
var jsonRespose = new JsonResponse
{
Success = _r.Success,
Message = _r.Message,
Data = null
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
*/
public ContentResult SetWMSFee(string strSTARTBILLINGDATE, string strOLDCUSTFEEDATE, string strINBSNO
, string strCUSTOMERNAME, Decimal outnums, string strASSOCIATEDNO, int strFEETYPE
, string strUserID, string strShowName, string sBillno, bool ck_jsfee, bool isKuCun)
{
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
var _r = WMSDAL.SetFee(sqlTran, strSTARTBILLINGDATE, strOLDCUSTFEEDATE, strINBSNO
, strCUSTOMERNAME, outnums, strASSOCIATEDNO, strFEETYPE
, strUserID, strShowName, sBillno, ck_jsfee, isKuCun);
var json = JsonConvert.Serialize(
new { Success = true, Message = "设置成功", data = _r });
return new ContentResult() { Content = json };
}
catch (Exception execError)
{
//result = -10;//有异常,插入失败
sqlTran.Rollback();
//result = -11;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
}
#region 查询库存,看是否有取用记录
public ContentResult GetCargoOut(string WMSGID)
{
var _count = WMSDAL.GetCargoOut(WMSGID);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = _count });
return new ContentResult() { Content = json };
}
#endregion
#region 入库财务审核
public ContentResult SubmitAudit ( string WMSList, string optype )
{
var billData = JsonConvert.Deserialize<List<WMSmb>>(WMSList);
DBResult result = WMSDAL.SubmitAudit(optype, Convert.ToString(Session["USERID"]), billData);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult CancelAudit ( string WMSList, string optype )
{
var billData = JsonConvert.Deserialize<List<WMSmb>>(WMSList);
//DBResult result = Chfee_AuditDAL.CancelAudit(optype, Convert.ToString(Session["DEPTGID"]), Convert.ToString(Session["USERID"]), GidStr);
DBResult result = WMSDAL.CancelAudit(optype, Convert.ToString(Session["USERID"]), billData);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult Audit ( String WMSList, String bill )
{
var billData = JsonConvert.Deserialize<List<WMSmb>>(WMSList);
DBResult result = WMSDAL.Audit( Convert.ToString(Session["USERID"]), billData);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult AuditBack ( String WMSList, String bill, string reasean )
{
var billData = JsonConvert.Deserialize<List<WMSmb>>(WMSList);
DBResult result = WMSDAL.AuditBack( Convert.ToString(Session["USERID"]), billData, reasean);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
#endregion
#region 出库财务审核
public ContentResult SubmitAudit_OUT ( string WMSList, string optype )
{
var billData = JsonConvert.Deserialize<List<WMSOUTmb>>(WMSList);
DBResult result = WMSDAL.SubmitAudit_OUT(optype, Convert.ToString(Session["USERID"]), billData);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult CancelAudit_OUT ( string WMSList, string optype )
{
var billData = JsonConvert.Deserialize<List<WMSOUTmb>>(WMSList);
//DBResult result = Chfee_AuditDAL.CancelAudit(optype, Convert.ToString(Session["DEPTGID"]), Convert.ToString(Session["USERID"]), GidStr);
DBResult result = WMSDAL.CancelAudit_OUT(optype, Convert.ToString(Session["USERID"]), billData);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult Audit_OUT ( String WMSList, String bill )
{
var billData = JsonConvert.Deserialize<List<WMSOUTmb>>(WMSList);
DBResult result = WMSDAL.Audit_OUT(Convert.ToString(Session["USERID"]), billData);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult AuditBack_OUT ( String WMSList, String bill, string reasean )
{
var billData = JsonConvert.Deserialize<List<WMSOUTmb>>(WMSList);
DBResult result = WMSDAL.AuditBack_OUT(Convert.ToString(Session["USERID"]), billData, reasean);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
#endregion
#region 获取编码规则的编码
//WmsEntity.WMSNO = getCodeRule("入库单号", "WMSNO", "WMS");//调用编码规则
public String getCodeRule(string strRULENAME, string strfield, string tablename, string DODATE)
{
//调用编码规则
string strRULEYEAR = "";
string strRULECONTENT = "";
string strCODENAME = "";
string strDEPTNO = "";
string strRULENOLENGTH = "";
int iRULENOLENGTH = 0;
int inum = 0;
string strCONTENT = "";
string USERID = CookieConfig.GetCookie_UserId(Request);
T_ALL_DA T_ALL_DA = new T_ALL_DA();
DataSet ds = T_ALL_DA.GetAllSQL("select * from code_rule where RULENAME='" + strRULENAME.Trim() + "' and RULETYPE=3");
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
{
//getCodeRuleEnabled(strRULENAME, strfield);
//
if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期"))
{
if (DODATE == "")
{
return "";
}
DateTime dETD = System.Convert.ToDateTime(DODATE);
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = dETD.ToString("yyyy") + dETD.ToString("MM");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = dETD.ToString("yy") + dETD.ToString("MM");
}
}
else
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = dETD.ToString("yyyy");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = dETD.ToString("yy");
}
}
}
else if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("自然月份"))
{
DateTime fwqdate = System.Convert.ToDateTime(T_ALL_DA.GetStrSQL("fwqdate", "select fwqdate=getdate()"));
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = fwqdate.ToString("yyyy") + fwqdate.ToString("MM");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = fwqdate.ToString("yy") + fwqdate.ToString("MM");
}
}
else
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = fwqdate.ToString("yyyy");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = fwqdate.ToString("yy");
}
}
}
//
if (ds.Tables[0].Rows[0]["ISCOMPANY"].ToString().Trim().Equals("True"))
{
strCODENAME = T_ALL_DA.GetStrSQL("CODENAME", "select CODENAME from [company] where GID=(select top 1 COMPANYID from user_company where USERID='" + USERID + "')");
}
if (ds.Tables[0].Rows[0]["ISDEPT"].ToString().Trim().Equals("True"))
{
strDEPTNO = T_ALL_DA.GetStrSQL("DEPTNO", "select DEPTNO from [sys_dept] where LINKID=(select top 1 COMPANYID from user_company where USERID='" + CookieConfig.GetCookie_UserId(Request) + "')");
}
strRULECONTENT = ds.Tables[0].Rows[0]["RULECONTENT"].ToString().Trim();
strRULECONTENT = strRULECONTENT.Replace("《COMPANY》", strCODENAME);
strRULECONTENT = strRULECONTENT.Replace("《DEPT》", strDEPTNO);
//
if (ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim() == "")
{
iRULENOLENGTH = 0;
}
else
{
iRULENOLENGTH = int.Parse(ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim());
}
strCONTENT = strRULECONTENT + strRULEYEAR;
//获取分公司的票号头字符
string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE codename='" + CookieConfig.GetCookie_OrgCode(Request) + "'");
strCONTENT = tempBANKSHEAD + strCONTENT;
//
strRULENOLENGTH = T_ALL_DA.GetStrSQL(strfield, "select top 1 " + strfield + " from [" + tablename + "] where " + strfield + " like '" + strCONTENT.Trim() + "%' and ISDELETE=0 order by " + strfield + " DESC");
if (strRULENOLENGTH == "")
{
strRULENOLENGTH = "1";
}
else
{
strRULENOLENGTH = strRULENOLENGTH.Replace(strCONTENT.Trim(), "");
inum = int.Parse(strRULENOLENGTH.Trim());
inum = inum + 1;
strRULENOLENGTH = inum.ToString();
}
int j = iRULENOLENGTH - strRULENOLENGTH.Length;
for (int i = 1; i <= j; i++)
{
strRULENOLENGTH = "0" + strRULENOLENGTH;
}
//
strCONTENT = strCONTENT + strRULENOLENGTH;
return strCONTENT;
}
}
}
return "";
}
public String getCodeRule(string _USERID,string ORGCODE, string strRULENAME, string strfield, string tablename, string DODATE )
{
//调用编码规则
string strRULEYEAR = "";
string strRULECONTENT = "";
string strCODENAME = "";
string strDEPTNO = "";
string strRULENOLENGTH = "";
int iRULENOLENGTH = 0;
int inum = 0;
string strCONTENT = "";
string USERID = _USERID;
T_ALL_DA T_ALL_DA = new T_ALL_DA();
DataSet ds = T_ALL_DA.GetAllSQL("select * from code_rule where RULENAME='" + strRULENAME.Trim() + "' and RULETYPE=3");
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
{
//getCodeRuleEnabled(strRULENAME, strfield);
//
if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期"))
{
if (DODATE == "")
{
return "";
}
DateTime dETD = System.Convert.ToDateTime(DODATE);
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = dETD.ToString("yyyy") + dETD.ToString("MM");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = dETD.ToString("yy") + dETD.ToString("MM");
}
}
else
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = dETD.ToString("yyyy");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = dETD.ToString("yy");
}
}
}
else if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("自然月份"))
{
DateTime fwqdate = System.Convert.ToDateTime(T_ALL_DA.GetStrSQL("fwqdate", "select fwqdate=getdate()"));
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = fwqdate.ToString("yyyy") + fwqdate.ToString("MM");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = fwqdate.ToString("yy") + fwqdate.ToString("MM");
}
}
else
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = fwqdate.ToString("yyyy");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = fwqdate.ToString("yy");
}
}
}
//
if (ds.Tables[0].Rows[0]["ISCOMPANY"].ToString().Trim().Equals("True"))
{
strCODENAME = T_ALL_DA.GetStrSQL("CODENAME", "select CODENAME from [company] where GID=(select top 1 COMPANYID from user_company where USERID='" + USERID + "')");
}
if (ds.Tables[0].Rows[0]["ISDEPT"].ToString().Trim().Equals("True"))
{
strDEPTNO = T_ALL_DA.GetStrSQL("DEPTNO", "select DEPTNO from [sys_dept] where LINKID=(select top 1 COMPANYID from user_company where USERID='" + USERID + "')");
}
strRULECONTENT = ds.Tables[0].Rows[0]["RULECONTENT"].ToString().Trim();
strRULECONTENT = strRULECONTENT.Replace("《COMPANY》", strCODENAME);
strRULECONTENT = strRULECONTENT.Replace("《DEPT》", strDEPTNO);
//
if (ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim() == "")
{
iRULENOLENGTH = 0;
}
else
{
iRULENOLENGTH = int.Parse(ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim());
}
strCONTENT = strRULECONTENT + strRULEYEAR;
//获取分公司的票号头字符
string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE codename='" + ORGCODE + "'");
strCONTENT = tempBANKSHEAD + strCONTENT;
//
strRULENOLENGTH = T_ALL_DA.GetStrSQL(strfield, "select top 1 " + strfield + " from [" + tablename + "] where " + strfield + " like '" + strCONTENT.Trim() + "%' and ISDELETE=0 order by " + strfield + " DESC");
if (strRULENOLENGTH == "")
{
strRULENOLENGTH = "1";
}
else
{
strRULENOLENGTH = strRULENOLENGTH.Replace(strCONTENT.Trim(), "");
inum = int.Parse(strRULENOLENGTH.Trim());
inum = inum + 1;
strRULENOLENGTH = inum.ToString();
}
int j = iRULENOLENGTH - strRULENOLENGTH.Length;
for (int i = 1; i <= j; i++)
{
strRULENOLENGTH = "0" + strRULENOLENGTH;
}
//
strCONTENT = strCONTENT + strRULENOLENGTH;
return strCONTENT;
}
}
}
return "";
}
protected void getCodeRuleEnabled(string strRULENAME, string strfield)
{
//是否生成之后允许编辑
T_ALL_DA T_ALL_DA = new T_ALL_DA();
DataSet ds = T_ALL_DA.GetAllSQL("select * from code_rule where RULENAME='" + strRULENAME.Trim() + "' and RULETYPE=3");
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
{
if (strfield == "BSNO")
{
if (ds.Tables[0].Rows[0]["ISALLOWEDITS"].ToString().Trim().Equals("True"))
{
//txt_outbsno.Disabled = false;
}
else
{
//txt_outbsno.Disabled = true;
}
}
}
}
}
}
public DataSet GetAllSQL(string strSQL)
{
DataSet DS = SqlHelper.OpenSqlDataSet(SqlHelper.ConnectionStringLocalTransaction, strSQL);
try
{
if (DS.Tables[0].Rows.Count <= 0)
{
DS = null;
}
}
catch
{
DS = null;
}
return DS;
}
#endregion
}
}