コード例 #1
0
        private void RefreshThongTinMaDonVi(string maDonVi)
        {
            _flag2             = false;
            txtMaSoThue.Text   = string.Empty;
            txtAddress.Text    = string.Empty;
            txtSoTaiKhoan.Text = string.Empty;
            cboTenDonVi.Text   = string.Empty;

            if (cboMaDonVi.Text.Trim() != string.Empty)
            {
                Result result = ThongTinKhachHangBus.GetThongTinMaDonVi(maDonVi);
                if (result.IsOK)
                {
                    ThongTinKhachHang ttkh = result.QueryResult as ThongTinKhachHang;
                    if (ttkh == null)
                    {
                        _flag2 = true;
                        return;
                    }

                    cboTenDonVi.Text   = ttkh.TenDonVi;
                    txtMaSoThue.Text   = ttkh.MaSoThue;
                    txtAddress.Text    = ttkh.DiaChi;
                    txtSoTaiKhoan.Text = ttkh.SoTaiKhoan;
                    cboHinhThucThanhToan.SelectedIndex = ttkh.HinhThucThanhToan.Value;
                }
                else
                {
                    MsgBox.Show(this.Text, result.GetErrorAsString("ThongTinKhachHangBus.GetThongTinMaDonVi"), IconType.Error);
                    Utility.WriteToTraceLog(result.GetErrorAsString("ThongTinKhachHangBus.GetThongTinMaDonVi"));
                }
            }
            _flag2 = true;
        }
コード例 #2
0
        private void XoaTenKhachHang()
        {
            if (cboTenNguoiMuaHang.Text.Trim() == string.Empty)
            {
                return;
            }

            if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa tên người mua hàng ?") == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            string thongTinKhachHangGUID = string.Empty;

            if (cboTenNguoiMuaHang.SelectedValue != null)
            {
                thongTinKhachHangGUID = cboTenNguoiMuaHang.SelectedValue.ToString();
            }
            Result result = ThongTinKhachHangBus.DeleteTenKhachHang(thongTinKhachHangGUID);

            if (!result.IsOK)
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ThongTinKhachHangBus.DeleteTenKhachHang"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ThongTinKhachHangBus.DeleteTenKhachHang"));
                return;
            }

            _flag2 = false;
            DataTable dt = cboTenNguoiMuaHang.DataSource as DataTable;

            DataRow[] rows = dt.Select(string.Format("ThongTinKhachHangGUID='{0}'", thongTinKhachHangGUID));
            if (rows != null && rows.Length > 0)
            {
                dt.Rows.Remove(rows[0]);
            }
            //foreach (var item in cboTenNguoiMuaHang.Items)
            //{
            //    if (item.ToString() == tenKhachHang)
            //    {
            //        cboTenNguoiMuaHang.Items.Remove(item);
            //        break;
            //    }
            //}

            cboTenNguoiMuaHang.Text = string.Empty;

            _flag2 = true;
        }
コード例 #3
0
        private void DisplayThongTinKhachHang()
        {
            _flag2 = false;
            Result result = ThongTinKhachHangBus.GetThongTinKhachHangList();

            if (result.IsOK)
            {
                DataTable dt = result.QueryResult as DataTable;
                cboTenNguoiMuaHang.DisplayMember = "TenKhachHang";
                cboTenNguoiMuaHang.ValueMember   = "ThongTinKhachHangGUID";
                cboTenNguoiMuaHang.DataSource    = dt;
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ThongTinKhachHangBus.GetThongTinKhachHangList"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ThongTinKhachHangBus.GetThongTinKhachHangList"));
            }
            _flag2 = true;
        }
コード例 #4
0
        private void XoaTenDonVi()
        {
            if (cboTenDonVi.Text.Trim() == string.Empty)
            {
                return;
            }

            if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa tên đơn vị ?") == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            string tenDonVi = cboTenDonVi.Text;
            Result result   = ThongTinKhachHangBus.DeleteTenDonVi(tenDonVi);

            if (!result.IsOK)
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ThongTinKhachHangBus.DeleteTenDonVi"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ThongTinKhachHangBus.DeleteTenDonVi"));
                return;
            }

            _flag2 = false;
            foreach (var item in cboTenDonVi.Items)
            {
                if (item.ToString() == tenDonVi)
                {
                    cboTenDonVi.Items.Remove(item);
                    break;
                }
            }

            cboTenDonVi.Text = string.Empty;

            _flag2 = true;
        }
コード例 #5
0
        private bool ExportInvoice()
        {
            try
            {
                if (!CheckInfo())
                {
                    return(false);
                }

                HoaDonXetNghiem invoice = new HoaDonXetNghiem();
                invoice.SoHoaDon          = _invoiceCode;
                invoice.NgayXuatHoaDon    = dtpkNgay.Value;
                invoice.TenNguoiMuaHang   = cboTenNguoiMuaHang.Text;
                invoice.DiaChi            = txtAddress.Text;
                invoice.TenDonVi          = cboTenDonVi.Text;
                invoice.MaDonVi           = cboMaDonVi.Text;
                invoice.MaSoThue          = txtMaSoThue.Text;
                invoice.SoTaiKhoan        = txtSoTaiKhoan.Text;
                invoice.HinhThucThanhToan = (byte)cboHinhThucThanhToan.SelectedIndex;
                invoice.VAT                = (double)numVAT.Value;
                invoice.CreatedDate        = DateTime.Now;
                invoice.CreatedBy          = Guid.Parse(Global.UserGUID);
                invoice.Status             = (byte)Status.Actived;
                invoice.ChuaThuTien        = !chkDaThuTien.Checked;
                invoice.MauSo              = Global.MauSoXetNghiemSauCung;
                invoice.KiHieu             = Global.KiHieuXetNghiemSauCung;
                invoice.HinhThucNhanHoaDon = raKhachTuLay.Checked ? "Khách tự lấy" : "Gởi qua bưu điện";
                invoice.Notes              = txtGhiChu.Text;

                List <ChiTietHoaDonXetNghiem> addedDetails = new List <ChiTietHoaDonXetNghiem>();
                for (int i = 0; i < dgDetail.RowCount - 1; i++)
                {
                    DataGridViewRow        row    = dgDetail.Rows[i];
                    ChiTietHoaDonXetNghiem detail = new ChiTietHoaDonXetNghiem();
                    detail.CreatedDate = DateTime.Now;
                    detail.CreatedBy   = Guid.Parse(Global.UserGUID);
                    detail.TenHangHoa  = row.Cells["TenHangHoa"].Value.ToString();

                    //if (row.Cells["DonViTinh"].Value != null)
                    //    detail.DonViTinh = row.Cells["DonViTinh"].Value.ToString();
                    //else
                    detail.DonViTinh = "Lần";

                    int soLuong = 1;
                    //if (row.Cells["SoLuong"].Value != null && row.Cells["SoLuong"].Value != DBNull.Value)
                    //    soLuong = Convert.ToInt32(row.Cells["SoLuong"].Value);
                    detail.SoLuong = soLuong;

                    //int donGia = 0;
                    //if (row.Cells["DonGia"].Value != null && row.Cells["DonGia"].Value != DBNull.Value)
                    //    donGia = Convert.ToInt32(row.Cells["DonGia"].Value);

                    //detail.DonGia = donGia;

                    int thanhTien = 0;
                    if (row.Cells["ThanhTien"].Value != null && row.Cells["ThanhTien"].Value != DBNull.Value)
                    {
                        thanhTien = Convert.ToInt32(row.Cells["ThanhTien"].Value);
                    }

                    detail.ThanhTien = thanhTien;
                    detail.DonGia    = thanhTien;

                    addedDetails.Add(detail);
                }

                Result result = HoaDonXetNghiemBus.InsertHoaDonXetNghiem(invoice, addedDetails);
                if (result.IsOK)
                {
                    //Insert thông tin khách hàng
                    ThongTinKhachHang thongTinKhachHang = new ThongTinKhachHang();
                    thongTinKhachHang.TenKhachHang = invoice.TenNguoiMuaHang;
                    //thongTinKhachHang.TenDonVi = invoice.TenDonVi;
                    thongTinKhachHang.MaDonVi = invoice.MaDonVi;
                    //thongTinKhachHang.MaSoThue = invoice.MaSoThue;
                    //thongTinKhachHang.DiaChi = invoice.DiaChi;
                    thongTinKhachHang.SoTaiKhoan        = invoice.SoTaiKhoan;
                    thongTinKhachHang.HinhThucThanhToan = invoice.HinhThucThanhToan;
                    result = ThongTinKhachHangBus.InsertThongTinKhachHang(thongTinKhachHang);
                    if (!result.IsOK)
                    {
                        MsgBox.Show(Application.ProductName, result.GetErrorAsString("ThongTinKhachHangBus.InsertThongTinKhachHang"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("ThongTinKhachHangBus.InsertThongTinKhachHang"));
                    }

                    _hoaDonXetNghiem = invoice;
                    if (!_isPrinted)
                    {
                        return(true);
                    }
                    OnPrint(invoice.HoaDonXetNghiemGUID.ToString());
                    return(true);
                }
                else
                {
                    MsgBox.Show(Application.ProductName, result.GetErrorAsString("HoaDonXetNghiemBus.InsertHoaDonXetNghiem"), IconType.Error);
                    Utility.WriteToTraceLog(result.GetErrorAsString("HoaDonXetNghiemBus.InsertHoaDonXetNghiem"));
                }
            }
            catch (Exception ex)
            {
                MsgBox.Show(Application.ProductName, ex.Message, IconType.Error);
                Utility.WriteToTraceLog(ex.Message);
            }

            return(false);
        }