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.

135 lines
4.2 KiB
C#

10 months ago
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.MsCodeServiceFeeTemplateDAL;
using DSWeb.MvcShipping.Models.MsCodeServiceFeeTemplate;
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 MsCodeServiceFeeTemplateController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
//
// GET
public ContentResult GetDataList(string condition)
{
var dataList = MsCodeServiceFeeTemplateDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
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)
{
MsCodeServiceFeeTemplate head = null;
if (handle == "edit")
{
var list = MsCodeServiceFeeTemplateDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new MsCodeServiceFeeTemplate();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetBodyList(string condition)
{
var dataList = MsCodeServiceFeeTemplateDAL.GetBodyList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult Save(string opstatus, string data, string body, string bodywork)
{
var headData = JsonConvert.Deserialize<MsCodeServiceFeeTemplate>(data);
var bodyList = JsonConvert.Deserialize<List<MsCodeServiceFeeTemplateDetail>>(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 modb = new ModelObjectDB();
modb.Save(headData);
var OS_ID = headData.GID;
DBResult result = MsCodeServiceFeeTemplateDAL.SaveDetail(headData, bodyList);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsCodeServiceFeeTemplateDAL.GetData("GID='" + OS_ID + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
//
// GET/Import/Cargoinfo/Delete
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize<MsCodeServiceFeeTemplate>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(headData);
if (result.Success == true) { MsCodeServiceFeeTemplateDAL.DeleteDetail(headData); }
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 参照部分
#endregion
}
}