protected void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(lblGlossaryEdit.Text)) { try { int a = 0; GlossaryBAL gl = new GlossaryBAL(); a = gl.SaveGlossary(txtTerm.Text, txtDescription.Text); if (a != 0) Page.ClientScript.RegisterStartupScript(typeof(Page), "key", "alert('Glossary Details Added.');location='AddGlossaryDetails.aspx';", true); Clear(); FetchDetails(); } catch (Exception ex) { if(ex.Message.StartsWith("Violation of PRIMARY KEY constraint")) Page.ClientScript.RegisterStartupScript(typeof(Page), "key", "alert('Glossary Details already added. Please try something.');location='AddGlossaryDetails.aspx';", true); } } else { int a = 0; GlossaryBAL gl = new GlossaryBAL(); a = gl.UpdateGlossary(lblGlossaryEdit.Text, txtTerm.Text, txtDescription.Text); if (a != 0) Page.ClientScript.RegisterStartupScript(typeof(Page), "key", "alert('Glossary Details updated.');location='AddGlossaryDetails.aspx';", true); Clear(); FetchDetails(); } }
protected void Gridview_OnRowCommand(object sender, GridViewCommandEventArgs e) { string _commandName; if (e.CommandArgument.ToString() == "Next" || e.CommandArgument.ToString() == "Last" || e.CommandArgument.ToString() == "First" || e.CommandArgument.ToString() == "Prev") { } else { // Get the selected index and the command name int _selectedIndex = int.Parse(e.CommandArgument.ToString()); _commandName = e.CommandName; if (_commandName == "Glosedit") { Label glid = (Label)grdGlossary.Rows[_selectedIndex].Cells[0].FindControl("lblGrdGlossaryID"); DataTable editdetails = new DataTable(); GlossaryBAL gl = new GlossaryBAL(); editdetails = gl.FetchGlossaryDetails(glid.Text); lblGlossaryEdit.Text = editdetails.Rows[0][0].ToString(); txtTerm.Text = editdetails.Rows[0][1].ToString(); txtDescription.Text = editdetails.Rows[0][2].ToString(); } } }
protected void btnSearch_Click(object sender, EventArgs e) { if (txtSearchTerm.Text != string.Empty) { GlossaryBAL gl = new GlossaryBAL(); ds = gl.FetchGlossary(); ds.Tables[0].DefaultView.RowFilter = "term like '%" + txtSearchTerm.Text + "%'"; grdGlossary.Visible = true; grdGlossary.DataSource = ds.Tables[0]; grdGlossary.DataBind(); if (grdGlossary.Rows.Count != 0) { Label1.Visible = false; } else { Label1.Visible = true; } } else { grdGlossary.Visible = false; Label1.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["glossaryid"] != null) { GlossaryBAL gl = new GlossaryBAL(); ds = gl.FetchGlossary(); ds.Tables[0].DefaultView.RowFilter = "term like '%" + Request.QueryString["glossaryid"].ToString() + "%'"; grdGlossary.Visible = true; grdGlossary.DataSource = ds.Tables[0]; grdGlossary.DataBind(); if (grdGlossary.Rows.Count != 0) { Label1.Visible = false; } else { Label1.Visible = true; } } else { GlosssaryFetch(); } } }
private void FetchDetails() { GlossaryBAL gl = new GlossaryBAL(); ds = gl.FetchGlossary(); grdGlossary.DataSource = ds.Tables[0]; grdGlossary.DataBind(); }
protected void gridPageChanging(object sender, GridViewPageEventArgs e) { GlossaryBAL gl = new GlossaryBAL(); ds = gl.FetchGlossary(); grdGlossary.DataSource = ds.Tables[0]; grdGlossary.PageIndex = e.NewPageIndex; grdGlossary.DataBind(); }
private void GlosssaryFetch() { // Bind the term and description details in grid.... GlossaryBAL gl = new GlossaryBAL(); ds = gl.FetchGlossary(); grdGlossary.DataSource = ds.Tables[0]; grdGlossary.DataBind(); // End Bind the term and description details in grid.... }
protected void btnDelete_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(lblGlossaryEdit.Text)) { int a = 0; GlossaryBAL gl = new GlossaryBAL(); a = gl.DeleteGlossaryDetails(lblGlossaryEdit.Text); if (a != 0) Page.ClientScript.RegisterStartupScript(typeof(Page), "key", "alert('Glossary Details Deleted.');location='AddGlossaryDetails.aspx';", true); Clear(); FetchDetails(); } else Page.ClientScript.RegisterStartupScript(typeof(Page), "key", "alert('Select Glossary Details to Delete.');location='AddGlossaryDetails.aspx';", true); }
protected void btnDelete_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(lblGlossaryEdit.Text)) { int a = 0; GlossaryBAL gl = new GlossaryBAL(); a = gl.DeleteGlossaryDetails(lblGlossaryEdit.Text); if (a != 0) { Page.ClientScript.RegisterStartupScript(typeof(Page), "key", "alert('Glossary Details Deleted.');location='AddGlossaryDetails.aspx';", true); } Clear(); FetchDetails(); } else { Page.ClientScript.RegisterStartupScript(typeof(Page), "key", "alert('Select Glossary Details to Delete.');location='AddGlossaryDetails.aspx';", true); } }
protected void btnSearch_Click(object sender, EventArgs e) { if (txtSearchTerm.Text != string.Empty) { GlossaryBAL gl = new GlossaryBAL(); ds = gl.FetchGlossary(); ds.Tables[0].DefaultView.RowFilter = "term like '%" + txtSearchTerm.Text + "%'"; grdGlossary.Visible = true; grdGlossary.DataSource = ds.Tables[0]; grdGlossary.DataBind(); if (grdGlossary.Rows.Count != 0) Label1.Visible = false; else Label1.Visible = true; } else { grdGlossary.Visible = false; Label1.Visible = true; } }
protected void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(lblGlossaryEdit.Text)) { try { int a = 0; GlossaryBAL gl = new GlossaryBAL(); a = gl.SaveGlossary(txtTerm.Text, txtDescription.Text); if (a != 0) { Page.ClientScript.RegisterStartupScript(typeof(Page), "key", "alert('Glossary Details Added.');location='AddGlossaryDetails.aspx';", true); } Clear(); FetchDetails(); } catch (Exception ex) { if (ex.Message.StartsWith("Violation of PRIMARY KEY constraint")) { Page.ClientScript.RegisterStartupScript(typeof(Page), "key", "alert('Glossary Details already added. Please try something.');location='AddGlossaryDetails.aspx';", true); } } } else { int a = 0; GlossaryBAL gl = new GlossaryBAL(); a = gl.UpdateGlossary(lblGlossaryEdit.Text, txtTerm.Text, txtDescription.Text); if (a != 0) { Page.ClientScript.RegisterStartupScript(typeof(Page), "key", "alert('Glossary Details updated.');location='AddGlossaryDetails.aspx';", true); } Clear(); FetchDetails(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["glossaryid"] != null) { GlossaryBAL gl = new GlossaryBAL(); ds = gl.FetchGlossary(); ds.Tables[0].DefaultView.RowFilter = "term like '%" + Request.QueryString["glossaryid"].ToString() + "%'"; grdGlossary.Visible = true; grdGlossary.DataSource = ds.Tables[0]; grdGlossary.DataBind(); if (grdGlossary.Rows.Count != 0) Label1.Visible = false; else Label1.Visible = true; } else GlosssaryFetch(); } }
protected void Page_Load(object sender, EventArgs e) { Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetNoStore(); if (!IsPostBack) { #region Fetch Grid Page Size Details... DataTable pg = new DataTable(); GeneralBAL pz = new GeneralBAL(); pg = pz.FetchGridPageSize(); if (pg.Rows.Count != 0 && pg.Rows[0][1].ToString() != string.Empty) { grdGlossary.PageSize = Convert.ToInt32(pg.Rows[0][1].ToString()); } #endregion GlossaryBAL gl = new GlossaryBAL(); ds = gl.FetchGlossary(); grdGlossary.DataSource = ds.Tables[0]; grdGlossary.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetNoStore(); if (!IsPostBack) { #region Fetch Grid Page Size Details... DataTable pg = new DataTable(); GeneralBAL pz = new GeneralBAL(); pg = pz.FetchGridPageSize(); if (pg.Rows.Count != 0 && pg.Rows[0][1].ToString() != string.Empty) grdGlossary.PageSize = Convert.ToInt32(pg.Rows[0][1].ToString()); #endregion GlossaryBAL gl = new GlossaryBAL(); ds = gl.FetchGlossary(); grdGlossary.DataSource = ds.Tables[0]; grdGlossary.DataBind(); } }