Esempio n. 1
0
 private void buttonX1_Click(object sender, EventArgs e)
 {
     checkso(textBoxX1);
     float GiamGia = a;
     BanHang.Model.Update update = new Model.Update();
     update.UpdateGiamGiaMonAn(MaHDCT, GiamGia);
     this.Close();
 }
Esempio n. 2
0
 private void buttonX1_Click(object sender, EventArgs e)
 {
     BanHang.Model.Update update = new Model.Update();
     checkso(textBoxX1);
     float Gia2 = a;
     update.UpdateGiaMonAn(MaHoaDonChiTiet, Gia2);
     this.Close();
 }
Esempio n. 3
0
 private void buttonX1_Click(object sender, EventArgs e)
 {
     int SoLuong = Convert.ToInt32(numericUpDown1.Value.ToString());
      BanHang.Model.Update update = new Model.Update();
      HoaDon.model.Load load = new HoaDon.model.Load();
      DataTable dt = load.LoadChiTietHoaDonTheoMaChiTietHoaDon(MaHDCT);
      int MaMonAn = Convert.ToInt32(dt.Rows[0][1].ToString());
      if (update.LayHangTrongKho(MaMonAn, SoLuong) == 1)
      {
          update.UpdateThemSoLuongMonAn(MaHDCT, SoLuong);
          this.Close();
      }
      else
      {
          MessageBox.Show("Không đủ nguyên liệu");
      }
 }
Esempio n. 4
0
 private void buttonX1_Click(object sender, EventArgs e)
 {
     int SoLuong = Convert.ToInt32(numericUpDown1.Value.ToString());
     if (SoLuong <= SoLuongTruoc)
     {
         BanHang.Model.Update update = new Model.Update();
         update.UpdateGiamSoLuongMonAn(MaHDCT, SoLuong);
         HoaDon.model.Load load = new HoaDon.model.Load();
         DataTable dt = load.LoadChiTietHoaDonTheoMaChiTietHoaDon(MaHDCT);
         int MaMonAn = Convert.ToInt32(dt.Rows[0][1].ToString());
         update.TraHangTrongKho(MaMonAn, SoLuong);
         this.Close();
     }
     else
     {
         MessageBox.Show("Số lượng giảm không được vượt quá số lượng ở hóa đơn");
     }
 }
Esempio n. 5
0
 private void buttonX1_Click(object sender, EventArgs e)
 {
     int MaBanTiep = Convert.ToInt32(comboTree1.SelectedValue.ToString());
     HoaDon.model.Load load1 = new HoaDon.model.Load();
     DataTable dt1 = load1.LoadHoaDonChuaThanhToanCanChon(MaBanTiep);
     if (dt1.Rows.Count == 0)
     {
         BanHang.Model.Load load = new Model.Load();
         DataTable dt = load.LoadBanAnTheoMaBan(MaBanTiep);
         string Ten = dt.Rows[0][1].ToString();
         BanHang.Model.Update update = new Model.Update();
         update.UpdateChuyenBanAn(MaBanAn, MaBanTiep, Ten);
         this.Close();
     }
     else
     {
         MessageBox.Show("Bàn đã có người ngồi");
     }
 }
Esempio n. 6
0
 private void buttonX1_Click(object sender, EventArgs e)
 {
     BanHang.Model.Update update = new Model.Update();
     update.UpdateBanAn(MaBan, textBoxX1.Text);
     this.Close();
 }
Esempio n. 7
0
        private void btnThanhToan_Click(object sender, EventArgs e)
        {
            try
            {
                if (MaHoaDon != 0)
                {
                    DialogResult dialogResult = MessageBox.Show("Bạn có chắc chắn muốn thanh toán", "Thanh toán", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        checkso(richtxtDichVu);
                        float DichVu = a;
                        checkso(richtxtTongTien);
                        float TongTien = a;
                        int GiamGia = Convert.ToInt32(numericUpDownGiamGia.Value.ToString());
                        int VAT = Convert.ToInt32(numericUpDownVAT.Value.ToString());
                        string GhiChu = richTextBoxExGhiChu.Text;
                        checkso(richtxtThanhToan);
                        float ThanhToan = a;
                        BanHang.Model.Update update = new BanHang.Model.Update();
                        if (checkBoxX1.Checked == false)
                        {
                            update.UpdateHoaDon(MaHoaDon, DichVu, GiamGia, VAT, TongTien, ThanhToan, GhiChu);
                        }
                        else
                        {
                            if (labelXID.Text != "")
                            {
                                int MaKhachHang = Convert.ToInt32(labelXID.Text);
                                string TenKhachHang = textBoxXKhachHang.Text;
                                update.UpdateHoaDonGhiNo(MaHoaDon, DichVu, GiamGia, VAT, TongTien, ThanhToan, GhiChu, MaKhachHang, TenKhachHang);
                            }
                            else
                            {
                                // Them Khach hang
                                BanHang.Model.Insert insert = new BanHang.Model.Insert();
                                insert.InsertKhachHang(textBoxXKhachHang.Text, textBoxXSDT.Text, richTextBoxExDiaChi.Text);
                                //update thoi
                                update.UpdateHoaDonGhiNoKhachHangMoi(MaHoaDon, DichVu, GiamGia, VAT, TongTien, ThanhToan, GhiChu);

                            }
                        }
                        DialogResult dialog = MessageBox.Show("Bạn có muốn in hóa đơn", "In hóa đơn", MessageBoxButtons.YesNo);

                            if(dialog== DialogResult.Yes)
                            {
                                BanHang.HoaDonBanHang hoadon = new BanHang.HoaDonBanHang(MaHoaDon);
                                hoadon.ShowDialog();

                            }
                        MaHoaDon = 0;
                        ResetBanHang();
                    }
                }
                else
                {
                    MessageBox.Show("Bạn chưa chọn hóa đơn");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 8
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)
            {

            }
        }
Esempio n. 9
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)
            {

            }
        }
Esempio n. 10
0
 //Tinh toan so luong mon an
 public void LoadSoLuongSanPham()
 {
     BanHang.Model.Update update = new BanHang.Model.Update();
     update.UpdateSoLuongMonAn();
 }
Esempio n. 11
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)
            {

            }
        }
Esempio n. 12
0
 public int LayHangTrongKho(int MaMonAn, float SoLuong)
 {
     BanHang.Model.Update update = new BanHang.Model.Update();
     return update.LayHangTrongKho(MaMonAn, SoLuong);
 }
Esempio n. 13
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();
        }
Esempio n. 14
0
 private void buttonX1_Click(object sender, EventArgs e)
 {
     BanHang.Model.Update update = new Model.Update();
     update.UpdateKhuVuc(Convert.ToInt32( comboTree1.SelectedValue.ToString()), textBoxX1.Text);
     this.Close();
 }