示例#1
0
        public ActionResult Index()
        {
            List <Entity.Fuel> fuel = FuelLogic.getInstance().getAllFuel();
            List <FuelModels>  Data = new List <FuelModels>();

            for (int i = 0; i < fuel.Count; i++)
            {
                FuelModels item = new FuelModels();
                item.FuelId          = fuel[i].FuilId;
                item.FuelName        = fuel[i].Name;
                item.Price           = fuel[i].Price;
                item.IsSubsidy       = fuel[i].IsSubsidy == "Y"?"Subsidi":"Non Subsidi";
                item.BackgroundColor = fuel[i].BackgroundColor;
                item.TextColor       = fuel[i].TextColor;
                item.CreatedDate     = fuel[i].CreatedDate;
                item.CreatedBy       = fuel[i].CreatedBy;
                item.UpdatedDate     = fuel[i].UpdatedDate;
                item.UpdatedBy       = fuel[i].UpdatedBy;

                Data.Add(item);
            }
            PagedList <FuelModels> page = new PagedList <FuelModels>();

            page.Content = Data;
            return(View(page));
        }
示例#2
0
        public void Add(FuelModels model)
        {
            try
            {
                string dateTimeDayNow = DateTime.Now.ToString("ddMMyyyyHHmmss");
                string dateDayNow     = DateTime.Now.ToString("ddMMyyyy");

                db = new BMotionDBEntities();
                Fuel fuelEntity = new Fuel();
                fuelEntity.FuilId          = model.FuelId;
                fuelEntity.Name            = model.FuelName;
                fuelEntity.Price           = model.Price;
                fuelEntity.IsSubsidy       = model.IsSubsidy;
                fuelEntity.BackgroundColor = model.BackgroundColor;
                fuelEntity.TextColor       = model.TextColor;
                fuelEntity.CreatedDate     = DateTime.Now;
                fuelEntity.CreatedBy       = SessionManager.NIP();
                db.Fuels.Add(fuelEntity);
                db.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#3
0
 public bool CheckExistingData(FuelModels model)
 {
     if (db.Fuels.Where(fuel => fuel.Name.Equals(model.FuelName)).Count() == 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#4
0
        public ActionResult Edit(FuelModels model)
        {
            try
            {
                FuelLogic.getInstance().Update(model);
                TempData["Success"] = "Success saving Data for " + model.FuelName;
            }
            catch (Exception e)
            {
                Logging.Log.getInstance().CreateLogError(e);
            }

            return(RedirectToAction("Index"));
        }
示例#5
0
 public void Update(FuelModels model)
 {
     try
     {
         db = new BMotionDBEntities();
         Fuel fuel = (from u in db.Fuels
                      where u.FuilId.Equals(model.FuelId)
                      select u).First();
         fuel.Name      = model.FuelName;
         fuel.Price     = model.Price;
         fuel.IsSubsidy = model.IsSubsidy;
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#6
0
        public ActionResult Create(FuelModels model)
        {
            try
            {
                if (FuelLogic.getInstance().CheckExistingData(model))
                {
                    FuelLogic.getInstance().Add(model);
                    TempData["Success"] = "Success saving Data for " + model.FuelName;
                }
                else
                {
                    TempData["Error"] = "User " + model.FuelName + " is exist";
                }
            }
            catch (Exception e)
            {
                Logging.Log.getInstance().CreateLogError(e);
            }

            return(RedirectToAction("Index"));
        }
示例#7
0
        public ActionResult Edit(int ID)
        {
            FuelModels model = new FuelModels();
            var        data  = db.Fuels.Where(f => f.FuilId == ID).ToList();

            if (data.Count() > 0)
            {
                model.FuelId          = data.FirstOrDefault().FuilId;
                model.FuelName        = data.FirstOrDefault().Name;
                model.Price           = data.FirstOrDefault().Price;
                model.IsSubsidy       = data.FirstOrDefault().IsSubsidy;
                model.BackgroundColor = data.FirstOrDefault().BackgroundColor;
                model.TextColor       = data.FirstOrDefault().TextColor;
                model.CreatedDate     = data.FirstOrDefault().CreatedDate;
                model.CreatedBy       = data.FirstOrDefault().CreatedBy;
                model.UpdatedDate     = data.FirstOrDefault().UpdatedDate;
                model.UpdatedBy       = data.FirstOrDefault().UpdatedBy;
            }
            else
            {
            }
            return(View(model));
        }
示例#8
0
        public ActionResult StrukBBM(string orderNo)
        {
            StruckModels struk = new StruckModels();
            //StruckOrderDetails orderDetail = new StruckOrderDetails();
            FuelModels                fuelModels = new FuelModels();
            List <StruckModels>       listModel  = new List <StruckModels>();
            List <StruckOrderDetails> listOrder  = new List <StruckOrderDetails>();
            List <FuelModels>         fuelList   = new List <FuelModels>();

            try
            {
                int  n;
                bool isNumeric = int.TryParse(orderNo, out n);
                var  list      = db.sp_StrukPengambilanBBM(orderNo).ToList();
                if (isNumeric)
                {
                    // Confirmation Struck
                    if (db.OrderDetails.AsEnumerable().Where(dtl => dtl.OrderDetailId == Int32.Parse(orderNo) && dtl.IsVerify == null).Count() > 0)
                    {
                        //OrderDetails model = new OrderDetails();
                        //model.OrderDetailId = Convert.ToInt32(orderNo);
                        //OrdersLogic.getInstance().VerifyOrder(model);

                        var verify = db.sp_OrderDetailVerify(orderNo);
                        return(Json("OK", JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json("Failed", JsonRequestBehavior.AllowGet));
                    }
                }
                // Get Struk
                else if (list.Count > 0)
                {
                    foreach (var item in list)
                    {
                        struk            = new StruckModels();
                        struk.OrderNo    = item.OrderNo;
                        struk.OutletNo   = item.OutletNo;
                        struk.OutletName = item.OutletName;
                        struk.Name       = item.Name;

                        struk.FuelName      = item.FuelName;
                        struk.Liter         = item.Liter;
                        struk.OrderDetailId = item.OrderDetailId;
                        struk.CreatedDate   = item.CreatedDate.Value.ToString("MM/dd/yyyy HH:mm:ss");
                        listModel.Add(struk);
                    }
                }
                else
                {
                    return(Json("Failed", JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                Logging.Log.getInstance().CreateLogError(e);
            }

            return(Json(listModel, JsonRequestBehavior.AllowGet));
        }