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

205 lines
7.3 KiB
C#

3 years ago
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.MsCodeFeeTemplate;
using DSWeb.MvcShipping.Models.MsCodeFeeTemplate;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
2 years ago
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Common.DB;
3 years ago
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsCodeFeeTemplateController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
//
// GET
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var dataList = MsCodeFeeTempldateDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetDataListStr(string sort, string condition)
{
var dataListStr = MsCodeFeeTempldateDAL.GetDataListStr(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
//
// GET/TruckMng/MsWlTyreAcc/GetData/
public ContentResult GetData(string handle, string condition)
{
CodeFeeTemplate head = null;
if (handle == "edit")
{
var list = MsCodeFeeTempldateDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new CodeFeeTemplate();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetBodyList(int start, int limit, string sort, string condition)
{
var dataList = MsCodeFeeTempldateDAL.GetBodyList(condition, sort);
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)
{
2 years ago
var canlogin = BasicDataRefDAL.CheckLogin(Session);
if (!canlogin.Success)
{
return (ContentResult)canlogin.Data;
}
3 years ago
var headData = JsonConvert.Deserialize<CodeFeeTemplate>(data);
var bodyList = JsonConvert.Deserialize<List<CodeFeeTemplateDetail>>(body);
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
headData.CREATEUSER = Convert.ToString(Session["USERID"]);
headData.CORPID = Convert.ToString(Session["COMPANYID"]);
headData.CREATETIME = DateTime.Now;
}
else if (opstatus == "edit")
{
2 years ago
if (!CanSave(headData))
{
var json = JsonConvert.Serialize(new { Success = false, Message = "不具备保存或删除的权限" });
return new ContentResult() { Content = json };
}
3 years ago
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
2 years ago
if (!CanSave(headData))
{
var json = JsonConvert.Serialize(new { Success = false, Message = "不具备保存或删除的权限" });
return new ContentResult() { Content = json };
}
3 years ago
headData.DbOperationType = DbOperationType.DbotDel;
}
var modb = new ModelObjectDB();
modb.Save(headData);
var GID = headData.GID;
DBResult result = MsCodeFeeTempldateDAL.SaveDetail(headData, bodyList, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsCodeFeeTempldateDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
2 years ago
/// <summary>
/// 删除
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
3 years ago
public ContentResult Delete(string data)
{
2 years ago
var canlogin = BasicDataRefDAL.CheckLogin(Session);
if (!canlogin.Success)
{
return (ContentResult)canlogin.Data;
}
3 years ago
var headData = JsonConvert.Deserialize<CodeFeeTemplate>(data);
2 years ago
if (!CanSave(headData))
{
var json = JsonConvert.Serialize(new { Success = false, Message = "不具备保存或删除的权限" });
return new ContentResult() { Content = json };
}
DBResult result =MsCodeFeeTempldateDAL.DeleteDetail(headData);
3 years ago
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetFeeUnit(string condition)
{
var dataList = MsCodeFeeTempldateDAL.GetFeeUnit(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
2 years ago
#region 查看权限 能否保存或删除
public bool CanSave(CodeFeeTemplate _head) {
var result = false;
var head = MsCodeFeeTempldateDAL.GetData("GID='" + _head.GID + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
var OperateRangeStr = BasicDataRefDAL.GetOperateRange("modCodeFeeTemplateSet", Convert.ToString(Session["USERID"]),"CORPID","CREATEUSER");
//operaterange = 0 全部 1分公司 2部门 3个人 4无
var candolist = MsCodeFeeTempldateDAL.GetDataList_Base("GID='" + head.GID + "' and " + OperateRangeStr);
if (candolist != null && candolist.Count > 0) {
result = true;
}
return result;
}
#endregion
3 years ago
#region 参照部分
#endregion
}
}