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/MsCwAccitemsDaterpControlle...

165 lines
5.1 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.MsCwAccitemsDaterp;
using DSWeb.MvcShipping.Models.MsCwAccitemsDaterp;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.Areas.CommMng.DAL;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsCwAccitemsDaterpController : 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 = MsCwAccitemsDaterpDAL.GetDataList(condition, 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 = MsCwAccitemsDaterpDAL.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)
{
CwAccitemsDateRp head = null;
if (handle == "edit")
{
var list = MsCwAccitemsDaterpDAL.GetDataList(condition);
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new CwAccitemsDateRp();
head.NOSAVERMBAMT = 0;
head.NOSAVEUSDAMT = 0;
head.GIFTAMT = 0;
head.ENTERTAINMENTAMT = 0;
head.TRAVELLINGAMT = 0;
head.OFFICESUPPLIESAMT = 0;
head.AUTOREPAIRAMT = 0;
head.ADPRINTINGAMT = 0;
head.CREATETIME = DateTime.Now;
head.CREATEUSERREF = Convert.ToString(Session["SHOWNAME"]);
head.CREATEUSER = Convert.ToString(Session["USERID"]);
head.OPDATE = DateTime.Now.ToString("yyyy-MM-dd");
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetBodyList( string sort, string condition)
{
var dataList = MsCwAccitemsDaterpDAL.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, string condit)
{
var headData = JsonConvert.Deserialize<CwAccitemsDateRp>(data);
var bodyList = JsonConvert.Deserialize<List<CwAccitemsDateRpDetail>>(body);
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
headData.CREATEUSER = Convert.ToString(Session["USERID"]);
headData.CREATETIME = DateTime.Now;
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
headData.ACCDATE = headData.OPDATE.Substring(7);
var modb = new ModelObjectDB();
modb.Save(headData);
var GID = headData.GID;
DBResult result = MsCwAccitemsDaterpDAL.SaveDetail(headData, bodyList,Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsCwAccitemsDaterpDAL.GetData("GID='" + GID + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize<CwAccitemsDateRp>(data);
DBResult result = MsCwAccitemsDaterpDAL.DeleteDetail(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 参照部分
#endregion
}
}