/// <summary> /// to Edit And Delete Command /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grdLandInfoRespondents_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditRow") { ViewState["LND_HOLDINGID"] = e.CommandArgument; getLandInfoRespondant(); btn_SaveRes.Text = "Update"; btn_ClearRes.Text = "Cancel"; //SetUpdateMode(true); BindGrid(true, true); } else if (e.CommandName == "DeleteRow") { int landholdID = Convert.ToInt32(e.CommandArgument); LandInfoRespondentsBLL objLIRBLL = new LandInfoRespondentsBLL(); objLIRBLL.DeleteLandInfoRespondents(landholdID); BindGrid(false, true); ClearLandHolding(); btn_SaveRes.Text = "Save"; btn_ClearRes.Text = "Clear"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('Data deleted successfully');", true); } }
/// <summary> /// to bind the gridView /// </summary> /// <param name="addRow"></param> /// <param name="deleteRow"></param> private void BindGrid(bool addRow, bool deleteRow) { LandInfoRespondents objLIRGF = new LandInfoRespondents(); LandInfoRespondentsBLL objLIRBLL = new LandInfoRespondentsBLL(); if (Session["HH_ID"] != null) { grdLandInfoRespondents.DataSource = objLIRBLL.GetLandInfoRespondents(Convert.ToInt32(Session["HH_ID"])); grdLandInfoRespondents.DataBind(); } }
/// <summary> /// to get the Land info Respondant /// </summary> private void getLandInfoRespondant() { LandInfoRespondentsBO LIR = new LandInfoRespondentsBO(); LandInfoRespondentsBLL objLIRBLL = new LandInfoRespondentsBLL(); LIR = objLIRBLL.GetLandInfoRespondentsByID(Convert.ToInt32(ViewState["LND_HOLDINGID"])); if (LIR != null) { DrpType.ClearSelection(); if (LIR.LND_TYPEID > 0) { DrpType.SelectedValue = LIR.LND_TYPEID.ToString(); } DrpUse.ClearSelection(); if (LIR.LND_USEID > 0) { DrpUse.SelectedValue = LIR.LND_USEID.ToString(); } DrpDistrict.ClearSelection(); if (DrpDistrict.Items.FindByText(LIR.DISTRICT) != null) { DrpDistrict.Items.FindByText(LIR.DISTRICT).Selected = true; } BindCounties(DrpDistrict.SelectedItem.Value); DrpCounty.ClearSelection(); if (DrpCounty.Items.FindByText(LIR.COUNTY) != null) { DrpCounty.Items.FindByText(LIR.COUNTY).Selected = true; } BindSubCounty(DrpCounty.SelectedItem.Value); DrpSubCounty.ClearSelection(); if (DrpSubCounty.Items.FindByText(LIR.SUBCOUNTY) != null) { DrpSubCounty.Items.FindByText(LIR.SUBCOUNTY).Selected = true; } BindVillages(DrpSubCounty.SelectedItem.Value); DrpVillage.ClearSelection(); if (DrpVillage.Items.FindByText(LIR.VILLAGE) != null) { DrpVillage.Items.FindByText(LIR.VILLAGE).Selected = true; } //DrpType.SelectedItem.Value = Convert.ToString(LIR.LND_TYPEID); //DrpUse.SelectedItem.Value = Convert.ToString(LIR.LND_USEID); //DrpDistrict.SelectedItem.Value = Convert.ToString(LIR.DISTRICT); //DrpCounty.SelectedItem.Value = Convert.ToString(LIR.COUNTY); //DrpSubCounty.SelectedItem.Value = Convert.ToString(LIR.SUBCOUNTY); //DrpVillage.SelectedItem.Value = Convert.ToString(LIR.VILLAGE); ddlTenureType.ClearSelection(); if (ddlTenureType.Items.FindByValue(LIR.TenureId.ToString()) != null) { ddlTenureType.SelectedValue = LIR.TenureId.ToString(); } if (LIR.ISPRIMARYRESIDENCE.ToLower() == "Yes".ToLower()) { ChkPrimary.Checked = true; } else { ChkPrimary.Checked = false; } if (LIR.ISAFFECTED.ToLower() == "Yes".ToLower()) { ChkAffected.Checked = true; } else { ChkAffected.Checked = false; } if (LIR.TOTALSIZE != -1) { txttotal.Text = Convert.ToString(LIR.TOTALSIZE); } else { txttotal.Text = string.Empty; } if (LIR.TENURE != null) { txttenure.Text = LIR.TENURE; } else { txttenure.Text = string.Empty; } } }
/// <summary> /// To save the data to the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_SaveRes_Click(object sender, EventArgs e) { ChangeRequestStatusLandHoldings(); LandInfoRespondentsBO objLIR = new LandInfoRespondentsBO(); objLIR.HOLDINGID = int.Parse(ViewState["LND_HOLDINGID"].ToString()); objLIR.HID = int.Parse(Session["HH_ID"].ToString()); objLIR.updatedBy = Convert.ToInt32(Session["USER_ID"].ToString()); if (DrpType.SelectedValue != "0") { objLIR.LND_TYPEID = Convert.ToInt32(DrpType.SelectedValue); } else { objLIR.LND_TYPEID = 0;//DBNull } if (DrpUse.SelectedValue != "0") { objLIR.LND_USEID = Convert.ToInt32(DrpUse.SelectedValue); } else { objLIR.LND_USEID = 0;//DBNull } if (DrpDistrict.SelectedValue != "0") { objLIR.DISTRICT = DrpDistrict.SelectedItem.Text; } else { objLIR.DISTRICT = string.Empty; } if (DrpCounty.SelectedValue != "0") { objLIR.COUNTY = DrpCounty.SelectedItem.Text; } else { objLIR.COUNTY = string.Empty; } if (DrpSubCounty.SelectedValue != "0") { objLIR.SUBCOUNTY = DrpSubCounty.SelectedItem.Text; } else { objLIR.SUBCOUNTY = string.Empty; } if (DrpVillage.SelectedValue != "0") { objLIR.VILLAGE = DrpVillage.SelectedItem.Text; } else { objLIR.VILLAGE = string.Empty; } if (ddlTenureType.SelectedValue != "0") { objLIR.TenureId = Convert.ToInt32(ddlTenureType.SelectedValue.ToString()); } else { objLIR.TenureId = 0; } if (!string.IsNullOrEmpty(txttenure.Text)) { objLIR.TENURE = txttenure.Text.Trim(); } else { objLIR.TENURE = string.Empty; } if (!string.IsNullOrEmpty(txttotal.Text)) { objLIR.TOTALSIZE = Convert.ToDecimal(txttotal.Text.Trim()); } else { objLIR.TOTALSIZE = -1; } if (ChkPrimary.Checked == true) { objLIR.ISPRIMARYRESIDENCE = "Yes"; } else if (ChkPrimary.Checked == false) { objLIR.ISPRIMARYRESIDENCE = "No"; } if (ChkAffected.Checked == true) { objLIR.ISAFFECTED = "Yes"; } else if (ChkAffected.Checked == false) { objLIR.ISAFFECTED = "No"; } LandInfoRespondentsBLL objLIRBLL = new LandInfoRespondentsBLL(); if (objLIR.HOLDINGID == 0) { objLIRBLL.AddLandInfoRespondents(objLIR); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('Data saved successfully');", true); } else { objLIRBLL.UpdateLandInfoRespondents(objLIR); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Updated", "alert('Data updated successfully');", true); btn_SaveRes.Text = "Save"; ViewState["LND_HOLDINGID"] = 0; } projectFrozen(); ClearLandHolding(); BindGrid(true, false); }