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.

155 lines
6.2 KiB
C#

using System;
using System.Linq;
using System.Web.Mvc;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
using System.Web.Script.Serialization;
using DSWeb.EntityDA;
using System.Data;
using System.Text;
using DSWeb.TruckMng.Comm.Cookie;
using DSWeb.Areas.MvcShipping.Models.MsOpSeaeTDSFTTemplate;
using DSWeb.Areas.MvcShipping.DAL.MsOpSeaeTDSFTTemplate;
using System.IO;
using DSWeb.MvcShipping.Helper;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsOpSeaeTDSFTTemplateController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
public ActionResult InEdit()
{
return View();
}
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
int count = 0;
string showname = Convert.ToString(Session["SHOWNAME"]);
string userid = Convert.ToString(Session["USERID"]);
string comid = Convert.ToString(Session["COMPANYID"]);
var dataList = MsOpSeaeTDSFTTemplateDAL.GetDataList(condition, userid, comid, showname, start, 100, out count, sort);
var timeStamp = DateTime.Now.ToShortDateString();
var json = JsonConvert.Serialize(new { success = true, Message = "查询成功", totalCount = count, data = dataList.ToList(), timeStamp = timeStamp });
return new ContentResult() { Content = json };
}
public ContentResult GetData(string OpStatus, string condition)
{
string userid = Convert.ToString(Session["USERID"]);
string showname = Convert.ToString(Session["SHOWNAME"]);
string comid = Convert.ToString(Session["COMPANYID"]);
int count = 0;
if (OpStatus == "add")
{
MsOpSeaeTDSFTTemplateModel et = new MsOpSeaeTDSFTTemplateModel();
et.gid = Guid.NewGuid().ToString();
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = et });
return new ContentResult() { Content = json };
}
else
{
var dataList = MsOpSeaeTDSFTTemplateDAL.GetDataList(condition, userid, comid, showname, 0, 1, out count);
if (dataList.Count > 0)
{
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList.ToList()[0] });
return new ContentResult() { Content = json };
}
else
{
var json = JsonConvert.Serialize(new { Success = true, Message = "无此数据", data = "" });
return new ContentResult() { Content = json };
}
}
}
public ContentResult Save(string opstatus, string data)
{
string userid = Convert.ToString(Session["USERID"]);
string comid = Convert.ToString(Session["COMPANYID"]);
var head = JsonConvert.Deserialize<MsOpSeaeTDSFTTemplateModel>(data);
head.userid = userid;
string msg = "";
int saveType = opstatus == "add" ? 0 : 1;
bool result = MsOpSeaeTDSFTTemplateDAL.Save(head, saveType, out msg);
var json = JsonConvert.Serialize(new { Success = result, Message = msg, Data = head.gid });
return new ContentResult() { Content = json };
}
public ContentResult Submit()
{
string userid = Convert.ToString(Session["USERID"]);
string comid = Convert.ToString(Session["COMPANYID"]);
string opstatus = Request["OpStatus"];
string data = Request["data"];
var head = JsonConvert.Deserialize<MsOpSeaeTDSFTTemplateModel>(data);
head.userid = userid;
head.createtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
string msg = "";
int saveType = opstatus == "add" ? 0 : 1;
if (saveType==0)
{
bool has = MsOpSeaeTDSFTTemplateDAL.GetIsExist(head.mbname, head.userid);
if (has)
{
var json2 = JsonConvert.Serialize(new { success = false, Message = "已存在此模板名!" });
return new ContentResult() { Content = json2 };
}
}
bool result = MsOpSeaeTDSFTTemplateDAL.Save(head, saveType, out msg);
var json = JsonConvert.Serialize(new { success = result, Message = msg, Data = head.gid });
return new ContentResult() { Content = json };
//string userid = Convert.ToString(Session["USERID"]);
//string comid = Convert.ToString(Session["COMPANYID"]);
//string opstatus = Request["OpStatus"];
//string data = Request["data"];
//var head = JsonConvert.Deserialize<MsOpSeaeTDSFTTemplateModel>(data);
//head.userid = userid;
//bool has = MsOpSeaeTDSFTTemplateDAL.GetIsExist(head.mbname, head.userid);
//if (has)
//{
// var json = JsonConvert.Serialize(new { Success = false, Message = "已存在此模板名!" });
// return new ContentResult() { Content = json };
//}
//else
//{
// string msg = "";
// int saveType = opstatus == "add" ? 0 : 1;
// bool result = MsOpSeaeTDSFTTemplateDAL.Save(head, saveType, out msg);
// var json = JsonConvert.Serialize(new { Success = result, Message = msg });
// return new ContentResult() { Content = json };
//}
}
public ContentResult Delete(string opstatus, string data)
{
var head = JsonConvert.Deserialize<List<MsOpSeaeTDSFTTemplateModel>>(data);
string msg = "";
bool result = MsOpSeaeTDSFTTemplateDAL.Delete(head, out msg);
var json = JsonConvert.Serialize(new { Success = result, Message = msg });
return new ContentResult() { Content = json };
}
}
}