using System;
using System.Linq;
using System.Web.Mvc;
using System.Collections.Generic;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.Import.DAL;
using DSWeb.Areas.Import.DAL.Cargoinfo;
using DSWeb.Areas.Import.Models.Cargoinfo;
using DSWeb.Areas.Import.Models.Cargociq;
using DSWeb.TruckMng.Comm.Cookie;
using DSWeb.TruckMng.Helper;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.TruckMng.Helper.Repository;
namespace DSWeb.Areas.Import.Controllers
{
///
///
///
[JsonRequestBehavior]
public class cargoinfoController : Controller
{
//
// GET: /Import/cargoinfo/
public ActionResult Index()
{
return View();
}
//
// GET: /Import/cargoinfo/Edit
public ActionResult Edit()
{
return View();
}
//
// GET:/Import/cargoinfo/GetDataList
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var dataList = CargoinfoDAL.GetDataList(condition);
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:/Import/Cargoinfo/GetData/
public ContentResult GetData(string handle, string condition)
{
Import_Cargoinfo headData = null;
if (handle == "edit")
{
var list = CargoinfoDAL.GetDataList(condition);
if (list.Count > 0)
headData = list[0];
}
if (headData == null)
{
headData = new Import_Cargoinfo();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = headData });
return new ContentResult() { Content = json };
}
//
// GET:/Import/CargoInfo/Save
public ContentResult Save(string opstatus, string data, string CIQbody, string CIQDELbody)
{
var headData = JsonConvert.Deserialize(data);
var bodyList = JsonConvert.Deserialize>(CIQbody);
var bodyDelList = JsonConvert.Deserialize>(CIQDELbody);
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
headData.ModelUIStatus = "I";
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
/*
var modb = new ModelObjectDB();
modb.Save(headData);
var cargoid = CargoinfoDAL.GetCargoid(Convert.ToString(headData.Code));
DBResult result = CargoinfoDAL.Save(headData, bodyList, Convert.ToString(cargoid));
*/
var modb = new ModelObjectRepository();
DBResult result = modb.Save(headData,
ModelObjectConvert.ToModelObjectList(bodyList),
ModelObjectConvert.ToModelObjectList(bodyDelList)
);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = CargoinfoDAL.GetHeadData(Convert.ToString(" code='"+headData.Code+"' "))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
//
// GET:/Import/Cargoinfo/Delete
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize(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) };
}
public ContentResult GetBodyList(int cargoid)
{
var condition = " CargoinfoID="+cargoid;
List list = CargoinfoDAL.GetBodyList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
#region 参照部分
#endregion
}
}