Exemplo n.º 1
0
        public ActionResult Update(ConsumerMaster 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, BAL.Common.LayoutType(loginsession.UserType));
                ViewBag.RoleName = loginsession.RoleName;
                if (ModelState.IsValid)
                {
                    try
                    {

                        model.CreateBy = Convert.ToInt64(loginsession.UserID);
                        if (ConsumerModel.UpdateConsumer(model))
                        {
                            return RedirectToAction("Index", "Consumer");
                        }
                        else
                        {
                            return Content("Unable to save , try again");
                        }
                    }
                    catch (Exception ex)
                    {
                        return Content("Execption:" + ex.Message);
                    }
                }
                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"); }
        }
Exemplo n.º 2
0
        public ActionResult AddRecord( String OwnerID, String PropID, String SiteID, String ClientID)
        {
            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;
                  ConsumerMaster _Consumer = new ConsumerMaster();
                  DAL.OwnerList ownerobj = new DAL.OwnerList();
                    String DClientID = String.Empty;
                    String DSiteID = String.Empty;
                    String DPropID = String.Empty;
                    String DOwnerID = String.Empty;
                    String DConsID = String.Empty;
                    if ((ClientID != null)&&(DSiteID != null)&&(PropID != null) && (OwnerID != null))
                    {
                        DClientID = BAL.Security.URLDecrypt(ClientID);
                        _Consumer.ClientID = Convert.ToInt64(DClientID);
                        ViewBag.Client_ID = Convert.ToInt64(DClientID);
                        DSiteID = BAL.Security.URLDecrypt(SiteID);
                        _Consumer.SiteID = Convert.ToInt64(DSiteID);
                        ViewBag.Site_ID = Convert.ToInt64(DSiteID);
                        DPropID = BAL.Security.URLDecrypt(PropID);
                        _Consumer.PropertyID = Convert.ToInt64(DPropID);
                        ViewBag.Property_ID = Convert.ToInt64(DPropID);

                        DOwnerID = BAL.Security.URLDecrypt(OwnerID);
                        _Consumer.OwnerID = Convert.ToInt64(DOwnerID);
                         ViewBag.Owner_ID = Convert.ToInt64(DOwnerID);
                        ownerobj = BAL.OwnerModel.ViewOwner(DOwnerID);

                        if (ownerobj != null)
                        {
                            _Consumer.Property = ownerobj.PropertyNo;
                            _Consumer.Client = ownerobj.Client;
                            _Consumer.Site = ownerobj.Site;
                            _Consumer.Owner = ownerobj.ContactName;

                        }
                    }

                    return View(_Consumer);
            }
            else
            { return RedirectToAction("Index", "Home"); }
        }
Exemplo n.º 3
0
        public ActionResult AddConsumer(ConsumerMaster 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, BAL.Common.LayoutType(loginsession.UserType));
                ViewBag.RoleName = loginsession.RoleName;
                if (ModelState.IsValid)
                {
                    try
                    {

                        model.CreateBy = Convert.ToInt64(loginsession.UserID);
                        String ConsumerID = ConsumerModel.AddConsumer(model);
                        if ((!String.IsNullOrEmpty(ConsumerID))&& (ConsumerID !="0"))
                        {
                            DAL.ConsumerList ConsumerObj = new ConsumerList();
                            ConsumerObj = BAL.ConsumerModel.ConsumerBySearchParmaterInfo(ConsumerID);
                            if (ConsumerObj != null)
                            {
                                return RedirectToAction("ConsumerDetails", "Search", new { consID = BAL.Security.URLEncrypt(ConsumerObj.ID), OwnerID = BAL.Security.URLEncrypt(ConsumerObj.OwnerID), PropID = BAL.Security.URLEncrypt(ConsumerObj.PropertyID), SiteID = BAL.Security.URLEncrypt(ConsumerObj.SiteID), ClientID = BAL.Security.URLEncrypt(ConsumerObj.ClientID), MeterID = BAL.Security.URLEncrypt("0") });
                            }
                            else
                            {
                  return RedirectToAction("Index", "Search", new { Field = BAL.Security.URLEncrypt(Convert.ToString("2")), search = "0" });
                            }

                        }
                        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"); }
        }
Exemplo n.º 4
0
        public ActionResult Edit(String ConsumerID)
        {
            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 (ConsumerID != null)
                {
                    String DecConsumerID = BAL.Security.URLDecrypt(ConsumerID);
                    if ((DecConsumerID != "0") && (DecConsumerID != null))
                    {
                        BAL.ConsumerMaster consumer = new BAL.ConsumerMaster();
                        try
                        {
                            consumer = BAL.ConsumerModel.EditConsumer(DecConsumerID);
                            ViewBag.Consumer = consumer.ID;
                            ViewBag.Owner = consumer.OwnerID;
                            ViewBag.Property = consumer.PropertyID;
                        }
                        catch (Exception ex)
                        { return Content(ex.Message); }
                        return View(consumer);
                    }
                    else { return RedirectToAction("Index", "Consumer"); }
                }
                else
                { return RedirectToAction("Index", "Consumer"); }
            }
            else
            { return RedirectToAction("Index", "Home"); }
        }
Exemplo n.º 5
0
       }//CreateConsumerRegistration


       public static Boolean CreateConsumer(ConsumerMaster Consumer)
       {
           Boolean flag = false;
           try
           {
               Icontext objtext = new BALConsumerRegister();
               flag = objtext.CreateRecord(Consumer);
           }
           catch (Exception ex)
           {
               throw;
           }
           return flag;
       }//CreateConsumer
Exemplo n.º 6
0
       }//EditConsumer

       public static bool UpdateConsumer(ConsumerMaster consumer)
       {
           Boolean flag = false;
           try
           {
               Icontext objinter = new BALConsumerRegister();
               flag = objinter.UpdateRecord(consumer);
           }
           catch (Exception ex)
           {
               throw;
           }
           return flag;
       }//UpdateProperty
Exemplo n.º 7
0
       }//CreateRecord


       public Object EditRecord(Int64 ConsumerID)
       {
            ConsumerMaster _consumer = new ConsumerMaster();
          
           try
           {
                Consumer consumer = DAL.DALConsumer.EditConsumer(Convert.ToInt64(ConsumerID));
               _consumer.ID = consumer.ID;
               if (consumer.OwnerID != null)
               {
                   _consumer.OwnerID = consumer.OwnerID;
               }
               if (consumer.PropertyID != null)
               {
                   _consumer.PropertyID = consumer.PropertyID;
               }
               
               if (consumer.ConsumerName != null)
               {
                   _consumer.ConsumerName = consumer.ConsumerName.Trim();
               }
               
               if (consumer.StartDate != null)
               {
                   _consumer.StartDate = Common.DateGBString(consumer.StartDate.ToString());
               }
               if (consumer.EndDate != null)
               {
                   _consumer.EndDate = Common.DateGBString(consumer.EndDate.ToString());
               }
               if (consumer.Address1 != null)
               {
                   _consumer.Address1 = consumer.Address1.Trim();
               }
               if (consumer.Address2 != null)
               {
                   _consumer.Address2 = consumer.Address2.Trim();
               }
               if (consumer.City != null)
               {
                   _consumer.City = consumer.City.Trim();
               }
               if (consumer.County != null)
               {
                   _consumer.County = consumer.County.Trim();
               }
               if (consumer.ZipCode != null)
               {
                   _consumer.ZipCode = consumer.ZipCode.Trim();
               }
               if (consumer.Email != null)
               {
                   _consumer.Email = consumer.Email.Trim();
               }
               if (consumer.Mobile != null)
               {
                   _consumer.Mobile = consumer.Mobile.Trim();
               }
               if (consumer.BankName != null)
               {
                   _consumer.BankName = consumer.BankName.Trim();
               }
               if (consumer.BankSortCode != null)
               {
                   _consumer.BankSortCode = consumer.BankSortCode.Trim();
               }
               if (consumer.BankAccount != null)
               {
                   _consumer.BankAccount = consumer.BankAccount.Trim();
               }


               if (consumer.FirstName != null)
               {
                   _consumer.FirstName = consumer.FirstName.Trim();
               }
               if (consumer.LastName != null)
               {
                   _consumer.LastName = consumer.LastName.Trim();
               }

               if (consumer.Notes != null)
               {
                   _consumer.Notes = consumer.Notes.Trim();
               }

               if (consumer.ClientRefNo != null)
               {
                   _consumer.ClientRefNo = consumer.ClientRefNo.Trim();
               }


               ConsumerInfo consumerinfo = new ConsumerInfo();
               consumerinfo.ConsumerID = consumer.ID;
               _consumer.Client = consumerinfo.GetClientName();
               _consumer.Site = consumerinfo.GetSiteName();
               _consumer.Property = consumerinfo.GetProperty();
               _consumer.Owner = consumerinfo.GetPropertyOwner();
           }
           catch (Exception ex)
           {
               throw;
           }
           return _consumer;
       }//EditRecord
Exemplo n.º 8
0
       }//UpdateConsumerField


       public static String AddConsumer(ConsumerMaster Consumer)
       {
           String ConsumerID = String.Empty;
           try
           {
               IRecordSave objtext = new BALConsumerRegister();
               ConsumerID = objtext.AddRecord(Consumer);
           }
           catch (Exception ex)
           {
               throw;
           }
           return ConsumerID;
       }//CreateConsumer
Exemplo n.º 9
0
        public ActionResult UpdatingConsumer(SearchConsumer model)
        {
            if (Session["Login"] != null)
             {
                 if (String.IsNullOrEmpty(model.EndDate.Trim()))
                 {
                     ModelState.AddModelError("End Date ", "Please Enter  EndDate");
                 }

                 if (String.IsNullOrEmpty(model.ForwardingAddress1.Trim()))
                 {
                     ModelState.AddModelError("End Date ", "Please Fill Up Addresss");
                 }

                 if (String.IsNullOrEmpty(model.ForwardingCity.Trim()))
                 {
                     ModelState.AddModelError("End Date ", "Please Fill Up City");
                 }
                 if (String.IsNullOrEmpty(model.ForwardingPostCode.Trim()))
                 {
                     ModelState.AddModelError("End Date ", "Please Fill Up PostCode");
                 }

                 if ((String.IsNullOrEmpty(model.ConsumerID.Trim())) && (String.IsNullOrEmpty(model.OwnerID.Trim())) && (String.IsNullOrEmpty(model.PropertyID.Trim())) && (String.IsNullOrEmpty(model.SiteID.Trim())) && (String.IsNullOrEmpty(model.ClientID.Trim()))&&  (String.IsNullOrEmpty(model.MeterID.Trim())))
                 {
                     ModelState.AddModelError("Error  ", "Please Try Again");
                 }

                  try
                {
                    if (ModelState.IsValid)
                    {
                        ConsumerMaster _consumer = new ConsumerMaster();
                        _consumer.ID = Convert.ToInt64(model.ConsumerID);
                        _consumer.EndDate = model.EndDate;
                        _consumer.ForwardingAddress1 = model.ForwardingAddress1;
                        _consumer.ForwardingAddress2 = model.ForwardingAddress2;
                        _consumer.ForwardingCity = model.ForwardingCity;
                        _consumer.ForwardingCounty = model.ForwardingCounty;
                        _consumer.ForwardingPostCode = model.ForwardingPostCode;
                        SearchConsumer Consumerobj = new SearchConsumer();
                        Consumerobj.ClientID = model.ClientID;
                        Consumerobj.SiteID = model.SiteID;
                        Consumerobj.PropertyID = model.PropertyID;
                        Consumerobj.MeterID = model.MeterID;
                        Consumerobj.OwnerID = model.OwnerID;
                        Consumerobj.ConsumerID = "0";

                            if (BAL.ConsumerModel.UpdateConsumerField(_consumer))
                            {

                                if (model.IsConsumer == true)
                                {
                                TempData["SearchParamList"] = Consumerobj;
                                return Json(new { result = 1, message = "Record was successfully Saved!" });
                                }
                                else {
                                    TempData["SearchParamList"] = Consumerobj;
                                return Json(new { result = 2, message = "Record was successfully Saved!" });

                                }

                            }
                            else
                            {
                                return Json(new { result = 0, message = "Record Save Failure, Try again" });

                            }
                    }
                    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 });

                    }

                }// try
                catch (Exception ex)
                {
                    return Json(new { result = 0, message = "ErrorMessage" + ":" + ex.StackTrace.ToString() });

                }
             }else
             { return RedirectToAction("Index", "Home"); }
        }
Exemplo n.º 10
0
        public ActionResult UpdateTelephone(List<SearchConsumer> ConsumerList)
        {
            if (Session["Login"] != null)
            {
                LoginSession loginsession = (LoginSession)Session["Login"];
                try
                {
                    List<SearchConsumer> _consumerList = new List<SearchConsumer>();
                    _consumerList = ConsumerList;
                    _consumerList.Select(c => { c.ModifyBy = Convert.ToInt64(loginsession.UserID); return c; }).ToList();
                    var Type = _consumerList.Select(a => a.ConsumerType).FirstOrDefault();
                    var ConsumerID = _consumerList.Select(a => a.ConsumerID).FirstOrDefault();
                    var OwnerID = _consumerList.Select(a => a.OwnerID).FirstOrDefault();
                    var PropertyID = _consumerList.Select(a => a.PropertyID).FirstOrDefault();
                    var Site_ID = _consumerList.Select(a => a.SiteID).FirstOrDefault();
                    var Client_ID = _consumerList.Select(a => a.ClientID).FirstOrDefault();
                    var Meter_Id = _consumerList.Select(a => a.MeterID).FirstOrDefault();
                     SearchConsumer Consumerobj = new SearchConsumer();
                     Consumerobj.ClientID = (String)Client_ID;
                     Consumerobj.SiteID = (String)Site_ID;
                     Consumerobj.PropertyID = (String)PropertyID;
                     Consumerobj.MeterID = (String)Meter_Id;
                     Consumerobj.OwnerID = (String)OwnerID;
                     Consumerobj.ConsumerID = (String)ConsumerID;
                    OwnerMaster _owner = new OwnerMaster();
                    ConsumerMaster _consumer = new ConsumerMaster();
                    if ((String)Type == "1")
                    {
                        _owner = _consumerList.Select(P => new OwnerMaster
                        {
                            ID = Convert.ToInt64(P.OwnerID),
                            Telephone = P.OwnerTele != null?P.OwnerTele : null ,
                            Email = P.OwnerEmail != null ?P.OwnerEmail : null,
                            ModifyBy=P.ModifyBy
                        }).FirstOrDefault();

                        if (_owner != null)
                        {
                            if (BAL.OwnerModel.UpdateOwnerField(_owner))
                            {
                                TempData["SearchParamList"] = Consumerobj;
                                return Json(new { Result = "true" }, JsonRequestBehavior.AllowGet);
                            }
                            else
                            {
                                return Json(new { Result = "false" }, JsonRequestBehavior.AllowGet);
                            }
                        }
                        else { return Json(new { Result = "false" }, JsonRequestBehavior.AllowGet); }
                    }
                    if ((String)Type == "2")
                    {
                        _consumer = _consumerList.Select(P => new ConsumerMaster
                        {
                            ID = Convert.ToInt64(P.ConsumerID),
                            Mobile = P.ConsumerTele != null?P.ConsumerTele:null ,
                            Email = P.ConsumerEmail != null ?P.ConsumerEmail:null,
                            ModifyBy = P.ModifyBy
                        }).FirstOrDefault();

                        if (_consumer != null)
                        {
                            if (BAL.ConsumerModel.UpdateConsumerField(_consumer))
                            {
                                TempData["SearchParamList"] = Consumerobj;
                                return Json(new { Result = "true" }, JsonRequestBehavior.AllowGet);
                            }
                            else
                            {
                                return Json(new { Result = "false" }, JsonRequestBehavior.AllowGet);
                            }
                        }
                        else { return Json(new { Result = "false" }, JsonRequestBehavior.AllowGet); }
                    }
                    else { return Json(new { Result = "false" }, JsonRequestBehavior.AllowGet); }
                }
                catch (Exception ex)
                {
                    return Content("Error:" + ex.StackTrace.ToString());
                }

            }
            else
            { return RedirectToAction("Index", "Home"); }
        }
Exemplo n.º 11
0
       }//  ConsumerBySearchParmaterInfo 

       public static bool UpdateConsumerInfromation(ConsumerMaster consumer)
       {
           Boolean flag = false;
           try
           {
               IModifyRecord objinter = new BALConsumerRegister();
               flag = objinter.UpdateRecord(consumer);
           }
           catch (Exception ex)
           {
               throw;
           }
           return flag;
       }//UpdateConsumerField