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/MsCwCarryOverController.cs

144 lines
8.4 KiB
C#

using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.MsCwCarryOverDAL;
using DSWeb.MvcShipping.Models.MsCwCarryOver;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using HcUtility.Comm;
using HcUtility.Core;
using System.Collections.Generic;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
using DSWeb.EntityDA;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsCwCarryOverController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
public ContentResult GetDataList(string condition)
{
var dataList = MsCwCarryOverDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetData(string condition)
{
MsCwVouchersGl2 head = MsCwCarryOverDAL.GetData(condition, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetMaxVou(string VKNO,string vktype,string VOUDATE)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var VOUNO = "";
if (vktype == "2") {
VOUNO = T_ALL_DA.GetStrSQL("VOUNO", "select isnull((select top 1 (VOUNO+2) from Cw_Vouchers_Gl WHERE STARTGID=(select top 1 GID from cw_design_startusing WITH(NOLOCK) where (ISDELETE=0 or ISDELETE is null) and ISENABLE=1 and GID=(select top 1 STARTGID from [cw_design_startusing_user] WITH(NOLOCK) where USERGID='" + Convert.ToString(Session["USERID"]) + "')) and VKNO='" + VKNO + "' and SUBSTRING(convert(varchar,VOUDATE,23),1,7)=SUBSTRING(convert(varchar,'"+VOUDATE+"',23),1,7) AND (CarryOverType='' or CarryOverType is NULL) ORDER by convert(int,VOUNO) desc),'1') AS VOUNO");
}
else
VOUNO = T_ALL_DA.GetStrSQL("VOUNO", "select isnull((select top 1 (VOUNO+1) from Cw_Vouchers_Gl WHERE STARTGID=(select top 1 GID from cw_design_startusing WITH(NOLOCK) where (ISDELETE=0 or ISDELETE is null) and ISENABLE=1 and GID=(select top 1 STARTGID from [cw_design_startusing_user] WITH(NOLOCK) where USERGID='" + Convert.ToString(Session["USERID"]) + "')) and VKNO='"+VKNO+ "' and SUBSTRING(convert(varchar,VOUDATE,23),1,7)=SUBSTRING(convert(varchar,'" + VOUDATE + "',23),1,7) AND (CarryOverType='' or CarryOverType is NULL) ORDER by convert(int,VOUNO) desc),'1') AS VOUNO");
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = VOUNO });
return new ContentResult() { Content = json };
}
#region 生成结转凭证
public ContentResult AddEdit(string dataHead, string dataQMTH, string dataJZSY, string dataGJSZ, string jsonBody)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var headData = JsonConvert.Deserialize<MsCwVouchersGl2>(dataHead.Replace("}", ",") + dataQMTH.Replace("{", "").Replace("}", ",") + dataJZSY.Replace("{", "").Replace("}", ",") + dataGJSZ.Replace("{", ""));
List<MsCwVouitemsGl2> bodyList = new List<MsCwVouitemsGl2>();
if (jsonBody != null)
{
bodyList = JsonConvert.Deserialize<List<MsCwVouitemsGl2>>(jsonBody);
}
DBResult result = MsCwCarryOverDAL.AddEdit(headData, bodyList, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
//
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsCwCarryOverDAL.GetData("", Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 结转到下期
public ContentResult Save(string dataHead, string dataQMTH, string dataJZSY, string dataGJSZ)
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var headData = JsonConvert.Deserialize<MsCwVouchersGl2>(dataHead.Replace("}", ",") + dataQMTH.Replace("{", "").Replace("}", ",") + dataJZSY.Replace("{", "").Replace("}", ",") + dataGJSZ.Replace("{", ""));
List<MsCwVouitemsGl2> bodyList = new List<MsCwVouitemsGl2>();
DBResult result = MsCwCarryOverDAL.Save(headData, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
//
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsCwCarryOverDAL.GetData("", Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 返结转到上期
public ContentResult SaveReturn()
{
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
List<MsCwVouitemsGl2> bodyList = new List<MsCwVouitemsGl2>();
DBResult result = MsCwCarryOverDAL.SaveReturn(Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
//
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsCwCarryOverDAL.GetData("", Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 判断凭证是否连号
public ContentResult isSave(string dataHead, string dataQMTH, string dataJZSY, string dataGJSZ)
{
var headData = JsonConvert.Deserialize<MsCwVouchersGl2>(dataHead.Replace("}", ",") + dataQMTH.Replace("{", "").Replace("}", ",") + dataJZSY.Replace("{", "").Replace("}", ",") + dataGJSZ.Replace("{", ""));
List<MsCwVouitemsGl2> bodyList = new List<MsCwVouitemsGl2>();
DBResult result = MsCwCarryOverDAL.isSave(headData, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
//
}
}