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.

102 lines
3.0 KiB
C#

11 months ago
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.MsStevedores;
using DSWeb.MvcShipping.Models.MsStevedores;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.MvcShipping.Helper.Repository;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsStevedoresController : 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)
{
int total = 0;
var dataList = MsStevedoresDAL.GetDataList(condition,start,limit,out total,sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = total, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
//
// GET/TruckMng/MsWlTyreAcc/GetData/
public ContentResult GetData(string handle, string condition)
{
Stevedores head = null;
var timeStamp = DateTime.Now.ToShortDateString();
if (handle == "edit")
{
head = MsStevedoresDAL.GetData(condition);
}
if (head == null)
{
head = new Stevedores();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head, timeStamp = timeStamp });
return new ContentResult() { Content = json };
}
public ContentResult Delete(string data)
{
string msg = "";
var headData = JsonConvert.Deserialize<List<Stevedores>>(data);
bool result = MsStevedoresDAL.Delete(headData,out msg);
var jsonRespose = new JsonResponse { Success = result, Message = msg };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult Save ( string opstatus, string data )
{
var head = JsonConvert.Deserialize<Stevedores>(data);
bool rst = false;
string outmsg = "";
if (opstatus == "add")
{
head.GID = Guid.NewGuid().ToString();
rst = MsStevedoresDAL.Save(head, 0, out outmsg);
}
else if (opstatus == "edit")
{
rst= MsStevedoresDAL.Save(head, 1,out outmsg);
}
var jsonRespose = new JsonResponse();
jsonRespose.Success = rst;
jsonRespose.Message = outmsg;
jsonRespose.Data = MsStevedoresDAL.GetData(" GID='" + head.GID + "'");
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
}