/// <summary> /// Update Database Make data as Obsoluted /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void IsObsolete_CheckedChanged(Object sender, EventArgs e) { string message = string.Empty; try { CheckBox chk = (CheckBox)sender; GridViewRow gr = (GridViewRow)chk.Parent.Parent; ViewState["CLANID"] = ((Literal)gr.FindControl("litCLANID")).Text; ClansBLL ClansBLLObj = new ClansBLL(); message = ClansBLLObj.Obsoleteclan(Convert.ToInt32(ViewState["CLANID"]), Convert.ToString(chk.Checked)); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data updated successfully"; } BindGrid(); if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Set edit mode for edit comand /// Delete data from the database for delete comand /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvClans_RowCommand(object sender, GridViewCommandEventArgs e) { string message = string.Empty; if (e.CommandName == "EditRow") { ViewState["CLANID"] = e.CommandArgument; GetClansDetails(); SetUpdateMode(true); } else if (e.CommandName == "DeleteRow") { //ViewState["CLANID"] = e.CommandArgument; ClansBLL ClansBLLObj = new ClansBLL(); message = ClansBLLObj.DeleteClansDetails(Convert.ToInt32(e.CommandArgument)); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data Deleted successfully"; } ClearData(); SetUpdateMode(false); BindGrid(); } if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } }
/// <summary> /// Used to update details to the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditClansDetails() { ClansBLL ClansBLLObj = new ClansBLL(); string message = ""; try { ClansBO ClansBOObj = new ClansBO(); if (ViewState["CLANID"] != null) { ClansBOObj.CLANID = Convert.ToInt32(ViewState["CLANID"].ToString()); } string uID = string.Empty; uID = Session["USER_ID"].ToString(); ClansBOObj.CLANNAME = txtClans.Text.ToString().Trim(); int TrbID = 0; TrbID = Convert.ToInt32(Request.QueryString["TribeID"]); ClansBOObj.TRIBEID = TrbID; ClansBOObj.UpdatedBy = Convert.ToInt32(uID); int count = ClansBLLObj.EDITClans(ClansBOObj); txtClans.Text = string.Empty; SetUpdateMode(false); if (count == -1) { message = "Data updated successfully"; BindGrid(); } else { message = "Unable to update data"; } } catch (Exception ex) { throw ex; } finally { ClansBLLObj = null; } if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } }
/// <summary> /// Set Grid Data source /// </summary> /// <param name="addRow"></param> /// <param name="deleteRow"></param> private void BindGrid() { try { ClansBLL ClansBLLObj = new ClansBLL(); gvClans.DataSource = ClansBLLObj.FetchALLClansList(Convert.ToInt32(ViewState["TRIBE_ID"])); gvClans.DataBind(); } catch (Exception ex) { throw ex; } }
/// <summary> /// used to fetch details /// </summary> /// <param name="addRow"></param> /// <param name="deleteRow"></param> private void GetClansDetails() { ClansBLL ClansBLLObj = new ClansBLL(); int ClanID = 0; if (ViewState["CLANID"] != null) { ClanID = Convert.ToInt32(ViewState["CLANID"]); } ClansBO ClansBOObj = new ClansBO(); ClansBOObj = ClansBLLObj.GetClansById(ClanID); txtClans.Text = ClansBOObj.CLANNAME; }
/// <summary> /// Used to save details to the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveClansDetails() { ClansBOObj = new ClansBO(); string message = ""; int count = 0; string Clans = string.Empty; string uID = string.Empty; uID = Session["USER_ID"].ToString(); ClansBLLObj = new ClansBLL(); try { ClansBOObj.CLANNAME = txtClans.Text.ToString().Trim(); ClansBOObj.TRIBEID = Convert.ToInt32(ViewState["TRIBE_ID"]); ClansBOObj.CreatedBy = Convert.ToInt32(uID); count = ClansBLLObj.InsertIntoClansMaster(ClansBOObj); txtClans.Text = string.Empty; if (count == -1) { message = "Data saved successfully"; BindGrid(); } else { message = "Unable to save data"; } } catch (Exception ee) { throw ee; } finally { ClansBLLObj = null; } if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } }