private bool ValidateInput() { bool r = true; if (string.IsNullOrEmpty(txtFirstName.Text)) { lblError.Text = "Please enter the First Name"; lblError.Visible = true; timError.Enabled = true; r = false; return(r); } if (string.IsNullOrEmpty(txtPhone.Text)) { lblError.Text = "Please enter a Contact Number"; lblError.Visible = true; timError.Enabled = true; r = false; return(r); } if (string.IsNullOrEmpty(txtEmail.Text)) { lblError.Text = "Please enter an Email"; lblError.Visible = true; timError.Enabled = true; r = false; return(r); } if (string.IsNullOrEmpty(txtEmail.Text)) { lblError.Text = "Please enter the Email Address"; lblError.Visible = true; timError.Enabled = true; r = false; return(r); } if (hdfStudentId.Value.ToInt() == 0) { var mStudent = new clsSchool.StudentDB().GetByEmail(txtEmail.Text); if (mStudent != null) { lblError.Text = "This email address already exists in the system"; lblError.Visible = true; timError.Enabled = true; r = false; return(r); } } return(r); }
private void RemoveStudent(int StudentId) { var mStudent = new clsSchool.StudentDB().GetById(StudentId); if (mStudent != null) { mStudent.Active = false; bool ok = new clsSchool.StudentDB().Update(mStudent); } LoadGrid(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["s"])) { hdfSearchFor.Value = Request.QueryString["s"]; } if (!string.IsNullOrEmpty(hdfSearchFor.Value)) { var mStudentList = new clsSchool.StudentDB().Search(hdfSearchFor.Value); grdStudent.DataSource = mStudentList; grdStudent.DataBind(); } } }
protected void btnSave_Click(object sender, EventArgs e) { if (!ValidateInput()) { return; } StudentId = 0; if (!string.IsNullOrEmpty(hdfStudentId.Value)) { StudentId = hdfStudentId.Value.ToInt(); } UnloadForm(StudentId); if (StudentId > 0) { bool ok = new clsSchool.StudentDB().Update(mStudentBase); if (!ok) { StudentId = -1; } } else { StudentId = new clsSchool.StudentDB().Add(mStudentBase); hdfStudentId.Value = StudentId.ToString(); } if (StudentId < 0) { // InputFailed("The database update failed, please try again."); } else { LoadGrid(); ResetForm(); } }