private void btnAbort_Click(object sender, EventArgs e) { if (gvAudits.SelectedRows.Count != 1) { return; } InventoryAuditVO audit = gvAudits.SelectedRows[0].Tag as InventoryAuditVO; if (audit == null) { return; } if (MessageBox.Show("All data will be lost. Are you sure you want to abort this audit?", "Abort Audit", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } audit.Status = AuditStatus.ABORT; CommonDatabaseContext dataContext = CreateCommonDatabaseContext(); InventoryAuditProcedures.EditAudit(audit, dataContext); if (!dataContext.Result) { MessageBox.Show("Error while aborting audit."); return; } LoadAudits(); }
private void btnContinue_Click(object sender, EventArgs e) { if (Downloaded) { NavControlBox.Action = NavBox.NavAction.SUBMIT; return; } //ConfirmTrakker confirmTrakker = new ConfirmTrakker(TrakkerId); //if (confirmTrakker.ShowDialog() == DialogResult.Cancel) //{ // return; //} UploadFiles(); SetButtonStates(); if (!Downloaded) { return; } ADS.ActiveAudit.DownloadDate = ShopDateTime.Instance.FullShopDateTime; CommonDatabaseContext dataContext = CreateCommonDatabaseContext(); InventoryAuditProcedures.EditAudit(ADS.ActiveAudit, dataContext); if (!dataContext.Result) { MessageBox.Show(dataContext.ErrorText); return; } }
private void btnContinue_Click(object sender, System.EventArgs e) { if (Uploaded) { NavControlBox.Action = NavBox.NavAction.SUBMIT; return; } DownloadFiles(); SetButtonStates(); if (!Uploaded) { return; } ADS.ActiveAudit.UploadDate = ShopDateTime.Instance.FullShopDateTime; CommonDatabaseContext dataContext = CreateCommonDatabaseContext(); InventoryAuditProcedures.EditAudit(ADS.ActiveAudit, dataContext); if (!dataContext.Result) { MessageBox.Show(dataContext.ErrorText); return; } }
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 btnPreviousAuditTrakker_Click(object sender, EventArgs e) { if (gvMissingItems.SelectedRows.Count != 1) { return; } TrakkerItem item = gvMissingItems.SelectedRows[0].Tag as TrakkerItem; if (item == null) { return; } CommonDatabaseContext dataContext = CreateCommonDatabaseContext(); InventoryAuditProcedures.GetPreviousLocation(ADS.ActiveAudit, item, dataContext); if (!dataContext.Result) { MessageBox.Show("No previous location"); return; } PreviousAuditTrakker previousAuditTrakker = new PreviousAuditTrakker(item); previousAuditTrakker.ShowDialog(); }
public EnterCaccItems() { InitializeComponent(); DataSet data; CommonDatabaseContext dataContext = CreateCommonDatabaseContext(); bool dataReturned = InventoryAuditProcedures.GetCACCInfo(ADS.ActiveAudit, dataContext, out data); gvItems.AutoGenerateColumns = false; gvItems.Columns["colShortCode"].DataPropertyName = "CAT_CODE"; gvItems.Columns["colCategory"].DataPropertyName = "CAT_DESC"; gvItems.Columns["colPreQty"].DataPropertyName = "ORG_QTY"; gvItems.Columns["ttl_cost"].DataPropertyName = "ORG_COST"; gvItems.Columns["colPreQty"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter; gvItems.Columns["colPreAvg"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter; gvItems.Columns["colPostQty"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter; gvItems.Columns["colPostQty"].DataPropertyName = "NEW_QTY"; gvItems.Columns["colPostAvgCost"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter; var bs = new BindingSource(); bs.DataSource = data.Tables["CACC_summary"]; gvItems.DataSource = bs; btnUndo.Enabled = false; }
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; }
void bwLoadTrakkerItems_DoWork(object sender, DoWorkEventArgs e) { TrakkerItems = new List <TrakkerItem>(); CommonDatabaseContext dataContext = CreateCommonDatabaseContext(); InventoryAuditProcedures.GetTrakkerItems(TrakkerItems, ADS.ActiveAudit, dataContext); e.Result = dataContext; }
private void btnContinue_Click(object sender, EventArgs e) { if (gvAudits.SelectedRows.Count != 1) { return; } InventoryAuditVO audit = gvAudits.SelectedRows[0].Tag as InventoryAuditVO; if (audit == null) { return; } panelButtons.Enabled = false; ProcessingMessage = new ProcessingMessage("Loading Audit Information", 0); ProcessingMessage.Show(); CommonDatabaseContext dataContext = CreateCommonDatabaseContext(); InventoryAuditProcedures.GetSummaryInfo(audit, dataContext); InventoryAuditProcedures.GetAdditionalAuditInfo(audit, dataContext); ProcessingMessage.Close(); if (!dataContext.Result) { MessageBox.Show("Error loading CACC information"); panelButtons.Enabled = true; return; } ADS.ActiveAudit = audit; switch (audit.Status) { case AuditStatus.ACTIVE: panelButtons.Enabled = true; NavControlBox.IsCustom = true; NavControlBox.CustomDetail = "VIEWACTIVEAUDIT"; NavControlBox.Action = NavBox.NavAction.SUBMIT; break; case AuditStatus.CLOSED: panelButtons.Enabled = true; NavControlBox.IsCustom = true; NavControlBox.CustomDetail = "VIEWCLOSEDAUDIT"; NavControlBox.Action = NavBox.NavAction.SUBMIT; break; default: MessageBox.Show("Status not implemented: " + audit.Status.ToString()); panelButtons.Enabled = true; break; } }
private void updateStats(InventoryAuditVO audit, bool isNewAudit) { if (_CurrentlyInUpdateStatus) { // Prevent update stats from being called twice. return; } try { if (AuditReportsProcedures.getAuditStatusSummary(audit.StoreNumber, audit.AuditId, isNewAudit, out dsAuditStatusSummary)) { if (dsAuditStatusSummary.Tables.Contains("OUTPUT") && dsAuditStatusSummary.Tables["OUTPUT"].Rows.Count == 3) { lblItemsMissingQty.Text = dsAuditStatusSummary.Tables["OUTPUT"].Rows[0][1].ToString(); lblCaccItemsMissingQty.Text = dsAuditStatusSummary.Tables["OUTPUT"].Rows[2][1].ToString(); ItemsUnexpectedQty.Text = dsAuditStatusSummary.Tables["OUTPUT"].Rows[1][1].ToString(); } // perhaps label20 || bool isCACCActual = InventoryAuditProcedures.setCaccTotals(audit, dsAuditStatusSummary.Tables[AuditReportsProcedures.PREAUDIT_CACC_SMRY].Rows, label20.Text != ACTUAL_CACC && isNewAudit); if (isCACCActual) { label20.Text = ACTUAL_CACC; } lblCompactDiscsCost.Text = audit.CompactDiscSummary.Cost.ToString("c"); lblCompactDiscsQty.Text = audit.CompactDiscSummary.Quantity.ToString(); lblVideoTapesCost.Text = audit.VideoTapeSummary.Cost.ToString("c"); lblVideoTapesQty.Text = audit.VideoTapeSummary.Quantity.ToString(); lblStandardVideoGamesCost.Text = audit.StandardVideoGameSummary.Cost.ToString("c"); lblStandardVideoGamesQty.Text = audit.StandardVideoGameSummary.Quantity.ToString(); lblPremiumVideoGamesCost.Text = audit.PremiumVideoGameSummary.Cost.ToString("c"); lblPremiumVideoGamesQty.Text = audit.PremiumVideoGameSummary.Quantity.ToString(); lblDvdDiscsCost.Text = audit.DvdDiscSummary.Cost.ToString("c"); lblDvdDiscsQty.Text = audit.DvdDiscSummary.Quantity.ToString(); lblExpectedCaccCost.Text = audit.GetTotalCaccCost().ToString("c"); lblExpectedCaccQty.Text = audit.GetTotalCaccQty().ToString(); } } catch (Exception ex) { MessageBox.Show(ex.StackTrace, "ERROR " + ex.Message); } }
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; } }
private void SelectStore_Load(object sender, EventArgs e) { List <SiteId> stores = new List <SiteId>(); CommonDatabaseContext dataContext = CreateCommonDatabaseContext(); bool retVal = InventoryAuditProcedures.GetStores(stores, dataContext); if (!retVal) { MessageBox.Show(dataContext.ErrorText); return; } ddlStore.DisplayMember = "StoreNumber"; ddlStore.DataSource = stores; }
private void bwPostAudit_DoWork(object sender, DoWorkEventArgs e) { CommonDatabaseContext dataContext = CreateCommonDatabaseContext(); ADS.beginTransactionBlock(); InventoryAuditProcedures.PostAudit(ADS.ActiveAudit, dataContext); if (!dataContext.Result) { ADS.endTransactionBlock(EndTransactionType.ROLLBACK); } else { ADS.endTransactionBlock(EndTransactionType.COMMIT); } e.Result = dataContext; }
private void InitiateAudit_Load(object sender, EventArgs e) { lblShopNumber.Text = ADS.ActiveAudit.StoreNumber; lblAuditorName.Text = ADS.ActiveAudit.InitiatedBy; lblMarketManagerName.Text = "Unknown"; cboTypeOfAudit.SelectedIndex = 0; cboAuditScope.SelectedIndex = 0; cboAuditReason.SelectedIndex = 0; cboReportDetail.SelectedIndex = 2; CommonDatabaseContext dataContext = CreateCommonDatabaseContext(); string marketManagerName = string.Empty; InventoryAuditProcedures.GetMarketManagerName(ref marketManagerName, dataContext); if (dataContext.Result) { lblMarketManagerName.Text = marketManagerName; } }
private void LoadStoresIfNecessary() { if (CachedStores != null) { return; } CachedStores = new List <SiteId>(); CommonDatabaseContext dataContext = CreateCommonDatabaseContext(); bool retVal = InventoryAuditProcedures.GetStores(CachedStores, dataContext); if (!retVal) { MessageBox.Show(dataContext.ErrorText); return; } ddlShopNumber.DisplayMember = "StoreNumber"; ddlShopNumber.DataSource = CachedStores; }
private void btnContinue_Click(object sender, EventArgs e) { //TODO: update the cacc counts in database CommonDatabaseContext dataContext = CreateCommonDatabaseContext(); int?nrCD, nrVideo, nrGames, nrPremGame, nrDVD; if (gvItems.CurrentCell.IsInEditMode) { gvItems.EndEdit(); } nrCD = Utilities.GetNullableIntegerValue(gvItems.Rows[0].Cells["colActualQty"].Value.ToString(), null); nrVideo = Utilities.GetNullableIntegerValue(gvItems.Rows[1].Cells["colActualQty"].Value.ToString(), null); nrGames = Utilities.GetNullableIntegerValue(gvItems.Rows[2].Cells["colActualQty"].Value.ToString(), null); nrPremGame = Utilities.GetNullableIntegerValue(gvItems.Rows[3].Cells["colActualQty"].Value.ToString(), null); nrDVD = Utilities.GetNullableIntegerValue(gvItems.Rows[4].Cells["colActualQty"].Value.ToString(), null); bool retval = InventoryAuditProcedures.persistCACCCounts(dataContext, ADS.ActiveAudit.StoreNumber, ADS.ActiveAudit.AuditId, GetWritableValue(nrCD), GetWritableValue(nrVideo), GetWritableValue(nrGames), GetWritableValue(nrPremGame), GetWritableValue(nrDVD)); NavControlBox.Action = NavBox.NavAction.SUBMIT; }
private void bwLoadInventorySummary_DoWork(object sender, DoWorkEventArgs e) { CommonDatabaseContext dataContextSummary = CreateCommonDatabaseContext(); InventoryAuditProcedures.GetSummary(ADS.ActiveAudit, dataContextSummary); if (!dataContextSummary.Result) { e.Result = dataContextSummary; } CommonDatabaseContext dataContextAuditInfo = CreateCommonDatabaseContext(); InventoryAuditProcedures.GetAdditionalAuditInfo(ADS.ActiveAudit, dataContextAuditInfo); if (!dataContextAuditInfo.Result) { e.Result = dataContextAuditInfo; } dataContextSummary.OutputDataSet2 = dataContextAuditInfo.OutputDataSet1; e.Result = dataContextSummary; }
private void btnContinue_Click(object sender, EventArgs e) { InventoryAuditVO audit = ADS.ActiveAudit; audit.AuditScope = ((EnumPair <AuditScope>)cboAuditScope.SelectedItem).Value; audit.AuditType = ((EnumPair <AuditType>)cboTypeOfAudit.SelectedItem).Value; audit.DateInitiated = ShopDateTime.Instance.FullShopDateTime; audit.ExitingShopManager = txtExitingShopManagerName.Text.Trim(); audit.MarketManagerPresent = cboMarketManagerPresent.AnswerYes; audit.AuditReason = ((EnumPair <AuditReason>)cboAuditReason.SelectedItem).Value; audit.ReportDetail = ((EnumPair <AuditReportDetail>)cboReportDetail.SelectedItem).Value; CommonDatabaseContext dataContext = new CommonDatabaseContext(); InventoryAuditProcedures.CreateAudit(audit, dataContext); if (!dataContext.Result) { MessageBox.Show("Error initiating audit."); return; } NavControlBox.Action = NavBox.NavAction.SUBMIT; }
private void btnChargeOff_Click(object sender, EventArgs e) { if (gvMissingItems.SelectedRows.Count == 0) { return; } ChargeOffContext = new ChargeOffContext(ADS); List <string> icns = new List <string>(); if (gvMissingItems.SelectedRows.Count > 1) { bool hasGun = false; bool hasNonGun = false; foreach (DataGridViewRow row in gvMissingItems.SelectedRows) { TrakkerItem item = row.Tag as TrakkerItem; if (item.IsGun) { hasGun = true; } else { hasNonGun = true; } icns.Add(item.Icn.ToString()); } if (hasGun && hasNonGun) { MessageBox.Show("Cannot charge off a firearm and a non-firearm at the same time."); return; } ChargeOffContext.IsGun = hasGun; ChargeOffContext.MultipleItems = true; } else { ChargeOffContext.MultipleItems = false; TrakkerItem item = gvMissingItems.SelectedRows[0].Tag as TrakkerItem; ChargeOffContext.ChargeOffAmount = item.PfiAmount; ChargeOffContext.Description = item.Description; ChargeOffContext.Icn = item.Icn; ChargeOffContext.IsGun = item.IsGun; icns.Add(item.Icn.ToString()); } ChargeOff chargeOff = new ChargeOff(ChargeOffContext); if (chargeOff.ShowDialog() == DialogResult.OK) { ChargeOffContext.ChargeOffDatabaseContext.AuditId = ADS.ActiveAudit.AuditId; ChargeOffContext.ChargeOffDatabaseContext.StoreNumber = ADS.ActiveAudit.StoreNumber; ChargeOffContext.ChargeOffDatabaseContext.Icns = icns; CommonDatabaseContext dataContext = CreateCommonDatabaseContext(); InventoryAuditProcedures.ChargeOff(ChargeOffContext.ChargeOffDatabaseContext, dataContext); if (dataContext != null && !dataContext.Result) { MessageBox.Show(dataContext.ErrorText); return; } LoadMissingItems(); } }
private void DownloadFiles() { ProcessingMessage = new ProcessingMessage("Retrieving upload files", 0); ProcessingMessage.Show(); try { string tmpPath = Path.Combine(Application.StartupPath, "tmp"); string trakkerPath = Path.Combine(tmpPath, "uptrak"); string trakkerIdPath = Path.Combine(tmpPath, "trakker.id"); if (!Directory.Exists(tmpPath)) { Directory.CreateDirectory(tmpPath); } FtpHelper ftpHelper = new FtpHelper(FtpHost, FtpUser, FtpPassword); ftpHelper.DownloadFile("tmp_" + ADS.ActiveAudit.StoreNumber + "/uptrak", trakkerPath, false); ftpHelper.DownloadFile("tmp_" + ADS.ActiveAudit.StoreNumber + "/trakker.id", trakkerIdPath, false); string[] fileContents = File.ReadAllLines(trakkerIdPath); if (fileContents.Length == 0 || string.IsNullOrWhiteSpace(fileContents[0])) { ProcessingMessage.Close(); throw new ApplicationException("trakker.id file is empty"); } int trakkerId = Utilities.GetIntegerValue(fileContents[0].Substring(fileContents[0].IndexOf('|') + 1), 0); ProcessingMessage.Hide(); ConfirmTrakker confirmTrakker = new ConfirmTrakker(trakkerId); if (confirmTrakker.ShowDialog() == DialogResult.Cancel) { ProcessingMessage.Close(); return; } ProcessingMessage.Show(); TrakkerFileReader trakkerFileReader = new TrakkerFileReader(trakkerPath); List <TrakkerItem> uploadedItems = trakkerFileReader.ReadFile(); int count = 0; if (uploadedItems.Count > 0) { ADS.beginTransactionBlock(); foreach (TrakkerItem item in uploadedItems) { count++; ProcessingMessage.Message = string.Format("Uploading record {0} of {1}", count, uploadedItems.Count); CommonDatabaseContext dataContext = new CommonDatabaseContext(); InventoryAuditProcedures.UploadTrakkerItem(item, ADS.ActiveAudit.AuditId, trakkerId, ADS.ActiveAudit.StoreNumber, dataContext); if (!dataContext.Result) { ADS.endTransactionBlock(EndTransactionType.ROLLBACK); MessageBox.Show(dataContext.ErrorText); return; } } ADS.endTransactionBlock(EndTransactionType.COMMIT); } ProcessingMessage.Close(); ChangeStatusMessage2("Records Uploaded from Trakker " + trakkerId); ChangeStatusValue2(uploadedItems.Count.ToString()); Uploaded = true; } catch (Exception exc) { ProcessingMessage.Close(); BasicExceptionHandler.Instance.AddException("Failed to upload trakker files", exc); MessageBox.Show(exc.Message); } }