private void dlgLamMoiSoHoaDon_Load(object sender, EventArgs e)
        {
            Result result = QuanLySoHoaDonXetNghiemBus.GetThayDoiSoHoaSonSauCung();

            if (result.IsOK)
            {
                if (result.QueryResult != null)
                {
                    NgayBatDauLamMoiSoHoaDonXetNghiemYKhoa thayDoiSauCung = result.QueryResult as NgayBatDauLamMoiSoHoaDonXetNghiemYKhoa;
                    dtpkNgayThayDoiSauCung.Value = thayDoiSauCung.NgayBatDau;
                    txtMauSoCu.Text      = thayDoiSauCung.MauSo;
                    txtKiHieuCu.Text     = thayDoiSauCung.KiHieu;
                    txtSoHDBatDauCu.Text = thayDoiSauCung.SoHoaDonBatDau.ToString();
                }
                else
                {
                    dtpkNgayThayDoiSauCung.Value = Global.MinDateTime;
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("QuanLySoHoaDonXetNghiemBus.GetThayDoiSoHoaSonSauCung"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("QuanLySoHoaDonXetNghiemBus.GetThayDoiSoHoaSonSauCung"));
            }

            dtpkNgayThayDoiMoi.Value = DateTime.Now;
        }
Example #2
0
        private void SetMinMaxNgayXuatHoaDon(int soHoaDon)
        {
            DateTime minDate = DateTime.Now;
            DateTime maxDate = DateTime.Now;
            Result   result  = QuanLySoHoaDonXetNghiemBus.GetMinMaxNgayXuatHoaDon(soHoaDon, ref minDate, ref maxDate);

            if (result.IsOK)
            {
                if (dtpkNgay.Value < minDate)
                {
                    dtpkNgay.Value = minDate;
                }
                if (dtpkNgay.Value > maxDate)
                {
                    dtpkNgay.Value = maxDate;
                }

                dtpkNgay.MinDate = minDate;
                dtpkNgay.MaxDate = maxDate;
            }
        }
Example #3
0
        private void GenerateCode()
        {
            Cursor.Current = Cursors.WaitCursor;
            Result result = QuanLySoHoaDonXetNghiemBus.GetSoHoaDon();

            if (result.IsOK)
            {
                int count = Convert.ToInt32(result.QueryResult);
                _invoiceCode       = Utility.GetCode(string.Empty, count, 7);
                lbInvoiceCode.Text = string.Format("Số: {0}", _invoiceCode);

                SetMinMaxNgayXuatHoaDon(count);
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("QuanLySoHoaDonXetNghiemBus.GetSoHoaDon"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("QuanLySoHoaDonXetNghiemBus.GetSoHoaDon"));
                this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                this.Close();
            }
        }
 private void dlgLamMoiSoHoaDon_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (this.DialogResult == System.Windows.Forms.DialogResult.OK)
     {
         if (MsgBox.Question(this.Text, "Bạn có thật sự muốn thay đổi số hóa đơn ?") == System.Windows.Forms.DialogResult.Yes)
         {
             if (dtpkNgayThayDoiSauCung.Value.ToString("dd/MM/yyyy") != dtpkNgayThayDoiMoi.Value.ToString("dd/MM/yyyy"))
             {
                 if (CheckInfo())
                 {
                     Result result = QuanLySoHoaDonXetNghiemBus.SetThayDoiSoHoaSon(dtpkNgayThayDoiMoi.Value, txtMauSoMoi.Text,
                                                                                   txtKiHieuMoi.Text, (int)numSoHDBatDauMoi.Value);
                     if (!result.IsOK)
                     {
                         MsgBox.Show(Application.ProductName, result.GetErrorAsString("QuanLySoHoaDonXetNghiemBus.SetThayDoiSoHoaSon"), IconType.Error);
                         Utility.WriteToTraceLog(result.GetErrorAsString("QuanLySoHoaDonXetNghiemBus.SetThayDoiSoHoaSon"));
                         e.Cancel = true;
                     }
                     else
                     {
                         Global.MauSoXetNghiemSauCung  = txtMauSoMoi.Text;
                         Global.KiHieuXetNghiemSauCung = txtKiHieuMoi.Text;
                         Global.NgayThayDoiSoHoaDonXetNghiemSauCung = dtpkNgayThayDoiMoi.Value;
                         Global.SoHoaDonXetNghiemBatDau             = (int)numSoHDBatDauMoi.Value;
                     }
                 }
                 else
                 {
                     e.Cancel = true;
                 }
             }
         }
         else
         {
             e.Cancel = true;
         }
     }
 }