Exemplo n.º 1
0
        // GET: /Tran/Create
        public ActionResult Create()
        {
            ViewBag.AgentID         = new SelectList(db.Agent, "AgentID", "AgentName");
            ViewBag.CommodityID     = new SelectList(db.Commodity, "CommodityID", "CommodityName");
            ViewBag.OriginCountryID = new SelectList(db.Country, "CountryID", "CountryName");
            ViewBag.ConsigneeID     = new SelectList(db.Customer, "CustomerID", "CustomerName");
            ViewBag.ShipperID       = new SelectList(db.Customer, "CustomerID", "CustomerName");
            ViewBag.CourierID       = new SelectList(db.Courier, "CourierID", "CourierName");
            ViewBag.SalesManID      = new SelectList(db.SalesMan, "SalesManID", "SalesManName");
            ViewBag.ShippingTermID  = new SelectList(db.ShippingTerm, "ShippingTermID", "ShippingTermName");
            ViewBag.ShippingTypeID  = new SelectList(db.ShippingType, "ShippingTypeID", "ShippingTypeName");

            ViewBag.POL = new SelectList(db.Port, "PortID", "PortName");
            ViewBag.POD = new SelectList(db.Port, "PortID", "PortName");
            try
            {
                int salesmanID = SalesManLogic.GetSalesManID(User.Identity.Name);
                ViewBag.CurrentSalesManName = db.SalesMan.FirstOrDefault(s => s.SalesManID == salesmanID).SalesManName;
            }
            catch
            {
                ViewBag.CurrentSalesManName = "none";
            }

            // zaatar
            ViewBag.countryList = new SelectList(db.Country.AsEnumerable(), "CountryID", "CountryName", "-- Select Agent Country --");//db.Country.ToList();


            ViewBag.ShippingTypes = db.ShippingType.ToList();
            return(View());
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "TranID,Updated,Updator,TranRefNumber,ReservationDate,BookingDate,BLNo,ShipperID,ConsigneeID,PhoneNumber,AgentID,SalesManID,ShippingTypeID,ShippingTypeNumbers,CommodityID,ShippingTermID,OriginCountryID,POL,POD,ETD,ETA,TT,FinalDistination,Notes,CourierID")] Tran tran)
        {
            tran.TranRefNumber = Helpers.CreateTranRefNumber();

            //get sales man ID to be saved in the tran.SalesManID
            if (tran.SalesManID == null)
            {
                tran.SalesManID = SalesManLogic.GetSalesManID(User.Identity.Name);
            }

            if (ModelState.IsValid)
            {
                db.Tran.Add(tran);
                db.SaveChanges();
                BusinessLogic.Calculations.CalcTran(tran.TranID, 6);
                //BusinessLogic.Calculations.CalcTotals(tran.TranID);
                return(RedirectToAction("Index"));
            }

            ViewBag.AgentID         = new SelectList(db.Agent, "AgentID", "AgentName", tran.AgentID);
            ViewBag.CommodityID     = new SelectList(db.Commodity, "CommodityID", "CommodityName", tran.CommodityID);
            ViewBag.OriginCountryID = new SelectList(db.Country, "CountryID", "CountryName", tran.OriginCountryID);
            ViewBag.ConsigneeID     = new SelectList(db.Customer, "CustomerID", "CustomerName", tran.ConsigneeID);
            ViewBag.ShipperID       = new SelectList(db.Customer, "CustomerID", "CustomerName", tran.ShipperID);
            ViewBag.CourierID       = new SelectList(db.Courier, "CourierID", "CourierName", tran.CourierID);
            ViewBag.SalesManID      = new SelectList(db.SalesMan, "SalesManID", "SalesManName", tran.SalesManID);
            ViewBag.ShippingTermID  = new SelectList(db.ShippingTerm, "ShippingTermID", "ShippingTermName", tran.ShippingTermID);
            // ZAATAR-MULTIST ViewBag.ShippingTypeID = new SelectList(db.ShippingType, "ShippingTypeID", "ShippingTypeName", tran.ShippingTypeID);

            ViewBag.POL = new SelectList(db.Port, "PortID", "PortName", tran.POL);
            ViewBag.POD = new SelectList(db.Port, "PortID", "PortName", tran.POD);


            // zaatar
            ViewBag.countryList = new SelectList(db.Country.AsEnumerable(), "CountryID", "CountryName", "-- Select Agent Country --");//db.Country.ToList();


            try
            {
                int salesmanID = SalesManLogic.GetSalesManID(User.Identity.Name);
                ViewBag.CurrentSalesManName = db.SalesMan.FirstOrDefault(s => s.SalesManID == salesmanID).SalesManName;
            }
            catch
            {
                ViewBag.CurrentSalesManName = "none";
            }


            return(View(tran));
        }