示例#1
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);
            }
        }
示例#2
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;
        }