protected void btnChange_Click(object sender, EventArgs e) { int obj = 0; int.TryParse(ChangePwdIdHiddenField.Value, out obj); // txtNewpwd.Text string fname = FacultyDAL.ChangePassword(Session["fcode"].ToString(), txtOldpwd.Text); if (fname == null) { lblMsg.Text = "Sorry! Invalid OldPassword! Try Again."; } else { faculty staff = new DataAccess.faculty(); staff.fcode = Session["fcode"].ToString(); staff.pwd = txtNewpwd.Text; staff.admno = obj; Manager.UpdateLogin(staff); lblMsg.Text = "Password Changed Sucessfully!"; } }
protected void Addstaff_Click(object sender, EventArgs e) { int staffId = 0; int.TryParse(StaffIdHiddenField.Value, out staffId); DA.faculty staff = new DataAccess.faculty(); staff.fname = SFnameBox.Text; staff.Surname = SSnameBox.Text; staff.dept = DeptTextBox.Text; staff.fcode = UnameBox.Text; staff.pwd = PwsdTextBox.Text; if (staffId > 0) { staff.admno = staffId; DA.Manager.UpdateStaff(staff); } else { DA.Manager.InsertStaff(staff); } //After insert, redirect to update page Response.Redirect(String.Format("AddNewStaff.aspx?StaffId={0}", staff.admno)); }
public static void InsertStaff(faculty staff) { using (ASMDataContext context = new ASMDataContext()) { context.faculties.InsertOnSubmit(staff); context.SubmitChanges(); } }
public static void UpdateLogin(faculty obj) { using (ASMDataContext context = new ASMDataContext()) { var login = context.faculties.SingleOrDefault(x => x.admno == obj.admno); if (login != null) { login.fcode = obj.fcode; login.pwd = obj.pwd; context.SubmitChanges(); } } }
public static void UpdateStaff(faculty staff) { using (ASMDataContext context = new ASMDataContext()) { var dbStaff = context.faculties.SingleOrDefault(x => x.fname == staff.fname); if (dbStaff != null) { dbStaff.fname = staff.fname; dbStaff.Surname = staff.Surname; dbStaff.dept = staff.dept; context.SubmitChanges(); } } }
partial void Deletefaculty(faculty instance);
partial void Updatefaculty(faculty instance);
partial void Insertfaculty(faculty instance);