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

244 lines
11 KiB
C#

2 years ago
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.MsCrmKeyCodeSetDAL;
using DSWeb.MvcShipping.Models.MsCrmKeyCodeSet;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using HcUtility.Comm;
using HcUtility.Core;
using System.Collections.Generic;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.DAL;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsCrmKeyCodeSetController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
public ContentResult GetDataList(string condition)
{
var dataList = MsCrmKeyCodeSetDAL.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 };
}
public ContentResult GetData(string condition)
{
MsCrmKeyCodeSet head = null;
head = MsCrmKeyCodeSetDAL.GetData(condition, Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult Save(string body, string condition)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
string errorstr = "";
var isPost = true;
var bodyList = JsonConvert.Deserialize<List<MsCrmKeyCodeSet>>(body);
//
if (isPost)
{
var modb = new ModelObjectDB();
DBResult result = null;
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
#region 默认值
MsCrmKeyCodeSet headRow = new MsCrmKeyCodeSet();
headRow.KEYTYPE = enumValue.KEYTYPE == null ? "" : enumValue.KEYTYPE.ToString().Trim();//上级ID
headRow.KEYVALUE = enumValue.KEYVALUE == null ? "" : enumValue.KEYVALUE.ToString().Trim();//值
//
if (enumValue.ID.ToString().Trim() == "*")
{
headRow.ID = Guid.NewGuid().ToString();//唯一编码
headRow.DbOperationType = DbOperationType.DbotIns;
}
else//"edit"
{
headRow.ID = enumValue.ID.ToString().Trim();//唯一编码
headRow.DbOperationType = DbOperationType.DbotUpd;
headRow.ModelUIStatus = "E";
}
#endregion
//
modb = new ModelObjectDB();
result = modb.Save(headRow);
if (result.Message.ToString().IndexOf("插入重复键") > -1)
{
errorstr += "重复数据不再重复插入!";
}
}
}
//
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsCrmKeyCodeSetDAL.GetData(condition, Convert.ToString(Session["COMPANYID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = errorstr + "重复,不允许保存!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult Delete(string data)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var modb = new ModelObjectDB();
var head = JsonConvert.Deserialize<MsCrmKeyCodeSet>(data);
DBResult result = modb.Delete(head);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 键值类别
public ContentResult GetCrmKeyCodeSet(string condition)
{
var dataList = MsCrmKeyCodeSetDAL.GetCrmKeyCodeSet(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList.ToList() });
return new ContentResult() { Content = json };
}
#endregion
public ContentResult GetDataList2(string condition)
{
var dataList = MsCrmKeyCodeSetDAL.GetDataList2(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GeEnumerationList(string condition)
{
return GetDataList2(condition);
}
public ContentResult GetData2(string condition)
{
Sys_EnumerationMD head = null;
head = MsCrmKeyCodeSetDAL.GetData2(condition);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult Save2(string body, string condition)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
string errorstr = "";
var isPost = true;
var bodyList = JsonConvert.Deserialize<List<Sys_EnumerationMD>>(body);
//
if (isPost)
{
var modb = new ModelObjectDB();
DBResult result = null;
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
#region 默认值
Sys_EnumerationMD headRow = new Sys_EnumerationMD();
headRow.NAME= enumValue.NAME.ToString().Trim();
headRow.VALUE = enumValue.VALUE.ToString().Trim();
headRow.TYPE = enumValue.TYPE.ToString().Trim();
if (enumValue.GID.ToString().Trim() == "*")
{
headRow.GID = Guid.NewGuid().ToString();//唯一编码
headRow.DbOperationType = DbOperationType.DbotIns;
}
else//"edit"
{
headRow.GID = enumValue.GID.ToString().Trim();//唯一编码
headRow.DbOperationType = DbOperationType.DbotUpd;
headRow.ModelUIStatus = "E";
}
#endregion
//
modb = new ModelObjectDB();
result = modb.Save(headRow);
if (result.Message.ToString().IndexOf("插入重复键") > -1)
{
errorstr += "重复数据不再重复插入!";
}
}
}
//
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsCrmKeyCodeSetDAL.GetData(condition, Convert.ToString(Session["COMPANYID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = errorstr + "重复,不允许保存!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult Delete2(string data)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var modb = new ModelObjectDB();
var head = JsonConvert.Deserialize<Sys_EnumerationMD>(data);
DBResult result = modb.Delete(head);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 键值类别
public ContentResult GetEnumerationType()
{
var dataList = MsCrmKeyCodeSetDAL.GetEnumerationType();
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList.ToList() });
return new ContentResult() { Content = json };
}
#endregion
}
}