使用 ++ 操作递增值时,进度条超过最大值。在下面的代码中,我有一个大小为 6004 的记录集,当它绕过循环时,它设法达到 6006,即使我已经放置了一个 if 语句来捕获它,当它达到 value++ 以将进度条重置为零时隐藏面板。
invoiceRecord = (SageDataObject240.InvoiceRecord)_workSpace.CreateObject(Resources.InvoiceRecord);
pnlProgress.Visible = true;
progBarSelectInvoices.Value = 0;
progBarSelectInvoices.Maximum = invoiceRecord.Count;
List<EdiInvoice> selectedInvoices = new List<EdiInvoice>();
EdiInvoice invoice;
DateTime fromDate = chkEnableFromDatePicker.Checked ? dtpFrom.Value.Date : DateTime.MinValue;
DateTime toDate = chkEnableToDatePicker.Checked ? dtpTo.Value.Date : DateTime.MaxValue;
int invoiceCount = 0;
int progressCount = 0;
int progresbarValue = 0;
int maxCount = invoiceRecord.Count + 1;
while (invoiceRecord.MoveLast())
{
progresbarValue = progBarSelectInvoices.Value++;
bool isPosted = (SDOHelper.Read<sbyte>(invoiceRecord, Resources.POSTED_CODE) == 1);
if (isPosted)
{
int invoiceNo = SDOHelper.Read<int>(invoiceRecord, Resources.INVOICE_NUMBER);
string invoiceCustomerReference = SDOHelper.Read<string>(invoiceRecord, Resources.ACCOUNT_REF);
bool isValidCustomerReference = (invoiceCustomerReference == _selectedCustomer.Reference || _selectedCustomer.IncludeBranchInvoices && _selectedCustomer.BranchCodes.ContainsKey(invoiceCustomerReference));
sbyte invoiceTypeCode = SDOHelper.Read<sbyte>(invoiceRecord, Resources.INVOICE_TYPE_CODE);
bool isValidType = invoiceTypeCode >= 0 && invoiceTypeCode <= 5;
string notes1 = SDOHelper.Read<string>(invoiceRecord, "NOTES_1");
bool isExported = notes1.Length > 2 && notes1.Substring(0, 3).Equals("EDI", StringComparison.CurrentCultureIgnoreCase);
DateTime invoiceDate = SDOHelper.Read<DateTime>(invoiceRecord, "INVOICE_DATE");
bool isInDateRange = invoiceDate >= fromDate && invoiceDate <= toDate;
噜噜哒
相关分类