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

135 lines
4.2 KiB
C#

3 years ago
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.Models.MsCodeCountry;
using DSWeb.MvcShipping.DAL.MsCodeCountry;
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 MsCodeCountryController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
//
// GET
public ContentResult GetDataList(int start, int limit, string condition,string sort)
{
var dataList = MsCodeCountryDAL.GetDataList(start, limit, condition, Convert.ToString(Session["COMPANYID"]), sort);
int count = MsCodeCountryDAL.getTotalCount(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
//
// GET/TruckMng/MsWlTyreAcc/GetData/
public ContentResult GetData(string handle, string condition)
{
CodeCountry head = null;
if (handle == "edit")
{
var list = MsCodeCountryDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"]));
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new CodeCountry();
}
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<CodeCountry>(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 = MsCodeCountryDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["COMPANYID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult Delete(string data)
{
var datalist = JsonConvert.Deserialize<List<CodeCountry>>(data);
var modb = new ModelObjectDB();
DBResult result = new DBDataSetResult();
var jsonRespose = new JsonResponse { Success = false, Message = "删除失败" };
foreach (var item in datalist)
{
result = modb.Delete(item);
if (!result.Success)//有失败直接返回结果
return new ContentResult { Content = JsonConvert.Serialize(jsonRespose) };
}
jsonRespose = new JsonResponse { Success = true, Message = "删除成功" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveDetail(string body)
{
var bodyList = JsonConvert.Deserialize<List<CodeCountry>>(body);
DBResult result = MsCodeCountryDAL.SaveDetail(bodyList, Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 参照部分
#endregion
}
}