private void 部门管理ToolStripMenuItem_Click(object sender, EventArgs e) { FormDepartment Dept = new FormDepartment(); Dept.StartPosition = FormStartPosition.CenterScreen; Dept.Show(); }
private void buttonFormDept_Click(object sender, EventArgs e) { FormDepartment employee = new FormDepartment(); employee.StartPosition = FormStartPosition.CenterScreen; employee.Show(); }
public ActionResult Edit(int Id) { FormDepartment formDepartment = db.FormDepartments.Find(Id); if (formDepartment == null) { return(RedirectToAction("HttpNotFoundError", "ErrorController")); } List <string> UsersId = new List <string>(); string NotificationTime = string.Empty; string UserId = User.Identity.GetUserId(); string Message = string.Empty; string FormName = string.Empty; Notification notification = null; int Form_Id = formDepartment.FormId; formDepartment.Updatedat = DateTime.Now.ToString("dd/MM/yyyy-HH:mm:ss"); if (formDepartment.Is_Active == true) { formDepartment.Is_Active = false; Message = "تم إلغاء تفعيل النموذج في القسم، النموذج:"; } else { formDepartment.Is_Active = true; Message = "تم تفعيل النموذج في القسم، النموذج:"; } NotificationTime = DateTime.Now.ToString("dd/MM/yyyy-HH:mm:ss"); formDepartment.UpdatedById = User.Identity.GetUserId(); db.Entry(formDepartment).State = EntityState.Modified; db.SaveChanges(); FormName = db.Forms.Find(formDepartment.FormId).Name; List <ApplicationUser> Users = db.Users.Where(a => a.DepartmentId == formDepartment.DepartmentId).ToList(); foreach (ApplicationUser user in Users) { notification = new Notification() { CreatedAt = NotificationTime, Active = false, UserId = user.Id, Message = Message + " " + FormName, NotificationOwnerId = UserId }; db.Notifications.Add(notification); } db.SaveChanges(); return(RedirectToAction("Index", new { @id = Form_Id, @msg = "EditSuccess" })); }
public ActionResult Create(int FormIdValue, List <int> Departments) { ViewBag.Current = "Forms"; if (Departments == null) { return(RedirectToAction("Index", new { @id = FormIdValue, @msg = "CreateError" })); } if (ModelState.IsValid) { List <string> UsersId = new List <string>(); string NotificationTime = string.Empty; string UserId = User.Identity.GetUserId(); FormDepartment formDepartment = null; Notification notification = null; foreach (int i in Departments) { NotificationTime = DateTime.Now.ToString("dd/MM/yyyy-HH:mm:ss"); formDepartment = new FormDepartment() { DepartmentId = i, FormId = FormIdValue, Is_Active = true, CreatedAt = DateTime.Now.ToString("dd/MM/yyyy-HH:mm:ss"), CreatedById = this.User.Identity.GetUserId() }; db.FormDepartments.Add(formDepartment); List <ApplicationUser> Users = db.Users.Where(a => a.DepartmentId == i).ToList(); foreach (ApplicationUser user in Users) { notification = new Notification() { CreatedAt = NotificationTime, Active = false, UserId = user.Id, Message = "تم إضافة نموذج جديد إلى القسم، النموذج :" + db.Forms.Find(FormIdValue).Name, NotificationOwnerId = UserId }; db.Notifications.Add(notification); } } db.SaveChanges(); return(RedirectToAction("Index", new { @id = FormIdValue, @msg = "CreateSuccess" })); } return(RedirectToAction("Index")); }
private void DepartamentosToolStripMenuItem_Click(object sender, EventArgs e) { if (FD != null) { FD.Close(); } FD = new FormDepartment { MdiParent = this }; FD.Activate(); FD.Show(); }
public ActionResult DeleteConfirmed(int id) { //Notification information: List <string> UsersId = new List <string>(); string NotificationTime = DateTime.Now.ToString("dd/MM/yyyy-HH:mm:ss"); string UserId = User.Identity.GetUserId(); string FormName = string.Empty; Notification notification = null; FormDepartment formDepartment = db.FormDepartments.Find(id); db.FormDepartments.Remove(formDepartment); int Form_id = formDepartment.FormId; FormName = db.Forms.Find(formDepartment.FormId).Name; int DepartmentId = formDepartment.DepartmentId; List <ApplicationUser> Users = db.Users.Where(a => a.DepartmentId == DepartmentId).ToList(); foreach (ApplicationUser user in Users) { notification = new Notification() { CreatedAt = NotificationTime, Active = false, UserId = user.Id, Message = "تم إزالةالنموذج من القسم، النموذج: " + " " + FormName, NotificationOwnerId = UserId }; db.Notifications.Add(notification); } db.SaveChanges(); //Remove Favorite user forms: List <string> UsersIdForDepartment = Users.Select(a => a.Id).ToList(); List <FavouriteForms> favoriteForms = db.FavouriteForms.Where(a => a.FormId == Form_id && UsersIdForDepartment.Contains(a.UserId)).ToList(); foreach (FavouriteForms f in favoriteForms) { db.FavouriteForms.Remove(f); } db.SaveChanges(); return(RedirectToAction("Index", new { @id = Form_id, @msg = "DeleteSuccess" })); }
public ActionResult Delete(int?id) { if (id == null) { return(RedirectToAction("BadRequestError", "ErrorController")); } FormDepartment formDepartment = db.FormDepartments.Include(a => a.Form).Include(a => a.Department).SingleOrDefault(a => a.Id == id); if (formDepartment == null) { return(RedirectToAction("HttpNotFoundError", "ErrorController")); } return(View(formDepartment)); }