private void GridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { LayoutControlGrid.Validate(); var statements = this.XPCollection.Cast <CDS.Client.DataAccessLayer.XDB.GLX_Account>(); if (statements.Count(n => n.EmailStatement) > 0 || statements.Count(n => n.PrintStatement) > 0) { btnProcessStatements.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; } else { btnProcessStatements.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; } }
private void btnProcessStatements_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { using (ProcessStatementsDialogue dlg = new ProcessStatementsDialogue()) { LayoutControlGrid.Validate(); using (var uow = new DevExpress.Xpo.Session()) { XDB.ORG_Company company = null; foreach (XDB.GLX_Account account in this.XPCollection) { switch (IsCustomer) { case true: company = uow.Query <XDB.ORG_Company>().SingleOrDefault(n => n.TypeId.Id == (byte)BL.ORG.ORG_Type.Customer && n.EntityId.EntityId.CodeSub == account.EntityId.CodeSub); break; case false: company = uow.Query <XDB.ORG_Company>().SingleOrDefault(n => n.TypeId.Id == (byte)BL.ORG.ORG_Type.Supplier && n.EntityId.EntityId.CodeSub == account.EntityId.CodeSub); break; } if (account.PrintStatement || account.EmailStatement) { dlg.Statements.Add(new CDS.Client.DataAccessLayer.Types.Statement() { EntityId = account.EntityId.Id, Code = account.EntityId.CodeSub, Name = account.EntityId.Name, Contact = company.AccountsContactName, Email = company.AccountsContactEmail, ShouldPrint = account.PrintStatement, ShouldEmail = account.EmailStatement }); } } } dlg.ShowDialog(); } if (StatementTask != null && StatementTask.Status != System.Threading.Tasks.TaskStatus.RanToCompletion) { Essential.BaseAlert.ShowAlert("Processing statements", "Statements will now be processed in the background.\nClick on \"View Active Processing\" to check progress.", Essential.BaseAlert.Buttons.Ok, Essential.BaseAlert.Icons.Information); btnViewActiveProcessing.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; btnProcessStatements.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; UpdateTimer.Start(); } }
private void GridView_MouseDown(object sender, MouseEventArgs e) { GridView view = sender as GridView; Point p = view.GridControl.PointToClient(MousePosition); GridHitInfo info = view.CalcHitInfo(p); if (info.HitTest == GridHitTest.Column) { LayoutControlGrid.Validate(); var statements = this.XPCollection.Cast <CDS.Client.DataAccessLayer.XDB.GLX_Account>(); bool clearEmail = false, clearPrint = false; if (info.Column == colEmailStatement && statements.Count(n => n.EmailStatement) > 0) { clearEmail = true; } else if (info.Column == colPrintStatement && statements.Count(n => n.PrintStatement) > 0) { clearPrint = true; } using (var uow = new DevExpress.Xpo.Session()) { XDB.ORG_Company company = null; foreach (CDS.Client.DataAccessLayer.XDB.GLX_Account account in XPCollection) { if (account.EntityId.AccountBalance == 0.00M) { continue; } switch (IsCustomer) { case true: company = uow.Query <XDB.ORG_Company>().SingleOrDefault(n => n.TypeId.Id == (byte)BL.ORG.ORG_Type.Customer && n.EntityId.EntityId.CodeSub == account.EntityId.CodeSub); break; case false: company = uow.Query <XDB.ORG_Company>().SingleOrDefault(n => n.TypeId.Id == (byte)BL.ORG.ORG_Type.Supplier && n.EntityId.EntityId.CodeSub == account.EntityId.CodeSub); break; } if (clearEmail) { account.EmailStatement = false; } else if (info.Column == colEmailStatement) { if (company.StatementPreference == "Email" || (company.StatementPreference == "Email, Print" || company.StatementPreference == "Print, Email")) { account.EmailStatement = true; } if (account.EntityId.AccountBalance != 0) { account.EmailStatement = true; } } if (clearPrint) { account.PrintStatement = false; } else if (info.Column == colPrintStatement) { if (company.StatementPreference == "Print" || (company.StatementPreference == "Email, Print" || company.StatementPreference == "Print, Email")) { account.PrintStatement = true; } if (account.EntityId.AccountBalance != 0) { account.PrintStatement = true; } } } } clearEmail = false; clearPrint = false; if (statements.Count(n => n.EmailStatement) > 0 || statements.Count(n => n.PrintStatement) > 0) { btnProcessStatements.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; } else { btnProcessStatements.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; } GridView.RefreshData(); } }