예제 #1
0
        public ActionResult Create(NotesDoc 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;
                ViewBag.TypeID = model.Type.ToString();
                ViewBag.RefID = model.RefID.ToString();
                if (ModelState.IsValid)
                {
                    try
                    {

                        model.CreateBy = Convert.ToInt64(loginsession.UserID);
                        if (NotesModel.CreateNotes(model))
                        {
                            ViewBag.NoteList = BAL.NotesModel.NotesRecordsList(model.Type.ToString(), model.RefID.ToString());
                            return Json(new { result = 1, message = "Record was successfully Saved!" });
                        }
                        else
                        {
                            ViewBag.NoteList = BAL.NotesModel.NotesRecordsList(model.Type.ToString(), model.RefID.ToString());
                            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"); }
        }
예제 #2
0
        public static Boolean CreateNotes(NotesDoc _notes)
        {
            Boolean flag = false;
               try
               {
               IRecordInsert objtext = new BALNotes();
               flag = objtext.AddRecord(_notes);
               }
               catch (Exception ex)
               {
               throw;
               }

               return flag;
        }
예제 #3
0
        public ActionResult UpdateNotes(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();
                     var Notes = _consumerList.Select(a => a.Notes).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;

                     NotesDoc _note = new NotesDoc();

                     if ((String)Type == "1")//owner
                     {

                         _note.RefID = Convert.ToInt64(OwnerID);
                         _note.Type = Convert.ToInt32("5");
                         _note.NoteDesc = Notes.Trim();
                         _note.CreateBy = Convert.ToInt64(loginsession.UserID);

                     }
                     if ((String)Type == "2")
                     {

                         _note.RefID = Convert.ToInt64(ConsumerID);
                         _note.Type = Convert.ToInt32("6");
                         _note.NoteDesc = Notes.Trim();
                         _note.CreateBy = Convert.ToInt64(loginsession.UserID);

                     }

                       if(_note != null)
                       {
                           if (BAL.NotesModel.CreateNotes(_note))
                           {
                            TempData["SearchParamList"] = Consumerobj;
                            return Json(new { Result = "true" }, JsonRequestBehavior.AllowGet);
                           }
                           else
                           { TempData["SearchParamList"] = Consumerobj;

                           return Json(new { Result = "true" }, JsonRequestBehavior.AllowGet);
                           }
                       }
                       else
                       {
                        TempData["SearchParamList"] = Consumerobj;
                           return Json(new { Result = "true" }, JsonRequestBehavior.AllowGet);
                       }

                 }//try
                 catch (Exception ex)
                 {
                     return Content("Error:" + ex.StackTrace.ToString());
                 }
             }
             else
             { return RedirectToAction("Index", "Home"); }
        }
예제 #4
0
        public JsonResult NoteUpdate(String mRefID, String mTypeID, String Notes)
        {
            if (Session["Login"] != null)
            {
                LoginSession loginsession = (LoginSession)Session["Login"];
                NotesDoc _note = new NotesDoc();
                if ((mRefID != "")&&(mTypeID!="")&&(Notes !=""))
                {
                    _note.RefID = Convert.ToInt64(mRefID);
                    _note.Type = Convert.ToInt32(mTypeID);
                    _note.NoteDesc = Notes.Trim();
                    _note.CreateBy = Convert.ToInt64(loginsession.UserID);
                    ViewBag.TypeID = _note.Type;
                    ViewBag.RefID = _note.RefID;
                    if (BAL.NotesModel.CreateNotes(_note))
                    {
                        return Json(new { Result = "true" }, JsonRequestBehavior.AllowGet);
                    }
                    else
                    { return Json(new { Result = "false" }, JsonRequestBehavior.AllowGet); }

                }

            }
            return Json(new { Result = false }, JsonRequestBehavior.AllowGet);
        }