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();
                    }
                }
            }
        }
コード例 #2
0
 public int UpdateBusTypeByName(BusType bt)
 {
     return btac.UpdateBusTypeByName(bt.Name, bt.Description, bt.Price, bt.Status);
 }
コード例 #3
0
 //-dc roi day=]] anh build di. Dung co chay. voi vi em chua lam cai present layer
 public DataTable SelectBusTypeByName(BusType bt)
 {
     return btac.SelectBusTypeByName(bt.Name);
 }
コード例 #4
0
 public DataTable SelectBusTypeByID(BusType bt)
 {
     return btac.SelectBusTypeByID(bt.BT_ID);
 }
コード例 #5
0
 public int InsertBusType(BusType bt)
 {
     return btac.InsertBusType(bt.BT_ID,bt.Name, bt.Description, bt.Price, bt.Status);
 }
コード例 #6
0
 public SqlDataReader DeleteBusTypeByName(BusType bt)
 {
     return btac.DeleteBusTypeByName(bt.Name);
 }
コード例 #7
0
 public SqlDataReader DeleteBusTypeByID(BusType bt)
 {
     return btac.DeleteBusTypeByID(bt.BT_ID);
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     bolbt = new Bol_BusType();
     bt = new BusType();
     GridView1.DataSource = bolbt.SelectAllBusType();
     GridView1.DataBind();
 }
        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();
                    }
                }
            }
        }
 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();
             }
         }
     }
 }