protected void BtnSave_Click(object sender, EventArgs e) { try { SYS_District = new SYS_District(); BAL_SYS_District = new SYS_District_BLogic(); SYS_District.stateid = Convert.ToInt32(ddlStateID.SelectedValue); SYS_District.countryid = Convert.ToInt32(ddlCountryID.SelectedValue); SYS_District.district = txtDistrict.Text; SYS_District.createdby = Convert.ToInt32(Session["EmpolyeeID"]); status = BAL_SYS_District.BAL_SYS_District_Insert(SYS_District, "Insert"); if (status == 1) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Message", "<script> alert('Record successfully inserted.')</script>", false); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Message", "<script> alert('Record not inserted.')</script>", false); } RefreshPageControls(); pnlSearch.CssClass = "Visible"; } catch (Exception ex) { throw ex; } ////finally ////{ } }
protected void BtnUpdate_Click(object sender, EventArgs e) { SYS_District = new SYS_District(); BAL_SYS_District = new SYS_District_BLogic(); SYS_District.districtid = Convert.ToInt32(ViewState["districtid"].ToString()); SYS_District.countryid = Convert.ToInt32(ddlCountryIDEdit.SelectedValue); SYS_District.stateid = Convert.ToInt32(ddlStateIDEdit.SelectedValue); SYS_District.district = txtDistrictEdit.Text; SYS_District.createdby = Convert.ToInt32(Session["EmpolyeeID"]); status = BAL_SYS_District.BAL_SYS_District_Update(SYS_District, "Update"); if (status == 1) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Message", "<script> alert('Record successfully updated.')</script>", false); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Message", "<script> alert('Record not updated.')</script>", false); } RefreshPageControls(); }
protected void BtnActDeactSub_Click(object sender, EventArgs e) { int CountChecked = 0; string DistrictIDStr = string.Empty; foreach (GridViewRow gr in grvSYS_Districtdetail.Rows) { CheckBox chk = new CheckBox(); chk = (CheckBox)gr.FindControl("chkSelect"); if (chk.Checked == true) { if (CountChecked == 0) { DistrictIDStr = grvSYS_Districtdetail.DataKeys[gr.RowIndex]["DistrictID"].ToString(); } else { DistrictIDStr = DistrictIDStr + "," + grvSYS_Districtdetail.DataKeys[gr.RowIndex]["DistrictID"].ToString(); } CountChecked = CountChecked + 1; } } if (CountChecked == 0) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Message", "<script> alert(' Please select one record to Active/Deactive.')</script>", false); } else { SYS_District = new SYS_District(); BAL_SYS_District = new SYS_District_BLogic(); ////SYS_District.districtid = DistrictIDStr; SYS_District.districtidStr = DistrictIDStr; if (rbActive.Checked == true) { SYS_District.isactive = true; } if (rbDeactive.Checked == true) { SYS_District.isactive = false; } status = BAL_SYS_District.BAL_SYS_District_Delete(SYS_District, "UpdateStatus"); string status1 = string.Empty; if (status == 1) { if (rbActive.Checked == true) { status1 = "Active."; } else if (rbDeactive.Checked == true) { status1 = "Deactive."; } string message = string.Format("Selected records successfully {0}", status1); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Message", "<script> alert('" + message + "')</script>", false); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Message", "<script> alert('Selected record not Active/Deactive.')</script>", false); } RefreshPageControls(); } }
private void bindgrvSYS_Districtdetail() { SYS_District = new SYS_District(); BAL_SYS_District = new SYS_District_BLogic(); DataSet dsSelect = new DataSet(); dsSelect = BAL_SYS_District.BAL_SYS_District_Select(SYS_District, "SelectAll"); if (dsSelect.Tables.Count > 0) { string searchCondition = string.Empty; if (ddlCountryIDSearch.SelectedIndex > 0) { searchCondition = " CountryID = " + ddlCountryIDSearch.SelectedValue.ToString(); } if (ddlStateIDSearch.SelectedIndex > 0) { if (searchCondition != string.Empty) { searchCondition = searchCondition + " and "; } searchCondition = "StateID = " + ddlStateIDSearch.SelectedValue.ToString(); } if (txtDistrictSearch.Text != string.Empty) { if (searchCondition != string.Empty) { searchCondition = searchCondition + " and "; } searchCondition = searchCondition + " District like '%" + txtDistrictSearch.Text + "%'"; } if (rlstActive.SelectedValue == "0") { if (searchCondition != string.Empty) { searchCondition = searchCondition + " and "; } searchCondition = searchCondition + " IsActive = 0"; } else if (rlstActive.SelectedValue == "1") { if (searchCondition != string.Empty) { searchCondition = searchCondition + " and "; } searchCondition = searchCondition + " IsActive = 1"; } DataView dv = new DataView(dsSelect.Tables[0]); dv.RowFilter = searchCondition; DataSet dsSelectSub = new DataSet(); dsSelectSub.Tables.Add(dv.ToTable()); GridViewOperations GrvOperation = new GridViewOperations(); GrvOperation.BindGridWithSorting(grvSYS_Districtdetail, dsSelectSub, this.SortField, this.SortDirection); } else { grvSYS_Districtdetail.DataSource = null; grvSYS_Districtdetail.DataBind(); } }