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

155 lines
4.2 KiB
C#

2 years ago
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.MsCrmClient;
using DSWeb.MvcShipping.Models.MsCrmClient;
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 MsCrmClientController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
public ActionResult VisitIndex()
{
return View();
}
//
// GET: /
public ActionResult VisitEdit()
{
return View();
}
public ActionResult VisitPlanIndex()
{
return View();
}
//
// GET: /
public ActionResult VisitPlanEdit()
{
return View();
}
//
// GET
public ContentResult GetVisitDataList(int start, int limit, string sort, string condition)
{
var totel = 0;
var dataList = MsCrmClientDAL.GetVisitDataList(condition, start, limit, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), out totel, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = totel, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
//
// GET/TruckMng/MsWlTyreAcc/GetData/
public ContentResult GetVisitData(string handle, string condition)
{
MsCrmClientVisit head = null;
if (handle == "edit")
{
head = MsCrmClientDAL.GetVisitData(condition);
}
if (head == null)
{
head = new MsCrmClientVisit();
head.SALE= Convert.ToString(Session["SHOWNAME"]);
head.VISITDATE = DateTime.Now.ToString("yyyy-MM-dd");
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult SaveVisit(string opstatus, string data)
{
var headData = JsonConvert.Deserialize<MsCrmClientVisit>(data);
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
headData.CREATEUSER = Convert.ToString(Session["USERID"]);
headData.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
if (headData.VISITDATE == "") headData.VISITDATE = null;
if (headData.NEXTDATE == "") headData.NEXTDATE = null;
var modb = new ModelObjectDB();
var result=modb.Save(headData);
var GID = headData.GID;
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsCrmClientDAL.GetVisitData("GID='" + GID + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteVisit(string data)
{
var headData = JsonConvert.Deserialize<MsCrmClientVisit>(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) };
}
#region 参照部分
#endregion
}
}