public ActionResult Create(TariffMaster model)
 {
     if (Session["Login"] != null)
     {
         if (String.IsNullOrEmpty(model.TariffName))
         {
             ModelState.AddModelError("Tariff Name", "Please Enter Tariff Name");
         }
         if (String.IsNullOrEmpty(model.TariffCode))
         {
             ModelState.AddModelError("Tariff Code", "Please Enter Tariff Code");
         }
         LoginSession loginsession = (LoginSession)Session["Login"];
         if (loginsession.ClientID != null)
         {
             ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(loginsession.ClientID), "Value", "Text");
         }
         else
         { ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text"); }
         ViewBag.TariffType = new SelectList(BAL.TariffModel.TariffTypeDropDownList(), "Value", "Text");
         if (ModelState.IsValid)
         {
             try
             {
                 model.CreateBy = Convert.ToInt64(loginsession.UserID);
                 if (TariffModel.CreateTariff(model))
                 {
                     return Json(new { result = 1, message = "Record was successfully Saved!" });
                 }
                 else
                 {
                     return Json(new { result = 0, message = "Duplicate Tariff Name " });
                 }
             }
             catch (Exception ex)
             {
                 return Json(new { result = 0, message = "ErrorMessage" + ":" + ex.StackTrace.ToString() });
             }
         }
         else
         {
             String errorMessage = String.Empty;
             String exception = String.Empty;
             foreach (var modelStateVal in ViewData.ModelState.Values)
             {
                 foreach (var error in modelStateVal.Errors)
                 {
                     errorMessage = error.ErrorMessage;
                     exception = error.Exception.ToString();
                 }
             }
             return Json(new { result = 0, message = "ErrorMessage" + ":" + exception });
         }
     }
     else
     { return RedirectToAction("Index", "Home"); }
 }
Beispiel #2
0
 public static bool UpdateTariff(TariffMaster tariff)
 {
     Boolean flag = false;
     try
     {
         Icontext objinter = new BALTariff();
         flag = objinter.UpdateRecord(tariff);
     }
     catch (Exception ex)
     {
         throw;
     }
     return flag;
 }
Beispiel #3
0
        public Object EditRecord(Int64 tariffID)
        {
            TariffMaster _tariff = new TariffMaster();
            try
            {
                Tariff tariff = DALTariff.EditTariff(Convert.ToInt32(tariffID));
                _tariff.ID = tariff.ID;

                if (tariff.TariffTypeID != null)
                {
                    _tariff.TariffTypeID = tariff.TariffTypeID;
                }
                if (tariff.ClientID != null)
                {
                    _tariff.ClientID = tariff.ClientID;
                }
                if (tariff.SiteID != null)
                {
                    _tariff.SiteID = tariff.SiteID;
                }
                if (tariff.SupplierID != null)
                {
                    _tariff.SupplierID = tariff.SupplierID;
                }

                if (tariff.AllSite != null)
                {
                    _tariff.AllSite = tariff.AllSite;
                }

                if (tariff.PopBandID != null)
                {
                    _tariff.PopBandID = tariff.PopBandID;
                }

                if (!String.IsNullOrEmpty(tariff.TariffName))
                {
                    _tariff.TariffName = tariff.TariffName;
                }
                if (!String.IsNullOrEmpty(tariff.TariffCode))
                {
                    _tariff.TariffCode = tariff.TariffCode;
                }
                if (!String.IsNullOrEmpty(tariff.UnitPrefix))
                {
                    _tariff.UnitPrefix = tariff.UnitPrefix;
                }
                if (tariff.UnitRate != null)
                {
                    _tariff.UnitRate = tariff.UnitRate.ToString();
                }
                if (tariff.VatRate != null)
                {
                    _tariff.VatRate = tariff.VatRate.ToString();
                }
                if (tariff.FromDate != null)
                {
                    _tariff.FromDate = Common.DateGBString(tariff.FromDate.ToString());
                }
                if (tariff.EndDate != null)
                {
                    _tariff.EndDate = Common.DateGBString(tariff.EndDate.ToString());
                }
                if (tariff.StartTime != null)
                {
                    _tariff.StartTime = Common.TimeGBString(tariff.StartTime.ToString());
                }
                if (tariff.EndTime != null)
                {
                    _tariff.EndTime = Common.TimeGBString(tariff.EndTime.ToString());
                }
                _tariff.IsDailyBasic = tariff.IsDailyBasic;
                TariffInfo Tariff = new TariffInfo ();
                Tariff.TariffID = Convert.ToInt32(tariffID);
                _tariff.Client = Tariff.GetClient();
                _tariff.Site = Tariff.GetSite();
                _tariff.Supplier = Tariff.GetSupplier();
                _tariff.pubband = Tariff.GetPropertyBand();
            }
            catch (Exception ex)
            {
                throw;
            }
            return _tariff;
        }
        public ActionResult Update(TariffMaster model)
        {
            if (Session["Login"] != null)
            {

               if (String.IsNullOrEmpty(model.TariffName))
                {
                    ModelState.AddModelError("Tariff Name", "Please Enter Tariff Name");
                }
                if (String.IsNullOrEmpty(model.TariffCode))
                {
                    ModelState.AddModelError("Tariff Code", "Please Enter Tariff Code");
                }
                if (ModelState.IsValid)
                {
                    try
                    {
                        LoginSession loginsession = (LoginSession)Session["Login"];
                        model.modifyBy = Convert.ToInt64(loginsession.UserID);
                        if (TariffModel.UpdateTariff(model))
                        {
                            return RedirectToAction("Index", "Tariff");
                        }
                        else
                        {
                            return Content("Unable to save , try again");
                        }
                    }
                    catch (Exception ex)
                    {
                        return Content("ErrorMessage" + ":" + ex.StackTrace.ToString());
                    }
                }
                else
                { return RedirectToAction("Index", "Tariff"); }
            }
            else
            { return RedirectToAction("Index", "Home"); }
        }
        public ActionResult Edit(String TariffID)
        {
            if (Session["Login"] != null)
            {
                LoginSession loginsession = (LoginSession)Session["Login"];
                ViewBag.CompanyLogo = loginsession.CompanyLogo;
                ViewBag.Layout1 = BAL.Common.LayoutType(loginsession.UserType);
                String actionName = this.ControllerContext.RouteData.Values["action"].ToString();
                String controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ViewBag.Menu = BAL.Common.GetActiveMenu(controllerName, actionName, BAL.Common.LayoutType(loginsession.UserType));
                ViewBag.RoleName = loginsession.RoleName;
                if (TariffID != null)
                {
                    String Dec_TariffID = BAL.Security.URLDecrypt(TariffID);
                    if ((Dec_TariffID != "0") && (Dec_TariffID != null))
                    {
                        TariffMaster tariff = new TariffMaster();
                        try
                        {
                            tariff = BAL.TariffModel.EditTariff(Dec_TariffID);
                            ViewBag.tariffID = tariff.ID;
                            ViewBag.Client = tariff.ClientID;
                            ViewBag.Site = tariff.SiteID;
                            ViewBag.Supplier = tariff.SupplierID;
                            ViewBag.Popband = tariff.PopBandID;
                            if (tariff.TariffTypeID != 0)
                            {
                                ViewBag.TariffType = new SelectList(BAL.TariffModel.TariffTypeDropDownList(), "Value", "Text", tariff.TariffTypeID);
                            }
                            else {
                                ViewBag.TariffType = new SelectList(BAL.TariffModel.TariffTypeDropDownList(), "Value", "Text");
                            }

                            if (tariff.StartTime != null)
                            {
                                ViewBag.STime = new SelectList(BAL.Common.TimeDropDownList(), "Value", "Text", tariff.StartTime);
                            }
                            else
                            {
                                ViewBag.STime = new SelectList(BAL.Common.TimeDropDownList(), "Value", "Text");
                            }
                            if (tariff.EndTime != null)
                            {
                                ViewBag.EndTime = new SelectList(BAL.Common.TimeDropDownList(), "Value", "Text", tariff.EndTime);
                            }
                            else
                            {
                                ViewBag.EndTime = new SelectList(BAL.Common.TimeDropDownList(), "Value", "Text");
                            }

                        }
                        catch (Exception ex)
                        { return Content(ex.Message); }
                        return View(tariff);
                    }
                    else
                    {
                        return RedirectToAction("Index", "Tariff");
                    }
                }
                else { return RedirectToAction("Index", "Tariff"); }
            }
            else
            { return RedirectToAction("Index", "Home"); }
        }