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

180 lines
5.5 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.Models.CodePackage;
using DSWeb.MvcShipping.DAL.MsCodePackage;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using System.Collections.Generic;
using DSWeb.SoftMng.Filter;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.MvcShipping.Models.CodeCtnEdi;
using DSWeb.MvcShipping.DAL.MsCodeCtnEdi;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsCodePackageController : Controller
{
//
// GET:
//[ModuleAuthFilter(Name = "modCodeBltype")]//权限过滤器
public ActionResult Index()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
//
// GET
public ContentResult GetDataList(string condition,string sort)
{
var dataList = MsCodePackageDAL.GetDataList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
//
// GET/TruckMng/MsWlTyreAcc/GetData/
public ContentResult GetData(string handle, string condition)
{
CodePackage head = null;
if (handle == "edit")
{
var list = MsCodePackageDAL.GetDataList(condition);
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new CodePackage();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult Save(string opstatus, string data,string body)
{
var headData = JsonConvert.Deserialize<CodePackage>(data);
var bodyList = JsonConvert.Deserialize<List<CodeCtnEdi>>(body);
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
var ct = MsCodePackageDAL.GetRdCount("GID<>'" + headData.GID + "' AND PKGS='" + headData.PKGS + "'");
if (ct != 0)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "包装类型不能重复!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
var copybodylist = new List<CodeCtnEdi>();
var ismost = false;
if (bodyList != null && bodyList.Count != 0)
{
foreach (var PORTEDI in bodyList)
{
PORTEDI.CTN = headData.PKGS;
var addbody = copybodylist.Find(x => x.EDINAME == PORTEDI.EDINAME && x.CTN == PORTEDI.CTN);
if (addbody != null)
{
ismost = true;
}
else
{
var newbody = new CodeCtnEdi();
newbody.EDINAME = PORTEDI.EDINAME;
newbody.CTN = PORTEDI.CTN;
copybodylist.Add(newbody);
}
}
}
if (ismost)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "EDI代码设置不允许重复" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
var modb = new ModelObjectDB();
var GID = headData.GID;
DBResult result = modb.Save(headData);
if (result.Success) {
MsCodeCtnEdiDAL.SavePkgsDetail(bodyList, Convert.ToString(Session["COMPANYID"]));
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsCodePackageDAL.GetData("GID='" + GID + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize<CodePackage>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveDetail(string body)
{
var bodyList = JsonConvert.Deserialize<List<CodePackage>>(body);
DBResult result = MsCodePackageDAL.SaveDetail(bodyList);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 参照部分
#endregion
}
}