using System; using System.Linq; using System.Web.Mvc; using DSWeb.MvcShipping.DAL.MsChDui; using DSWeb.MvcShipping.Models.MsChDui; using DSWeb.MvcShipping.Models.MsChDuiView; using DSWeb.MvcShipping.Helper; using DSWeb.MvcShipping.Comm.Cookie; using DSWeb.Areas.CommMng.DAL; using System.Collections.Generic; using HcUtility.Comm; using HcUtility.Core; using DSWeb.MvcShipping.DAL.MsSysBillNoSet; using DSWeb.MvcShipping.Models.MsSysBillNoSet; using DSWeb.Areas.MvcShipping.DAL.Disports; using DSWeb.MvcShipping.Models.MsCodeGoods; using DSWeb.MvcShipping.DAL.MsCodeGoods; using DSWeb.Areas.MvcShipping.Models.Disport; using DSWeb.Areas.MvcShipping.DAL.code_vesselModelDal; using DSWeb.Areas.MvcShipping.Models.MsCodeVesselSetModel; using DSWeb.Common.DB; using System.Data; namespace DSWeb.MvcShipping.Controllers { [JsonRequestBehavior] public class MsCodeVesselSetController : Controller { // // GET: public ActionResult Index() { return View(); } // // GET: / public ActionResult Edit() { return View(); } public ActionResult FootEdit() { return View(); } // // GET: public ContentResult GetDataList(int start, int limit, string sort, string condition) { var dataList = code_vessel.GetVesselList(condition); var list = dataList.Skip(start).Take(limit).ToList(); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list }); return new ContentResult() { Content = json }; } public ContentResult GetDataListRm(string vessel) { var dataList = code_vessel.GetVesselList($" vessel like '%{vessel}%' "); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList }); return new ContentResult() { Content = json }; } public ContentResult GetData(string handle, string condition) { code_vesselModel head = null; if (handle == "edit") { var list = code_vessel.GetVesselByID(condition); if (list.Count > 0) head = list[0]; } if (head == null) { head = new code_vesselModel(); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult GetFootList(int start, int limit, string sort, string condition) { var dataList = code_vessel.GetVoynoList(condition); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetFootData(string handle, string VOID) { CodeVoyno head = new CodeVoyno(); var cdc = new CommonDataContext(); if (handle == "edit") { var list = cdc.Voynos.Where(x => x.VOID == VOID).ToList(); if (list.Count > 0) head = list[0]; } else { } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult UpdateBsVesselVoy(string data) { var headData = JsonConvert.Deserialize(data); DBResult result = code_vessel.UpdateBsVesselVoy(headData); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #region 获取航次列表 public ContentResult GetVoynotList(string VOYNO) { var dataList = code_vessel.GetVoynotList(VOYNO); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } #endregion public ContentResult Save(string opstatus, string data) { var headData = JsonConvert.Deserialize(data); if (opstatus == "add") { DBResult re = code_vessel.InsertDetail(headData); if (re.Success==false) { var jsonRespose = new JsonResponse { Success = re.Success, Message =re.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } else if (opstatus == "edit") { headData.DbOperationType = DbOperationType.DbotUpd; headData.ModelUIStatus = "E"; } else { headData.DbOperationType = DbOperationType.DbotDel; } var modb = new ModelObjectDB(); modb.Save(headData); var GID = headData.DM_ID; DBResult result = code_vessel.SDetail(headData); var jRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = code_vessel.GetVesselByID(GID) // }; return new ContentResult() { Content = JsonConvert.Serialize(jRespose) }; } public ContentResult SaveFoot(string opstatus, string data) { data = data.Replace("❥", "<"); var headData = JsonConvert.Deserialize(data); var cdc = new CommonDataContext(); var jRespose = new JsonResponse { Success = true, Message = "", }; try { if (opstatus == "add") { cdc.Voynos.Add(headData); cdc.SaveChanges(); } else if (opstatus == "edit") { var oldheaddata = cdc.Voynos.First(x => x.VOID == headData.VOID); cdc.SetValue(oldheaddata, headData, true); } } catch (Exception e) { jRespose.Success = false; jRespose.Message = e.Message; } return new ContentResult() { Content = JsonConvert.Serialize(jRespose) }; } public ContentResult Delete(string data) { var headData = JsonConvert.Deserialize(data); DBResult result = code_vessel.DeleteDetail(headData); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #region 删除foot public ContentResult DeleteFoot(string data) { var headData = JsonConvert.Deserialize(data); DBResult result = code_vessel.DeleteDetailFoot(headData); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion #region 参照部分 #endregion #region 导入船期信息 /// /// /// /// [HttpPost] public ContentResult ImportVoyno() { var dt = new DataTable(); var MFNO = Request.Form["MFNO"]; JsonResponse jr = BasicDataRefDAL.GetExcelDT(Request, ref dt, Server.MapPath("../../UploadFiles/BasicDal"), "A1:Z");//A1:N var jsonRespose = new JsonResponse { Success = false, Message = "" }; var result = new ContentResult(); if (jr.Success) { var table = dt; EdiDataContext edc = new EdiDataContext(); var CTNCODE = 0; var newctnList = new List(); var oldctnlist = edc.EdiCtns.Where(x => x.MFNO == MFNO).ToList(); try { foreach (DataRow row in table.Rows) { if (string.IsNullOrWhiteSpace(getRowValue("箱号"))) continue; string getRowValue(string fieldname) { return Convert.ToString(row[fieldname]).Trim(); } CTNCODE++; var newctn = new OpSeaeEdiCtn(MFNO); newctn.CTNCODE = string.Format("{0:d2}", CTNCODE); //CTNCODE.ToString(); var XiangxingName = "";//ChangeInfo.CheckCTNALL(getRowValue("箱型")); if (XiangxingName == "") { jr.ErrorMessage($"序号{CTNCODE}的箱型【{getRowValue("箱型")}】不符合要求"); } newctn.CTNALL = XiangxingName; if (XiangxingName.Length == 4) { newctn.SIZE = XiangxingName.Substring(0, 2); newctn.CTN = XiangxingName.Substring(2, 2); } newctn.CNTRNO = getRowValue("箱号"); newctn.SEALNO = getRowValue("封号"); try { newctn.PKGS = Convert.ToInt32(getRowValue("件数")); } catch { newctn.PKGS = 0; } try { newctn.KGS = Convert.ToDecimal(getRowValue("重量")); } catch { newctn.KGS = 0; } try { newctn.CBM = Convert.ToDecimal(getRowValue("尺码")); } catch { newctn.CBM = 0; } try { newctn.PIZHONG = Convert.ToDecimal(getRowValue("皮重")); } catch { newctn.PIZHONG = 0; } newctn.ChengZhongZhongLiang = newctn.PIZHONG + newctn.KGS; newctn.ZhongKongBiaoShi = 5; var KINDPKGSNAME = getRowValue("包装"); var edicode = "";//ChangeInfo.GetPackageEDICode(KINDPKGSNAME, ""); if (edicode == "") { jr.ErrorMessage($"序号{CTNCODE}的包装信息【{KINDPKGSNAME}】不符合要求"); } newctn.KINDPKGS = KINDPKGSNAME; if (oldctnlist.Exists(x => x.CNTRNO == newctn.CNTRNO)) { var oldctn = oldctnlist.First(x => x.CNTRNO == newctn.CNTRNO); oldctn.Update(newctn); } else { newctnList.Add(newctn); } } if (!jr.Success) { return jr.getContentReult_success(); }; if (newctnList.Count > 0) { edc.EdiCtns.AddRange(newctnList); } edc.SaveChanges(); return jr.getContentReult_success(); } catch (Exception e) { jr.ErrorMessage(e.Message); return jr.getContentReult_success(); } } else { return jr.getContentReult_success(); } } #endregion } }