Esempio n. 1
0
        public ActionResult UpdatePartial(OrderShipmentLine model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //Temporary, because unable to pass Grid column as a parameter to fill combo in grid
                    model.ItemId = SessionHelper.ItemId;
                    model.Id     = currentId;
                    string result = ShipmentHelper.Update(model);
                    if (!string.IsNullOrEmpty(result))
                    {
                        ViewData["EditError"] = result;
                    }
                }
                catch (Exception ex)
                {
                    ViewData["EditError"] = ex.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please correct all errors!";
            }

            return(PartialView("_Detail", SessionHelper.Shipment.OrderShipments));
        }
Esempio n. 2
0
        public ActionResult AddNewPartial(OrderShipmentLine model)
        {
            //Never be in this case..
            if (ModelState.IsValid)
            {
                try
                {
                    if (SessionHelper.Order.OrderDetail != null && SessionHelper.Order.OrderDetail.Count() > 0)
                    {
                        model.Id = SessionHelper.Invoice.InvoiceDetail.LastOrDefault().Id + 1;
                    }
                    else
                    {
                        model.Id = 1;
                    }

                    string result = ShipmentHelper.Insert(model);
                    if (!string.IsNullOrEmpty(result))
                    {
                        ViewData["EditError"] = result;
                    }
                }
                catch (Exception ex)
                {
                    ViewData["EditError"] = ex.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please correct all errors!";
            }
            return(PartialView("_Detail", SessionHelper.Shipment.OrderShipments));
        }
Esempio n. 3
0
        public ActionResult Create()
        {
            OrderShipmentModel newShipment = SessionHelper.Shipment;

            if (newShipment == null)
            {
                newShipment = new OrderShipmentModel
                {
                    DeliveryDate   = DateTime.Now,
                    CompanyId      = AuthenticationHelper.CompanyId.Value,
                    OrderShipments = new List <OrderShipmentLine>()
                };
                SessionHelper.Shipment = newShipment;
            }

            newShipment.Customers = CustomerHelper.GetActiveCustomersCombo(newShipment.DeliveryDate);
            if (newShipment.Customers != null && newShipment.Customers.Count() > 0)
            {
                newShipment.CustomerId = newShipment.CustomerId > 0 ? newShipment.CustomerId : 0;
                newShipment.Customers.Add(new SelectListItem {
                    Text = "-- Select --", Value = "0"
                });
                newShipment.CustomerSites = CustomerHelper.GetCustomerSitesCombo(newShipment.CustomerId);
                if (newShipment.CustomerSites != null && newShipment.CustomerSites.Count() > 0)
                {
                    newShipment.CustomerSiteId = newShipment.CustomerSiteId > 0 ? newShipment.CustomerSiteId : 0;
                    newShipment.CustomerSites.Add(new SelectListItem {
                        Text = "-- Select --", Value = "0"
                    });
                }
            }

            newShipment.Orders = OrderHelper.GetOrdersCombo();
            if (newShipment.Orders != null && newShipment.Orders.Count() > 0)
            {
                newShipment.OrderId = newShipment.OrderId > 0 ? newShipment.OrderId : 0;
                newShipment.Orders.Add(new SelectListItem {
                    Text = "-- Select --", Value = "0"
                });
            }

            newShipment.Warehouses = WarehouseHelper.GetWarehousesCombo(SessionHelper.SOBId);
            if (newShipment.Warehouses != null && newShipment.Warehouses.Count() > 0)
            {
                newShipment.WarehouseId = newShipment.WarehouseId > 0 ? newShipment.WarehouseId : Convert.ToInt64(newShipment.Warehouses.First().Value);
            }

            newShipment.DeliveryNo = "New";
            SessionHelper.Shipment = newShipment;
            SessionHelper.Shipment.OrderShipments = ShipmentHelper.GetShipment(newShipment.WarehouseId, newShipment.CustomerId, newShipment.CustomerSiteId, newShipment.OrderId).OrderShipments;

            return(View("Edit", newShipment));
        }
Esempio n. 4
0
        public ActionResult DeletePartial(OrderShipmentLine model)
        {
            try
            {
                model.Id = currentId;
                string result = ShipmentHelper.Delete(model);
                if (!string.IsNullOrEmpty(result))
                {
                    ViewData["EditError"] = result;
                }
            }
            catch (Exception ex)
            {
                ViewData["EditError"] = ex.Message;
            }

            return(PartialView("_Detail", SessionHelper.Shipment.OrderShipments));
        }
Esempio n. 5
0
        public ActionResult Save(DateTime deliveryDate, string deliveryNo, long warehouseId, long companyId)
        {
            SessionHelper.Shipment.WarehouseId = warehouseId;
            SessionHelper.Shipment.CompanyId   = companyId;

            if (deliveryNo == "New")
            {
                SessionHelper.Shipment.DeliveryDate = DateTime.Now;
                SessionHelper.Shipment.DeliveryNo   = ShipmentHelper.GenerateDeliveryNum(SessionHelper.Shipment);
            }
            else
            {
                SessionHelper.Shipment.DeliveryDate = deliveryDate;
                SessionHelper.Shipment.DeliveryNo   = deliveryNo;
            }

            string result = ShipmentHelper.Save(SessionHelper.Shipment);

            SessionHelper.Shipment = null;
            return(Json(result));
        }
Esempio n. 6
0
        public ActionResult Edit(string no, DateTime date)
        {
            OrderShipmentModel orderShipment = ShipmentHelper.GetShipmentEdit(no, date);

            orderShipment.Customers = CustomerHelper.GetActiveCustomersCombo(orderShipment.DeliveryDate);
            if (orderShipment.Customers != null && orderShipment.Customers.Count() > 0)
            {
                orderShipment.CustomerId = orderShipment.CustomerId > 0 ? orderShipment.CustomerId : Convert.ToInt64(orderShipment.Customers.First().Value);
                orderShipment.Customers.Add(new SelectListItem {
                    Text = "-- Select --", Value = "0"
                });
                orderShipment.CustomerSites = CustomerHelper.GetCustomerSitesCombo(orderShipment.CustomerId);
                if (orderShipment.CustomerSites != null && orderShipment.CustomerSites.Count() > 0)
                {
                    orderShipment.CustomerSiteId = orderShipment.CustomerSiteId > 0 ? orderShipment.CustomerSiteId : Convert.ToInt64(orderShipment.CustomerSites.First().Value);
                    orderShipment.CustomerSites.Add(new SelectListItem {
                        Text = "-- Select --", Value = "0"
                    });
                }
            }

            orderShipment.Orders = OrderHelper.GetOrdersCombo();
            if (orderShipment.Orders != null && orderShipment.Orders.Count() > 0)
            {
                orderShipment.OrderId = orderShipment.OrderId > 0 ? orderShipment.OrderId : Convert.ToInt64(orderShipment.Orders.First().Value);
                orderShipment.Orders.Add(new SelectListItem {
                    Text = "-- Select --", Value = "0"
                });
            }

            orderShipment.Warehouses = WarehouseHelper.GetWarehousesCombo(SessionHelper.SOBId);
            if (orderShipment.Warehouses != null && orderShipment.Warehouses.Count() > 0)
            {
                orderShipment.WarehouseId = orderShipment.WarehouseId > 0 ? orderShipment.WarehouseId : Convert.ToInt64(orderShipment.Warehouses.First().Value);
            }

            SessionHelper.Shipment = orderShipment;

            return(View("Edit", orderShipment));
        }
Esempio n. 7
0
 public ActionResult ListPartial()
 {
     return(PartialView("_List", ShipmentHelper.GetShipments()));
 }
Esempio n. 8
0
 public ActionResult DetailPartialParams(long warehouseId, long customerId, long customerSiteId, long orderId)
 {
     SessionHelper.Shipment.OrderShipments = ShipmentHelper.GetShipment(warehouseId, customerId, customerSiteId, orderId).OrderShipments;
     return(PartialView("_Detail", SessionHelper.Shipment.OrderShipments));
 }
Esempio n. 9
0
 public ActionResult Delete(string no, DateTime date)
 {
     ShipmentHelper.Delete(no, date);
     return(RedirectToAction("Index"));
 }