protected void save_Click(object sender, EventArgs e) { string chargesID = Request.QueryString["chargesID"]; if ((!string.IsNullOrEmpty(chargesID.Trim())) && (!chargesID.Trim().Equals("0"))) { string charges = txt_charges.Value; if (string.IsNullOrWhiteSpace(charges)) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('All fields required.');", true); return; } string type = ""; if (VehicleTypeSedan.Checked) { type = "Sedan"; } else if (VehicleTypeVan.Checked) { type = "Van"; } else if (VehicleTypeBus.Checked) { type = "Bus"; } bool VehicleTypeIsNormal = (VehicleTypeEconomy.Checked) ? true : false; if (type.ToLower().Trim().Equals("van") && (!VehicleTypeIsNormal)) { VehicleTypeEconomy.Checked = true; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Luxury type not set for Van.');", true); return; } if (type.ToLower().Trim().Equals("bus") && (!VehicleTypeIsNormal)) { VehicleTypeEconomy.Checked = true; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Luxury type not set for Bus.');", true); return; } string result = CitiesRepo.updateCityPrice(new tbl_autoCharges { charges = charges, chargesID = int.Parse(chargesID), updatedAt = DateTime.Now, from_city = int.Parse(fromCity_dropDown.SelectedValue), to_city = int.Parse(toCity_dropDown.SelectedValue), VehicleTypeIsNormal = VehicleTypeIsNormal, type = type }); if (result.Equals("true")) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Updated Successfully.');", true); } else if (result.Equals("already")) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('This city name is already exist.');", true); } else if (result.Equals("same")) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Same city names not allowed.');", true); } else { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Something went wrong.');", true); } } else { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Something went wrong.');", true); } }