Exemple #1
0
        private void btnUpdateBillExport_Click(object sender, EventArgs e)
        {
            if (txtIDBillExport.Text == "")
            {
                MessageBox.Show("Bạn phải chọn Hóa đơn cần chỉnh sửa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClearDisplay();
                return;
            }
            HoaDonBanHang_DTO phieunhap = new HoaDonBanHang_DTO();

            phieunhap.MaHDB = (string)dtgvInfoListOfBillExport.CurrentRow.Cells["MaHDB"].Value;
            phieunhap.MaKH  = txtIDCustomer.Text.ToString();
            phieunhap.TenKH = txtNameCustomer.Text.ToString();

            phieunhap.NgayNhap = Convert.ToDateTime(dtpkDateTimeExport.Text.ToString());
            phieunhap.TenCH    = txtNameStore.Text;
            phieunhap.TongTien = Convert.ToDouble(txtTotalPayExport.Text.ToString());
            phieunhap.TongNo   = Convert.ToDouble(txtTotalDebtExport.Text.ToString());

            if (HoaDonBanHang_BUS.SuaPHBan(phieunhap))
            {
                LoadPhieuBanHang();
                MessageBox.Show("Hóa đơn bán hàng cập nhật thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClearDisplay();
                return;
            }
            MessageBox.Show("Hóa đơn bán hàng cập nhật thất bại !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemple #2
0
        private void btnDeleteBillExport_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtIDBillExport.Text == "" || txtNameStore.Text == "" || txtTotalPayExport.Text == "" ||
                    txtTotalDebtExport.Text == "" || txtIDCustomer.Text == "")
                {
                    XtraMessageBox.Show("Bạn phải chọn Hóa đơn cần xóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    ClearDisplay();
                    return;
                }

                HoaDonBanHang_DTO phieuhang = new HoaDonBanHang_DTO();
                phieuhang.MaHDB = txtIDBillExport.Text;
                if (HoaDonBanHang_BUS.XoaPHBan(phieuhang))
                {
                    LoadPhieuBanHang();
                    LoadHoaDonBan();

                    uctKhachHang.uctKH.LoadKhachHang();
                    uctQuanLiTienNoKhachHang.uctQLTienNoKH.LoadDSKH_NoTien();
                    ClearDisplay();
                    XtraMessageBox.Show("Hóa đơn bán hàng xóa thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    return;
                }
            }
            catch
            {
                XtraMessageBox.Show("Hóa đơn bán hàng xóa thất bại !\nBạn phải xóa Chi tiết Phiếu bán hàng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Exemple #3
0
        private void btnAddBillExport_Click(object sender, EventArgs e)
        {
            if (txtIDBillExport.Text == "" || txtNameStore.Text == "" || txtTotalPayExport.Text == "" ||
                txtTotalDebtExport.Text == "" || txtIDCustomer.Text == "")
            {
                MessageBox.Show("Bạn phải điền đầy đủ thông tin !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClearDisplay();
                return;
            }

            HoaDonBanHang_DTO phieuban = new HoaDonBanHang_DTO();

            phieuban.MaHDB    = txtIDBillExport.Text;
            phieuban.MaKH     = txtIDCustomer.Text.ToString();
            phieuban.TenKH    = txtNameCustomer.Text.ToString();
            phieuban.NgayNhap = Convert.ToDateTime(dtpkDateTimeExport.Text.ToString());
            phieuban.TenCH    = txtNameStore.Text;
            phieuban.TongTien = Convert.ToDouble(txtTotalPayExport.Text.ToString());
            phieuban.TongNo   = Convert.ToDouble(txtTotalDebtExport.Text.ToString());

            if (HoaDonBanHang_BUS.ThemPHBan(phieuban))
            {
                MessageBox.Show("Thêm Hóa đơn bán hàng thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LoadPhieuBanHang();
                ClearDisplay();
                return;
            }
            MessageBox.Show("Thêm Hóa đơn bán hàng thất bại !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemple #4
0
        private void LoadHoaDonBan()
        {
            List <HoaDonBanHang_DTO> hd = HoaDonBanHang_BUS.LoadPhieuBan();

            cmbIDBillExportDetail.DataSource    = hd;
            cmbIDBillExportDetail.ValueMember   = "MaHDB";
            cmbIDBillExportDetail.DisplayMember = "MaHDB";
        }
        private void btnUpdateTotalDebt_Click(object sender, EventArgs e)
        {
            SqlConnection con  = DataProvider.KetNoi();
            SqlCommand    cmd  = new SqlCommand("CAPNHAT_TIENNOKH", con);
            SqlCommand    cmd1 = new SqlCommand("CAPNHAT_TINHTRANGKH", con);

            try
            {
                cmd.CommandType  = CommandType.StoredProcedure;
                cmd1.CommandType = CommandType.StoredProcedure;

                SqlParameter p = new SqlParameter("@MaKH", txtIDCustomer.Text);
                cmd.Parameters.Add(p);
                p = new SqlParameter("@TongNo", Convert.ToDouble(txtTotalDebtOfPay.Text));
                cmd.Parameters.Add(p);

                cmd.ExecuteNonQuery();


                SqlParameter p1 = new SqlParameter("@MaKH", txtIDCustomer.Text);
                cmd1.Parameters.Add(p1);
                cmd1.ExecuteNonQuery();

                DataProvider.DongKetNoi(con);
                XtraMessageBox.Show("Tổng nợ của khách hàng cập nhập thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                uctKhachHang.uctKH.LoadKhachHang();
                LoadDSKH_NoTien();
                LoadThongTin_ThanhToanKH(txtIDCustomer.Text.ToString());

                txtIDCustomer.Text   = dtgvListCustomer.CurrentRow.Cells["MaKH"].Value.ToString();
                txtNameCustomer.Text = dtgvListCustomer.CurrentRow.Cells["TenKH"].Value.ToString();

                // Load Data

                string[] arr = HoaDonBanHang_BUS.DS_TongNo(txtIDCustomer.Text).ToArray();
                txtTotalDebt.Text      = arr[0];
                txtPay.Text            = "";
                txtTotalDebtOfPay.Text = "";
                return;
            }
            catch
            {
                XtraMessageBox.Show("Tổng nợ của khách hàng cập nhập thất bại !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Exemple #6
0
        private void btnAddBillExport_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtIDBillExport.Text == "" || txtNameStore.Text == "" || txtTotalPayExport.Text == "" ||
                    txtTotalDebtExport.Text == "" || txtIDCustomer.Text == "")
                {
                    XtraMessageBox.Show("Bạn phải điền đầy đủ thông tin !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    return;
                }

                HoaDonBanHang_DTO phieuban = new HoaDonBanHang_DTO();
                phieuban.MaHDB    = txtIDBillExport.Text;
                phieuban.MaKH     = txtIDCustomer.Text.ToString();
                phieuban.TenKH    = txtNameCustomer.Text.ToString();
                phieuban.NgayNhap = Convert.ToDateTime(dtpkDateTimeExport.Text.ToString());
                phieuban.TenCH    = txtNameStore.Text;
                phieuban.TongTien = Convert.ToDouble(txtTotalPayExport.Text.ToString());
                phieuban.TongNo   = Convert.ToDouble(txtTotalDebtExport.Text.ToString());
                phieuban.GhiChu   = txtNote.Text;

                if (HoaDonBanHang_BUS.ThemPHBan(phieuban))
                {
                    uctKhachHang.uctKH.LoadKhachHang();
                    LoadPhieuBanHang();
                    LoadHoaDonBan();
                    cmbIDBillExportDetail.Text = txtIDBillExport.Text;
                    uctQuanLiTienNoKhachHang.uctQLTienNoKH.LoadDSKH_NoTien();
                    ClearDisplay();

                    XtraMessageBox.Show("Thêm Hóa đơn bán hàng thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    return;
                }
            }catch
            {
                XtraMessageBox.Show("Thêm Hóa đơn bán hàng thất bại !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Exemple #7
0
        private void btnDeleteBillExport_Click(object sender, EventArgs e)
        {
            if (txtIDBillExport.Text == "")
            {
                MessageBox.Show("Bạn phải chọn Hóa đơn cần xóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClearDisplay();
                return;
            }

            HoaDonBanHang_DTO phieuhang = new HoaDonBanHang_DTO();

            phieuhang.MaHDB = (string)dtgvInfoListOfBillExport.CurrentRow.Cells["MaHDB"].Value;
            if (HoaDonBanHang_BUS.XoaPHBan(phieuhang))
            {
                LoadPhieuBanHang();
                MessageBox.Show("Hóa đơn bán hàng xóa thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClearDisplay();
                return;
            }
            MessageBox.Show("Hóa đơn bán hàng xóa thất bại !\nBạn phải xóa Chi tiết Phiếu bán hàng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void dtgvListCustomer_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            txtPay.Text = "";
            try
            {
                lbListBill.Items.Clear();
                if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
                {
                    txtIDCustomer.Text   = dtgvListCustomer.CurrentRow.Cells["MaKH"].Value.ToString();
                    txtNameCustomer.Text = dtgvListCustomer.CurrentRow.Cells["TenKH"].Value.ToString();

                    List <string> dsMaHDB = HoaDonBanHang_BUS.LoadDS_MaHDB(txtIDCustomer.Text.ToString());
                    if (dsMaHDB == null)
                    {
                        return;
                    }
                    else
                    {
                        foreach (string item in dsMaHDB)
                        {
                            lbListBill.Items.Add(item);
                        }
                    }

                    string[] arr = HoaDonBanHang_BUS.DS_TongNo(txtIDCustomer.Text).ToArray();
                    txtTotalDebt.Text = arr[0];

                    txtIDPay.Text = DataProvider.ExcuteScalar(string.Format("SELECT MaTT=dbo.fcGetMaTT()"));
                    LoadThongTin_ThanhToanKH(txtIDCustomer.Text.ToString());
                    sum = Convert.ToDouble(txtTotalDebt.Text.ToString());
                    txtTotalDebtOfPay.Text = "";
                    // UpdateTotalDebt();
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
        public void LoadDSKH_NoTien()
        {
            List <HoaDonBanHang_DTO> khachhang = HoaDonBanHang_BUS.DS_KHNoTien();

            dtgvListCustomer.DataSource = khachhang;
            if (dtgvListCustomer.Rows.Count == 0)
            {
                dtgvListCustomer.ColumnCount          = 2;
                dtgvListCustomer.ColumnHeadersVisible = true;
                dtgvListCustomer.Columns[0].Name      = "MaKH";
                dtgvListCustomer.Columns[1].Name      = "TenKH";

                dtgvListCustomer.Columns[0].DataPropertyName = "MaKH";
                dtgvListCustomer.Columns[1].DataPropertyName = "TenKH";

                dtgvListCustomer.Columns[0].HeaderText = "Mã KH";
                dtgvListCustomer.Columns[1].HeaderText = "Tên khách hàng";

                dtgvListCustomer.Columns[0].Width = 150;
                dtgvListCustomer.Columns[1].Width = 150;
            }
        }
Exemple #10
0
        private void LoadPhieuBanHang()
        {
            List <HoaDonBanHang_DTO> listPhieuBan = HoaDonBanHang_BUS.LoadPhieuBan();

            dtgvInfoListOfBillExport.DataSource = listPhieuBan;
        }