public CreateStaffViewModel(CreateStaffView mainOpen) { main = mainOpen; Staff = new tblStaff(); AllEnqaqements = GetAllEnqaqements(); AvailableLevels = GetAllAvalaibleLevels(); }
// GET: Staff/Delete/5 public ActionResult Delete(tblStaff staffToDelete) { var d = instance.tblStaffs.Where(x => x.id == staffToDelete.id).FirstOrDefault(); instance.tblStaffs.Remove(d); instance.SaveChanges(); return(View("StaffDetails")); }
public ActionResult DeleteConfirmed(int id) { tblStaff tblStaff = db.tblStaffs.Find(id); db.tblStaffs.Remove(tblStaff); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "IDStaff,Lastname,Firstname,ContactNo,DateHired,DateTerminated,Status,Notes,Username,Email,Password")] tblStaff tblStaff) { if (ModelState.IsValid) { db.Entry(tblStaff).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblStaff)); }
public ActionResult Create([Bind(Exclude = "Id")] tblStaff addDetails) { if (!ModelState.IsValid) { return(View()); } instance.tblStaffs.Add(addDetails); instance.SaveChanges(); //Response.Redirect("StudentAdmission",true); return(RedirectToAction("StaffDetails")); }
public ActionResult Create([Bind(Include = "IDStaff,Lastname,Firstname,ContactNo,DateHired,DateTerminated,Status,Notes,Username,Email,Password")] tblStaff tblStaff) { if (ModelState.IsValid) { db.tblStaffs.Add(tblStaff); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblStaff)); }
private void dataGridView1_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { staffid = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value); tblStaff tb = db.tblStaffs.Where(a => a.StaffId == staffid).FirstOrDefault(); txtStaffName.Text = tb.StaffName; txtUsername.Text = tb.UserName; txtPassword.Text = tb.Password; txtEmail.Text = tb.Email; txtContactNumber.Text = tb.ContactNo; }
private void btnDelete_Click(object sender, EventArgs e) { tblStaff tb = db.tblStaffs.Where(a => a.StaffId == staffid).FirstOrDefault(); db.tblStaffs.Remove(tb); if (db.SaveChanges() > 0) { MessageBox.Show("Staff ID Removed"); LoadGrid(); } }
public ActionResult Edit(tblStaff staffToEdit) { var orignalRecord = (from m in instance.tblStaffs where m.id == staffToEdit.id select m).First(); if (!ModelState.IsValid) { return(View(orignalRecord)); } instance.Entry(orignalRecord).CurrentValues.SetValues(staffToEdit); instance.SaveChanges(); return(RedirectToAction("StaffDetails")); }
public OwnerViewModel(Owner openOwner) { owner = openOwner; newEmployee = new tblUser(); newManager = new tblManager(); newStaff = new tblStaff(); qualification = new tblProfessionalQualification(); engagement = new tblEngagement(); gender = new tblGender(); engagementList = Service.Service.GetEngagementList(); qualificationList = Service.Service.GetQualificationList(); genderList = Service.Service.GetGenderList(); }
// GET: Staffs/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblStaff tblStaff = db.tblStaffs.Find(id); if (tblStaff == null) { return(HttpNotFound()); } return(View(tblStaff)); }
public ActionResult EditRecordHT(string id) { tbl_HomeTesting testing = new tbl_HomeTesting(); GetViewBags(); tblStaff tblStaff = flu.tblStaffs.Find(id); if (tblStaff != null) { testing.FirstName = tblStaff.FirstName; testing.Surname = tblStaff.LastName; } testing.EmployeeNumber = id; return(PartialView("~/Views/Staff/_AddStaffTestingKit.cshtml", testing)); }
public ActionResult Login(tblStaff user) { var checkLogin = db.tblStaffs.Where(x => x.Username.Equals(user.Username) && x.Password.Equals(user.Password)).FirstOrDefault(); if (checkLogin != null) { Session["IDStaff"] = user.IDStaff.ToString(); Session["Username"] = user.Username.ToString(); return(RedirectToAction("Index", "Resident")); } else { ViewBag.Notification = "Username or Password doesn't match!"; } return(View()); }
private void btnUpdate_Click(object sender, EventArgs e) { tblStaff tb = db.tblStaffs.Where(a => a.StaffId == staffid).FirstOrDefault(); tb.StaffName = txtStaffName.Text; tb.UserName = txtUsername.Text; tb.Password = txtPassword.Text; tb.Email = txtEmail.Text; tb.ContactNo = txtContactNumber.Text; if (db.SaveChanges() > 0) { LoadGrid(); MessageBox.Show("Staff Details Updated"); ClearData(); } ; }
private void btnSave_Click(object sender, EventArgs e) { tblStaff tb = new tblStaff(); tb.StaffName = txtStaffName.Text; tb.UserName = txtUsername.Text; tb.Password = txtPassword.Text; tb.Email = txtEmail.Text; tb.ContactNo = txtContactNumber.Text; db.tblStaffs.Add(tb); if (db.SaveChanges() > 0) { LoadGrid(); MessageBox.Show("Staff Details Added"); ClearData(); } ; }
//check who has log in private void LoginExecute(object obj) { person.password = (obj as PasswordBox).Password; tblUser currentUser = Service.Service.IsValidUser(person.username, person.password); if (currentUser == null) { if (person.isOwner()) { Owner o = new Owner(); login.Close(); o.ShowDialog(); } else { MessageBox.Show("Invalid username or password.Try again"); } } else { person.id = currentUser.userId; switch (person.role) { case "staff": tblStaff st = Service.Service.getStaff(currentUser.userId); Staff s = new Staff(); s.ShowDialog(); break; case "manager": tblManager man = Service.Service.getManager(currentUser.userId); Manager m = new Manager(man); login.Close(); m.ShowDialog(); break; } } }
private void Save2Execute(object obj) { try { string currentPassword2 = (obj as PasswordBox).Password; newEmployee.password = currentPassword2; tblUser e = Service.Service.AddUser(newEmployee); newStaff.userId = e.userId; newStaff.genderId = gender.id; newStaff.engegamentId = engagement.id; tblStaff me = Service.Service.AddStaff(newStaff); if (e != null && me != null) { MessageBox.Show("Staff has been succesfully created!"); newEmployee = new tblUser(); newStaff = new tblStaff(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void Save2Execute() { try { tblUser e = Service.Service.AddUser(newEmployee); newStaff.userId = e.userId; newStaff.genderId = gender.id; newStaff.engegamentId = engagement.id; tblStaff me = Service.Service.AddStaff(newStaff); if (e != null && me != null) { MessageBox.Show("Staff has been succesfully created!"); } else { MessageBox.Show("Error. Try again."); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
protected void btnAdd_Click(object sender, EventArgs e) { string errorString = string.Empty; lblError.Visible = false; tblStaff staffTbl = new tblStaff(); try { if (txtJobPosition.Text.Trim().Length > 0 && txtName.Text.Trim().Length > 0 && txtFamily.Text.Trim().Length > 0) { staffTbl.idCompany = 1; staffTbl.StaffName = txtName.Text; staffTbl.StaffFamily = txtFamily.Text; staffTbl.StaffJobPosition = txtJobPosition.Text; staffTbl.idStaffRole = 1; staffTbl.StaffBirthdate = ""; staffTbl.StaffHiringDate = ""; staffTbl.StaffStartDate = ""; staffTbl.StaffEndDate = ""; staffTbl.StaffUsername = ""; staffTbl.StaffPassword = ""; if (txtBithdate.Text.Length > 0) { staffTbl.StaffBirthdate = txtBithdate.Text; } else { staffTbl.StaffBirthdate = ""; } // file upload start string filename = string.Empty; if (IsPostBack) { Boolean fileOK = false; String path = Server.MapPath("~/images/staff/"); if (fuGallery.HasFile) { String fileExtension = System.IO.Path.GetExtension(fuGallery.FileName).ToLower(); String[] allowedExtensions = { ".jpg", ".png", ".bmp", ".tif" }; for (int i = 0; i < allowedExtensions.Length; i++) { if (fileExtension == allowedExtensions[i]) { fileOK = true; } } } if (fileOK) { try { fuGallery.PostedFile.SaveAs(path + fuGallery.FileName); filename = fuGallery.FileName; } catch (Exception ex) { lblError.Text = "A promblem with uplouding picture"; } } else { lblError.Text = "Not valid picture"; } } // file upload end staffTbl.StaffPicAddr = "images/staff/"; if (filename.Length > 0) { staffTbl.StaffPicName = filename; } else { lblError.Visible = true; } if (txtHiringDate.Text.Trim().Length > 0) { staffTbl.StaffHiringDate = txtHiringDate.Text; } else { staffTbl.StaffHiringDate = ""; } if (txtMajor.Text.Trim().Length > 0) { staffTbl.StaffMajor = txtMajor.Text; } else { staffTbl.StaffMajor = ""; } if (txtCertificate.Text.Trim().Length > 0) { staffTbl.StaffCertificate = txtCertificate.Text; } else { staffTbl.StaffCertificate = ""; } if (txtWord.Text.Trim().Length > 0) { staffTbl.StaffWords = txtWord.Text; } else { staffTbl.StaffWords = ""; } staffTbl.allow = "1"; if (txtDetail.Text.Trim().Length > 0) { staffTbl.StaffDetail = txtDetail.Text; } else { staffTbl.StaffDetail = ""; } if (txtEmail.Text.Trim().Length > 0) { staffTbl.StaffEmail = txtEmail.Text; } else { staffTbl.StaffEmail = ""; } if (txtTel.Text.Trim().Length > 0) { staffTbl.SatffTel = txtTel.Text; } else { staffTbl.SatffTel = ""; } if (txtMob.Text.Trim().Length > 0) { staffTbl.StaffMobile = txtMob.Text; } else { staffTbl.StaffMobile = ""; } if (lblError.Visible == false) { staffTbl.Create(); } Response.Redirect("staff.aspx"); } else { lblError.Text = "* Please fill nesessary items"; lblError.Visible = true; } } catch (Exception ex) { lblError.Text = ex.ToString(); lblError.Visible = true; throw; } }