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.

202 lines
7.3 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.MsOpApplyServiceDAL;
using DSWeb.MvcShipping.Models.MsOpApplyService;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using HcUtility.Comm;
using HcUtility.Core;
using System.Collections.Generic;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsOpApplyServiceController : 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 = MsOpApplyServiceDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
//
// GET/TruckMng/MsWlTyreAcc/GetData/
public ContentResult GetData(string handle, string BsNo, string OPField)
{
MsOpApplyService head = null;
var condition = " BsNo='" + BsNo + "' and OPField='" + OPField + "'";
var list = MsOpApplyServiceDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request));
if (list.Count > 0)
head = list[0];
if (head == null)
{
head = new MsOpApplyService();
head.OPFIELD = OPField;
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetServiceDetailList(string BsNo, string OPField, string sort)
{
var dataList = MsOpApplyServiceDAL.GetBodyList(" BsNo='" + BsNo + "' and OPField='" + OPField + "'", sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult Save(string bsno, string data, string body)
{
var headData = JsonConvert.Deserialize<MsOpApplyService>(data);
var bodyList = JsonConvert.Deserialize<List<MsOpApplyServiceDetail>>(body);
if (headData.BSNO == "*")
{
headData.DbOperationType = DbOperationType.DbotIns;
}
else
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
if (headData.BSNO =="*") { headData.BSNO = bsno; }
var modb = new ModelObjectDB();
modb.Save(headData);
var BSNO = headData.BSNO;
DBResult result = MsOpApplyServiceDAL.SaveDetail(headData, bodyList);
var condition = " BsNo='" + headData.BSNO + "' and OPField='" + headData.OPFIELD + "'";
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsOpApplyServiceDAL.GetData(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
//
// GET/TruckMng/MsWlTyreAcc/Save
/*
public ContentResult Save(string opstatus, string data)
{
FeeTemplate head = JsonConvert.Deserialize<FeeTemplate>(data);
if (opstatus == "add")
{
head.DbOperationType = DbOperationType.DbotIns;
head.OrgCode = CookieConfig.GetCookie_OrgCode(Request);
}
else if (opstatus == "edit")
{
head.DbOperationType = DbOperationType.DbotUpd;
}
else
{
head.DbOperationType = DbOperationType.DbotDel;
}
var modb = new ModelObjectDB();
DBResult result = modb.Save(head);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsWlTyreAccDAL.GetData("SerialNo=" + head.SerialNo + "", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
*/
public ContentResult GetDataViewList(int start, int limit, string sort, string condition)
{
var dataList = MsOpApplyServiceDAL.GetDataViewList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]),sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
//
// GET/TruckMng/MsWlTyreAcc/GetData/
public ContentResult GetViewData(string handle, string BsNo)
{
MsOpApplyServiceView head = null;
var condition = " s.BsNo='" + BsNo + "'";
var list = MsOpApplyServiceDAL.GetDataViewList(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 MsOpApplyServiceView();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult Delete(string data)
{
var head = JsonConvert.Deserialize<MsOpApplyService>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(head);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 参照部分
#endregion
}
}