public ActionResult QueryAction(decimal?orderSeq, string custAlias, string poNum, int currentPage, int pageSize) { if (Session[CHubConstValues.SessionUser] == null) { return(RedirectToAction("Login", "Account")); } int totalCount = 0; CHubEntities db = new CHubEntities(); TS_OR_HEADER_BLL hBLL = new TS_OR_HEADER_BLL(db); List <TS_OR_HEADER> result = hBLL.GetHeaders(orderSeq, custAlias, poNum, currentPage, pageSize, out totalCount); var obj = new { result = result, totalCount = totalCount }; return(Json(obj)); }
public ActionResult InitOrder(decimal orderSeq) { //if (Session[CHubConstValues.SessionUser] == null) // return RedirectToAction("Login", "Account"); using (CHubEntities db = new CHubEntities()) { string appUser = Session[CHubConstValues.SessionUser].ToString(); ExVAliasAddr priAddr = null; ExVAliasAddr AltAddr = null; List <OrderLineItem> olReslut = new List <OrderLineItem>(); bool isSaved = false; bool splInd = true; string poNum = ""; string dueDate = ""; string note = ""; V_ALIAS_ADDR_DFLT_BLL dfltBLL = new V_ALIAS_ADDR_DFLT_BLL(db); V_ALIAS_ADDR_SPL_BLL splBLL = new V_ALIAS_ADDR_SPL_BLL(db); TS_OR_HEADER_BLL hBLL = new TS_OR_HEADER_BLL(db); List <TS_OR_HEADER> hList = hBLL.GetHeadersBySeq(orderSeq); if (hList != null && hList.Count > 0) { isSaved = true; //Get primary addr and Alt addr foreach (var item in hList) { //special ship if (item.SPL_IND == CHubConstValues.IndY) { splInd = true; if (item.SHIPFROM_SEQ == 0) { poNum = item.CUSTOMER_PO_NO; dueDate = item.DUE_DATE.ToString("yyyy-MM-dd"); note = item.ORDER_NOTES; priAddr = splBLL.GetSpecifyAliasAddrSPL(item.ALIAS_NAME, item.TO_SYSTEM, item.CUSTOMER_NO, item.BILL_TO_LOCATION, item.SHIP_TO_LOCATION, item.DEST_LOCATION); } if (item.SHIPFROM_SEQ == 1) { AltAddr = splBLL.GetSpecifyAliasAddrSPL(item.ALIAS_NAME, item.TO_SYSTEM, item.CUSTOMER_NO, item.BILL_TO_LOCATION, item.SHIP_TO_LOCATION, item.DEST_LOCATION); } } else { splInd = false; if (item.SHIPFROM_SEQ == 0) { poNum = item.CUSTOMER_PO_NO; dueDate = item.DUE_DATE.ToString("yyyy-MM-dd"); note = item.ORDER_NOTES; priAddr = dfltBLL.GetSpecifyAliasAddrDFLT(item.ALIAS_NAME, item.TO_SYSTEM, item.CUSTOMER_NO, item.BILL_TO_LOCATION, item.SHIP_TO_LOCATION); } if (item.SHIPFROM_SEQ == 1) { AltAddr = dfltBLL.GetSpecifyAliasAddrDFLT(item.ALIAS_NAME, item.TO_SYSTEM, item.CUSTOMER_NO, item.BILL_TO_LOCATION, item.SHIP_TO_LOCATION); } } } TS_OR_DETAIL_BLL dBLL = new TS_OR_DETAIL_BLL(db); List <TS_OR_DETAIL> dList = dBLL.GetDetailsBySeq(orderSeq); //change detail ot orderLine OrderLineCheckArg arg = new OrderLineCheckArg(); arg.primarySysID = priAddr.SysID; arg.primaryWareHouse = priAddr.WareHouse; arg.customerNo = priAddr.CustomerNo; if (AltAddr != null) { arg.altSysID = AltAddr.SysID; arg.altWareHosue = AltAddr.WareHouse; } foreach (var item in dList) { arg.olItem = new OrderLineItem(); arg.olItem.CustomerPartNo = item.CUSTOMER_PART_NO; arg.olItem.Qty = item.BUY_QTY; arg.olItem.OrderLineNo = item.ORDER_LINE_NO; CheckOrderLineItemAction(arg); olReslut.Add(arg.olItem); } } else { TS_OR_HEADER_STAGE_BLL hsBLL = new TS_OR_HEADER_STAGE_BLL(db); List <TS_OR_HEADER_STAGE> hsList = hsBLL.GetHeaderStageBySeq(orderSeq); if (hsList != null && hsList.Count > 0) { isSaved = false; //Get primary addr and Alt addr stage foreach (var item in hsList) { //special ship if (item.SPL_IND == CHubConstValues.IndY) { splInd = true; if (item.SHIPFROM_SEQ == 0) { poNum = item.CUSTOMER_PO_NO; dueDate = item.DUE_DATE.ToString("yyyy-MM-dd"); note = item.ORDER_NOTES; priAddr = splBLL.GetSpecifyAliasAddrSPL(item.ALIAS_NAME, item.TO_SYSTEM, item.CUSTOMER_NO, item.BILL_TO_LOCATION, item.SHIP_TO_LOCATION, item.DEST_LOCATION); } } else { splInd = false; if (item.SHIPFROM_SEQ == 0) { poNum = item.CUSTOMER_PO_NO; dueDate = item.DUE_DATE.ToString("yyyy-MM-dd"); note = item.ORDER_NOTES; priAddr = dfltBLL.GetSpecifyAliasAddrDFLT(item.ALIAS_NAME, item.TO_SYSTEM, item.CUSTOMER_NO, item.BILL_TO_LOCATION, item.SHIP_TO_LOCATION); } } } TS_OR_DETAIL_STAGE_BLL dsBLL = new TS_OR_DETAIL_STAGE_BLL(db); List <TS_OR_DETAIL_STAGE> dsList = dsBLL.GetDetailsStageByOrderSeq(orderSeq); //change detail ot orderLine OrderLineCheckArg arg = new OrderLineCheckArg(); arg.primarySysID = priAddr.SysID; arg.primaryWareHouse = priAddr.WareHouse; arg.customerNo = priAddr.CustomerNo; arg.altSysID = null; arg.altWareHosue = null; foreach (var item in dsList) { arg.olItem = new OrderLineItem(); arg.olItem.CustomerPartNo = item.CUSTOMER_PART_NO; arg.olItem.Qty = item.BUY_QTY; arg.olItem.OrderLineNo = item.ORDER_LINE_NO; CheckOrderLineItemAction(arg); olReslut.Add(arg.olItem); } } else { this.Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Content("Wrong Order Seq")); } } var obj = new { priAddr = priAddr, altAddr = AltAddr, orderLines = olReslut, isSaved = isSaved, splInd = splInd, poNum = poNum, dueDate = dueDate, note = note }; return(Json(obj)); } }
public ActionResult SaveOrder(OrderSaveArg arg) { try { if (arg.headInfo == null) { return(Content("fail")); } string appUser = Session[CHubConstValues.SessionUser].ToString(); CHubEntities db = new CHubEntities(); TS_OR_HEADER_BLL bll = new TS_OR_HEADER_BLL(db); //Header part TS_OR_HEADER orHeader = ManualClassConvert.ConvertExAliaAddr2Header(arg.headInfo, arg.seq, arg.dueDate, arg.orderType, arg.shipCompFlag, arg.customerPONO, arg.orderNote, arg.isSpecialShip, appUser); TS_OR_HEADER altORHeader = null; if (arg.altHeadInfo != null) { altORHeader = ManualClassConvert.ConvertExAliaAddr2Header(arg.altHeadInfo, arg.seq, arg.dueDate, arg.orderType, arg.shipCompFlag, arg.customerPONO, arg.orderNote, arg.isSpecialShip, appUser, true); } //Detail part List <TS_OR_DETAIL> detailList = null; if (arg.olList != null && arg.olList.Count > 0) { detailList = new List <TS_OR_DETAIL>(); foreach (var item in arg.olList) { //ignore wrong lines if (string.IsNullOrEmpty(item.PartNo) || string.IsNullOrEmpty(item.PriAVLCheckColor)) { continue; } TS_OR_DETAIL detail = ManualClassConvert.ConvertOLItem2Detail(item, arg.seq, appUser); detailList.Add(detail); } } decimal seq = 0; if (string.IsNullOrEmpty(arg.seq)) { seq = bll.AddHeadersWithDetails(orHeader, altORHeader, detailList); } else { seq = bll.UpdateHeadersWithDetails(orHeader, altORHeader, detailList); } if (seq != 0.00M) { return(Content(seq.ToString())); } else { Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(Content("Fail to save order")); } } catch (Exception ee) { //log ee Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(Content(ee.Message)); } }