private void btnNewAudit_Click(object sender, EventArgs e) { List <InventoryAuditVO> audits = new List <InventoryAuditVO>(); CommonDatabaseContext dataContext = CreateCommonDatabaseContext(); if (!InventoryAuditProcedures.GetInventoryAudits(audits, null, "ACTIVE", dataContext)) { MessageBox.Show("Error loading active audits."); return; } if (audits.Any(a => a.StoreNumber == ADS.LoggedInUserSecurityProfile.StoreNumber)) { MessageBox.Show("There is already an active audit for this store. Complete the existing audit and try again."); return; } ADS.ActiveAudit = new InventoryAuditVO(); ADS.ActiveAudit.StoreNumber = ADS.LoggedInUserSecurityProfile.StoreNumber; ADS.ActiveAudit.InitiatedBy = ADS.ActiveUserData.CurrentUserFullName; NavControlBox.IsCustom = true; NavControlBox.CustomDetail = "INITIATEAUDIT"; NavControlBox.Action = NavBox.NavAction.SUBMIT; }
private void btnContinue_Click(object sender, EventArgs e) { SiteId store = ddlStore.SelectedItem as SiteId; if (store == null) { return; } List <InventoryAuditVO> audits = new List <InventoryAuditVO>(); CommonDatabaseContext dataContext = CreateCommonDatabaseContext(); if (!InventoryAuditProcedures.GetInventoryAudits(audits, null, "ACTIVE", dataContext)) { MessageBox.Show("Error loading active audits."); return; } if (audits.Any(a => a.StoreNumber == store.StoreNumber)) { MessageBox.Show("There is already an active audit for this store. Complete the existing audit and try again."); return; } ADS.ActiveAudit = new InventoryAuditVO(); ADS.ActiveAudit.StoreNumber = store.StoreNumber; ADS.ActiveAudit.InitiatedBy = ADS.ActiveUserData.CurrentUserFullName; NavControlBox.Action = NavBox.NavAction.SUBMIT; }
private void LoadAudits() { List <InventoryAuditVO> audits = new List <InventoryAuditVO>(); CommonDatabaseContext dataContext = CreateCommonDatabaseContext(); bool retVal = false; gvAudits.Rows.Clear(); if (IsAuditStatusClosed()) { retVal = InventoryAuditProcedures.GetInventoryAudits(audits, ddlShopNumber.Text, null, dataContext); //Closed } else { retVal = InventoryAuditProcedures.GetInventoryAudits(audits, null, "ACTIVE", dataContext); } if (!retVal) { MessageBox.Show(dataContext.ErrorText); return; } List <InventoryAuditVO> sortedAudits = new List <InventoryAuditVO>(); foreach (var audit in audits.FindAll(a => a.StoreNumber == ADS.CurrentSiteId.StoreNumber).OrderBy(ao => ao.DateInitiated).ToList()) { sortedAudits.Add(audit); } foreach (var audit in audits.FindAll(a => a.StateCode == ADS.CurrentSiteId.State && !sortedAudits.Any(sa => sa.AuditId == a.AuditId)).OrderBy(ao => ao.StoreNumber).ThenBy(at => at.DateInitiated).ToList()) { sortedAudits.Add(audit); } foreach (var audit in audits.FindAll(a => !sortedAudits.Any(sa => sa.AuditId == a.AuditId)).OrderBy(ao => ao.StoreNumber).ThenBy(at => at.DateInitiated).ToList()) { sortedAudits.Add(audit); } foreach (InventoryAuditVO audit in sortedAudits) { DataGridViewRow row = gvAudits.Rows.AddNew(); row.Cells[colAuditNumber.Index].Value = audit.AuditId; row.Cells[colAuditType.Index].Value = audit.AuditType.ToString(); row.Cells[colShopNumber.Index].Value = audit.StoreNumber; row.Cells[colDateInitiated.Index].Value = audit.DateInitiated; row.Cells[colLastUpdated.Index].Value = audit.LastUpdated; row.Cells[colInitiatedBy.Index].Value = audit.InitiatedBy; row.Tag = audit; } }