/// <summary> /// Add new city /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { string cityID = txtID.Text; string cityName = txtName.Text; string nationalID = txtNationalID.Text; if (CityDAO.DulicateCity(cityID)) { phError.Controls.Add(new LiteralControl("<div class='alert alert-danger'>")); Label error = new Label(); error.Text = "CityID has been dupplicated!"; phError.Controls.Add(error); phError.Controls.Add(new LiteralControl("</div>")); return; } else if (string.IsNullOrEmpty(cityID) || string.IsNullOrEmpty(cityName) || string.IsNullOrEmpty(nationalID)) { phError.Controls.Add(new LiteralControl("<div class='alert alert-danger'>")); Label error = new Label(); error.Text = "All data must not be empty!"; phError.Controls.Add(error); phError.Controls.Add(new LiteralControl("</div>")); return; } else { City c = new City(); c.CityID = cityID; c.CityName = cityName; c.NationalID = nationalID; if (CityDAO.AddCity(c)) { Session["addOK"] = "New CITY has been added!"; Response.Redirect("AdminCity.aspx"); } } }