Beispiel #1
0
 public static Boolean CreateMeter(Meterclass meter)
 {
     Boolean flag = false;
     try
     {
         Icontext objtext = new BALMeter();
         flag = objtext.CreateRecord(meter);
     }
     catch (Exception ex)
     {
         throw;
     }
     return flag;
 }
        public ActionResult Update(Meterclass model)
        {
            if (Session["Login"] != null)
            {
                LoginSession loginsession = (LoginSession)Session["Login"];
                ViewBag.CompanyLogo = loginsession.CompanyLogo;
                if (String.IsNullOrEmpty(model.PropertyID.ToString()))
                {
                    ModelState.AddModelError("Proptery", "Please Select Property ");
                }

                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.Frequency = new SelectList(BAL.MeterModel.MeterReadFrequencyDropDownList(), "Value", "Text");
                ViewBag.Category = new SelectList(BAL.MeterModel.MeterCategoryDropDownList(), "Value", "Text");

                if (ModelState.IsValid)
                {
                    try
                    {

                        model.ModifyBy = Convert.ToInt64(loginsession.UserID);
                        if (MeterModel.UpdateMeter(model))
                        {
                            return RedirectToAction("Index", "Meter");
                        }
                        else
                        {
                            return Content("Unable to save , try again");
                        }
                    }
                    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 #3
0
        public Object EditRecord(Int64 MeterID)
        {
            Meterclass _meter = new Meterclass();
            try
            {
                Meter meter = DAL.DALMeter.EditMeter(Convert.ToInt64(MeterID));
                _meter.ID = meter.ID;
                MeterInfo meterobj = new MeterInfo();
                meterobj.MeterID = meter.ID;
                _meter.Client = meterobj.GetClient();
                _meter.Site = meterobj.GetSite();
                _meter.Property = meterobj.GetProperty();
                _meter.Supplier = meterobj.GetSupplier();

                if (meter.PropertyID != null)
                {
                    _meter.PropertyID = meter.PropertyID;
                }

                if (meter.SupplierID != null)
                {
                    _meter.SupplierID = meter.SupplierID;
                }
                if (meter.FrequencyID != null)
                {
                    _meter.FrequencyID = meter.FrequencyID;
                }
                if (meter.Category != null)
                {
                    _meter.CategoryID = Convert.ToInt32(meter.Category);
                }
                if (meter.DeviceID != null)
                {
                    _meter.DeviceID = meter.DeviceID.Trim();
                }
                if (meter.MeterSerial != null)
                {
                    _meter.MeterSerial = meter.MeterSerial.Trim();
                }
                if (meter.Warrenty != null)
                {
                    _meter.Warrenty = Common.DateGBString(meter.Warrenty.ToString());
                }
               // if (meter.BillingOffset != null)
              //  {
                    _meter.BillingOffset = meter.BillingOffset;
               // }

                    if (meter.OffsetValue != null)
                    {
                        _meter.Offsetvalue = Convert.ToString(meter.OffsetValue);
                    }
                    else
                    {
                        _meter.Offsetvalue = "";
                    }

                if (meter.MeterStartDate != null)
                {
                    _meter.MeterStartDate = Common.DateGBString(meter.MeterStartDate.ToString());
                }
                if (meter.MeterEndDate != null)
                {
                    _meter.MeterEndDate = Common.DateGBString(meter.MeterEndDate.ToString());
                }

                if (meter.OpeningReading != null)
                {
                    _meter.OpeningReading = meter.OpeningReading;
                }

                if (meter.IsHighFrequency != null)
                {
                    if (meter.IsHighFrequency == 0)
                    {
                        _meter.IsHighFrequency = false;
                    }
                    else
                    { _meter.IsHighFrequency = true; }
                }

                if (meter.FrequencyInterval != null)
                {
                    _meter.FrequencyInterval = Common.TimeGBString(meter.FrequencyInterval.ToString());
                }

                MeterLog merterlog = DAL.DALMeter.EditMeterLog(Convert.ToInt64(MeterID));

                _meter.Operation = merterlog.OperationInput;
                if (merterlog.StartDate != null)
                {
                    _meter.ReadInputStart = Common.DateGBString(merterlog.StartDate.ToString());
                }

                if (merterlog.EndDate != null)
                {
                    _meter.ReadInputEndDate = Common.DateGBString(merterlog.EndDate.ToString());
                }

            }
            catch (Exception ex)
            {
                throw;
            }
            return _meter;
        }
        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))
                     {
                         Meterclass meter  = new Meterclass();
                         try
                         {
                             meter = BAL.MeterModel.EditMeter(DecMeterID);
                             ViewBag.MeterID = meter.ID.ToString();
                             ViewBag.PropertyID = meter.PropertyID.ToString();
                             ViewBag.Supplier = meter.SupplierID;
                             ViewBag.Frequency = new SelectList(BAL.MeterModel.MeterReadFrequencyDropDownList(), "Value", "Text", meter.FrequencyID);
                              ViewBag.Category = new SelectList(BAL.MeterModel.MeterCategoryDropDownList(), "Value", "Text",meter.CategoryID);
                              if (meter.FrequencyInterval != null)
                              {
               ViewBag.Interval = new SelectList(BAL.Common.TimeIntervalDropDownList(), "Value", "Text", meter.FrequencyInterval);
                              }
                              else
                              {
                                  ViewBag.Interval = new SelectList(BAL.Common.TimeIntervalDropDownList(), "Value", "Text");
                              }

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

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

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