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/Import/Controllers/FactoryCargoNameController.cs

212 lines
6.6 KiB
C#

3 years ago
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.FactoryCargoName;
using DSWeb.Areas.Import.Models.CargoName;
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
{
/// <summary>
///
/// </summary>
[JsonRequestBehavior]
public class FactoryCargoNameController : Controller
{
//
// GET: /Import/cargoinfo/
public ActionResult Index()
{
return View();
}
//
// GET: /Import/cargoinfo/Edit
public ActionResult Edit()
{
return View();
}
//
// GET/Import/cargoinfo/GetDataList
public ContentResult GetFactoryNoList(int start, int limit, string sort, string condition)
{
var dataList = FactoryCargoNameDAL.GetFactoryNoList2(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 };
}
public ContentResult GetData ( string handle, string condition )
{
Import_FactoryNo2 head = null;
if (handle == "edit" || handle == "view" || handle == "copynew")
{
var list = FactoryCargoNameDAL.GetFactoryNoList2(condition);
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new Import_FactoryNo2();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetCargoNameList(int start, int limit, string sort, string condition)
{
var dataList = FactoryCargoNameDAL.GetCargoNameList2(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/
//
// GET/Import/CargoInfo/Save
public ContentResult Save(string opstatus, string data , string CargoNamebody, string CargoNameDelbody)
{
var head = JsonConvert.Deserialize<Import_FactoryNo2>(data);
var CargoNameList = JsonConvert.Deserialize<List<Import_CargoName2>>(CargoNamebody);
var CargoNameDelList = JsonConvert.Deserialize<List<Import_CargoName2>>(CargoNameDelbody);
if (opstatus == "add")
{
head.DbOperationType = DbOperationType.DbotIns;
head.ModelUIStatus = "I";
head.GID = Guid.NewGuid().ToString() ; //获取合同号
}
else if (opstatus == "edit")
{
head.DbOperationType = DbOperationType.DbotUpd;
head.ModelUIStatus = "E";
}
else
{
head.DbOperationType = DbOperationType.DbotDel;
}
if (!string.IsNullOrWhiteSpace(CargoNamebody)) {
//看枚举类型30内的信息
var cargotypelist = BasicDataRefDAL.GetTSysEnumValueListByTypeid("30");
foreach (var cargoname in CargoNameList) {
if (string.IsNullOrWhiteSpace(cargoname.CARGOTYPE)) {
setcargotype(cargoname, cargotypelist);
}
}
}
var modb = new ModelObjectRepository();
DBResult result = modb.Save(head,
ModelObjectConvert<Import_CargoName2>.ToModelObjectList(CargoNameList),
ModelObjectConvert<Import_CargoName2>.ToModelObjectList(CargoNameDelList)
);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = FactoryCargoNameDAL.GetData("GID='" + head.GID + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
private void setcargotype(Import_CargoName2 cargoname, List<CommMng.Models.TSysEnumValueDataModel> cargotypelist) {
foreach (var enumitem in cargotypelist) {
if (cargoname.CNNAME.IndexOf(enumitem.EnumValueName) >= 0) {
cargoname.CARGOTYPE = enumitem.EnumValueName;
return;
}
}
}
public ContentResult Delete ( string data )
{
var head = JsonConvert.Deserialize<Import_FactoryNo2>(data);
var modb = new ModelObjectDB();
var USERID = CookieConfig.GetCookie_UserId(Request);
DBResult result = modb.Delete(head);
var ContractNo = head.GID;
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
//为了清除用证信息
//var _count = 0;
//_count = FactoryCargoNameDAL.DELUseApp(ContractNo);
//_count = _count + XXHDAL.ClearHTH(ContractNo);
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
//
// GET/Import/Cargoinfo/Delete
/*
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize<Import_Cargoinfo>(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<Import_Cargociq> 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
}
}