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.

259 lines
8.2 KiB
C#

11 months ago
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.Models.SysBillType;
using DSWeb.MvcShipping.Models.MsSysBillNoSet;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsSysBillNoSetController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
//
// GET
public ContentResult GetDataList(string condition,string sort)
{
var dataList = MsSysBillNoSetDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"]), 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)
{
SysBillNoSet head = null;
if (handle == "edit")
{
var list = MsSysBillNoSetDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"]));
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new SysBillNoSet();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult Save(string opstatus, string data)
{
var headData = JsonConvert.Deserialize<SysBillNoSet>(data);
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
var modb = new ModelObjectDB();
var GID = headData.GID;
DBResult result = modb.Save(headData);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsSysBillNoSetDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["COMPANYID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize<SysBillNoSet>(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<SysBillNoSet>>(body);
DBResult result = MsSysBillNoSetDAL.SaveBillSetDetail(bodyList, Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetBillTypeDataList(string condition, string sort)
{
var dataList = MsSysBillNoSetDAL.GetBillTypeDataList(condition, Convert.ToString(Session["COMPANYID"]), 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 GetBillTypeData(string handle, string condition)
{
BillType head = null;
if (handle == "edit")
{
var list = MsSysBillNoSetDAL.GetBillTypeDataList(condition, Convert.ToString(Session["COMPANYID"]));
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new BillType();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult SaveBillType(string opstatus, string data)
{
var headData = JsonConvert.Deserialize<BillType>(data);
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
var modb = new ModelObjectDB();
var GID = headData.GID;
DBResult result = modb.Save(headData);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsSysBillNoSetDAL.GetBillTypeData("GID='" + GID + "'", Convert.ToString(Session["COMPANYID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteBillType(string data)
{
var headData = JsonConvert.Deserialize<BillType>(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 SaveBillTypeDetail(string body)
{
var bodyList = JsonConvert.Deserialize<List<BillType>>(body);
DBResult result = MsSysBillNoSetDAL.SaveBillTypeDetail(bodyList, Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteBsNo(string custno)
{
DBResult result = MsSysBillNoSetDAL.DeleteBsNo(custno);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetNewNo(string bltype, string ruleblno, string etd, string accdate)
{
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='" + bltype + "' AND RULEBLNO='" + ruleblno + "'", Convert.ToString(Session["COMPANYID"]));
if (billnoset.BILLTYPE != "")
{
var custno = MsSysBillNoSetDAL.GetBillNo(billnoset, etd, accdate);
var jsonRespose = new JsonResponse { Success = true, Message = custno };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else {
var jsonRespose = new JsonResponse { Success =false, Message ="未设置生成规则,请先设置编号生成规则!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
#region 参照部分
#endregion
}
}