// Update #region Update Data protected void btnUpdate_Click(object sender, EventArgs e) { BL_University objBL = new BL_University(); EWA_University objEWA = new EWA_University(); try { string[] confirmValue = Request.Form["confirm_value"].Split(','); if (confirmValue[confirmValue.Length - 1] == "Yes") { lock (this) { SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString); cn.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Select * from [tblUniversity] "; cmd.Connection = cn; SqlDataReader rd = cmd.ExecuteReader(); //while (rd.Read()) //{ // if (rd[1].ToString() == txtUniversityName.Text) // { // flag = true; // break; // } //} if (flag == true) { msgBox.ShowMessage("Record Already Exist!!!", "Saved", UserControls.MessageBox.MessageStyle.Successfull); clear(); // ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Designation Already Exists')", true); } else { Action("Update"); clear(); btnNew.Visible = true; btnUpdate.Enabled = false; btnDelete.Enabled = false; } } } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
//Save University #region SaveData protected void btnSave_Click(object sender, EventArgs e) { BL_University objBL = new BL_University(); EWA_University objEWA = new EWA_University(); try { lock (this) { SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString); cn.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Select * from [tblUniversity] "; cmd.Connection = cn; SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { if (rd[1].ToString() == txtUniversityName.Text) { flag = true; break; } } if (flag == true) { msgBox.ShowMessage("Record Already Exist!!!", "Saved", UserControls.MessageBox.MessageStyle.Successfull); clear(); // ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Designation Already Exists')", true); } else { Action("Save"); clear(); } } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
// Delete #region [Delete University] protected void btnDelete_Click(object sender, EventArgs e) { BL_University objBL = new BL_University(); EWA_University objEWA = new EWA_University(); try { string[] confirmValue = Request.Form["confirm_value"].Split(','); if (confirmValue[confirmValue.Length - 1] == "Yes") { lock (this) { Action("Delete"); clear(); } } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }