using System; using System.Linq; using System.Text; using System.Web.Mvc; using DSWeb.MvcShipping.DAL.MsOpAirnDAL; using DSWeb.MvcShipping.Models.MsOpAirn; using DSWeb.MvcShipping.Models.MsOpAireBill; using DSWeb.MvcShipping.Helper; using DSWeb.MvcShipping.Comm.Cookie; using HcUtility.Comm; using HcUtility.Core; using System.Collections.Generic; using System.IO; using System.Data; using System.Data.OleDb; using DSWeb.Areas.CommMng.DAL; using DSWeb.Areas.RptMng.Comm; using DSWeb.Areas.CommMng.Models; using DSWeb.MvcShipping.DAL.MsBaseInfoDAL; using DSWeb.MvcShipping.DAL.MsSysBillNoSet; using DSWeb.MvcShipping.Models.MsSysBillNoSet; using DSWeb.MvcShipping.Models.MsOpApply; using DSWeb.MvcShipping.DAL.MsOpApplyDAL; using DSWeb.MvcShipping.DAL.MsSysParamSet; using DSWeb.TruckMng.Helper.Repository; using DSWeb.MvcShipping.DAL.MsInfoClient; using DSWeb.Areas.MvcShipping.Models.Message.VGM; using DSWeb.Common.DB; namespace DSWeb.MvcShipping.Controllers { [JsonRequestBehavior] public class MsOpAirnController : Controller { // // GET: public ActionResult Index() { return View(); } public ActionResult Edit() { return View(); } public ActionResult FeeEdit() { return View(); } public ActionResult FenList() { return View(); } public ActionResult SeaeFeeView() { return View(); } public ActionResult FeeAmendEdit() { return View(); } public ActionResult ReceiptEdit() { return View(); } public ActionResult BillEdit() { return View(); } public ActionResult FenEdit() { return View(); } public ActionResult PiLiangFeeEdit() { return View(); } public ActionResult HistryFeeIndex() { return View(); } public ActionResult HistryBillIndex() { return View(); } public ActionResult FenBillList() { return View(); } public ActionResult PiLiangFenFee() { return View(); } public ActionResult PiLiangOpBill() { return View(); } public ActionResult EditView() { return View(); } public ContentResult GetDataList(int start, int limit, string sort, string condition, string bltype,string load) { var dataList = MsOpAirnDAL.GetDataList(condition, bltype, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort, load); var list = dataList.Skip(start).Take(limit); var isopen = MsBaseInfoDAL.GetUserModuleEnable("modAirn_Del", Session["USERID"].ToString()); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetDataListStr( string sort, string condition) { var dataListStr = MsOpAirnDAL.GetDataListStr(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功",data = dataListStr }); return new ContentResult() { Content = json }; } public ContentResult GetFenList(int start, int limit, string sort, string condition) { var dataList = MsOpAirnDAL.GetFenList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), 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 }; } public ContentResult GetFreightList ( int start, int limit, string sort, string condition ) { var dataList = MsOpAirn_FreightDAL.GetBodyList(condition, 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 }; } public ContentResult GetData(string handle, string condition,string BLTYPE) { MsOpAirn head = null; if (handle == "edit") { head = MsOpAirnDAL.GetData(condition); } if (head == null) { head = new MsOpAirn(); head.OP = Convert.ToString(Session["SHOWNAME"]); head.INPUTBY= Convert.ToString(Session["SHOWNAME"]); head.CUSTSERVICE = Convert.ToString(Session["SHOWNAME"]); head.ISSUEBY = Convert.ToString(Session["SHOWNAME"]); head.ISSUEDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); head.ETD = System.DateTime.Now.ToString("yyyy-MM-dd"); head.SALEDEPT = Convert.ToString(Session["DEPTNAME"]); head.PFREIGHT = "0"; head.PVALUEFEE = "0"; head.PCARRIEROT = "0"; head.POTFREIGHT = "0"; head.PTOTAL = "0"; head.CFREIGHT = "0"; head.CVALUEFEE = "0"; head.CCARRIEROT = "0"; head.COTFREIGHT = "0"; head.CTOTAL = "0"; head.PORTLOADID = "TAO"; head.PORTLOAD = "青岛"; } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult Save ( string opstatus, string data, string data2, string data3,string CargoBody, string CargoDelBody) { var aaa = ""; var dataall = data.Replace("}", ",") + (data2.Replace("{", "")).Replace("}", ",") + data3.Replace("{", ""); //var dataall = data.Replace("}", ",") + data2.Replace("{", ""); var BSNO = ""; var result = DoSave(opstatus, dataall, CargoBody, CargoDelBody,out BSNO); if (result.Success == true) { var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsOpAirnDAL.GetData(" B.BSNO='" + BSNO + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } private DBResult DoSave ( string opstatus, string data, string CargoBody, string CargoDelBody, out string BSNO ) { var headData = JsonConvert.Deserialize(data); DBResult result=new DBResult(); var CargobodyList = JsonConvert.Deserialize>(CargoBody); var CargodelbodyList = JsonConvert.Deserialize>(CargoDelBody); if (headData.BLTYPE == "国内分单" && string.IsNullOrWhiteSpace( headData.HBLNO)) { headData.HBLNO = PubSysDAL.GetBillNo("0201"); //headData.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); } var oldheadData = MsOpAirnDAL.GetData(" B.BSNO='" + headData.BSNO + "' "); //if (oldheadData.FEESTATUS == true) { // result.SetErrorInfo("费用锁定的业务不允许修改"); //} var isPost = true; var errorstr = ""; //var isuse = false; var iscreatecustno = false; if (headData.CORPID == "" || headData.CORPID == null) { headData.CORPID = Convert.ToString(Session["COMPANYID"]); } if (headData.MBLNO != "" && headData.MBLNO != null && headData.BLTYPE == "国内主单") { var ct = MsOpAirnDAL.GetRdCount(" MBLNO='" + headData.MBLNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "' and BLTYPE='国内主单'"); if (ct != 0 && opstatus == "add") { isPost = false; errorstr = "主单号"; } } if (opstatus == "add") { headData.INPUTBY = Convert.ToString(Session["SHOWNAME"]); headData.BSDATE = DateTime.Now; headData.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd"); headData.BSSTATUS = false; headData.FEESTATUS = false; headData.DbOperationType = DbOperationType.DbotIns; headData.ModelUIStatus = "I"; } else if (opstatus == "edit") { headData.DbOperationType = DbOperationType.DbotUpd; headData.ModelUIStatus = "E"; //20230217 增加判断 只要存在一条bsno=headData.BSNO的ch_fee //则将原数据的费用信息 覆盖到即将保存的headdata中 //即:如果有应收应付费用 则不允许修改主单或分单中的费用相关字段 var feecount = BasicDataRefDAL.GetExist("ch_fee", " BSNO='" + headData.BSNO + "' and feestatus not in(1,6) "); if (feecount > 0) { headData.BLFRT = oldheadData.BLFRT; headData.PFREIGHT = oldheadData.PFREIGHT; headData.CFREIGHT = oldheadData.CFREIGHT; headData.PVALUEFEE = oldheadData.PVALUEFEE; headData.CVALUEFEE = oldheadData.CVALUEFEE; headData.PCARRIEROT = oldheadData.PCARRIEROT; headData.CCARRIEROT = oldheadData.CCARRIEROT; headData.POTFREIGHT = oldheadData.POTFREIGHT; headData.COTFREIGHT = oldheadData.COTFREIGHT; headData.PTOTAL = oldheadData.PTOTAL; headData.CTOTAL = oldheadData.CTOTAL; headData.OTFEE = oldheadData.OTFEE; headData.OTFEE1 = oldheadData.OTFEE1; headData.OTFEE1AMOUNT = oldheadData.OTFEE1AMOUNT; headData.OTFEE2 = oldheadData.OTFEE2; headData.OTFEE2AMOUNT = oldheadData.OTFEE2AMOUNT; headData.OTFEE3 = oldheadData.OTFEE3; headData.OTFEE3AMOUNT = oldheadData.OTFEE3AMOUNT; headData.OTFEE4 = oldheadData.OTFEE4; headData.OTFEE4AMOUNT = oldheadData.OTFEE4AMOUNT; headData.OTFEE5 = oldheadData.OTFEE5; headData.OTFEE5AMOUNT = oldheadData.OTFEE5AMOUNT; headData.OTFEE6 = oldheadData.OTFEE6; headData.OTFEE6AMOUNT = oldheadData.OTFEE6AMOUNT; headData.OTFEE7 = oldheadData.OTFEE7; headData.OTFEE7AMOUNT = oldheadData.OTFEE7AMOUNT; headData.OTFEE8 = oldheadData.OTFEE8; headData.OTFEE8AMOUNT = oldheadData.OTFEE8AMOUNT; } } else { headData.DbOperationType = DbOperationType.DbotDel; } //if (headData.MASTERNO == null || headData.MASTERNO =="") { headData.MASTERNO = headData.BSNO; } if (headData.ETA == "") headData.ETA = null; if (headData.ETD == "") headData.ETD = null; if (headData.STLDATE == "") headData.STLDATE = null; if (headData.INSPECTIONDATE == "") headData.INSPECTIONDATE = null; if (headData.CUSTOMDATE == "") headData.CUSTOMDATE = null; headData.PORTLOAD = MsBaseInfoDAL.DelPortCn(headData.PORTLOAD); headData.PORTDISCHARGE = MsBaseInfoDAL.DelPortCn(headData.PORTDISCHARGE); BSNO = headData.BSNO; if (headData.BLTYPE == "国内主单" && headData.MASTERNO != "" && opstatus != "add") { //如果是编辑 需要根据MASTERNO,清除库存主单使用记录 MsOpAirnDAL.ExecSql(" update op_airn_RECEIPT set RSTATUS='入库',OP='" + Convert.ToString(Session["SHOWNAME"]) + "',OPDATE=getdate() where GID=(select Masterno from OP_AIRN where BSNO='" + headData.BSNO + "') "); } if (headData.ETD != "" && headData.CUSTOMERNAME != "" && headData.STLNAME == "")// headData.STLDATE == "" && { //根据客户、开船日计算账期 var _dmb = MsInfoClientDAL.GetSTLDATE(headData.CUSTOMERNAME, "国内空运", headData.ETD, headData.SALE); headData.STLNAME = _dmb.STLNAME; headData.STLDATE = _dmb.STLDATE; if (_dmb.STLNAME == "") { headData.STLNAME = "现结买单"; headData.STLDATE = headData.ISSUEDATE; } } if (isPost) { //增加一个判断 如无揽货人sale则报警不保存 BasicDataRefDAL.SaveLog("opstatus="+ opstatus+":"+JsonConvert.Serialize(headData)+"//"+ JsonConvert.Serialize(CargobodyList), Convert.ToString(Session["SHOWNAME"]),"内贸空运","主单保存"); var modb = new ModelObjectRepository(); result = modb.Save(headData, ModelObjectConvert.ToModelObjectList(CargobodyList), ModelObjectConvert.ToModelObjectList(CargodelbodyList) ); if (result.Success == true) { //如果是主单保存 则清空所有相关分单的主单编号 写入新的编号 if (headData.BLTYPE == "国内主单") { MsOpAirnDAL.ExecSql(" update Op_Airn set MBLNO='" + headData.MBLNO + "' where HBLNO='" + headData.HBLNO + "' and BLTYPE='国内分单' "); if (headData.MASTERNO != "") MsOpAirnDAL.ExecSql(" update op_airn_RECEIPT set RSTATUS='取用',OP='" + Convert.ToString(Session["SHOWNAME"]) + "',OPDATE=getdate() where GID='" + headData.MASTERNO + "' "); } if (headData.BLTYPE == "国内分单") { MsOpAirnDAL.ExecSql(" update Op_Airn set CUSTOMERNAME='" + headData.CUSTOMERNAME + "',CONSIGNEE='" + headData.CONSIGNEE + "',CONSIGNEEID='" + headData.CONSIGNEEID + "',PORTDISCHARGEID='" + headData.PORTDISCHARGEID + "',PORTDISCHARGE='" + headData.PORTDISCHARGE + "',ETD='" + headData.ETD + "',FLYTIME='" + headData.FLYTIME +"'" + ",SALE='"+ headData.SALE + "'" + " where BLTYPE='国内主单' and HBLNO='"+headData.HBLNO+"' and isnull(ISVOID,0)=0 "); if (opstatus != "add") { #region 更新主单中的燃油费 //按照前端燃油费的计算方法,没办法重写一遍。。。 //20230217 判断主单目前是否有应收应付费用 如果没有 才进行燃油费更改 //如果有 就不进行更改 var 主单 = MsOpAirnDAL.GetData(" BLTYPE='国内主单' and HBLNO='" + headData.HBLNO + "' "); var feecount = BasicDataRefDAL.GetExist("ch_fee", " BSNO='" + 主单.BSNO + "' "); if (feecount > 0) { //如果有 就不进行更改 } else { //20230217 判断主单目前是否有应收应付费用 如果没有 才进行燃油费更改 double weight = 0; if (CargobodyList != null && CargobodyList.Count > 0) foreach (MsOpAirn_Cargomb item in CargobodyList) { weight += Convert.ToDouble(item.WEIGHT); } double fuelFee = 0; var updstr = ""; switch (headData.AIRLINES) { case "山东航空": fuelFee = 0.2 * weight; //燃油费四舍五入取整 int shFuelFee = (int)(Math.Round(fuelFee, 0)); if (shFuelFee < 10) shFuelFee = 10; updstr = " update Op_Airn set OTFEE1='燃油费',OTFEE1AMOUNT='" + shFuelFee + "' where BLTYPE='国内主单' and HBLNO='" + headData.HBLNO + "' and isnull(ISVOID,0)=0 "; break; case "青岛航空": fuelFee = 0.2 * weight; //燃油费四舍五入取整 int qhFuelFee = (int)(Math.Round(fuelFee, 0)); if (qhFuelFee < 10) qhFuelFee = 10; updstr = " update Op_Airn set OTFEE1='燃油费',OTFEE1AMOUNT='" + qhFuelFee + "' where BLTYPE='国内主单' and HBLNO='" + headData.HBLNO + "' and isnull(ISVOID,0)=0 "; break; case "南方航空": fuelFee = 0.2 * weight; //燃油费向上取整 int nfFuelFee = (int)(Math.Ceiling(fuelFee)); updstr = " update Op_Airn set OTFEE1='燃油费',OTFEE1AMOUNT='" + nfFuelFee + "' where BLTYPE='国内主单' and HBLNO='" + headData.HBLNO + "' and isnull(ISVOID,0)=0 "; break; case "吉祥航空": fuelFee = 0.2 * weight; if (fuelFee < 1) { fuelFee = 1; } else { fuelFee = Math.Round(fuelFee, 2); } updstr = " update Op_Airn set OTFEE1='燃油费',OTFEE1AMOUNT='" + fuelFee + "' where BLTYPE='国内主单' and HBLNO='" + headData.HBLNO + "' and isnull(ISVOID,0)=0 "; break; case "深圳航空": fuelFee = 0.2 * weight; if (fuelFee < 1) { fuelFee = 1; } else { fuelFee = Math.Round(fuelFee, 2); } updstr = " update Op_Airn set OTFEE1='燃油费',OTFEE1AMOUNT='" + fuelFee + "' where BLTYPE='国内主单' and HBLNO='" + headData.HBLNO + "' and isnull(ISVOID,0)=0 "; break; case "春秋航空": //燃油费四舍五入取整 fuelFee = Math.Round(0.2 * weight, 0); if (fuelFee < 1) { fuelFee = 1; } updstr = " update Op_Airn set OTFEE1='燃油费',OTFEE1AMOUNT='" + fuelFee + "' where BLTYPE='国内主单' and HBLNO='" + headData.HBLNO + "' and isnull(ISVOID,0)=0 "; break; case "厦门航空": //燃油费四舍五入 改为取整 fuelFee = Math.Round(0.2 * weight, 0); if (fuelFee < 1) { fuelFee = 1; } updstr = " update Op_Airn set OTFEE1='燃油费',OTFEE1AMOUNT='" + fuelFee + "' where BLTYPE='国内主单' and HBLNO='" + headData.HBLNO + "' and isnull(ISVOID,0)=0 "; break; default: fuelFee = 0.2 * weight; //燃油费四舍五入取整,前端用的tofixed() int otherFuelFee = (int)(Math.Round(fuelFee, 0)); updstr = " update Op_Airn set OTFEE1='燃油费',OTFEE1AMOUNT='" + otherFuelFee + "' where BLTYPE='国内主单' and HBLNO='" + headData.HBLNO + "' and isnull(ISVOID,0)=0 "; break; } if (updstr != "") { BasicDataRefDAL.SaveLog(updstr, Convert.ToString(Session["SHOWNAME"]), "内贸空运", "主单费用"); MsOpAirnDAL.ExecSql(updstr); } //20220914 然后更新杂费和合计数 主单.SetPFee_Main(); 主单.DbOperationType = DbOperationType.DbotUpd; 主单.ModelUIStatus = "E"; var _r = modb.Save(主单); } #endregion } } } else { MsSysBillNoSetDAL.DeleteBsNo(headData.CUSTNO); } BSNO = headData.BSNO; return result; } else { if (iscreatecustno == true) MsSysBillNoSetDAL.DeleteBsNo(headData.CUSTNO); result.Success = false; result.Message = errorstr + "重复,不允许保存!"; return result; } } //20161215 在分单编号生成主单 public ContentResult MakeMain ( string opstatus, string data, string data2, string data3, string CargoBody, string CargoDelBody , string OLDMBLNO = "", string FDBSNO = "" ) { //如果有旧主单号 则将其重新设为入库; var dataall = data.Replace("}", ",") + (data2.Replace("{", "")).Replace("}", ",") + data3.Replace("{", ""); var headData = JsonConvert.Deserialize(dataall); headData.ISSUEDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //如果新的主单号在op_airn中已经存在,则返回错误 var OLDZD2 = MsOpAirnDAL.GetData(" MBLNO='" + headData.MBLNO + "' and HBLNO<>'" + headData.HBLNO + "' "); if (OLDZD2.MBLNO == headData.MBLNO) { var jsonRespose = new JsonResponse { Success = false, Message = "主单号<" + headData.MBLNO + ">在系统内已存在!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } DBResult result = new DBResult(); if (OLDMBLNO != "") { //MsOpAirnDAL.ExecSql(" update op_airn_RECEIPT set RSTATUS='入库',OP='" + Convert.ToString(Session["SHOWNAME"]) + "',OPDATE=getdate() where RECEIPTNO='" + OLDMBLNO + "' "); var OLDZD = MsOpAirnDAL.GetData(" MBLNO='" + OLDMBLNO + "' and HBLNO='" + headData.HBLNO + "' and BLTYPE='国内主单' "); var SHOWNAME= Session["SHOWNAME"].ToString(); if (OLDZD != null) { var modb = new ModelObjectDB(); result = modb.Delete(OLDZD, "update op_airn_RECEIPT set RSTATUS='领用',OP='" + Convert.ToString(Session["SHOWNAME"]) + "',OPDATE=getdate() where GID=(select Masterno from OP_AIRN where BSNO='" + OLDZD.BSNO + "')" //写一个取消调用的主单日志 , "insert into op_airn_RECEIPTDO select newid(),GID R_GID,BSNO,FIRSTCODE,RECEIPTNO,RTYPE,ISBAOCANG,ISWMS,'取消使用' RSTATUS,'" + SHOWNAME + "',getdate(),'' " + "from op_airn_RECEIPT where GID=(select Masterno from OP_AIRN where BSNO='" + OLDZD.BSNO + "')" ); } } var _ZDBSNO = ""; var Mainsaveresult = DoSave(opstatus, dataall, CargoBody, CargoDelBody,out _ZDBSNO); if (Mainsaveresult.Success == true) { //写一个主单取用的日志 var r1 = BasicDataRefDAL.ExecSql("insert into op_airn_RECEIPTDO select newid(),GID R_GID,BSNO,FIRSTCODE,RECEIPTNO,RTYPE,ISBAOCANG,ISWMS,'签出使用' RSTATUS,'" + Session["SHOWNAME"].ToString() + "',getdate(),'' " + "from op_airn_RECEIPT where FIRSTCODE+'-'+RECEIPTNO=(select MBLNO from OP_AIRN where BSNO='" + FDBSNO + "')"); var jsonRespose = new JsonResponse { Success = true, Message = "", Data = MsOpAirnDAL.GetData(" B.BSNO='" + FDBSNO + "' ") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var jsonRespose = new JsonResponse { Success = false, Message = Mainsaveresult.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public ContentResult Delete(string data) { var head = JsonConvert.Deserialize(data); head = MsOpAirnDAL.GetData("B.BSNO='" + head.BSNO + "'"); var isfee = MsOpAirnDAL.GetFeeCount(head.BSNO); if (isfee) { var jsonRespose = new JsonResponse { Success = false, Message ="此票业务存在费用,请先删除费用才能删除此票业务!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var BSNO = head.BSNO; var modb = new ModelObjectDB(); DBResult result = new DBResult(); if (head.BLTYPE == "国内主单") { result = modb.Delete(head, "update op_airn_RECEIPT set RSTATUS='入库',OP='" + Convert.ToString(Session["SHOWNAME"]) + "',OPDATE=getdate() where GID=(select Masterno from OP_AIRN where BSNO='" + head.BSNO + "')" ,"update OP_AIRN set MBLNO='' where BLTYPE='国内分单' and MBLNO='"+head.MBLNO+"'" ); } if (head.BLTYPE == "国内分单") { if (head.MBLNO != "") { result.Success = false; result.Message = "已经生成主单,请先删除其主单"; } else { result = modb.Delete(head); } } if (result.Success == true) { MsSysBillNoSetDAL.DeleteBsNo(head.CUSTNO); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public ContentResult VoidMain ( string data ) { var head = JsonConvert.Deserialize(data); if (head.BLTYPE != "国内主单") { var jsonRespose = new JsonResponse { Success = false, Message = "只能作废国内主单!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } var isfee = MsOpAirnDAL.GetFeeCount(head.BSNO); if (isfee) { var jsonRespose = new JsonResponse { Success = false, Message = "此票业务存在费用,请先删除费用才能作废主单!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var BSNO = head.BSNO; //var modb = new ModelObjectRepository(); //DBResult result = new DBResult(); head.OTFEE = "0"; head.OTFEE1 = ""; head.OTFEE1 = "0"; head.OTFEE2 = ""; head.OTFEE2 = "0"; head.OTFEE3 = ""; head.OTFEE3 = "0"; head.OTFEE4 = ""; head.OTFEE4 = "0"; head.OTFEE5 = ""; head.OTFEE5 = "0"; head.OTFEE6 = ""; head.OTFEE6 = "0"; head.OTFEE7 = ""; head.OTFEE7 = "0"; head.OTFEE8 = ""; head.OTFEE8 = "0"; head.PFREIGHT = "0"; head.CFREIGHT = "0"; head.PVALUEFEE = "0"; head.CVALUEFEE = "0"; head.PCARRIEROT = "0"; head.CCARRIEROT = "0"; head.POTFREIGHT = "0"; head.COTFREIGHT = "0"; head.PTOTAL = "0"; head.CTOTAL = "0"; head.DbOperationType = DbOperationType.DbotUpd; head.ModelUIStatus = "E"; var modb = new ModelObjectRepository(); DBResult result = modb.Save( head ); if (head.BLTYPE == "国内主单") { //MsOpAirnDAL.ExecSql(" update op_airn_RECEIPT set RSTATUS='入库',OP='" + Convert.ToString(Session["SHOWNAME"]) + "',OPDATE=getdate() where GID=(select Masterno from OP_AIRN where BSNO='" + headData.BSNO + "') "); MsOpAirnDAL.ExecSql(" update op_airn_RECEIPT set RSTATUS='作废',OP='" + Convert.ToString(Session["SHOWNAME"]) + "',OPDATE=getdate() where GID=(select Masterno from OP_AIRN where BSNO='" + head.BSNO + "')" //+ " update OP_AIRN set ISVOID=1 where BSNO='" + head.BSNO + "' " + " update OP_AIRN set MBLNO='' where BLTYPE='国内分单' and MBLNO='" + head.MBLNO + "'"); var r1 = BasicDataRefDAL.ExecSql("insert into op_airn_RECEIPTDO select newid(),GID R_GID,BSNO,FIRSTCODE,RECEIPTNO,RTYPE,ISBAOCANG,ISWMS,'作废' RSTATUS,'" + Session["SHOWNAME"].ToString() + "',getdate(),'' " + "from op_airn_RECEIPT where FIRSTCODE+'-'+RECEIPTNO='" + head.MBLNO + "' "); } var jsonRespose = new JsonResponse { Success = true, Message = "" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } //进行领用和取消领用 public ContentResult DoLY ( string RSTATUS, string USERNAME, string LYBody ) { var _LYBodyList = JsonConvert.Deserialize>(LYBody); var GIDList=""; foreach (var _R in _LYBodyList) { if (GIDList == "") { GIDList = "'" + _R.GID + "'"; } else { GIDList = GIDList+",'" + _R.GID + "'"; } } var LYBodyList = MsOpAirn_RECEIPTWMSDAL.GetBodyList("R.GID in(" + GIDList + ")"); var LYBodyListDEL = new List(); var DoList = new List(); var DoListDEL = new List(); var BSNO=""; foreach (var _R in LYBodyList) { if (RSTATUS == "领用" && _R.RSTATUS == "入库") { _R.RSTATUS = "领用"; } else if (RSTATUS == "取消领用" && _R.RSTATUS == "领用"){ _R.RSTATUS = "入库"; } else if (RSTATUS == "退单" && _R.RSTATUS == "入库") { _R.RSTATUS = "退单"; } else if (RSTATUS == "取消退单" && _R.RSTATUS == "退单") { _R.RSTATUS = "入库"; } else { continue; } _R.OP = USERNAME; _R.OPDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); BSNO = _R.BSNO; var _d = new MsOpAirn_RECEIPTDOmb(); _d.GID = Guid.NewGuid().ToString(); _d.R_GID = _R.GID; _d.BSNO = ""; _d.FIRSTCODE = _R.FIRSTCODE; _d.RECEIPTNO = _R.RECEIPTNO; _d.RTYPE = _R.RTYPE; _d.ISBAOCANG = _R.ISBAOCANG; _d.ISWMS = _R.ISWMS; _d.RSTATUS = RSTATUS; _d.OP = USERNAME; _d.OPDATE = _R.OPDATE; _d.REMARK = ""; DoList.Add(_d); } var modb = new ModelObjectRepository(); DBResult result = modb.SaveComm("BSNO",BSNO, ModelObjectConvert.ToModelObjectList(LYBodyList), ModelObjectConvert.ToModelObjectList(LYBodyListDEL) ); result = modb.SaveComm("BSNO",BSNO, ModelObjectConvert.ToModelObjectList(DoList), ModelObjectConvert.ToModelObjectList(DoListDEL) ); //return result; var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #region 提单信息 public ContentResult GetBillList(int start, int limit, string sort, string condition) { var dataList = MsOpAirnDAL.GetBillList(condition, 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 }; } public ContentResult GetBillData(string handle, string condition) { MsOpAireBill head = null; if (handle == "edit") { head = MsOpAirnDAL.GetBillData(condition); } if (head == null) { head = new MsOpAireBill(); head.INPUTBY = Convert.ToString(Session["SHOWNAME"]); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult BillSave(string opstatus, string data,string body) { var headData = JsonConvert.Deserialize(data); if (opstatus == "add") { headData.INPUTBY = Convert.ToString(Session["SHOWNAME"]); headData.AS_ID = Guid.NewGuid().ToString(); headData.DbOperationType = DbOperationType.DbotIns; } else if (opstatus == "edit") { headData.DbOperationType = DbOperationType.DbotUpd; headData.ModelUIStatus = "E"; } else { headData.DbOperationType = DbOperationType.DbotDel; } if (headData.ETA == "") headData.ETA = null; if (headData.ETD == "") headData.ETD = null; if (headData.ISSUEDATE == "") headData.ISSUEDATE = null; var modb = new ModelObjectDB(); var AS_ID = headData.AS_ID; DBResult result = modb.Save(headData); //if (result.Success == true) //{ // result = MsOpSeaeDAL.SaveBillDetail(AS_ID, bodyList, Convert.ToString(Session["USERID"])); //} var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsOpAirnDAL.GetBillData("AS_ID='" + AS_ID + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult BillDelete(string data) { var head = JsonConvert.Deserialize(data); var modb = new ModelObjectDB(); var AS_ID = head.AS_ID; DBResult result = modb.Delete(head); //if (result.Success == true) { MsOpSeaeDAL.DeleteDetail(AS_ID); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion #region 生成报关信息 public ContentResult SaveBG(string data, string data2) { var aaa = ""; var head = JsonConvert.Deserialize(data.Replace("}", ",") + data2.Replace("{", "")); var headData = new MsOpApply(); var isuse = MsBaseInfoDAL.GetRuleUse("委托编号", "4"); if (isuse) { headData.CUSTNO = MsOpApplyDAL.getCodeRule("委托编号", "CUSTNO", headData.BSDATE.ToString().Trim(), headData.ACCDATE.ToString().Trim(), Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"])); } if (headData.CORPID == "" || headData.CORPID == null) { headData.CORPID = Convert.ToString(Session["COMPANYID"]); } headData.MASTERNO = head.BSNO; headData.INPUTBY = Convert.ToString(Session["SHOWNAME"]); headData.BSDATE = DateTime.Now; headData.DbOperationType = DbOperationType.DbotIns; headData.CUSTOMERNAME = head.CUSTOMERNAME; headData.MBLNO = head.MBLNO; headData.VESSEL = head.VESSEL; headData.BSSOURCE = head.BSSOURCE; headData.BSSOURCEDETAIL = head.BSSOURCEDETAIL; headData.ETD = head.ETD; headData.ETA = head.ETA; headData.PKGS = head.PKGS; headData.KGS = head.KGS; headData.CBM = head.CBM; headData.PORTLOAD = head.PORTLOAD; headData.PORTDISCHARGE = head.PORTDISCHARGE; headData.SALE = head.SALE; headData.SALEDEPT = head.SALEDEPT; headData.BSTYPE = "3"; headData.CUSTOMNO = head.CUSTOMNO; headData.CUSTOMDATE = head.CUSTOMDATE; headData.INSPECTIONNO = head.INSPECTIONNO; headData.INSPECTIONDATE = head.INSPECTIONDATE; headData.ENTERP = head.ENTERP; headData.ENTERPID = head.ENTERPID; var modb = new ModelObjectDB(); DBResult result = modb.Save(headData); if (result.Success == true) { result.Success = true; result.Message = "生成成功"; } else { result.Success = false; result.Message = "生成过程发生错误"; } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion #region 商品信息 public ContentResult GetCargoList ( string condition ) { var dataList = MsOpAirnDAL.GetCargoList(condition); //var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } #endregion } }