private void ChiTietHoaDon_Load(object sender, EventArgs e)
        {
            HoaDon.model.Load load = new model.Load();
            DataTable dt = new DataTable();
            if (check == 2)
            {
                DataTable dtHoaDonNhapHang = load.LoadHoaDonNhapHangTheoMaHoaDon(ID);
                string ThoiGian = dtHoaDonNhapHang.Rows[0][1].ToString();
                //     string ViTri = dtHoaDon.Rows[0][2].ToString();
                //    string Khach = dtHoaDon.Rows[0][13].ToString();
                //     string MaKhach = dtHoaDon.Rows[0][12].ToString();
                int ThanhToan = Convert.ToInt32(dtHoaDonNhapHang.Rows[0][2].ToString());
                dt = load.LoadChiTietHoaDonNhapHang(ID);
                lblNgay.Text = ThoiGian;
                lblBan.Visible = false;
                lblKhachHang.Visible = false;
                lblTongTien.Text = ThanhToan.ToString();

            }
            else if(check ==1)
            {

                DataTable dtHoaDon = load.LoadHoaDonTheoMaHoaDon(ID);
                string ThoiGian = dtHoaDon.Rows[0][1].ToString();
                string ViTri = dtHoaDon.Rows[0][11].ToString();
                string Khach = dtHoaDon.Rows[0][13].ToString();
                string MaKhach = dtHoaDon.Rows[0][12].ToString();
                int ThanhToan = Convert.ToInt32( dtHoaDon.Rows[0][8].ToString());
                dt = load.LoadChiTietHoaDonTheoMaHoaDon(ID);
                lblNgay.Text = ThoiGian;
                lblBan.Text = ViTri;
                lblKhachHang.Text = Khach;
                lblTongTien.Text = ThanhToan.ToString();

                if (MaKhach!=""&& Convert.ToInt32(MaKhach)!=0)
                {
                    MaKhachHang = Convert.ToInt32(MaKhach);
                    groupPanel1.Visible = true;
                    BanHang.Model.Load load1 = new BanHang.Model.Load();
                    DataTable dtKhach = load1.LoadKhachHangTheoMaKhach(MaKhachHang);
                    labelXSDT.Text = dtKhach.Rows[0][2].ToString();
                    richTextBoxExDiaChi.Text = dtKhach.Rows[0][1].ToString();
                }

            }

            dgvChiTietHoaDon.DataSource = dt;
            dgvChiTietHoaDon.AllowUserToResizeRows = false;
            for (int i = 0; i < dt.Rows.Count; i++)
            {

                dgvChiTietHoaDon.Rows[i].Cells["ST"].Value = i + 1;

            }
        }
Exemple #2
0
 private void btnThongKeChiPhiTheoTuan_Click(object sender, EventArgs e)
 {
     HoaDon.model.Load load = new HoaDon.model.Load();
     DataTable dt = new DataTable();
     dt = load.LoadHoaDonNhapHangThongKe(dateTimeInputThongKeTuNgay.Value, dateTimeInputThongKeDenNgay.Value);
     ThongKe.CrystalReportThongKeChiPhiTheoTuan cry = new ThongKe.CrystalReportThongKeChiPhiTheoTuan();
     cry.SetDataSource(dt);
     crystalReportViewer1.ReportSource = cry;
     crystalReportViewer1.Refresh();
 }
Exemple #3
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            //nho them try catch
            try
            {
                int ID = Convert.ToInt32(lblMaMon.Text);
                string Ten = lblName.Text;
                float SoLuong = float.Parse(txtSoLuong.Value.ToString());
                string DonVi = dgvThucDon.SelectedRows[0].Cells[2].Value.ToString();
                float Gia = float.Parse(dgvThucDon.SelectedRows[0].Cells[3].Value.ToString()) ;
                checkso(richTextBoxExGiamGia);
                float GiamGia = a;
                float TongTien = Gia* SoLuong - GiamGia;
                if (MaHoaDon != 0)
                {
                    //neu chua co mon thi insert con neu khong thi update
                    //Kiem tra mon an co cung maMonAn va MaHoaDon
                    HoaDon.model.Load load = new HoaDon.model.Load();
                    DataTable dt = load.LoadMonAn(MaHoaDon, ID);
                    if (dt.Rows.Count == 0)
                    {
                        //InsertMonAn
                        BanHang.Model.Insert insert = new BanHang.Model.Insert();
                        insert.InsertHoaDonChiTiet(MaHoaDon, ID, Ten, SoLuong, DonVi, Gia, GiamGia, TongTien);
                        LoadChiTietHoaDon(MaHoaDon);
                    }
                    else
                    {
                        //Update
                        int MaChiTietHoaDon = Convert.ToInt32(dt.Rows[0][0].ToString());

                        BanHang.Model.Update update = new BanHang.Model.Update();
                        update.UpdateChiTietHoaDon(MaChiTietHoaDon, SoLuong, GiamGia);
                        LoadChiTietHoaDon(MaHoaDon);
                    }
                    resetThucDon();
                    LayHangTrongKho(ID, SoLuong);
                    LoadSoLuongSanPham();
                    loadThucDon();
                }
                else
                {
                    MessageBox.Show("Bạn chưa chọn bàn");
                }

            }
            catch (Exception)
            {

            }
        }
Exemple #4
0
        private void btnHuy_Click(object sender, EventArgs e)
        {
            try
            {
                if(MaHoaDon!=0)
                {
                    DialogResult dialog = MessageBox.Show("Bạn có muốn hủy bàn", "Hủy", MessageBoxButtons.YesNo);
                    if (dialog == DialogResult.Yes)
                    {
                        for (int i = 0; i < dataGridViewXListMonAn.Rows.Count; i++)
                        {
                            int MaChiTiet = Convert.ToInt32(dataGridViewXListMonAn.Rows[i].Cells[1].Value.ToString());
                            int SoLuong = Convert.ToInt32(dataGridViewXListMonAn.Rows[i].Cells[4].Value.ToString());

                            BanHang.Model.Update update = new BanHang.Model.Update();
                            HoaDon.model.Load load = new HoaDon.model.Load();
                            DataTable dt = load.LoadChiTietHoaDonTheoMaChiTietHoaDon(MaChiTiet);
                            int MaMonAn = Convert.ToInt32(dt.Rows[0][1].ToString());
                            update.TraHangTrongKho(MaMonAn, SoLuong);
                        }

                        ////BanHang.Model.Delete delete = new BanHang.Model.Delete();
                        ////delete.DeleteMonAn(MaChiTiet);

                        BanHang.Model.Delete delete = new BanHang.Model.Delete();
                        delete.DeleteHoaDon(MaHoaDon);
                        LoadChiTietHoaDon(MaHoaDon);
                        LoadSoLuongSanPham();
                        loadThucDon();
                        ResetBanHang();
                        MaHoaDon = 0;
                    }

                }
                else
                {
                    MessageBox.Show("Bạn chưa chọn hóa đơn");
                }
            }
            catch (Exception)
            {

            }
        }
Exemple #5
0
 public void LoadHoaDonNhapHang()
 {
     KiemTraHoaDon = 2;
     HoaDon.model.Load load = new HoaDon.model.Load();
     DataTable dt = load.LoadHoaDonNhapHang(dateTimeInput1.Value, dateTimeInput2.Value);
     loadDataHoaDon(dt);
     lblHoaDon.Text = dt.Rows.Count.ToString();
     int Tong = 0;
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         Tong = Convert.ToInt32(dt.Rows[i][2].ToString()) + Tong;
     }
     txtTongTien.Text = Tong.ToString();
 }
Exemple #6
0
        public void LoadHoaDonChuaThanhToanDangChon()
        {
            try
            {
                int MaBan = Convert.ToInt32(listViewExKhuVuc.SelectedItems[0].Name.ToString());
                HoaDon.model.Load load = new HoaDon.model.Load();
                DataTable HoaDon = load.LoadHoaDonChuaThanhToanCanChon(MaBan);
                lblThoiGian.Text = HoaDon.Rows[0][1].ToString();
                lblViTri.Text = HoaDon.Rows[0][11].ToString();
                richtxtTongTien.Text = HoaDon.Rows[0][6].ToString();
                MaHoaDon = Convert.ToInt32(HoaDon.Rows[0][0].ToString());
                LoadChiTietHoaDon(MaHoaDon);
                labelXID.Text = "";
                textBoxXKhachHang.Text = "";
                textBoxXSDT.Text = "";
                richTextBoxExDiaChi.Text = "";
                checkBoxX1.Checked = false;

            }
            catch (Exception)
            {
                MaHoaDon = 0;
                DataTable dt = new DataTable();
                dataGridViewXListMonAn.DataSource = dt;
                lblThoiGian.Text = "";
                lblViTri.Text = "";
                richtxtTongTien.Text = "";
                richtxtThanhToan.Text = "";
                numericUpDownGiamGia.Value = 0;
                numericUpDownVAT.Value = 0;
                labelXID.Text = "";
                textBoxXKhachHang.Text = "";
                textBoxXSDT.Text = "";
                richTextBoxExDiaChi.Text = "";
                checkBoxX1.Checked = false;

            }
        }
Exemple #7
0
        private void toolStripMenuItemXoaBan_Click(object sender, EventArgs e)
        {
            try
            {
                //check khu vuc
                int MaBanAn = Convert.ToInt32(listViewExKhuVuc.SelectedItems[0].Name.ToString());

                HoaDon.model.Load load = new HoaDon.model.Load();
                DataTable HoaDon = load.LoadHoaDonChuaThanhToanCanChon(MaBanAn);
                if (HoaDon.Rows.Count == 0)
                {
                    DialogResult dialogResult = MessageBox.Show("Bạn có chắc chắn không", "Xóa", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        BanHang.Model.Delete delete = new BanHang.Model.Delete();
                        delete.DeleteBanAn(MaBanAn);
                    }
                    LoadKhuVuc();
                }
                else
                {
                    MessageBox.Show("Hóa đơn chưa thanh toán");
                }

            }
            catch (Exception)
            {

            }
        }
Exemple #8
0
        private void toolStripMenuItemHuyMon_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridViewXListMonAn.SelectedRows[0].Cells[1].Value.ToString() != null)
                {
                     DialogResult dialogResult = MessageBox.Show("Bạn có chắc chắn muốn xóa", "Xóa", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
            {
                int MaChiTiet = Convert.ToInt32(dataGridViewXListMonAn.SelectedRows[0].Cells[1].Value.ToString());
                int SoLuong = Convert.ToInt32(dataGridViewXListMonAn.SelectedRows[0].Cells[4].Value.ToString());

                    BanHang.Model.Update update = new BanHang.Model.Update();
                    HoaDon.model.Load load = new HoaDon.model.Load();
                    DataTable dt = load.LoadChiTietHoaDonTheoMaChiTietHoaDon(MaChiTiet);
                    int MaMonAn = Convert.ToInt32(dt.Rows[0][1].ToString());
                    update.TraHangTrongKho(MaMonAn, SoLuong);

                BanHang.Model.Delete delete = new BanHang.Model.Delete();
                delete.DeleteMonAn(MaChiTiet);
                LoadChiTietHoaDon(MaHoaDon);
                LoadSoLuongSanPham();
                loadThucDon();
            }
                }
            }
            catch (Exception)
            {

            }
        }
Exemple #9
0
        private void toolStripMenuItemChuyenBan_Click(object sender, EventArgs e)
        {
            try
            {
                int MaBanAn = Convert.ToInt32(listViewExKhuVuc.SelectedItems[0].Name.ToString());
                HoaDon.model.Load load = new HoaDon.model.Load();
                DataTable HoaDon = load.LoadHoaDonChuaThanhToanCanChon(MaBanAn);
                if (HoaDon.Rows.Count > 0)
                {
                    BanHang.ChuyenBan chuyen = new BanHang.ChuyenBan(MaBanAn,HoaDon.Rows[0][11].ToString());
                    chuyen.ShowDialog();
                    LoadKhuVuc();
                }
            }
            catch
            {

            }
        }
Exemple #10
0
 private DataTable loadHoaDon()
 {
     HoaDon.model.Load load = new HoaDon.model.Load();
     return  load.LoadHoaDonChuaThanhToan();
 }
Exemple #11
0
        public void LoadChiTietHoaDon(int MaHoaDon)
        {
            try
            {
                HoaDon.model.Load load = new HoaDon.model.Load();
                dataGridViewXListMonAn.DataSource = load.LoadChiTietHoaDonChuaThanhToanCanChon(MaHoaDon);
                dataGridViewXListMonAn.AllowUserToResizeRows = false;
                dataGridViewXListMonAn.Columns[1].Visible = false;
                dataGridViewXListMonAn.Columns[2].Visible = false;
                dataGridViewXListMonAn.Columns[3].Width = 200;
                for (int i = 0; i < dataGridViewXListMonAn.Rows.Count; i++)
                {

                    dataGridViewXListMonAn.Rows[i].Cells["STT1"].Value = i + 1;

                }
                TinhToanHoaDon();
            }
            catch (Exception)
            {

            }
        }
Exemple #12
0
        private void dgvThucDon_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {

                int ID = Convert.ToInt32(dgvThucDon.SelectedRows[0].Cells[0].Value.ToString());
                string Ten = dgvThucDon.SelectedRows[0].Cells[1].Value.ToString();
                float SoLuong =  1;
                string DonVi = dgvThucDon.SelectedRows[0].Cells[2].Value.ToString();
                float Gia = float.Parse(dgvThucDon.SelectedRows[0].Cells[3].Value.ToString());
                float GiamGia = 0;
                float TongTien = Gia * SoLuong - GiamGia;
                if (LayHangTrongKho(ID, SoLuong) == 1)
                {
                    if (MaHoaDon != 0)
                    {
                        //neu chua co mon thi insert con neu khong thi update
                        //Kiem tra mon an co cung maMonAn va MaHoaDon
                        HoaDon.model.Load load = new HoaDon.model.Load();
                        DataTable dt = load.LoadMonAn(MaHoaDon, ID);
                        if (dt.Rows.Count == 0)
                        {
                            //InsertMonAn
                            BanHang.Model.Insert insert = new BanHang.Model.Insert();
                            insert.InsertHoaDonChiTiet(MaHoaDon, ID, Ten, SoLuong, DonVi, Gia, GiamGia, TongTien);
                            LoadChiTietHoaDon(MaHoaDon);

                        }
                        else
                        {
                            //Update
                            int MaChiTietHoaDon = Convert.ToInt32(dt.Rows[0][0].ToString());

                            BanHang.Model.Update update = new BanHang.Model.Update();
                            update.UpdateChiTietHoaDon(MaChiTietHoaDon, SoLuong, GiamGia);
                            LoadChiTietHoaDon(MaHoaDon);
                        }
                }
                }
                else
                {
                    MessageBox.Show("Bạn chưa chọn hàng hoặc hết đồ");
                }
            }
            catch (Exception)
            {

            }
            LoadSoLuongSanPham();
            loadThucDon();
            resetThucDon();
        }