public static void DeleteUser(string args) { int Pap_NeighbrID = Convert.ToInt32(args.Trim()); neighbourBLL neighbourBLLobj = new neighbourBLL(); neighbourBLLobj.Delete(Pap_NeighbrID); (new Neighbours()).BindGrid(); }
/// <summary> /// to get the data from the database and bind it to the GridView /// </summary> private void BindGrid() { neighbourBLL neighbourBLLobj = new neighbourBLL(); if (grdNeighbor == null) { grdNeighbor = new GridView(); } grdNeighbor.DataSource = neighbourBLLobj.GetneigbrDetails(Convert.ToInt32(Session["HH_ID"])); grdNeighbor.DataBind(); }
/// <summary> /// to get the NeighBour Data /// </summary> private void GetNeighbor() { neighbourBLL neighbourBLLobj = new neighbourBLL(); int Pap_NeighbrID = 0; if (ViewState["PAP_NEIGHBOURID"] != null) { Pap_NeighbrID = Convert.ToInt32(ViewState["PAP_NEIGHBOURID"]); } NeighbourBO Neighbourobj = new NeighbourBO(); Neighbourobj = neighbourBLLobj.GetNeighbrById(Pap_NeighbrID); txtNeighbrID.Text = Neighbourobj.PAP_NEIGHBOURID1.ToString(); txtNeibrName.Text = Neighbourobj.TRN_PAP_NEIGHBOURNAme1.ToString(); ddldirectionDropDownList.ClearSelection(); if (ddldirectionDropDownList.Items.FindByValue(Neighbourobj.DIRECTION1.ToString()) != null) { ddldirectionDropDownList.Items.FindByValue(Neighbourobj.DIRECTION1.ToString()).Selected = true; } string RadioButtn = Neighbourobj.BOUNDARIESCONFIRMED1.ToString(); RadioButton1.Checked = false; RadioButton2.Checked = false; if (RadioButtn == "Yes") { RadioButton1.Checked = true; } else if (RadioButtn == "No") { RadioButton2.Checked = true; } rdoBoundaryDisputesYes.Checked = false; rdoBoundaryDisputesNo.Checked = false; if (Neighbourobj.BOUNDARY_DISPUTE.ToString().ToUpper() == "YES") { rdoBoundaryDisputesYes.Checked = true; txtBoundaryDisputes.Text = Neighbourobj.DISPUTE_DETAILS.ToString(); ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowHideBoundaryDisputes", "ShowHideBoundaryDisputes(1);", true); } else if (Neighbourobj.BOUNDARY_DISPUTE.ToString().ToUpper() == "NO") { rdoBoundaryDisputesNo.Checked = true; txtBoundaryDisputes.Text = Neighbourobj.DISPUTE_DETAILS.ToString(); ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowHideBoundaryDisputes", "ShowHideBoundaryDisputes(0);", true); } }
/// <summary> /// to Edit and Delete Command /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grdNeighr_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditRow") { ViewState["PAP_NEIGHBOURID"] = e.CommandArgument; GetNeighbor(); SetUpdateMode(true); } else if (e.CommandName == "DeleteRow") { int Pap_NeighbrID = Convert.ToInt32(e.CommandArgument); neighbourBLL neighbourBLLobj = new neighbourBLL(); neighbourBLLobj.Delete(Pap_NeighbrID); clearfields(); SetUpdateMode(false); BindGrid(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('Deleted successfully');", true); } }
/// <summary> /// to save the data to the database and clear the data fields by calling clearfields() methods /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { string message = ""; bool dataUpdated = false; ChangeRequestStatusNeighbours(); if (txtNeighbrID.Text.ToString().Trim() == string.Empty) { neighbourBLL neighbourBLLobj = new neighbourBLL(); try { string uID = Session["USER_ID"].ToString(); string hhid = Session["HH_ID"].ToString(); NeighbourBO Neighbourobj = new NeighbourBO(); Neighbourobj.TRN_PAP_NEIGHBOURNAme1 = txtNeibrName.Text.ToString().Trim(); Neighbourobj.DIRECTION1 = ddldirectionDropDownList.SelectedItem.ToString().Trim(); if (RadioButton1.Checked == true) { Neighbourobj.BOUNDARIESCONFIRMED1 = RadioButton1.Text.ToString(); //RadioButton2.Checked = false; } else { Neighbourobj.BOUNDARIESCONFIRMED1 = RadioButton2.Text.ToString(); //RadioButton1.Checked = false; } if (rdoBoundaryDisputesYes.Checked == true) { Neighbourobj.BOUNDARY_DISPUTE = RadioButton1.Text.ToUpper(); if (txtBoundaryDisputes.Text.Length > 800) { Neighbourobj.DISPUTE_DETAILS = txtBoundaryDisputes.Text.Substring(0, 800); } else { Neighbourobj.DISPUTE_DETAILS = txtBoundaryDisputes.Text; } } else { Neighbourobj.BOUNDARY_DISPUTE = RadioButton2.Text.ToUpper(); Neighbourobj.DISPUTE_DETAILS = ""; } Neighbourobj.CREATEDBY1 = Convert.ToInt32(uID); Neighbourobj.HHID1 = Convert.ToInt32(hhid); neighbourBLL BLLobj = new neighbourBLL(); message = BLLobj.Insert(Neighbourobj); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data saved successfully"; dataUpdated = true; } if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } if (dataUpdated) { projectFrozen(); getApprrequtStatusNeighbours(); } BindGrid(); clearfields(); } catch (Exception ex) { throw ex; } finally { neighbourBLLobj = null; } } else if (txtNeighbrID.Text.ToString().Trim() != string.Empty) { neighbourBLL neighbourBLLobj = new neighbourBLL(); try { string uID = Session["USER_ID"].ToString(); string hhid = Session["HH_ID"].ToString(); NeighbourBO Neighbourobj = new NeighbourBO(); Neighbourobj.TRN_PAP_NEIGHBOURNAme1 = txtNeibrName.Text.ToString().Trim(); Neighbourobj.PAP_NEIGHBOURID1 = Convert.ToInt32(txtNeighbrID.Text.ToString().Trim()); Neighbourobj.DIRECTION1 = ddldirectionDropDownList.SelectedItem.ToString(); if (RadioButton1.Checked == true) { Neighbourobj.BOUNDARIESCONFIRMED1 = RadioButton1.Text.ToString(); //RadioButton2.Checked = false; } else { Neighbourobj.BOUNDARIESCONFIRMED1 = RadioButton2.Text.ToString(); //RadioButton1.Checked = false; } string radbtn = Neighbourobj.BOUNDARIESCONFIRMED1.ToString(); if (rdoBoundaryDisputesYes.Checked == true) { Neighbourobj.BOUNDARY_DISPUTE = RadioButton1.Text.ToUpper(); Neighbourobj.DISPUTE_DETAILS = txtBoundaryDisputes.Text; } else { Neighbourobj.BOUNDARY_DISPUTE = RadioButton2.Text.ToUpper(); Neighbourobj.DISPUTE_DETAILS = ""; } Neighbourobj.BOUNDARIESCONFIRMED1 = radbtn.ToString(); Neighbourobj.CREATEDBY1 = Convert.ToInt32(uID); Neighbourobj.HHID1 = Convert.ToInt32(hhid); neighbourBLL BLLobj = new neighbourBLL(); message = BLLobj.EditNeighbr(Neighbourobj); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data updated successfully"; dataUpdated = true; } if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } if (dataUpdated) { projectFrozen(); getApprrequtStatusNeighbours(); } SetUpdateMode(false); BindGrid(); clearfields(); } catch (Exception ex) { throw ex; } finally { neighbourBLLobj = null; } } }