protected void btnUpdate_Click(object sender, EventArgs e) { bc = new Bol_City(); ct = new City(); if (txtID.Text == "") { Response.Write("Vui long nhap ten hay id can cap nhat !!!"); txtID.Focus(); } else { if (DropDownList4.SelectedValue.ToString() == "ByID") { if (bc.CheckCityExistByID(Convert.ToInt32(txtSearch.Text)) == 1) { if (TextBox1.Text == "") { Response.Write("Ban dang de trong phan cap nhat !!!"); TextBox1.Focus(); } else { ct.Ci_ID = Convert.ToInt32(TextBox1.Text); GridView1.DataSource = bc.UpdateCityByID(ct); GridView1.DataBind(); Response.Write("Update thanh cong"); } } else { Response.Write("ID nay khong ton tai !!!"); } } else if (DropDownList4.SelectedValue.ToString() == "ByName") { if (bc.CheckCityExistByName(txtSearch.Text) == 1) { ct.Name = TextBox1.Text; GridView1.DataSource = bc.UpdateCityByName(ct); GridView1.DataBind(); } else { Response.Write("Name nay khong ton tai !!!"); } } } }
protected void btnSearch_Click(object sender, EventArgs e) { bc = new Bol_City(); ct = new City(); if (txtSearch.Text == "") { Response.Write("Vui long nhap tu khoa muon tim !!!"); txtSearch.Focus(); } else { if (DropDownList1.SelectedValue.ToString() == "ByID") { if (bc.CheckCityExistByID(Convert.ToInt32(txtSearch.Text)) == 1) { ct.Ci_ID = Convert.ToInt32(txtSearch.Text); GridView1.DataSource = bc.SelectCityByID(ct); GridView1.DataBind(); } else { Response.Write("ID nay khong ton tai !!!"); txtSearch.Focus(); } } else if (DropDownList1.SelectedValue.ToString() == "ByName") { if (bc.CheckCityExistByName(txtSearch.Text) == 1) { ct.Name = txtSearch.Text; GridView1.DataSource = bc.SelectCityByName(ct); GridView1.DataBind(); } else { Response.Write("Name nay khong ton tai !!!"); txtName.Focus(); } } } }
protected void btnDelete_Click(object sender, EventArgs e) { bc = new Bol_City(); ct = new City(); if (txtDelete.Text == "") { Response.Write("Nhap id hay ten can xoa !!!"); txtDelete.Focus(); } else if (DropDownList4.SelectedValue.ToString() == "ByID") { if (bc.CheckCityExistByID(Convert.ToInt32(txtSearch.Text)) == 1) { ct.Ci_ID = Convert.ToInt32(TextBox1.Text); GridView1.DataSource = bc.DeleteCityByID(ct); GridView1.DataBind(); } else { Response.Write("ID nay khong ton tai !!!"); } } else if (DropDownList4.SelectedValue.ToString() == "ByName") { if (bc.CheckCityExistByName(txtSearch.Text) == 1) { ct.Name = TextBox1.Text; GridView1.DataSource = bc.DeleteCityByName(ct); GridView1.DataBind(); Response.Write("Xoa thanh cong !!!"); } else { Response.Write("Name nay khong ton tai !!!"); } } }