public ActionResult Create(DisConnectedSupplyClass 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 (String.IsNullOrEmpty(model.ClientID.ToString()))
                {
                    ModelState.AddModelError("Client", "Please Select  Client");
                }
                if (String.IsNullOrEmpty(model.SiteID.ToString()))
                {
                    ModelState.AddModelError("Site", "Please Select  Site");
                }

                if (String.IsNullOrEmpty(model.SupplierID.ToString()))
                {
                    ModelState.AddModelError("Supply", "Please Select  Supply");
                }

                if (ModelState.IsValid)
                {
                    try
                    {

                        model.CreateBy = Convert.ToInt64(loginsession.UserID);
                        if (BAL.DisConnectedSupplyModel.CreateDisConnectedSupply(model))
                        {
                            return Json(new { result = 1, message = "Record was successfully Saved!" });
                        }
                        else
                        {
                            return Json(new { result = 0, message = "Duplicate Energy Supplier " });
                        }
                    }
                    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 Update(DisConnectedSupplyClass model)
        {
            if (Session["Login"] != null)
            {
                try
                {
                    LoginSession loginsession = (LoginSession)Session["Login"];
                    model.ModifyBy = Convert.ToInt64(loginsession.UserID);
                    if (BAL.DisConnectedSupplyModel.UpdateDisConnectedSupply(model))
                    {
                        return RedirectToAction("Index", "Disconnected");
                    }
                    else
                    {
                        return Content("Unable to save ,Plz Try again");
                    }
                }
                catch (Exception ex)
                {
                    return Content("ErrorMessage" + ":" + ex.StackTrace.ToString());
                }

            }
            else
            { return RedirectToAction("Index", "Home"); }
        }
Пример #3
0
        public Object EditRecord(Int64 DisConnectedId)
        {
            DisConnectedSupplyClass _DisConnected = new DisConnectedSupplyClass();
            try
            {
                DAL.DisConnectedSupply DisConnected = DAL.DALDisConnectedSupply.EditDisConnectedSupply(Convert.ToInt64(DisConnectedId));
                _DisConnected.ID = Convert.ToInt64(DisConnected.ID);

                if (DisConnected.ClientID != null)
                {
                    _DisConnected.ClientID = Convert.ToInt64(DisConnected.ClientID);
                }
                if (DisConnected.SiteID != null)
                {
                    _DisConnected.SiteID = Convert.ToInt64(DisConnected.SiteID);
                }

                if (DisConnected.SupplierID != null)
                {
                    _DisConnected.SupplierID = Convert.ToInt64(DisConnected.SupplierID);
                }

                if (DisConnected.ConsumptionValue != null)
                {
                    _DisConnected.ConsumptionValue = DisConnected.ConsumptionValue.ToString();
                }

                if (DisConnected.FormDate != null)
                {
                    _DisConnected.FromDate = BAL.Common.DateGBString(DisConnected.FormDate.ToString());
                }

                if (DisConnected.ToDate != null)
                {
                    _DisConnected.ToDate = BAL.Common.DateGBString(DisConnected.ToDate.ToString());
                }
                else
                {
                    _DisConnected.ToDate = null;
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return _DisConnected;
        }
 public ActionResult Edit(String DisConnectedID)
 {
     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 (DisConnectedID != null)
         {
             String DecDisConnectedID = BAL.Security.URLDecrypt(DisConnectedID);
             if ((DecDisConnectedID != "0") && (DecDisConnectedID != null))
             {
                 DisConnectedSupplyClass DisConnected = new DisConnectedSupplyClass();
                 try
                 {
                     DisConnected = BAL.DisConnectedSupplyModel.EditDisConnectedSupply(DecDisConnectedID);
                     ViewBag.UnOccupiedID = DisConnected.ID;
                     ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text", DisConnected.ClientID);
                     ViewBag.Site = new SelectList(BAL.SiteModel.SiteDropDownList(loginsession.UserID.ToString(), DisConnected.ClientID, loginsession.UserType.ToString(), loginsession.RoleName), "Value", "Text", DisConnected.SiteID);
                     ViewBag.Supplier = new SelectList(BAL.SupplyModel.SupplierDropDownList(Convert.ToInt64(DisConnected.ClientID), Convert.ToInt64(DisConnected.SiteID)), "Value", "Text", DisConnected.SupplierID);
                 }
                 catch (Exception ex)
                 { return Content(ex.Message); }
                 return View(DisConnected);
             }
         }
         {
             return RedirectToAction("Index", "Disconnected");
         }
     }
     else
     { return RedirectToAction("Index", "Home"); }
 }
Пример #5
0
        public static Boolean UpdateDisConnectedSupply(DisConnectedSupplyClass DisConnected)
        {
            Boolean flag = false;
            try
            {
                Icontext objtext = new BALDisConnectedSupply();
                flag = objtext.UpdateRecord(DisConnected);
            }
            catch (Exception ex)
            {
                throw;
            }

            return flag;
        }