private void SetMinMaxNgayXuatHoaDon(int soHoaDon) { DateTime minDate = DateTime.Now; DateTime maxDate = DateTime.Now; Result result = QuanLySoHoaDonBus.GetMinMaxNgayXuatHoaDon(soHoaDon, _fromDate, _toDate, ref minDate, ref maxDate); if (minDate == Global.MinDateTime) { minDate = _fromDate; } if (maxDate == Global.MaxDateTime) { maxDate = _toDate; } if (result.IsOK) { if (dtpkNgay.Value < minDate) { dtpkNgay.Value = minDate; } if (dtpkNgay.Value > maxDate) { dtpkNgay.Value = maxDate; } dtpkNgay.MinDate = minDate; dtpkNgay.MaxDate = maxDate; } }
private void SetMauHoaDon() { if (cboMauHoaDon.SelectedValue == null) { return; } string mauHoaDon = cboMauHoaDon.Text; int index = mauHoaDon.IndexOf("-"); if (index >= 0) { _mauSo = mauHoaDon.Substring(0, index); _kiHieu = mauHoaDon.Substring(index + 1, mauHoaDon.Length - index - 1); Result result = QuanLySoHoaDonBus.GetThayDoiSoHoaDon(_mauSo, _kiHieu, ref _toNgayThayDoiHD); if (result.IsOK) { NgayBatDauLamMoiSoHoaDon nbdlm = result.QueryResult as NgayBatDauLamMoiSoHoaDon; _fromNgayThayDoiHD = nbdlm.NgayBatDau; } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("QuanLySoHoaDonBus.GetThayDoiSoHoaDon"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("QuanLySoHoaDonBus.GetThayDoiSoHoaDon")); } } }
private void dlgLamMoiSoHoaDon_Load(object sender, EventArgs e) { Result result = QuanLySoHoaDonBus.GetThayDoiSoHoaSonSauCung(); if (result.IsOK) { if (result.QueryResult != null) { NgayBatDauLamMoiSoHoaDon thayDoiSauCung = result.QueryResult as NgayBatDauLamMoiSoHoaDon; 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("QuanLySoHoaDonBus.GetThayDoiSoHoaSonSauCung"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("QuanLySoHoaDonBus.GetThayDoiSoHoaSonSauCung")); } dtpkNgayThayDoiMoi.Value = DateTime.Now; }
private void PhatSinhSoHoaDon() { Cursor.Current = Cursors.WaitCursor; int count = (int)numNo.Value; dgSoHoaDon.DataSource = null; Result result = QuanLySoHoaDonBus.GetSoHoaDonChuaXuat(count, _fromDate, _toDate); if (result.IsOK) { DataTable dt = result.QueryResult as DataTable; if (dt.Rows.Count < count) { result = QuanLySoHoaDonBus.GetMaxSoHoaDon(_fromDate, _toDate); if (result.IsOK) { int maxSoHoaDon = Convert.ToInt32(result.QueryResult); int delta = count - dt.Rows.Count; for (int i = 0; i < delta; i++) { maxSoHoaDon++; DataRow newRow = dt.NewRow(); newRow["SoHoaDon"] = maxSoHoaDon; dt.Rows.Add(newRow); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("QuanLySoHoaDonBus.GetMaxSoHoaDon"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("QuanLySoHoaDonBus.GetMaxSoHoaDon")); } } dgSoHoaDon.DataSource = dt; RefreshNo(); } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("QuanLySoHoaDonBus.GetSoHoaDonChuaXuat"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("QuanLySoHoaDonBus.GetSoHoaDonChuaXuat")); } }
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 = QuanLySoHoaDonBus.SetThayDoiSoHoaSon(dtpkNgayThayDoiMoi.Value, txtMauSoMoi.Text, txtKiHieuMoi.Text, (int)numSoHDBatDauMoi.Value); if (!result.IsOK) { MsgBox.Show(Application.ProductName, result.GetErrorAsString("QuanLySoHoaDonBus.SetThayDoiSoHoaSon"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("QuanLySoHoaDonBus.SetThayDoiSoHoaSon")); e.Cancel = true; } else { Global.MauSoSauCung = txtMauSoMoi.Text; Global.KiHieuSauCung = txtKiHieuMoi.Text; Global.NgayThayDoiSoHoaDonSauCung = dtpkNgayThayDoiMoi.Value; Global.SoHoaDonBatDau = (int)numSoHDBatDauMoi.Value; } } else { e.Cancel = true; } } } else { e.Cancel = true; } } }
private void DisplayComboMauHoaDon() { Result result = QuanLySoHoaDonBus.GetMauHoaDonList(); if (result.IsOK) { MethodInvoker method = delegate { _flag = true; object key = cboMauHoaDon.SelectedValue; cboMauHoaDon.DataSource = result.QueryResult as DataTable; cboMauHoaDon.DisplayMember = "MauHoaDon"; cboMauHoaDon.ValueMember = "MaNgayBatDauGUID"; if (key != null) { cboMauHoaDon.SelectedValue = key; } SetMauHoaDon(); _flag = false; }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("QuanLySoHoaDonBus.GetMauHoaDonList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("QuanLySoHoaDonBus.GetMauHoaDonList")); } }