public JsonResult ConsumerDetails(String mConsumerID)
        {
            if (Session["Login"] != null)
            {
                try
                {
                    LoginSession loginsession = (LoginSession)Session["Login"];

                    if ((mConsumerID != null) && (mConsumerID != ""))
                    {
                        ConsumerList Consumer = new ConsumerList();
                        Consumer = BAL.SearchModel.ViewConsumer(mConsumerID);
                        return Json(new { ConsName = Consumer.ConsumerName, ConsAddress = Consumer.ConsumerAddress, ConsCity = Consumer.City, ConsCounty = Consumer.County, ConsZipcode = Consumer.ZipCode, Owner = Consumer.OwnerName, property = Consumer.Property, ConsEmail = Consumer.Email, ConsMobile = Consumer.Mobile, ConsStartDate = Consumer.ConsumerStartDate, ConsEndDate = Consumer.ConsumerEndDate }, JsonRequestBehavior.AllowGet);

                    }
                }
                catch (Exception ex)
                {
                    return Json(null);
                }

            }
            return Json(null);
        }
        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"); }
        }
 public ActionResult CView(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);
             DAL.ConsumerList consumer = new DAL.ConsumerList();
             if ((DecConsumerID != "0") && (DecConsumerID != null))
             {
                 try
                 {
                     consumer = BAL.ConsumerModel.ViewConsumer(DecConsumerID);
                 }
                 catch (Exception ex)
                 {
                     return Content("Execption:" + ex.Message);
                 }
             }
             return View(consumer);
         }
         else
         { return RedirectToAction("Index", "Consumer"); }
     }
     else
     { return RedirectToAction("Index", "Home"); }
 }
Beispiel #4
0
       }// AddRecord



       public Object RecordView(String ConsumerID)
       {
           DAL.ConsumerList consumer = new DAL.ConsumerList();
           try
           {
               consumer = DAL.DALConsumerCls.ViewConsumer(ConsumerID);
           }
           catch (Exception ex)
           {
               throw;
           }
           return consumer;
       }//ViewRecord
Beispiel #5
0
 public Object ViewRecord(Int64 ConsumerID)
 {
     DAL.ConsumerList consumer = new DAL.ConsumerList();
     try
     {
         consumer = DAL.DALConsumer.ViewConsumer(Convert.ToInt64(ConsumerID));
     }
     catch (Exception ex)
     {
         throw;
     }
     return consumer;
 }//ViewRecord
Beispiel #6
0
 public static ConsumerList ViewConsumer(String ConsumerID)
 {
     ConsumerList Consumer = new ConsumerList();
     using (var context = new SycousCon())
     {
         try
         {
             var parID = new SqlParameter
             {
                 ParameterName = "ID",
                 Value = ConsumerID,
                 Direction = ParameterDirection.Input
             };
             Consumer = context.ExecuteStoreQuery<ConsumerList>("exec [SYCOUS].[GetConsumerDetails] @ID", parID).FirstOrDefault();
             return Consumer;
         }
         catch (Exception ex)
         {
             context.Dispose();
             throw;
         }
     }
 }
Beispiel #7
0
        public static ConsumerList ViewConsumer(Int64 ConsumerID)
        {
            ConsumerList objconsumer = new ConsumerList();
            using (var context = new SycousCon())
            {
                try
                {
                    objconsumer = (from Y in context.Consumers
                                   join P in context.Properties
                                    on Y.PropertyID equals P.ID
                                   join O in context.Owners
                                         on Y.OwnerID equals O.ID
                                   join S in context.SiteMasters
                                     on P.SiteID equals S.Id
                                   join C in context.ClientMasters
                                   on S.ClientID equals C.ClientID
                                  // join R in context.ConsumerRegs
                                  // on Y.ID equals R.ConsumerID
                                   //join U in context.UserREGs
                                   //on R.USERID equals U.UserID
                                   where (Y.IsDeleted == 0 && P.IsDeleted == 0 && O.IsDeleted == 0 && Y.ID == ConsumerID )
                                   orderby Y.CreateDate descending, Y.ModifyDate descending
                                   select new ConsumerList()
                                   {
                                       ID = SqlFunctions.StringConvert((Double)Y.ID).Trim(),
                                       Property = P.PropertyNumber + " " + P.Address1  ,
                                       Client = C.Name,
                                       Site = S.SiteName,
                                       Owner = ((O.FirstName.Trim() != "") ? O.FirstName.Trim() : "") + "   " + ((O.LastName.Trim() == null) ? "" : O.LastName.Trim()),
                                       ConsumerName = ((Y.FirstName.Trim() != "") ? Y.FirstName.Trim() : "") + "   " + ((Y.LastName.Trim() == null) ? "" : Y.LastName.Trim()),
                                       StartDate = Y.StartDate,
                                       EndDate = Y.EndDate,
                                       Address1 = Y.Address1,
                                       Address2 = Y.Address2,
                                       City = Y.City,
                                       County = Y.County,
                                       ZipCode = Y.ZipCode,
                                       Email = Y.Email,
                                       Mobile = Y.Mobile,
                                       BankName = Y.BankName,
                                       BankSortCode = Y.BankSortCode,
                                       BankAccount = Y.BankAccount,
                                      // RegistrationEmail = R.Email
                                       //FirstName= U.FirstName,
                                       //LastName = U.LastName,
                                       //Question =U.HintQuestion,
                                       //Answer =U.HintAns
                                       ClientRef=Y.ClientRefNo,
                                       Notes = Y.Notes
                                   }).FirstOrDefault();

                    return objconsumer;
                }
                catch (Exception ex)
                {
                    context.Dispose();
                    throw;
                }
            }
        }