void load_hoadon(string query)
        {
            DAOHoaDon hd = new DAOHoaDon();
            DataTable tb = new DataTable();

            tb = hd.locHoaDon(query);
            dtg_hoadon.DataSource = tb;
        }
Example #2
0
        void loadChiTietHoaDon()
        {
            DAOTable         ban = new DAOTable();
            DAOHoaDon        hd  = new DAOHoaDon();
            DAOChiTietHoaDon ct  = new DAOChiTietHoaDon();

            if (ban.KTBanDangSD(Globals.Maban))
            {
                dtg_chitiet.DataSource         = ct.getChiTietHoaDon(Globals.Mahoadon);
                dtg_chitiet.AllowUserToAddRows = false;
                txt_tongtien.text = hd.getTongbill(Globals.Mahoadon).ToString();
            }
        }
Example #3
0
 private void btn_thanhtoan_Click(object sender, EventArgs e)
 {
     try
     {
         DAOHoaDon a = new DAOHoaDon();
         a.ThanhToan(Globals.Mahoadon);
         MessageBox.Show("Thanh toan thanh cong");
         //update trang thai ban
         DAOTable tb = new DAOTable();
         tb.UpdatetableStatus(Globals.Maban, 1);
     }
     catch
     {
     }
 }
 private void delete_button_Click(object sender, EventArgs e)
 {
     try
     {
         int       a  = int.Parse(dtg_hoadon.CurrentRow.Cells[0].Value.ToString());
         DAOHoaDon hd = new DAOHoaDon();
         hd.xoahoadon(a);
         DataTable tb = new DataTable();
         tb = hd.getHoaDon();
         dtg_hoadon.DataSource = tb;
     }
     catch (Exception lo)
     {
         MessageBox.Show(lo.Message);
     }
 }
        private void frmdanhsachdonhang_Load(object sender, EventArgs e)
        {
            if (Globals.role == "employee")
            {
                delete_button.Visible = false;
            }


            try
            {
                DAOHoaDon hd = new DAOHoaDon();
                DataTable tb = new DataTable();
                tb = hd.getHoaDon();
                dtg_hoadon.DataSource = tb;
            }
            catch
            {
            }
        }
Example #6
0
        private void btn_dathang_Click(object sender, EventArgs e)
        {
            try
            {
                HoaDon hd = new HoaDon();
                hd.Maban = Globals.Maban;
                hd.Manv  = Globals.NV;

                hd.Thoigian  = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                hd.Tongbill  = tongtien;
                hd.Trangthai = false;
                hd.Mavoucher = int.Parse(cbVoucher.Text);
                DAOHoaDon        a   = new DAOHoaDon();
                DAOChiTietHoaDon DCT = new DAOChiTietHoaDon();
                a.DatHang(hd);
                int mahoadon = a.getCurrentMahoadon(Globals.Maban);
                for (int i = 0; i < dtg_chitiet.Rows.Count - 1; i++)
                {
                    int           soluong = int.Parse(dtg_chitiet.Rows[i].Cells[2].Value.ToString());
                    ChiTietHoaDon ct      = new ChiTietHoaDon();
                    if (soluong != 0)
                    {
                        ct.Mahoadon = mahoadon;
                        ct.Mamonan  = int.Parse(dtg_chitiet.Rows[i].Cells[0].Value.ToString());
                        ct.Soluong  = soluong;
                        DCT.Themvaochitiethoadon(ct);
                    }
                }
                MessageBox.Show("Dat hang thanh cong");
                Globals.SetMahoadon(mahoadon);
                DAOTable tb = new DAOTable();
                tb.UpdatetableStatus(Globals.Maban, 0);
            }
            catch (SqlException oke)
            {
                MessageBox.Show(oke.Message);
            }
        }
Example #7
0
        private void Bt_Click(object sender, EventArgs e)
        {
            Button bt = sender as Button;
            object a  = bt.Tag;

            Globals.SetMaban(Convert.ToInt32(a));
            frmdatdonhang frm = new frmdatdonhang();
            DAOHoaDon     hd  = new DAOHoaDon();
            // kt xem ban co dang su dung hay ko
            DAOTable         ban = new DAOTable();
            DAOChiTietHoaDon ct  = new DAOChiTietHoaDon();

            if (ban.KTBanDangSD(Globals.Maban))
            {
                Globals.SetMahoadon(hd.getCurrentMahoadon(Globals.Maban));
                Globals.SetChiTietHoaDon(ct.getChiTietHoaDon(Globals.Mahoadon));
            }



            frm.Show();
            frm.FormClosed += Frm_FormClosed;
        }