Ejemplo n.º 1
0
        public ActionResult Create(BulkMeterMaster model)
        {
            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 (loginsession.ClientID != null)
                {
                    ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(loginsession.ClientID), "Value", "Text");
                }
                else
                { ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text"); }

                if (ModelState.IsValid)
                {
                    try
                    {
                        model.CreateBy = Convert.ToInt64(loginsession.UserID);
                        if (BAL.BulkMeterModel.CreateBulkMeter(model))
                        {
                            return Json(new { result = 1, message = "Record was successfully Saved!" });
                        }
                        else
                        {
                            return Json(new { result = 0, message = "Duplicate Meter" });
                        }
                    }
                    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"); }
        }
Ejemplo n.º 2
0
 public static bool UpdateBulkMeter(BulkMeterMaster BulkMeter)
 {
     Boolean flag = false;
     try
     {
         Icontext objinter = new BALBulkMeter();
         flag = objinter.UpdateRecord(BulkMeter);
     }
     catch (Exception ex)
     {
         throw;
     }
     return flag;
 }
Ejemplo n.º 3
0
        public Object EditRecord(Int64 BulkMeterId)
        {
            BulkMeterMaster _Bulk = new BulkMeterMaster();
            try
            {
                BulkMeter Bulk = DAL.DALBulkMeter.EditBulkMeter(Convert.ToInt64(BulkMeterId));
                _Bulk.ID = Bulk.ID;

                if (Bulk.ClientID != null)
                {
                    _Bulk.ClientID = Convert.ToInt64(Bulk.ClientID);
                }

                if (Bulk.SiteID != null)
                {
                    _Bulk.SiteID = Convert.ToInt64(Bulk.SiteID);
                }
                if (Bulk.SupplyID != null)
                {
                    _Bulk.SupplyID = Convert.ToInt64(Bulk.SupplyID);
                }
                if (Bulk.DeviceID != null)
                {
                    _Bulk.DeviceID = Bulk.DeviceID;
                }
                if (Bulk.StartDate != null)
                {
                    _Bulk.StartDate = Common.DateGBString(Bulk.StartDate.ToString());
                }
                if (Bulk.EndDate != null)
                {
                    _Bulk.EndDate = Common.DateGBString(Bulk.EndDate.ToString());
                }
                if (Bulk.Warrenty != null)
                {
                    _Bulk.Warrenty = Common.DateGBString(Bulk.Warrenty.ToString());
                }
                if (Bulk.OpeningReading != null)
                {
                    _Bulk.OpeningReading = Bulk.OpeningReading.Trim();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return _Bulk;
        }
Ejemplo n.º 4
0
        public ActionResult Update(BulkMeterMaster model)
        {
            if (Session["Login"] != null)
            {
                LoginSession loginsession = (LoginSession)Session["Login"];
                ViewBag.CompanyLogo = loginsession.CompanyLogo;
                if (ModelState.IsValid)
                {
                    try
                    {
                        model.ModifyBy = Convert.ToInt64(loginsession.UserID);
                        if (BAL.BulkMeterModel.UpdateBulkMeter(model))
                        {
                            return RedirectToAction("Index", "BulkMeter");
                        }
                        else
                        {
                            return Content("Unable to save , try again");
                        }
                    }
                    catch (Exception ex)
                    {
                        return Content("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"); }
        }
Ejemplo n.º 5
0
        public ActionResult Edit(String MeterID)
        {
            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 (MeterID != null)
                {
                    String DecMeterID = BAL.Security.URLDecrypt(MeterID);
                    if ((DecMeterID != "0") && (DecMeterID != null))
                    {
                        BulkMeterMaster meter = new BulkMeterMaster();
                        try
                        {
                            meter = BAL.BulkMeterModel.EditBulkMeter(DecMeterID);
                            ViewBag.BulkID = meter.ID.ToString();
                            if (loginsession.ClientID != null)
                            {
                                ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(loginsession.ClientID), "Value", "Text", meter.ClientID);
                            }
                            else
                            { ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text", meter.ClientID); }

                            if (meter.SiteID != null)
                            {

                                ViewBag.Site = new SelectList(BAL.SiteModel.SiteDropDownList(loginsession.UserID.ToString(), Convert.ToInt64(meter.ClientID), loginsession.UserType.ToString(), loginsession.RoleName), "Value", "Text", meter.SiteID);
                            }
                            else
                            {
                                ViewBag.Site = new SelectList(BAL.Common.Default_DDR(), "Value", "Text");
                            }
                            if (meter.SupplyID != null)
                            {
                                ViewBag.supply = new SelectList(BAL.SupplyModel.SupplierDropDownList(Convert.ToInt64(meter.ClientID), Convert.ToInt64(meter.SiteID)), "Value", "Text", meter.SupplyID);
                            }
                            else {

                                ViewBag.supply = new SelectList(BAL.Common.Default_DDR(), "Value", "Text");
                            }

                        }
                        catch (Exception ex)
                        { return Content(ex.Message); }
                        return View(meter);

                    }
                    else
                    {
                        return RedirectToAction("Index", "BulkMeter");
                    }

                }
                else { return RedirectToAction("Index", "BulkMeter"); }
            }
            else
            { return RedirectToAction("Index", "Home"); }
        }