private void xembaocao_Click(object sender, EventArgs e)
 {
     if (Loai.SelectedIndex == 0)
     {
         dataGridViewbanchay.DataSource = null;
         dataGridViewbanchay.DataSource = tbhoadonct;
     }
     else
     if (Loai.SelectedIndex > 0 && Ten.Text != "")
     {
         TBhoadonct tbhoadonct_1 = new TBhoadonct("select MASAPHAM,TENSANPHAM,sum(SOLUONG),Sum(GIA) from TBL_HOADONCT join TBL_HOADON on TBL_HOADONCT.MAHDBAN=TBL_HOADON.MAHDBAN "
                                                  + " where LOAISANPHAM='" + Loai.SelectedItem.ToString() + "' and TENSANPHAM= '" + Ten.Text + "'" +
                                                  "group by MASAPHAM, TENSANPHAM");
         dataGridViewbanchay.DataSource = null;
         dataGridViewbanchay.DataSource = tbhoadonct_1;
     }
     else
     if (Loai.SelectedIndex > 0)
     {
         TBhoadonct tbhoadonct_1 = new TBhoadonct("select MASAPHAM,TENSANPHAM,sum(SOLUONG),Sum(GIA) from TBL_HOADONCT join TBL_HOADON on TBL_HOADONCT.MAHDBAN = TBL_HOADON.MAHDBAN "
                                                  + "where LOAISANPHAM='" + Loai.SelectedItem.ToString() + "'" +
                                                  "group by MASAPHAM, TENSANPHAM");
         dataGridViewbanchay.DataSource = null;
         dataGridViewbanchay.DataSource = tbhoadonct_1;
     }
     else
     if (Ten.Text != "")
     {
         TBhoadonct tbhoadonct_1 = new TBhoadonct("select MASAPHAM,TENSANPHAM,sum(SOLUONG),Sum(GIA) from TBL_HOADONCT join TBL_HOADON on TBL_HOADONCT.MAHDBAN = TBL_HOADON.MAHDBAN "
                                                  + " where TENSANPHAM='" + Ten.Text + "'" +
                                                  "group by MASAPHAM, TENSANPHAM");
         dataGridViewbanchay.DataSource = null;
         dataGridViewbanchay.DataSource = tbhoadonct_1;
     }
 }
 private void Loai_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (Loai.SelectedIndex == 0)
     {
         dataGridViewbanchay.DataSource = null;
         dataGridViewbanchay.DataSource = tbhoadonct;
     }
     else
     if (Loai.SelectedIndex > 0 && Ten.Text != "")
     {
         TBhoadonct tbhoadonct_1 = new TBhoadonct("select MASAPHAM,TENSANPHAM,sum(SOLUONG),Sum(GIA) from TBL_HOADONCT join TBL_HOADON on TBL_HOADONCT.MAHDBAN = TBL_HOADON.MAHDBAN "
                                                  + "where LOAISANPHAM='" + Loai.SelectedItem.ToString() + "' and TENSANPHAM= '" + Ten.Text + "'" +
                                                  "group by MASAPHAM, TENSANPHAM");
         dataGridViewbanchay.DataSource = null;
         dataGridViewbanchay.DataSource = tbhoadonct_1;
     }
     else
     if (Loai.SelectedIndex > 0)
     {
         TBhoadonct tbhoadonct_1 = new TBhoadonct("select MASAPHAM,TENSANPHAM,sum(SOLUONG),Sum(GIA) from TBL_HOADONCT join TBL_HOADON on TBL_HOADONCT.MAHDBAN = TBL_HOADON.MAHDBAN "
                                                  + "where LOAISANPHAM='" + Loai.SelectedItem.ToString() + "'" +
                                                  "group by MASAPHAM, TENSANPHAM");
         dataGridViewbanchay.DataSource = null;
         dataGridViewbanchay.DataSource = tbhoadonct_1;
     }
     else
     if (Ten.Text != "")
     {
         TBhoadonct tbhoadonct_1 = new TBhoadonct("select MASAPHAM,TENSANPHAM,sum(SOLUONG),Sum(GIA) from TBL_HOADONCT join TBL_HOADON on TBL_HOADONCT.MAHDBAN = TBL_HOADON.MAHDBAN "
                                                  + " where TENSANPHAM='" + Ten.Text + "'" +
                                                  "group by MASAPHAM, TENSANPHAM");
         dataGridViewbanchay.DataSource = null;
         dataGridViewbanchay.DataSource = tbhoadonct_1;
     }
     else
     if (Loai.SelectedIndex > 0 && Ten.Text != "" && Tu.Value <= Den.Value)
     {
         TBhoadonct tbhoadonct_1 = new TBhoadonct("select MASAPHAM,TENSANPHAM,sum(SOLUONG),Sum(GIA) from TBL_HOADONCT join TBL_HOADON on TBL_HOADONCT.MAHDBAN = TBL_HOADON.MAHDBAN "
                                                  + " where TENSANPHAM='" + Ten.Text + "'and LOAISANPHAM = '" + Loai.SelectedItem.ToString() + "' and NGAYBAN >='" + Tu.Value.ToShortDateString() + "'and NGAYBAN<='" + Den.Value.ToShortDateString() + "'" +
                                                  "group by MASAPHAM, TENSANPHAM");
         dataGridViewbanchay.DataSource = null;
         dataGridViewbanchay.DataSource = tbhoadonct_1;
     }
     else
     if (Tu.Value <= Den.Value)
     {
         TBhoadonct tbhoadonct_1 = new TBhoadonct("select MASAPHAM,TENSANPHAM,sum(SOLUONG),Sum(GIA) from TBL_HOADONCT join TBL_HOADON on TBL_HOADONCT.MAHDBAN = TBL_HOADON.MAHDBAN "
                                                  + " where NGAYBAN >='" + Tu.Value.ToShortDateString() + "'and NGAYBAN<='" + Den.Value.ToShortDateString() + "'" +
                                                  "group by MASAPHAM, TENSANPHAM");
         dataGridViewbanchay.DataSource = null;
         dataGridViewbanchay.DataSource = tbhoadonct_1;
     }
     else
     if (Loai.SelectedIndex > 0 && Tu.Value <= Den.Value)
     {
         TBhoadonct tbhoadonct_1 = new TBhoadonct("select MASAPHAM,TENSANPHAM,sum(SOLUONG),Sum(GIA) from TBL_HOADONCT join TBL_HOADON on TBL_HOADONCT.MAHDBAN = TBL_HOADON.MAHDBAN "
                                                  + "where LOAISANPHAM = '" + Loai.SelectedItem.ToString() + "' and NGAYBAN >='" + Tu.Value.ToShortDateString() + "'and NGAYBAN<='" + Den.Value.ToShortDateString() + "'" +
                                                  "group by MASAPHAM, TENSANPHAM");
         dataGridViewbanchay.DataSource = null;
         dataGridViewbanchay.DataSource = tbhoadonct_1;
     }
     else
     if (Ten.Text != "" && Tu.Value <= Den.Value)
     {
         TBhoadonct tbhoadonct_1 = new TBhoadonct("select MASAPHAM,TENSANPHAM,sum(SOLUONG),Sum(GIA) from TBL_HOADONCT join TBL_HOADON on TBL_HOADONCT.MAHDBAN = TBL_HOADON.MAHDBAN "
                                                  + "where TENSANPHAM='" + Ten.Text + "' and NGAYBAN >='" + Tu.Value.ToShortDateString() + "'and NGAYBAN<='" + Den.Value.ToShortDateString() + "'" +
                                                  "group by MASAPHAM, TENSANPHAM");
         dataGridViewbanchay.DataSource = null;
         dataGridViewbanchay.DataSource = tbhoadonct_1;
     }
 }