using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using DSWeb.Areas.TruckMng.Models.Comm; using DSWeb.Areas.CommMng.DAL; using DSWeb.Areas.Import.DAL.XXH; using DSWeb.Areas.Import.Models.XXH; using DSWeb.Areas.Import.Models.create; using DSWeb.TruckMng.Comm.Cookie; using DSWeb.TruckMng.Helper; using DSWeb.TruckMng.Helper.Repository; using HcUtility.Comm; using HcUtility.Core; using DSWeb.SoftMng.Filter; namespace DSWeb.Areas.Import.Controllers { [JsonRequestBehavior] public class createController : Controller { // // GET: /Import/create //[ModuleAuthFilter(Name = "modXXH_create")]//权限过滤器 public ActionResult Index() { return View(); } // // GET: /Import/create/Edit public ActionResult Edit() { return View(); } public ActionResult Index2 ( ) { return View(); } // // GET: /Import/create/Edit public ActionResult Edit2 ( ) { return View(); } // // GET:/Import/create/Save public ContentResult Save ( string opstatus, string data, string CargoBody, string CargoDelBody ) { var head = JsonConvert.Deserialize(data); var CargobodyList = JsonConvert.Deserialize>(CargoBody); var CargodelbodyList = JsonConvert.Deserialize>(CargoDelBody); head.MODIFIEDUSER = Session["SHOWNAME"].ToString(); head.MODIFIEDTIME = System.DateTime.Now.ToString(); if (opstatus == "add") { head.DbOperationType = DbOperationType.DbotIns; head.ModelUIStatus = "I"; if (head.Mainstate == "") { head.Mainstate = "0"; } head.ContractNo = PubSysDAL.GetBillNo("0201"); //获取合同号 head.MODIFIEDUSER = Session["SHOWNAME"].ToString(); head.MODIFIEDTIME = System.DateTime.Now.ToString(); head.CORPID = Convert.ToString(Session["COMPANYID"]); //20131011 应客户要求,将合同号改为接单人手动填写的必填项目。不再自动生成合同号 /*自动填写接单审单人id headData.UserCode = CookieConfig.GetCookie_UserCode(Request); headData.UserName = CookieConfig.GetCookie_UserName(Request); headData.OrgCode = CookieConfig.GetCookie_OrgCode(Request); headData.OrgName = CookieConfig.GetCookie_OrgName(Request);*/ //headData.LrDate = DateTime.Now; } else if (opstatus == "edit") { head.DbOperationType = DbOperationType.DbotUpd; head.ModelUIStatus = "E"; } else { head.DbOperationType = DbOperationType.DbotDel; } var modb = new ModelObjectRepository(); DBResult result = modb.Save(head, ModelObjectConvert.ToModelObjectList(CargobodyList), ModelObjectConvert.ToModelObjectList(CargodelbodyList) ); BasicDataRefDAL.SaveLog(head,Session["USERID"].ToString(),"进口贸易接单","保存"); //刷新父窗口上的父节点 var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'", CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_UserName(Request), CookieConfig.GetCookie_CompanyId(Request)) }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult Save2 ( string opstatus, string data, string CargoBody, string CargoDelBody ) { var head = JsonConvert.Deserialize(data); var CargobodyList = JsonConvert.Deserialize>(CargoBody); var CargodelbodyList = JsonConvert.Deserialize>(CargoDelBody); head.MODIFIEDUSER = Session["SHOWNAME"].ToString(); head.MODIFIEDTIME = System.DateTime.Now.ToString(); if (opstatus == "add") { head.DbOperationType = DbOperationType.DbotIns; head.ModelUIStatus = "I"; if (head.Mainstate == "") { head.Mainstate = "0"; } head.ContractNo = PubSysDAL.GetBillNo("0201"); //获取合同号 head.MODIFIEDUSER = Session["SHOWNAME"].ToString(); head.MODIFIEDTIME = System.DateTime.Now.ToString(); head.CORPID = Convert.ToString(Session["COMPANYID"]); //20131011 应客户要求,将合同号改为接单人手动填写的必填项目。不再自动生成合同号 /*自动填写接单审单人id headData.UserCode = CookieConfig.GetCookie_UserCode(Request); headData.UserName = CookieConfig.GetCookie_UserName(Request); headData.OrgCode = CookieConfig.GetCookie_OrgCode(Request); headData.OrgName = CookieConfig.GetCookie_OrgName(Request);*/ //headData.LrDate = DateTime.Now; } else if (opstatus == "edit") { head.DbOperationType = DbOperationType.DbotUpd; head.ModelUIStatus = "E"; } else { head.DbOperationType = DbOperationType.DbotDel; } var modb = new ModelObjectRepository(); DBResult result = modb.Save(head, ModelObjectConvert.ToModelObjectList(CargobodyList), ModelObjectConvert.ToModelObjectList(CargodelbodyList) ); BasicDataRefDAL.SaveLog(head, Session["USERID"].ToString(), "进口贸易接单", "保存"); //刷新父窗口上的父节点 var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'", CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_UserName(Request), CookieConfig.GetCookie_CompanyId(Request)) }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SaveList ( string data ) { var headList = JsonConvert.Deserialize>(data); var bodyList = JsonConvert.Deserialize>(data); foreach (var _c in bodyList) { _c.id = _c.cgid; } var result = new DBResult(); var _L = ModelHeadConvert.ToModelObjectList(headList); foreach (var _head in headList) { var modb = new ModelObjectRepository(); //var _b=new Create_Cargomb(); var _BL = new List(); var _BLD = new List(); foreach (var _c in bodyList) { if (_c.cgid == _head.cgid) { _BL.Add(_c); break; } } _head.DbOperationType = DbOperationType.DbotUpd; _head.ModelUIStatus = "E"; _head.MODIFIEDUSER = Session["SHOWNAME"].ToString(); _head.MODIFIEDTIME = System.DateTime.Now.ToString(); result = modb.Save(_head , ModelObjectConvert.ToModelObjectList(_BL) , ModelObjectConvert.ToModelObjectList(_BLD) ); BasicDataRefDAL.SaveLog(_head, Session["USERID"].ToString(), "进口贸易_接单列表", "保存"); } //刷新父窗口上的父节点 var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; /* var jsonRespose = new JsonResponse { Success = false, Message = "暂时停用", //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") };*/ return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult GetDataList(int start, int limit, string sort, string condition) { var dataList = XXHDAL.GetDataList(condition, CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_UserName(Request), CookieConfig.GetCookie_CompanyId(Request), sort); 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 }; } #region 参照部分 #endregion } }