Beispiel #1
0
        private void THANHTOAN_HOADON_BANLE_TRALAI()
        {
            bool   success          = false;
            string TONGTIEN_BANGCHU = ConvertSoThanhChu.ChuyenDoiSoThanhChu(_NVGDQUAY_ASYNCCLIENT_DTO_GLOBAL.THANHTIEN);

            try
            {
                LUU_DULIEU(_NVGDQUAY_ASYNCCLIENT_DTO_GLOBAL);
            }
            catch
            {
                MessageBox.Show("CẢNH BÁO ! XẢY RA LỖI KHI LƯU HÓA ĐƠN NÀY, HÃY LƯU LẠI HÓA ĐƠN ĐỂ KIỂM TRA ! XIN CẢM ƠN ");
            }
            try
            {
                string MA_TEN_KHACHHANG = "";
                if (Config.CheckConnectToServer())
                {
                    MA_TEN_KHACHHANG = FrmThanhToanService.LAY_MA_TEN_KHACHHANG_FROM_ORACLE(_NVGDQUAY_ASYNCCLIENT_BILL_GLOBAL.MAKHACHHANG);
                }
                else
                {
                    MA_TEN_KHACHHANG = FrmThanhToanService.LAY_MA_TEN_KHACHHANG_FROM_SQLSERVER(_NVGDQUAY_ASYNCCLIENT_BILL_GLOBAL.MAKHACHHANG);
                }
                using (frmPrintBill_TraLai frmBanTraLai = new frmPrintBill_TraLai())
                {
                    try
                    {
                        BILL_DTO infoBill = new BILL_DTO()
                        {
                            ADDRESS      = Session.Session.CurrentAddress,
                            CONLAI       = _NVGDQUAY_ASYNCCLIENT_BILL_GLOBAL.TIEN_TRALAI_KHACH,
                            PHONE        = Session.Session.CurrentPhone,
                            MAKH         = MA_TEN_KHACHHANG,
                            DIEM         = _NVGDQUAY_ASYNCCLIENT_BILL_GLOBAL.SODIEM,
                            INFOTHUNGAN  = "THU NGÂN: " + Session.Session.CurrentTenNhanVien,
                            MA_GIAODICH  = _NVGDQUAY_ASYNCCLIENT_BILL_GLOBAL.MA_GIAODICH,
                            THANHTIENCHU = TONGTIEN_BANGCHU,
                            TIENKHACHTRA = _NVGDQUAY_ASYNCCLIENT_BILL_GLOBAL.TIENKHACH_TRA,
                            TENCUAHANG   = Session.Session.CurrentNameStore
                        };
                        frmBanTraLai.PrintInvoice_BanLeTraLai(infoBill, _NVGDQUAY_ASYNCCLIENT_BILL_GLOBAL);
                    }
                    catch
                    {
                    }
                    finally
                    {
                        this.handler(true);
                        this.Dispose();
                        frmBanTraLai.Dispose();
                        frmBanTraLai.Refresh();
                    }
                }
            }
            catch (Exception ex)
            {
                WriteLogs.LogError(ex);
            }
        }
 private void txtThanhToan_TienMat_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode != Keys.Enter)
     {
         if (!txtThanhToan_TienMat.Text.Equals(txtThanhToan_TienThanhToan.Text))
         {
             decimal THANHTOAN_TIENTHE        = 0;
             string  THANHTOAN_TIENMAT_STRING = txtThanhToan_TienMat.Text;
             int     start = txtThanhToan_TienMat.Text.Length - txtThanhToan_TienMat.SelectionStart;
             THANHTOAN_TIENMAT_STRING = THANHTOAN_TIENMAT_STRING.Replace(",", "");
             decimal THANHTOAN_TIENMAT = 0;
             decimal.TryParse(THANHTOAN_TIENMAT_STRING, out THANHTOAN_TIENMAT);
             TONGTIEN_KHACHTRA = THANHTOAN_TIENMAT;
             decimal THANHTOAN_TONGTIEN = 0;
             decimal.TryParse(txtThanhToan_TienThanhToan.Text.Trim().Replace(",", ""), out THANHTOAN_TONGTIEN);
             _NVGDQUAY_ASYNCCLIENT_DTO_GLOBAL.TIENMAT      = THANHTOAN_TIENMAT;
             _NVGDQUAY_ASYNCCLIENT_DTO_GLOBAL.TIENKHACHDUA = THANHTOAN_TIENMAT;
             decimal THANHTOAN_TIENTRALAI = THANHTOAN_TIENTHE + THANHTOAN_TIENMAT - THANHTOAN_TONGTIEN;
             txtThanhToan_TienMat.Text           = FormatCurrency.FormatMoney(THANHTOAN_TIENMAT_STRING);
             txtThanhToan_TienMat.SelectionStart = -start + txtThanhToan_TienMat.Text.Length;
             if (THANHTOAN_TIENTRALAI > 0)
             {
                 txtThanhToan_TienTraLai.Text     = FormatCurrency.FormatMoney(THANHTOAN_TIENTRALAI);
                 txtThanhToan_TraLai_BangChu.Text = ConvertSoThanhChu.ChuyenDoiSoThanhChu(THANHTOAN_TIENTRALAI);
             }
             else
             {
                 txtThanhToan_TienTraLai.Text = "-" + FormatCurrency.FormatMoney(THANHTOAN_TIENTRALAI);
             }
             _NVGDQUAY_ASYNCCLIENT_DTO_GLOBAL.TIENTRALAI = THANHTOAN_TIENTRALAI;
         }
         else
         {
             return;
         }
     }
     else
     {
         decimal tienThanhToan = 0;
         decimal.TryParse(txtThanhToan_TienTraLai.Text, out tienThanhToan);
         if (tienThanhToan >= 0)
         {
             THANHTOAN_HOADON_BANLE_TRALAI();
         }
         else
         {
             NotificationLauncher.ShowNotificationError("THÔNG BÁO", "SỐ TIỀN SAI !", 1, "0x1", "0x8", "normal");
         }
     }
 }
 private void txtThanhToan_TienMat_Validating(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (txtThanhToan_TienMat.Text.Trim().Length > 0)
     {
         decimal TIENMAT_KHACHTRA, TONGTIEN_HOADON, TIEN_TRALAI = 0;
         decimal.TryParse(txtThanhToan_TienMat.Text.Trim(), out TIENMAT_KHACHTRA);
         decimal.TryParse(txtThanhToan_TienThanhToan.Text.Trim(), out TONGTIEN_HOADON);
         TIEN_TRALAI = TIENMAT_KHACHTRA - TONGTIEN_HOADON;
         if (TIEN_TRALAI >= 0 && TIEN_TRALAI < 1000000)
         {
             txtThanhToan_TienTraLai.Text     = FormatCurrency.FormatMoney(TIEN_TRALAI);
             txtThanhToan_TraLai_BangChu.Text = ConvertSoThanhChu.ChuyenDoiSoThanhChu(TIEN_TRALAI);
             btnThanhToan_Save.Focus();
             _NVGDQUAY_ASYNCCLIENT_DTO_GLOBAL.TIENMAT      = TIENMAT_KHACHTRA;
             _NVGDQUAY_ASYNCCLIENT_DTO_GLOBAL.TIENTRALAI   = TIEN_TRALAI;
             _NVGDQUAY_ASYNCCLIENT_DTO_GLOBAL.TIENKHACHDUA = TIENMAT_KHACHTRA;
         }
         else if (TIEN_TRALAI < 0)
         {
             txtThanhToan_TienMat.SelectAll();
         }
         else
         {
             DialogResult result = MessageBox.Show("SỐ TIỀN TRẢ LẠI QUÁ LỚN ?", "THAO TÁC SAI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             if (result == DialogResult.OK)
             {
                 TIEN_TRALAI = TIEN_TRALAI / 10;
                 txtThanhToan_TienTraLai.Text                  = FormatCurrency.FormatMoney(TIEN_TRALAI);
                 txtThanhToan_TraLai_BangChu.Text              = ConvertSoThanhChu.ChuyenDoiSoThanhChu(TIEN_TRALAI);
                 _NVGDQUAY_ASYNCCLIENT_DTO_GLOBAL.TIENMAT      = TIENMAT_KHACHTRA;
                 _NVGDQUAY_ASYNCCLIENT_DTO_GLOBAL.TIENTRALAI   = TIEN_TRALAI;
                 _NVGDQUAY_ASYNCCLIENT_DTO_GLOBAL.TIENKHACHDUA = TIENMAT_KHACHTRA;
             }
         }
     }
 }
        private void THANHTOAN_HOADON_BANLE_TRALAI()
        {
            string TONGTIEN_BANGCHU = ConvertSoThanhChu.ChuyenDoiSoThanhChu(_NVGDQUAY_ASYNCCLIENT_DTO_GLOBAL.TTIENCOVAT);

            try
            {
                LUU_DULIEU(_NVGDQUAY_ASYNCCLIENT_DTO_GLOBAL);
            }
            catch
            {
                MessageBox.Show("CẢNH BÁO ! XẢY RA LỖI KHI LƯU HÓA ĐƠN NÀY, HÃY LƯU LẠI HÓA ĐƠN ĐỂ KIỂM TRA ! XIN CẢM ƠN ");
            }
            try
            {
                string MA_TEN_KHACHHANG = "";

                string msg = Config.CheckConnectToServer(out bool result);
                if (msg.Length > 0)
                {
                    MessageBox.Show(msg); return;
                }

                if (result)
                {
                    MA_TEN_KHACHHANG = FrmThanhToanService.LAY_MA_TEN_KHACHHANG_FROM_ORACLE(_NVGDQUAY_ASYNCCLIENT_BILL_GLOBAL.MAKHACHHANG);
                }
                else
                {
                    MA_TEN_KHACHHANG = FrmThanhToanService.LAY_MA_TEN_KHACHHANG_FROM_SQLSERVER(_NVGDQUAY_ASYNCCLIENT_BILL_GLOBAL.MAKHACHHANG);
                }

                using (frmPrintBill_TraLai frmBanTraLai = new frmPrintBill_TraLai())
                {
                    try
                    {
                        BILL_DTO infoBill = new BILL_DTO()
                        {
                            ADDRESS      = Session.Session.CurrentAddress,
                            CONLAI       = _NVGDQUAY_ASYNCCLIENT_BILL_GLOBAL.TIENTRALAI,
                            PHONE        = Session.Session.CurrentPhone,
                            MAKH         = MA_TEN_KHACHHANG,
                            DIEM         = 0,
                            INFOTHUNGAN  = "THU NGÂN: " + _NVGDQUAY_ASYNCCLIENT_BILL_GLOBAL.NGUOITAO + "\t QUẦY: " + _NVGDQUAY_ASYNCCLIENT_BILL_GLOBAL.MAQUAYBAN,
                            MAGIAODICH   = _NVGDQUAY_ASYNCCLIENT_BILL_GLOBAL.MAGIAODICH,
                            THANHTIENCHU = TONGTIEN_BANGCHU,
                            TIENKHACHTRA = _NVGDQUAY_ASYNCCLIENT_BILL_GLOBAL.TIENKHACHDUA,
                            QUAYHANG     = _NVGDQUAY_ASYNCCLIENT_BILL_GLOBAL.MAQUAYBAN,
                        };
                        frmBanTraLai.PrintInvoice_BanLeTraLai(infoBill, _NVGDQUAY_ASYNCCLIENT_BILL_GLOBAL);
                    }
                    catch
                    {
                    }
                    finally
                    {
                        this.handler(true);
                        this.Dispose();
                        frmBanTraLai.Dispose();
                        frmBanTraLai.Refresh();
                    }
                }
            }
            catch (Exception ex)
            {
                WriteLogs.LogError(ex);
            }
        }