private void fillControls(SqlInt32 CityID) { CitiesENT entCity = new CitiesENT(); CitiesBAL balCity = new CitiesBAL(); entCity = balCity.SelectByPK(CityID); if (entCity != null) { if (!entCity.CityName.IsNull) { txtCityName.Text = entCity.CityName.Value.ToString(); } if (!entCity.Pincode.IsNull) { txtPincode.Text = entCity.Pincode.Value.ToString(); } if (!entCity.STDCode.IsNull) { txtSTDCode.Text = entCity.STDCode.Value.ToString(); } if (!entCity.StateID.IsNull) { ddlState.SelectedValue = entCity.StateID.Value.ToString(); } } else { lblError.Text = balCity.Message; } }
protected void btnSave_Click(object sender, EventArgs e) { #region Server Side Validation lblError.Text = ""; if (txtCityName.Text.Trim().ToUpper() == "") { lblError.Text += "Enter City Name <br/>"; } if (ddlState.SelectedValue == "-1") { lblError.Text += "Please Select State <br/>"; } if (lblError.Text != "") { return; } #endregion Server Side Validation #region Collecting Data CitiesENT entCity = new CitiesENT(); if (ddlState.SelectedValue != "-1" && txtCityName.Text.Trim().ToUpper() != "") { entCity.CityName = txtCityName.Text.Trim().ToUpper(); entCity.StateID = Convert.ToInt32(ddlState.SelectedValue); entCity.Pincode = txtPincode.Text.Trim(); entCity.STDCode = txtSTDCode.Text.Trim(); } CitiesBAL balCity = new CitiesBAL(); #endregion Collecting Data if (Request.QueryString["CityID"] == null) { #region insertingData if (balCity.Insert(entCity)) { Response.Redirect("~/AdminPanel/City/CityList.aspx"); } else { lblError.Text = balCity.Message; } #endregion insertingData } else { #region updatingData entCity.CityID = Convert.ToInt32(Request.QueryString["CityID"]); if (balCity.Update(entCity)) { Response.Redirect("~/AdminPanel/City/CityList.aspx"); } else { lblError.Text = balCity.Message; } #endregion updatingData } }
private void FillGridViewCity() { CitiesBAL balCity = new CitiesBAL(); DataTable dtCity = new DataTable(); dtCity = balCity.SelectAll(); if (dtCity != null && dtCity.Rows.Count > 0) { } }
public static void FillDropDownListCity(DropDownList ddl) { CitiesBAL balCity = new CitiesBAL(); ddl.DataSource = balCity.SelectForDropdownList(); ddl.DataValueField = "CityID"; ddl.DataTextField = "CityName"; ddl.DataBind(); ddl.Items.Insert(0, new ListItem("Select Item", "-1")); }
private void FillGridViewCity() { CitiesBAL balCity = new CitiesBAL(); DataTable dtCity = new DataTable(); dtCity = balCity.SelectAll(); if (dtCity != null && dtCity.Rows.Count > 0) { gvCityList.DataSource = dtCity; gvCityList.DataBind(); } }
protected void gvCityList_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandArgument != null) { CitiesBAL balCity = new CitiesBAL(); if (balCity.Delete(Convert.ToInt32(e.CommandArgument.ToString().Trim()))) { Response.Redirect("~/Adminpanel/City/CityList.aspx"); lblError.Text = ""; } else { lblError.Text = balCity.Message; } } }