/// <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 grdDistrict_RowCommand(object sender, GridViewCommandEventArgs e) { string message = string.Empty; if (e.CommandName == "EditRow") { ViewState["MAXCAPID"] = e.CommandArgument; GetDistrictById(); SetUpdateMode(true); } else if (e.CommandName == "DeleteRow") { MaxCapBLL DistrictBLLobj = new MaxCapBLL(); message = DistrictBLLobj.DeleteMaxCap(Convert.ToInt32(e.CommandArgument)); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data deleted successfully"; } SetUpdateMode(false); ClearData(); BindGrid(); } if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } }
/// <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; string MAXCAPID = ((Literal)gr.FindControl("litDistrictID")).Text; MaxCapBLL DistrictBLLobj = new MaxCapBLL(); message = DistrictBLLobj.ObsoleteMaxCap(Convert.ToInt32(MAXCAPID), Convert.ToString(chk.Checked), Convert.ToInt32(Session["USER_ID"])); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data updated successfully"; } ClearData(); BindGrid(); if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Obsoleted", "alert('" + message + "');", true); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Set Grid Data source /// </summary> /// <param name="addRow"></param> /// <param name="deleteRow"></param>e private void BindGrid() { MaxCapBLL DistrictBLLobj = new MaxCapBLL(); grdDistrict.DataSource = DistrictBLLobj.GetAllMaxCap(Convert.ToInt32(Session["PROJECT_ID"])); grdDistrict.DataBind(); }
/// <summary> /// Set Grid Data source /// </summary> /// <param name="addRow"></param> /// <param name="deleteRow"></param>e public void searchBind(string District) { MaxCapBLL DistrictBLLobj = new MaxCapBLL(); grdDistrict.DataSource = DistrictBLLobj.GetMaxCap(District); grdDistrict.DataBind(); // DDLSearchDistrictName.ClearSelection(); //txtSearchDistrict.Text = string.Empty; }
/// <summary> /// to update data to database /// </summary> /// <returns></returns> private void UpdateDistrict() { MaxCapBLL DistrictBLLobj = new MaxCapBLL(); MaxCapBO DistrictBOobj = new MaxCapBO(); string message = ""; try { if (ViewState["MAXCAPID"] != null) { DistrictBOobj.MaxCapID = Convert.ToInt32(ViewState["MAXCAPID"].ToString()); } string uID = string.Empty; uID = Session["USER_ID"].ToString(); DistrictBOobj.DistrictID = Convert.ToInt32(ddlDistrictName.SelectedItem.Value); DistrictBOobj.ProjectID = Convert.ToInt32(Session["PROJECT_ID"]); DistrictBOobj.MaxCapVal = Convert.ToDecimal(txtMaxCap.Text.Trim()); DistrictBOobj.UpdatedBy = Convert.ToInt32(uID); message = DistrictBLLobj.UpdateMaxCap(DistrictBOobj); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data updated successfully"; } ClearData(); SetUpdateMode(false); BindGrid(); if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Updated", "alert('" + message + "');", true); } } catch (Exception ex) { throw ex; } finally { DistrictBLLobj = null; } }
/// <summary> /// to get District names based on ID /// </summary> /// <returns></returns> private void GetDistrictById() { MaxCapBLL DistrictBLLobj = new MaxCapBLL(); MaxCapBO DistrictBOobj = DistrictBLLobj.GetMaxCapById(Convert.ToInt32(ViewState["MAXCAPID"])); if (DistrictBOobj != null) { txtMaxCap.Text = Convert.ToString(DistrictBOobj.MaxCapVal); } ddlDistrictName.ClearSelection(); if (ddlDistrictName.Items.FindByText(DistrictBOobj.DistrictName.ToString()) != null) { ddlDistrictName.Items.FindByText(DistrictBOobj.DistrictName.ToString()).Selected = true; } DistrictBOobj = null; DistrictBLLobj = null; }