protected void Page_Load(object sender, EventArgs e) { bolbt = new Bol_BusType(); bt = new BusType(); GridView1.DataSource = bolbt.SelectAllBusType(); GridView1.DataBind(); }
protected void btnDelete_Click(object sender, EventArgs e) { bolbt = new Bol_BusType(); bt = new BusType(); if (txtDelete.Text == "") { Response.Write("Nhap ten hay id can xoa !!!"); txtDelete.Focus(); } else { if (DropDownList3.SelectedValue.ToString() == "ByID") { if (bolbt.CheckBusTypeExistByID(Convert.ToInt32(txtDelete.Text)) == 1) { bt.BT_ID = Convert.ToInt32(txtDelete.Text); GridView1.DataSource = bolbt.DeleteBusTypeByID(bt); GridView1.DataBind(); } else { Response.Write("ID nay khong ton tai !!!"); txtName.Focus(); } } else if (DropDownList3.SelectedValue.ToString() == "ByName") { if (bolbt.CheckBusTypeExistByID(Convert.ToInt32(txtDelete.Text)) == 1) { bt.Name = txtDelete.Text; GridView1.DataSource = bolbt.DeleteBusTypeByName(bt); GridView1.DataBind(); } else { Response.Write("Name nay khong ton tai !!!"); txtName.Focus(); } } } }
protected void btnSearch_Click(object sender, EventArgs e) { bt = new BusType(); bolbt = new Bol_BusType(); if (txtSearch.Text == "") { Response.Write("Vui long nhap tu khoa muon tim !!!"); txtSearch.Focus(); } else { if (DropDownList1.SelectedValue.ToString() == "ByID") { if (bolbt.CheckBusTypeExistByID(Convert.ToInt32(txtSearch.Text)) == 1) { bt.BT_ID = Convert.ToInt32(txtSearch.Text); GridView1.DataSource = bolbt.SelectBusTypeByID(bt); GridView1.DataBind(); } else { Response.Write("ID nay khong ton tai !!!"); txtSearch.Focus(); } } else if (DropDownList1.SelectedValue.ToString() == "ByName") { if (bolbt.CheckBusTypeExistByName(txtSearch.Text) == 1) { bt.Name = txtSearch.Text; GridView1.DataSource = bolbt.SelectBusTypeByName(bt); GridView1.DataBind(); } else { Response.Write("Name nay khong ton tai !!!"); txtSearch.Focus(); } } } }
protected void btnUpdate_Click(object sender, EventArgs e) { bt = new BusType(); bolbt = new Bol_BusType(); if (txtID.Text == "") { Response.Write("Vui long nhap ten !!!"); txtID.Focus(); } else { if (DropDownList2.SelectedValue.ToString() == "ByID") { if (bolbt.CheckBusTypeExistByID(Convert.ToInt32(txtID.Text)) == 1) { if (txtName.Text == "") { Response.Write("Vui long nhap thong tin update !!!"); txtName.Focus(); } else if (txtDescription.Text == "") { Response.Write("Vui long nhap thong tin update !!!"); txtDescription.Focus(); } else if (txtPrice.Text == "") { Response.Write("Vui long nhap thong tin update !!!"); txtPrice.Focus(); } else if (txtID.Text == "") { Response.Write("Vui long nhap thong tin update !!!"); txtID.Focus(); } else { bt.BT_ID = Convert.ToInt32(txtID.Text); bt.Name = txtName.Text; bt.Description = txtDescription.Text; bt.Price = Convert.ToDouble(txtPrice.Text); if (RadioButton3.Checked) { bt.Status = true; } else if (RadioButton4.Checked) { bt.Status = false; } try { GridView1.DataSource = bolbt.UpdateBusTypeByID(bt); GridView1.DataBind(); } catch (Exception ex) { Response.Write(ex.Message + "SAO LAI THE NHI !!!"); } } } else { Response.Write("ID nay khong ton tai !!!"); txtID.Focus(); } } else if (DropDownList2.SelectedValue.ToString() == "ByName") { if (bolbt.CheckBusTypeExistByName(txtID.Text) == 1) { bt.Name = txtName.Text; bt.Description = txtDescription.Text; bt.Price = Convert.ToDouble(txtPrice.Text); if (RadioButton3.Checked) { bt.Status = true; } else if (RadioButton4.Checked) { bt.Status = false; } try { GridView1.DataSource = bolbt.UpdateBusTypeByName(bt); GridView1.DataBind(); } catch (Exception ex) { Response.Write(ex.Message + "CHAN CHUA KIA !!!"); } } else { Response.Write("Name nay khong ton tai !!!"); txtName.Focus(); } } } }