//only person can edit a complaint who add a complaint!
        // GET: Complaint/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            complaint complaint      = db.complaint.Find(id);
            var       SessionControl = Convert.ToInt32(HttpContext.Session["UserDatabaseID"]);

            if (SessionControl != complaint.FK_USER_ID)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (complaint == null)
            {
                return(HttpNotFound());
            }
            if (complaint.STATUS.ToUpper().Trim() != "NEW")
            {
                TempData["warn"] = "This complaint already seen by a maintanence officer,You can not edit or Delete!";
                return(View(complaint));
            }
            SetCategory();
            ViewBag.Itemlist       = new SelectList(GetItemType(), "ID", "Item_Type");
            ViewBag.DepartmentList = new SelectList(GetDepartmentList(), "ID", "DEPT_NAME");
            return(View(complaint));
        }
Esempio n. 2
0
        // GET: MaintanenceComplaint/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            int       quoteint  = (int)id;
            complaint complaint = db.complaint.Find(id);

            ViewBag.StatusList = GetStatus();
            int sessionControl          = Convert.ToInt32(HttpContext.Session["UserDatabaseID"]);
            ComplaintHistoryModel model = new ComplaintHistoryModel()
            {
                CompID       = quoteint,
                CategoryUser = sessionControl,
            };

            if (complaint == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FK_CATEGORY_ID = new SelectList(db.category, "ID", "CATEGORY_NAME", complaint.FK_CATEGORY_ID);
            ViewBag.FK_ITEM_ID     = new SelectList(db.item, "ID", "ITEM_NAME", complaint.FK_ITEM_ID);
            ViewBag.FK_Location_ID = new SelectList(db.location, "ID", "ROOM_ID", complaint.FK_Location_ID);
            ViewBag.FK_USER_ID     = new SelectList(db.user, "ID", "FIRST_NAME", complaint.FK_USER_ID);
            return(View(model));
        }
Esempio n. 3
0
        public ActionResult Index()
        {
            int sessionRoleControl = Convert.ToInt32(HttpContext.Session["RoleID"]);
            var sessionControl     = Convert.ToString(HttpContext.Session["UserID"]);

            if (sessionRoleControl != 7)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                try
                {
                    var       SessionControl = Convert.ToInt32(HttpContext.Session["UserDatabaseID"]);
                    int       UserDBID       = Convert.ToInt32(SessionControl);
                    complaint modal          = new complaint();
                    var       dbComplaint    = (from d in db.complaint
                                                where d.category.FK_USER_ID == SessionControl & d.STATUS.Trim().ToUpper() != "SOLVED" & d.STATUS.Trim().ToUpper() != "UNSOLVED"
                                                select d).OrderByDescending(x => x.START_DATE);
                    var complianttoStatusNew = (from d in db.complaint
                                                where d.category.FK_USER_ID == UserDBID
                                                select d.STATUS).ToList();


                    return(View(dbComplaint.ToList()));
                }
                catch (Exception ex)
                {
                    TempData["error"] = "error occured while listing complaint please try again! if problem occur again contact your administrator!";
                    return(RedirectToAction("Index", "Home"));
                }
            }
        }
        public ActionResult CreateComplaint(complaint complaint, int FK_CATEGORY_ID, HttpPostedFileBase ComplaintImg)
        {
            var SessionDB = Convert.ToInt32(Session["UserDatabaseID"]);
            // Control the which user Login
            var SessionControl = HttpContext.Session["UserID"];
            // Select the item name if there is already complaint about
            var itemname = db.item.Where(x => x.ID == complaint.FK_ITEM_ID).Select(x => x.ITEM_NAME).Single();
            // İf item Exist by name on database eg. Computer 9
            var itemExist = _complaintRepository.GetMany(x => x.IsActive == true && x.ITEM_ID.Trim().ToUpper() == (itemname + " " + complaint.ITEM_ID).ToUpper().Trim());

            if (complaint != null)
            {
                try
                {
                    user User = _userRepository.GetById(Convert.ToInt32(SessionControl));
                    complaint.FK_CATEGORY_ID = FK_CATEGORY_ID;
                    if (ComplaintImg != null)
                    {
                        string FileName = Guid.NewGuid().ToString().Replace("-", "");
                        string Path     = System.IO.Path.GetExtension(Request.Files[0].FileName);
                        string FullPath = "/External/ComplaintImg/" + FileName + Path;
                        Request.Files[0].SaveAs(Server.MapPath(FullPath));
                        complaint.ImgURL = FullPath;
                    }
                    else
                    {
                        complaint.ImgURL = null;
                    }
                    complaint.START_DATE = DateTime.Now;
                    complaint.STATUS     = "New";
                    complaint.FK_USER_ID = SessionDB;
                    complaint.IsActive   = true;
                    if (itemExist != null)
                    {
                        complaint.PRIORITY = +1;
                    }
                    else
                    {
                        complaint.ITEM_ID = complaint.ITEM_ID;
                    }
                    _complaintRepository.Insert(complaint);
                    _complaintRepository.Save();
                    return(Json(new ResultJson {
                        Success = true, Message = "Complaint Added Successfully"
                    }));
                }
                catch (Exception ex)
                {
                    return(Json(new ResultJson {
                        Success = true, Message = "Error Occured While adding Complaint.Try Again!"
                    }));
                }
            }

            SetCategory();
            //ViewBag.Itemlist = new SelectList(GetItemType(), "ID", "Item_Type");
            ViewBag.DepartmentList = new SelectList(GetDepartmentList(), "ID", "DEPT_NAME");
            return(View(complaint));
        }
Esempio n. 5
0
        protected void ButtonSubmit_Click(object sender, EventArgs e)
        {
            //string strcon = ConfigurationManager.ConnectionStrings["db"].ConnectionString;
            // using (SqlConnection con = new SqlConnection(strcon))
            // {
            con = obj.Con;
            SqlCommand cmd = new SqlCommand("SubmitComplaint", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@C_body", TextBox1.Text);
            cmd.Parameters.AddWithValue("@C_DOS", DateTime.Now.ToShortDateString());
            cmd.Parameters.AddWithValue("@C_SB", Label1.Text);
            cmd.Parameters.AddWithValue("@C_type", DropDownList1.SelectedValue);

            SqlParameter outid = new SqlParameter();

            outid.ParameterName = "@Id";
            outid.SqlDbType     = System.Data.SqlDbType.Int;
            outid.Direction     = System.Data.ParameterDirection.Output;
            outid.Size          = 50;
            cmd.Parameters.Add(outid);
            try
            {
                if (con.State != ConnectionState.Open) //connection object may have broken, executing, etc states so we should not use state==closed)
                {
                    con.Open();
                }
                int k   = cmd.ExecuteNonQuery(); //no. of rows affected
                int cId = (int)outid.Value;      //compalint_id (autogenerated) returned.

                //only to store in a complaint object-(not needed otherwise)

                complaint comp = new complaint();
                employee  emp  = new employee();
                emp.EmployeeId      = Label1.Text;
                comp.Complaint_body = TextBox1.Text;

                comp.Date_of_submission = DateTime.Today;
                comp.Type         = DropDownList1.SelectedValue;
                comp.Submitted_By = emp;
                comp.Status       = "Pending";
                comp.ComplaintId  = cId;


                if (k != 0)
                {
                    con.Close();
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Complaint Registered!! Complaint id is= " + cId.ToString() + " ' );window.location.href='ecPortalM.aspx';", true);
                }


                con.Close();
                //}
            }
            catch (Exception er)
            {
                Response.Write(er);
            }
        }
Esempio n. 6
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            complaint c = cs.GetById(id);

            cs.Delete(c);
            cs.Commit();
            return(RedirectToAction("Index"));
        }
Esempio n. 7
0
        public ActionResult DeleteConfirmed(int id)
        {
            complaint complaint = db.complaint.Find(id);

            db.complaint.Remove(complaint);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 8
0
 public ActionResult Edit([Bind(Include = "complaint_id,complaint1,route_id")] complaint complaint)
 {
     if (ModelState.IsValid)
     {
         db.Entry(complaint).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(complaint));
 }
        public PartialViewResult RecentComplaintMaintanenceOfficer()
        {
            var       SessionControl = HttpContext.Session["UserDatabaseID"];
            int       UserDBID       = Convert.ToInt32(SessionControl);
            complaint modal          = new complaint();
            var       dbComplaint    = (from d in db.complaint
                                        where d.category.FK_USER_ID == UserDBID
                                        select d).OrderBy(x => x.START_DATE);

            return(PartialView(dbComplaint.ToList().Take(10)));
        }
Esempio n. 10
0
        public ActionResult Edit(int id, ComplaintViewModel comp)
        {
            complaint cm = cs.GetById(id);

            cm.Description   = comp.Description;
            cm.Subject       = comp.Subject;
            cm.importanceLvl = comp.importanceLvl;
            cs.Update(cm);
            cs.Commit();
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteComplaint(int id, int idd, complaint col)
        {
            var student   = db.Students.Where(c => c.StudentId == idd).FirstOrDefault();
            var complaint = db.complaints.Where(c => c.complaintId == id).SingleOrDefault();

            db.complaints.Remove(complaint);
            var StudentComplaintRelation = db.StudentcomplaintRelations.Where(c => c.complaintId == id && c.StudentId == student.StudentId).SingleOrDefault();

            db.StudentcomplaintRelations.Remove(StudentComplaintRelation);
            db.SaveChanges();
            return(RedirectToAction("StudentsList6"));
        }
Esempio n. 12
0
        // GET: Mail/Create
        public ActionResult Create()
        {
            EmailFormModel ef = new EmailFormModel();

            if (Session["complaint"] != null)
            {
                complaint cv = Session["complaint"] as complaint;
                ef.ToEmail = us.GetById((int)cv.MyUser_idUser).Email;
                return(View(ef));
            }
            return(View());
        }
        public PartialViewResult RecentComplaint()
        {
            var SessionControl = HttpContext.Session["UserDatabaseID"];
            int UserDBID       = Convert.ToInt32(SessionControl);
            //List<complaint>
            //var dbComplaint = db.complaint.Where(x => x.FK_USER_ID == (Convert.ToInt32(SessionControl)) & x.IsActive == true).ToList().Take(10);
            complaint modal       = new complaint();
            var       dbComplaint = (from d in db.complaint
                                     where d.FK_USER_ID == UserDBID
                                     select d).OrderByDescending(x => x.START_DATE);

            return(PartialView(dbComplaint.ToList().Take(10)));
        }
Esempio n. 14
0
        // GET: Complaint/Delete/5
        public ActionResult Delete(int id)
        {
            complaint          comp = cs.GetById(id);
            ComplaintViewModel cm   = new ComplaintViewModel();

            cm.Description   = comp.Description;
            cm.creationDate  = comp.creationDate;
            cm.Subject       = comp.Subject;
            cm.importanceLvl = comp.importanceLvl;
            cm.MyUser_idUser = (int)comp.MyUser_idUser;
            cm.user          = us.GetById((int)comp.MyUser_idUser);
            return(View(cm));
        }
        public ActionResult DeleteComplaint(int id, complaint col)
        {
            var user      = UserManager.FindById(User.Identity.GetUserId());
            var student   = db.Students.Where(c => c.UserId == user.Id).SingleOrDefault();
            var complaint = db.complaints.Where(c => c.complaintId == id).SingleOrDefault();

            db.complaints.Remove(complaint);
            var StudentComplaintRelation = db.StudentcomplaintRelations.Where(c => c.complaintId == id && c.StudentId == student.StudentId).SingleOrDefault();

            db.StudentcomplaintRelations.Remove(StudentComplaintRelation);
            db.SaveChanges();
            return(RedirectToAction("CompliantsList"));
        }
Esempio n. 16
0
        // GET: MaintanenceComplaint/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            complaint complaint = db.complaint.Find(id);

            if (complaint == null)
            {
                return(HttpNotFound());
            }
            return(View(complaint));
        }
Esempio n. 17
0
        public async Task <ActionResult> Create(EmailFormModel model)
        {
            if (ModelState.IsValid)
            {
                var body    = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
                var message = new MailMessage();
                message.To.Add(new MailAddress(model.ToEmail));        // replace with valid value _receiver
                message.From       = new MailAddress(model.FromEmail); // replace with valid value _ sender
                message.Subject    = "Answer about your Complaint";
                message.Body       = string.Format(body, model.FromName, model.FromEmail, model.Message);
                message.IsBodyHtml = true;

                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******", // replace with valid value
                        Password = "******"                // replace with valid value
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "smtp.gmail.com";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;

                    try
                    {
                        await smtp.SendMailAsync(message);

                        if (Session["complaint"] != null)
                        {
                            complaint cv = Session["complaint"] as complaint;
                            complaint c  = cs.GetById(cv.id);
                            c.gere = true;
                            cs.Update(c);
                            cs.Commit();
                            Session["complaint"] = null;
                        }
                    }
                    catch (SmtpFailedRecipientsException e)
                    {
                        Console.WriteLine("erreur mail not send !  s" + e.StatusCode);
                        return(View());
                    }

                    return(RedirectToAction("Sent"));
                }
            }
            return(View(model));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            complaint complaint = db.complaint.Find(id);
            string    file_name = complaint.ImgURL;
            string    path      = Server.MapPath(file_name);
            FileInfo  file      = new FileInfo(path);

            if (file.Exists) // Check file is exist as physcaly
            {
                file.Delete();
            }
            db.complaint.Remove(complaint);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 19
0
        public ActionResult Create(ComplaintViewModel comp)
        {
            complaint c = new complaint();

            c.Description   = comp.Description;
            c.creationDate  = DateTime.Now;
            c.Subject       = comp.Subject;
            c.importanceLvl = comp.importanceLvl;
            c.MyUser_idUser = (int)comp.MyUser_idUser;
            //c.user = us.GetById((int)comp.MyUser_idUser);
            cs.Add(c);
            cs.Commit();

            return(RedirectToAction("Index"));
        }
        public ActionResult AddComplaint(complaint model)
        {
            var user    = UserManager.FindById(User.Identity.GetUserId());
            var student = db.Students.Where(c => c.UserId == user.Id).SingleOrDefault();

            db.complaints.Add(model);
            var StudentCompliantRelation = new StudentcomplaintRelation
            {
                complaintId = model.complaintId,
                StudentId   = student.StudentId
            };

            db.StudentcomplaintRelations.Add(StudentCompliantRelation);
            db.SaveChanges();
            return(RedirectToAction("CompliantsList"));
        }
        public ActionResult Edit([Bind(Include = "ID,COMMENT,STATUS,START_DATE,PRIORITY,FK_USER_ID,FK_CATEGORY_ID,IsActive,FK_Location_ID,FK_ITEM_ID,ITEM_ID")] complaint complaint, HttpPostedFileBase ComplaintImg)
        {
            var SessionControl = Convert.ToInt32(HttpContext.Session["UserDatabaseID"]);


            if (SessionControl != complaint.FK_USER_ID)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (ComplaintImg != null)
            {
                string   FileName = complaint.ImgURL;
                string   FilePath = Server.MapPath(FileName);
                FileInfo file     = new FileInfo(FilePath);
                if (file.Exists)
                {
                    file.Delete();
                }

                string file_name = Guid.NewGuid().ToString().Replace("-", "");
                string path      = System.IO.Path.GetExtension(Request.Files[0].FileName);
                string fullpath  = "/External/Haber/" + file_name + path;
                Request.Files[0].SaveAs(Server.MapPath(fullpath));
                complaint.ImgURL = fullpath;
            }
            if (ModelState.IsValid)
            {
                db.complaint.Attach(complaint);
                var entry = db.Entry(complaint);
                entry.Property(x => x.COMMENT).IsModified        = true;
                entry.Property(x => x.START_DATE).IsModified     = true;
                entry.Property(x => x.PRIORITY).IsModified       = true;
                entry.Property(x => x.FK_USER_ID).IsModified     = true;
                entry.Property(x => x.IsActive).IsModified       = true;
                entry.Property(x => x.FK_Location_ID).IsModified = true;
                entry.Property(x => x.FK_ITEM_ID).IsModified     = true;
                entry.Property(x => x.ITEM_ID).IsModified        = true;
                entry.Property(x => x.ImgURL).IsModified         = true;
                db.Entry(complaint).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            SetCategory();
            ViewBag.Itemlist       = new SelectList(GetItemType(), "ID", "Item_Type");
            ViewBag.DepartmentList = new SelectList(GetDepartmentList(), "ID", "DEPT_NAME");
            return(View(complaint));
        }
        // GET: Complaint/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            complaint complaint      = db.complaint.Find(id);
            var       queryComplaint = (from comp in db.complaint
                                        join u in db.user on comp.FK_USER_ID equals u.ID
                                        join cate in db.category on comp.FK_CATEGORY_ID equals cate.ID
                                        join loc in db.location on comp.FK_Location_ID equals loc.ID
                                        join i in db.item on comp.FK_ITEM_ID equals i.ID
                                        join it in db.itemtype on i.ID equals it.ID
                                        orderby(cate.CATEGORY_NAME)
                                        where comp.ID == id
                                        select new ComplaintModel
            {
                STATUS = comp.STATUS,
                COMMENT = comp.COMMENT,
                UserName = u.FIRST_NAME + " " + u.LAST_NAME,
                ITEM_ID = comp.ITEM_ID,
                IsActive = comp.IsActive,
                ComplaintId = comp.ID,
                CategoryName = cate.CATEGORY_NAME,
                PRIORITY = comp.PRIORITY,
                STARTDATE = comp.START_DATE,
                itemName = i.ITEM_NAME,
                RoomNo = loc.ROOM_ID,
                ImgUrl = comp.ImgURL
            });

            if (queryComplaint == null)
            {
                return(HttpNotFound());
            }
            var SessionControl = Convert.ToInt32(HttpContext.Session["RoleID"]);

            if (complaint.STATUS.Trim().ToUpper() == "NEW" & SessionControl == 7)
            {
                complaint.STATUS = "SEEN".Trim().ToUpper();
                db.complaint.Attach(complaint);
                var entry = db.Entry(complaint);
                entry.Property(x => x.STATUS).IsModified = true;
                db.SaveChanges();
            }
            return(View(complaint)); //Instead of using single return value it is faster and reliable to use it "singleordefault".
        }
        // GET: Complaint/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            complaint complaint = db.complaint.Find(id);

            if (complaint == null)
            {
                return(HttpNotFound());
            }
            SetCategory();
            //ViewBag.Itemlist = new SelectList(GetItemType(), "ID", "Item_Type");
            ViewBag.DepartmentList = new SelectList(GetDepartmentList(), "ID", "DEPT_NAME");
            return(View(complaint));
        }
Esempio n. 24
0
        public ActionResult Create([Bind(Include = "complaint_id,complaint1,route_id")] complaint complaint)
        {
            if (ModelState.IsValid)
            {
                db.complaints.Add(complaint);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.route_id = from r in db.routes.ToList()
                               select new
            {
                id          = r.route_id,
                about_route = r.source + " - " + r.destination
            };

            return(View(complaint));
        }
        public ActionResult AddComplaint(int id, complaint model)
        {
            var complaint = new complaint
            {
                Date   = model.Date,
                Detail = model.Detail
            };

            db.complaints.Add(complaint);
            var StudentCompliantRelation = new StudentcomplaintRelation
            {
                complaintId = complaint.complaintId,
                StudentId   = id
            };

            db.StudentcomplaintRelations.Add(StudentCompliantRelation);
            db.SaveChanges();
            return(RedirectToAction("StudentsList5"));
        }
Esempio n. 26
0
        // GET: MaintanenceComplaint/Create
        public ActionResult Create(int?id)
        {
            var SessionControl = Convert.ToInt32(HttpContext.Session["RoleID"]);

            if (SessionControl != 7)
            {
                TempData["warning"] = "Un Authorized Action";
                return(RedirectToAction("Index", "Home"));
            }
            int                   sessionControl = Convert.ToInt32(HttpContext.Session["UserDatabaseID"]);
            complaint             model          = db.complaint.Find(id);
            ComplaintHistoryModel cmhmodel       = new ComplaintHistoryModel()
            {
                CategoryID   = model.FK_CATEGORY_ID,
                CompID       = model.ID,
                CategoryUser = sessionControl,
            };
            var query = db.complaint_history.Distinct().Select(x => x.STATUS);

            ViewBag.StatusList = GetStatus();
            var categoryList = db.category.ToList();

            ViewBag.FK_CATEGORY_ID = categoryList;

            var types = new List <ComplaintHistoryStatus>();

            types.Add(new ComplaintHistoryStatus()
            {
                Id = 0, ComplaintStatus = "On Progress"
            });
            types.Add(new ComplaintHistoryStatus()
            {
                Id = 1, ComplaintStatus = "Solved"
            });
            types.Add(new ComplaintHistoryStatus()
            {
                Id = 2, ComplaintStatus = "UnSolved"
            });
            ViewBag.PartialTypes = types;
            return(View(cmhmodel));
        }
Esempio n. 27
0
        // GET: Complaint/Edit/5
        public ActionResult Edit(int id)
        {
            List <string> lst = new List <string>();

            foreach (var item in Enum.GetValues(typeof(subjectType)))
            {
                lst.Add(item.ToString());
            }
            complaint          comp = cs.GetById(id);
            ComplaintViewModel cm   = new ComplaintViewModel();

            cm.Description   = comp.Description;
            cm.creationDate  = comp.creationDate;
            cm.Subject       = comp.Subject;
            cm.subjectLst    = lst.ToSelectListItems2();
            cm.importanceLvl = comp.importanceLvl;
            cm.MyUser_idUser = (int)comp.MyUser_idUser;
            cm.user          = us.GetById((int)comp.MyUser_idUser);

            return(View(cm));
        }
Esempio n. 28
0
        private void obrišiToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (reclamationGV.SelectedRows.Count == 0)
            {
                MessageBox.Show("Niste odabrali nijednu reklamaciju.");
                return;
            }

            DialogResult result = MessageBox.Show("Da li ste sigurni da želite obrisati odabrane reklamacije?", "Brisanje reklamacija", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                int selIndex = reclamationGV.SelectedRows[0].Index;
                for (int i = 0; i < reclamationGV.SelectedRows.Count; i++)
                {
                    int id = 0;
                    try
                    {
                        id = (int)reclamationGV.SelectedRows[i].Cells[0].Value;
                    }
                    catch (NullReferenceException)
                    {
                        //the row is already deleted
                        continue;
                    }

                    complaint v = db.complaints.Find(id);
                    if (v != null)
                    {
                        v.isActive = 0;
                    }
                }
                db.SaveChanges();
                Reclamation_Load(sender, e);
                if (selIndex != 0 && selIndex < reclamationGV.Rows.Count)
                {
                    reclamationGV.Rows[selIndex - 1].Selected = true;
                }
            }
        }
 public ActionResult Edit([Bind(Include = "ID,COMMENT,STATUS,START_DATE,PRIORITY,FK_USER_ID,FK_CATEGORY_ID,IsActive,FK_Location_ID,FK_ITEM_ID,ITEM_ID")] complaint complaint)
 {
     if (ModelState.IsValid)
     {
         db.complaint.Attach(complaint);
         var entry = db.Entry(complaint);
         entry.Property(x => x.COMMENT).IsModified        = true;
         entry.Property(x => x.START_DATE).IsModified     = true;
         entry.Property(x => x.PRIORITY).IsModified       = true;
         entry.Property(x => x.FK_USER_ID).IsModified     = true;
         entry.Property(x => x.IsActive).IsModified       = true;
         entry.Property(x => x.FK_Location_ID).IsModified = true;
         entry.Property(x => x.FK_ITEM_ID).IsModified     = true;
         entry.Property(x => x.ITEM_ID).IsModified        = true;
         db.Entry(complaint).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     SetCategory();
     //ViewBag.Itemlist = new SelectList(GetItemType(), "ID", "Item_Type");
     ViewBag.DepartmentList = new SelectList(GetDepartmentList(), "ID", "DEPT_NAME");
     return(View(complaint));
 }
        //onyl the person can delete a complaint who added a complaint.
        // GET: Complaint/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            complaint complaint      = db.complaint.Find(id);
            var       SessionControl = Convert.ToInt32(HttpContext.Session["UserDatabaseID"]);

            if (SessionControl != complaint.FK_USER_ID)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (complaint == null)
            {
                return(HttpNotFound());
            }
            if (complaint.STATUS.ToUpper().Trim() != "NEW")
            {
                TempData["warn"] = "This complaint already seen or modified by a maintanence officer,You can not edit or Delete!";
                return(View(complaint));
            }
            return(View(complaint));
        }