protected void BtnSave_Click(object sender, EventArgs e) { try { if (ddlState.SelectedValue == "0") { //LblMsg.Text = "Select State Code...."; ddlState.Focus(); return; } if (ddlCountry.SelectedValue == "0") { //LblMsg.Text = "Select Country Code...."; ddlCountry.Focus(); return; } if (TxtCityName.Text.Length == 0) { // LblMsg.Text = "City Name Is Blank, Enter Valid State Value...."; TxtCityName.Focus(); return; } BLayer.CityName = TxtCityName.Text; BLayer.StateId = int.Parse(ddlState.SelectedValue); BLayer.CountryId = int.Parse(ddlCountry.SelectedValue); StrSql = new StringBuilder(); StrSql.Length = 0; StrSql.AppendLine("Insert Into City_Mast (CityName,StateId,CountryId,Entry_Date,Entry_Time,Entry_UID,UpdFlag) "); StrSql.AppendLine("Values (@CityName"); StrSql.AppendLine(",@StateId"); StrSql.AppendLine(",@CountryId"); StrSql.AppendLine(",GetDate()"); StrSql.AppendLine(",Convert(VarChar,GetDate(),108)"); StrSql.AppendLine(",@UID"); StrSql.AppendLine(",0)"); Cmd = new SqlCommand(StrSql.ToString(), SqlFunc.gConn); Cmd.Parameters.AddWithValue("@CityName", BLayer.CityName); Cmd.Parameters.AddWithValue("@StateId", BLayer.StateId); Cmd.Parameters.AddWithValue("@CountryId", BLayer.CountryId); Cmd.Parameters.AddWithValue("@UID", HidFldUID.Value.ToString()); SqlFunc.ExecuteNonQuery(Cmd); FillGrid(); TxtCityName.Text = ""; TxtCityName.Focus(); LblMsg.Text = "City added successfully"; } catch (Exception ex) { Response.Write(ex); } }
protected void Page_Load(object sender, EventArgs e) { if (this.IsPostBack == false) { TxtCityName.Focus(); this.Form.DefaultButton = BtnGo.UniqueID; LblMessage.Text = Request.QueryString["Message"]; DataTable ObjCountryTable = MyJobPortalModel.Country.GetCountryRecords("status='Active'"); DdlCountry.DataSource = ObjCountryTable; DdlCountry.DataBind(); DdlCountry.Items.Insert(0, new ListItem("--Select--", "--Select--")); DdlState.Items.Add(new ListItem("--Select--", "--Select--")); ShowGridView(); } }
protected void BtnUpdateCity_Click(object sender, EventArgs e) { if (this.IsValid == true) { if ((int)MyJobPortalModel.City.GetCityRecords("CityName='" + TxtCityNameEdit.Text + "' and Id<>" + HdnCityId.Value).Rows.Count > 0) { LblDuplicateCityNameErrorEdit.Visible = true; return; } else { MyJobPortalModel.City ObjNewCity = new MyJobPortalModel.City(int.Parse(HdnCityId.Value)); ObjNewCity.CityName = TxtCityNameEdit.Text; ObjNewCity.CountryId = int.Parse(DdlCountryEdit.SelectedValue); ObjNewCity.StateId = int.Parse(DdlStateEdit.SelectedValue); ObjNewCity.Status = DdlStatus.SelectedValue; ObjNewCity.Update(); EditCityModal.Visible = false; TxtCityName.Focus(); this.Form.DefaultButton = BtnGo.UniqueID; ShowGridView(); } } }
protected void LnkBtnCloseCity_Click(object sender, EventArgs e) { EditCityModal.Visible = false; TxtCityName.Focus(); this.Form.DefaultButton = BtnGo.UniqueID; }