public void SaveNewCity() { CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; MasterData objmst = new MasterData(); string cityname, statename, zipcode; cityname = textInfo.ToTitleCase(txtmetrocityname.Text.Trim()); statename = txtstate.Text; zipcode = ""; int countryid = 0, stateid; countryid = Convert.ToInt32(ddlcountry.SelectedItem.Value); Nullable<int> timezoneid = null; timezoneid = (ddltimezone.SelectedIndex > 0) ? Convert.ToInt32(ddltimezone.SelectedItem.Value) : timezoneid; stateid = Convert.ToInt32(ddlstate.SelectedItem.Value); int newcityid = objmst.CityDetails_Insert(cityname, stateid, statename, countryid, zipcode, timezoneid); hdnmetrocityid.Value = newcityid.ToString(); }
public void SaveNewNearbyCity() { TextBox txtcitynearby = (TextBox)Repnearbymetro.Controls[Repnearbymetro.Controls.Count - 1].FindControl("txtcitynearby"); TextBox txtstatenc = (TextBox)Repnearbymetro.Controls[Repnearbymetro.Controls.Count - 1].FindControl("txtstatenc"); DropDownList ddlstatenc = (DropDownList)Repnearbymetro.Controls[Repnearbymetro.Controls.Count - 1].FindControl("ddlstatenc"); DropDownList ddlcountrync = (DropDownList)Repnearbymetro.Controls[Repnearbymetro.Controls.Count - 1].FindControl("ddlcountrync"); TextBox txtZipCodenc = (TextBox)Repnearbymetro.Controls[Repnearbymetro.Controls.Count - 1].FindControl("txtZipCodenc"); MasterData objmst = new MasterData(); string cityname, statename, zipcode; cityname = txtcitynearby.Text.Trim(); statename = (ddlcountrync.SelectedItem.Text.ToLower() != "usa") ? txtstatenc.Text : ddlstatenc.SelectedItem.Text; zipcode = txtZipCodenc.Text; int countryid = 0, stateid; Nullable<int> timezoneid = null; countryid = Convert.ToInt32(ddlcountrync.SelectedItem.Value); stateid = Convert.ToInt32(ddlstatenc.SelectedItem.Value); int newcityid = objmst.CityDetails_Insert(cityname, stateid, statename, countryid, zipcode, timezoneid); if (newcityid < 0) { lblerrmsg.Text = "Error: Data did not submit. Please contact system administrator!"; lblerrmsg.ForeColor = System.Drawing.Color.Red; } hdnnearbycityid.Value = newcityid.ToString(); }
public Nullable<Int32> InsertCitydetails() { Int32 newcityid = Convert.ToInt32(hdncityid.Value); if (!string.IsNullOrEmpty(txtcity.Text.Trim())) { string cityname, statename, zipcode, countryname; int countryid, stateid, cityid; cityid = Convert.ToInt16(hdncityid.Value); cityname = txtcity.Text.Trim(); statename = txtstate.Text.Trim(); zipcode = txtzipcode.Text.Trim(); countryname = ddlcountry.SelectedItem.Text.Trim(); stateid = Convert.ToInt32(ddlstate.SelectedItem.Value); countryid = Convert.ToInt32(ddlcountry.SelectedItem.Value); if (cityid == 0 || (statename.Trim() != hdnstate.Value.Trim() || countryname.Trim() != hdncountry.Value.Trim() || zipcode.Trim() != hdnzipcode.Value.Trim())) { MasterData objmst = new MasterData(); newcityid = objmst.CityDetails_Insert(cityname, stateid, statename, countryid, zipcode, null); hdncityid.Value = newcityid.ToString(); } } // fillstate(); // fillcitydetails(newcityid, txtaddress.Text, "0"); if (newcityid == 0) { return null; } else { return newcityid; } }