public ActionResult Create(OwnerMaster model)
        {
            if (Session["Login"] != null)
            {

                if (ModelState.IsValid)
                {
                    try
                    {
                        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));
                        model.CreateBy = Convert.ToInt64(loginsession.UserID);

                        if (OwnerModel.CreateOwner(model))
                        {
                            return Json(new { result = 1, message = "Record was successfully Saved!" });
                        }
                        else
                        {
                            return Json(new { result = 0, message = "Duplicate Notification 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"); }
        }
Esempio n. 2
0
        //Client As owner
        Object IRecordEdit.EditRecord(Int64 OwnerID)
        {
            OwnerMaster _owner = new OwnerMaster();
            try
            {
                OwnerAsClient owner = DAL.DALOwnerAsClient.EditOwner(Convert.ToInt64(OwnerID));
                _owner.ID = owner.ID;

                if (owner.StartDate != null)
                {
                    _owner.StartDate = Common.DateGBString(owner.StartDate.ToString());
                }

                if (owner.ClientID != null)
                {
                    _owner.ClientID = owner.ClientID;
                }

                if (owner.SiteID != null)
                {
                    _owner.SiteID = owner.SiteID;
                }
                if (owner.PropertyID != null)
                {
                    _owner.propertyID = owner.PropertyID;
                }
                if (owner.Enddate != null)
                {
                    _owner.EndDate = Common.DateGBString(owner.Enddate.ToString());
                }

                OwnerAsClientInfo OW = new OwnerAsClientInfo();
                OW.OwnerAsClientID = owner.ID;
                _owner.Client = OW.GetClient();
                _owner.Site = OW.GetSite();
                _owner.Property = OW.GetProperty();

            }
            catch (Exception ex)
            {
                throw;
            }
            return _owner;
        }
Esempio n. 3
0
        public Object EditRecord(Int64 OwnerID)
        {
            OwnerMaster _owner = new OwnerMaster();
            try
            {
                Owner owner = DAL.DALOwner.EditOwner(Convert.ToInt64(OwnerID));
                _owner.ID = owner.ID;
                if (owner.ContactName != null)
                {
                    _owner.ContactName = owner.ContactName.Trim();
                }
                if (owner.StartDate != null)
                {
                    _owner.StartDate = Common.DateGBString(owner.StartDate.ToString());
                }
                if (owner.BankName != null)
                {
                    _owner.BankName = owner.BankName.Trim();
                }
                if (owner.BankSortCode != null)
                {
                    _owner.BankSortCode = owner.BankSortCode.Trim();
                }
                if (owner.BankAccountNo != null)
                {
                    _owner.BankAccountNo = owner.BankAccountNo.Trim();
                }
                if (owner.Address1 != null)
                {
                    _owner.Address1 = owner.Address1.Trim();
                }
                if (owner.Address2 != null)
                {
                    _owner.Address2 = owner.Address2.Trim();
                }
                if (owner.Corrs != null)
                {
                    _owner.Corrs = owner.Corrs.Trim();
                }
                if (owner.City != null)
                {
                    _owner.City = owner.City.Trim();
                }
                if (owner.County != null)
                {
                    _owner.County = owner.County.Trim();
                }
                if (owner.PostCode != null)
                {
                    _owner.PostCode = owner.PostCode.Trim();
                }
                if (owner.Email != null)
                {
                    _owner.Email = owner.Email.Trim();
                }
                if (owner.MailService != null)
                {
                    _owner.MailService = owner.MailService;
                }
                if (owner.Telephone != null)
                {
                    _owner.Telephone = owner.Telephone.Trim();
                }
                if (owner.Mobile != null)
                {
                    _owner.Mobile = owner.Mobile.Trim();
                }
                if (owner.Agent != null)
                {
                    _owner.Agent = owner.Agent.Trim();
                }

                if (owner.AgentTelephone != null)
                {
                    _owner.AgentTelephone = owner.AgentTelephone.Trim();
                }

                if (owner.AgentEmail != null)
                {
                    _owner.AgentEmail = owner.AgentEmail.Trim();
                }

                if (owner.SiteID != null)
                {
                    _owner.SiteID = owner.SiteID;
                }
                if (owner.PropertyID != null)
                {
                    _owner.propertyID = owner.PropertyID;
                }
                if (owner.Enddate != null)
                {
                    _owner.EndDate = Common.DateGBString(owner.Enddate.ToString());
                }

                if (owner.FirstName != null)
                {
                    _owner.FirstName = owner.FirstName.Trim();
                }
                if (owner.LastName != null)
                {
                    _owner.LastName = owner.LastName.Trim();
                }

                if (owner.Notes != null)
                {
                    _owner.Notes = owner.Notes.Trim();
                }
                if (owner.ClientRefNo!= null)
                {
                    _owner.ClientRefNo = owner.ClientRefNo.Trim();
                }

                OwnerInfo OW = new OwnerInfo();
                OW.OwnerID = owner.ID;
                _owner.Client = OW.GetClient();
                _owner.Site = OW.GetSite();
                _owner.Property = OW.GetProperty();

            }
            catch (Exception ex)
            {
                throw;
            }
            return _owner;
        }
Esempio n. 4
0
 public static bool UpdateOwnerField(OwnerMaster owner)
 {
     Boolean flag = false;
     try
     {
         IUpdate objinter = new BALOwner();
         flag = objinter.UpdateRecord(owner);
     }
     catch (Exception ex)
     {
         throw;
     }
     return flag;
 }
Esempio n. 5
0
 public static Boolean CreateOwner(OwnerMaster owner)
 {
     Boolean flag = false;
     try
     {
         Icontext objtext = new BALOwner();
         flag = objtext.CreateRecord(owner);
     }
     catch (Exception ex)
     {
         throw;
     }
     return flag;
 }
Esempio n. 6
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"); }
        }
Esempio n. 7
0
        public ActionResult UpdateRecord(OwnerMaster model)
        {
            if (Session["Login"] != null)
            {

             //   if (ModelState.IsValid)

                if((model.ID != null) &&(model.EndDate != null))
                {

                    try
                    {
                        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));
                        model.CreateBy = Convert.ToInt64(loginsession.UserID);
                        if (OwnerModel.UpdateOwnerAsClient(model))
                        {
                            return RedirectToAction("Index", "Owner");
                        }
                        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 : Try again"  });
                }

            }
            else
            { return RedirectToAction("Index", "Home"); }
        }
Esempio n. 8
0
 //public ActionResult OwnerView(String OwnerID)
 //{
 //    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));
 //        if (OwnerID != null)
 //        {
 //            String Dec_OwnerID = BAL.Security.URLDecrypt(OwnerID);
 //            DAL.OwnerList owner = new DAL.OwnerList();
 //            if ((Dec_OwnerID != "0") && (Dec_OwnerID != null))
 //            {
 //                try
 //                {
 //                    owner = BAL.OwnerModel.ViewOwnerAsClientRecord(Dec_OwnerID);
 //                }
 //                catch (Exception ex)
 //                {
 //                    return Content("Execption:" + ex.Message);
 //                }
 //            }
 //            return View(owner);
 //        }
 //        else
 //        { return RedirectToAction("Index", "Notify"); }
 //    }
 //    else
 //    { return RedirectToAction("Index", "Home"); }
 //}//
 public ActionResult EditRecord(String OwnerID)
 {
     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));
         if (OwnerID != null)
         {
             String Dec_OwnerID = BAL.Security.URLDecrypt(OwnerID);
             if ((Dec_OwnerID != "0") && (Dec_OwnerID != null))
             {
                 OwnerMaster owner = new OwnerMaster();
                 try
                 {
                     owner = BAL.OwnerModel.EditOwnerAsClient(Dec_OwnerID);
                     ViewBag.Owner_ID = owner.ID;
                     ViewBag.Site = owner.SiteID;
                     ViewBag.Property = owner.propertyID;
                 }
                 catch (Exception ex)
                 { return Content(ex.Message); }
                 return View(owner);
             }
             else { return RedirectToAction("Index", "Owner"); }
         }
         else
         { return RedirectToAction("Index", "Owner"); }
     }
     else
     { return RedirectToAction("Index", "Home"); }
 }