Exemplo n.º 1
0
 private void buttonX1_Click(object sender, EventArgs e)
 {
     if (textBoxX1.Text != "")
     {
         BanHang.Model.Insert insert = new Model.Insert();
         insert.InsertBanAn(textBoxX1.Text, MaKhuVuc);
         this.Close();
     }
 }
Exemplo n.º 2
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());
            }
        }
Exemplo n.º 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)
            {

            }
        }
Exemplo n.º 4
0
        private void listViewExKhuVuc_DoubleClick(object sender, EventArgs e)
        {
            DataTable dtHoaDonChuaThanhToan = loadHoaDon();
            int check = 0;
            if (dtHoaDonChuaThanhToan.Rows.Count > 0)
            {
                for (int k = 0; k < dtHoaDonChuaThanhToan.Rows.Count; k++)
                {
                    if (dtHoaDonChuaThanhToan.Rows[k][2].ToString() == listViewExKhuVuc.SelectedItems[0].Name.ToString())
                    {
                        check = 1;
                    }

                }
                if (check == 0)
                {
                    listViewExKhuVuc.SelectedItems[0].ImageIndex = 3;
                    int MaBan = Convert.ToInt32(listViewExKhuVuc.SelectedItems[0].Name.ToString());
                    string TenBan = listViewExKhuVuc.SelectedItems[0].Text.ToString();
                    //Tao Hoa Don
                    BanHang.Model.Insert insert = new BanHang.Model.Insert();
                    insert.InsertHoaDon(MaBan,TenBan);
                    LoadHoaDonChuaThanhToanDangChon();
                }
            }
            else
            {

                listViewExKhuVuc.SelectedItems[0].ImageIndex = 3;
                int MaBan = Convert.ToInt32(listViewExKhuVuc.SelectedItems[0].Name.ToString());
                //Tao Hoa Don
                BanHang.Model.Insert insert = new BanHang.Model.Insert();
                string TenBan = listViewExKhuVuc.SelectedItems[0].Text.ToString();
                insert.InsertHoaDon(MaBan,TenBan);
                LoadHoaDonChuaThanhToanDangChon();

            }
            labelXID.Text = "";
            textBoxXKhachHang.Text = "";
            textBoxXSDT.Text = "";
            richTextBoxExDiaChi.Text = "";
            checkBoxX1.Checked = false;
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
0
 private void buttonX1_Click(object sender, EventArgs e)
 {
     BanHang.Model.Insert insert = new Model.Insert();
     insert.InsertKhuVuc(textBoxX1.Text);
     this.Close();
 }