using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using DSWeb.Areas.OA.Models.Comm; using DSWeb.TruckMng.Comm.Cookie; using DSWeb.TruckMng.Helper; using DSWeb.TruckMng.Helper.Repository; using DSWeb.Areas.CommMng.DAL; using HcUtility.Comm; using HcUtility.Core; using Microsoft.Practices.EnterpriseLibrary.Data; using System.Text; using System.Data; using DSWeb.Areas.Import.DAL.ReceiptIO; using DSWeb.Areas.Import.Models.ReceiptIO; using DSWeb.EntityDA; using WebSqlHelper; namespace DSWeb.Areas.Import.Controllers { [JsonRequestBehavior] public class ReceiptIOController : Controller { // // GET: /Import/XXH public ActionResult Index() { return View(); } // // GET: /Import/XXH/Edit public ActionResult Edit() { return View(); } // // GET:/Import/XXH/GetDataList public ContentResult GetDataList(int start, int limit, string sort, string condition) { var dataList = ReceiptIODAL.GetDataList(condition,Convert.ToString(Session["USERID"])); 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) { ReceiptIOmb head = null; if (handle == "edit") { var list = ReceiptIODAL.GetDataList(condition, Convert.ToString(Session["USERID"])); if (list.Count > 0) head = list[0]; } if (head == null) { head = new ReceiptIOmb(); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult Save(string opstatus, string data, string Body, string DelBody) { var head = JsonConvert.Deserialize(data); var bodyList = JsonConvert.Deserialize>(Body); var DelbodyList = JsonConvert.Deserialize>(DelBody); if (opstatus == "add") { head.DbOperationType = DbOperationType.DbotIns; head.ModelUIStatus = "I"; head.GID = PubSysDAL.getGuid(); head.CORPID = Convert.ToString(Session["COMPANYID"]); head.DEPTGID = Convert.ToString(Session["USERID"]); if (bodyList!=null) foreach (var IOBody in bodyList) { if (IOBody.GID == "") { IOBody.GID = PubSysDAL.getGuid(); } else { } } } else if (opstatus == "edit") { head.CORPID = Convert.ToString(Session["COMPANYID"]); head.DEPTGID = Convert.ToString(Session["USERID"]); if (bodyList != null) foreach (var IOBody in bodyList) { if (IOBody.GID == "") { IOBody.GID = PubSysDAL.getGuid(); } else { } } head.DbOperationType = DbOperationType.DbotUpd; head.ModelUIStatus = "E"; } else { head.DbOperationType = DbOperationType.DbotDel; } //首先判断插入的快递单据明细是否重复 if (bodyList != null) { foreach (var R_Body in bodyList) { if (R_Body.ReceiptName == ""||R_Body.NeedType=="") { var jsonRespose = new JsonResponse { Success = false, Message = R_Body.CUSTNO + "/" + R_Body.MBLNO + " 没有指定单据类型或单据操作 无法进行处理", Data = "" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } var _count = ReceiptIODAL.SearchBody(R_Body); /* if (_count > 0) { var jsonRespose = new JsonResponse { Success = false, Message = R_Body.CUSTNO + "/" + R_Body.MBLNO + " 的 " + R_Body.ReceiptName + " 已经进行过 '" + R_Body.NeedType + "'", Data = "" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; }*/ } } var modb = new ModelObjectRepository(); DBResult result = modb.Save(head, ModelObjectConvert.ToModelObjectList(bodyList), ModelObjectConvert.ToModelObjectList(DelbodyList) ); //head.OP = CookieConfig.GetCookie_UserName(Request); //head.COMPANY = CookieConfig.GetCookie_OrgName(Request); if (result.Success == true) { var Userid=CookieConfig.GetCookie_UserId(Request); var UserName=CookieConfig.GetCookie_UserName(Request); if (bodyList!=null) ReceiptIODAL.WriteBody(bodyList, Userid, head); ReceiptIODAL.InsertRemark(bodyList, head); if (DelbodyList != null) ReceiptIODAL.DelBody(DelbodyList, Userid, head); } //刷新父窗口上的父节点 var jsonRespose2 = new JsonResponse { Success = result.Success, Message = result.Message, Data = ReceiptIODAL.GetData(" GID='" + head.GID + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } public ContentResult Delete(string data,string USERID) { var head = JsonConvert.Deserialize(data); var GID = head.GID; var modb = new ModelObjectDB(); DBResult result = modb.Delete(head,USERID,true); var _count = 0; if (result.Success == true) { _count=ReceiptIODAL.DELBody(GID); var ReceiptList = ReceiptIODAL.GetBodyList(" IO_GID='" + GID + "' "); var Userid = CookieConfig.GetCookie_UserId(Request); var UserName = CookieConfig.GetCookie_UserName(Request); _count = _count + ReceiptIODAL.DelBody(ReceiptList, Userid, head); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult GetBodyList ( string GID ) { var dataList = ReceiptIODAL.GetBodyList(" IO_GID='" + GID + "' "); var list = dataList; var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetRemark ( string BSNO ) { var dataList = ReceiptIODAL.GetRemark(BSNO); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } #region 参照部分 #endregion /* public ContentResult TESTC ( ) { var dataList = new List(); var n1=new Testmb(); n1.fieldLabel = "DisplayLabel"; n1.name = "display1"; dataList.Add(n1); var list = dataList; var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; }*/ } }