public bool Remove(Expression <Func <Company, bool> > expression) { var companies = _CompanyApp.Search(expression).Include(c => c.FiltersCompanies).ToList(); _CompanyApp.Remove(companies); return(_connection.Save()); }
private void InitializeStrutureColumns() { try { var column1 = new DataGridViewTextBoxColumn { Name = "TableName", HeaderText = @"Tabelas", ValueType = typeof(string) }; gridFilterCompany.SComponent.Columns.Add(column1); var companies = _companyApp.Search().ToList(); foreach (var item in companies) { gridFilterCompany.SComponent.Columns.Add(new DataGridViewTextBoxColumn { Tag = item.Id, Name = $"Column{ item.Id }", HeaderText = item.CorporateName, ValueType = typeof(string), }); } } catch (Exception) { // ignored } }
public FLogin(SplashScreen splash) { _splashScreen = splash; var ri = new RepositoryInjection(); var conn = ri.GetClass <IFactoryConnection>(); _userApp = new UserApp(conn); _companyApp = new CompanyApp(conn); _translateApp = new TranslateApp(conn); _tableApp = new TableApp(conn); _dbTableApp = new DbTableApp(conn); _automaticNumberingApp = new AutomaticNumberingApp(conn); _userController = new UserController(conn); GlobalUser.Forms = _tableApp.Search().ToList(); GlobalUser.Translates = _translateApp.Search().ToList(); GlobalUser.Tables = _dbTableApp.Search().ToList(); GlobalUser.AutomaticNumberings = _automaticNumberingApp.Search().ToList(); InitializeComponent(); Unidade.ObjetoApp = new InvokeMethod(typeof(CompanyController), TypeExecute.SearchAll, "ListCompany", typeof(Company)); Unidade.DisplayMember = "PersonName"; Unidade.ValueMember = "Id"; Unidade.Enabled = false; Unidade.Refresh(); Unidade.SComponent.DropDown += SComponentOnDropDown; Unidade.Caption = "Unidade"; EntrarButton.SComponent.BackColor = Color.DarkSlateGray; EntrarButton.SComponent.ForeColor = Color.White; EntrarButton.SComponent.Text = @"Entrar"; EntrarButton.SComponent.Click += EntrarButton_Click; EntrarButton.Enabled = false; SenhaTextBox.SComponent.PasswordChar = '*'; SenhaTextBox.Caption = "Senha"; SenhaTextBox.SComponent.TextChanged += SenhaComponentOnTextChanged; UsuarioTextBox.SComponent.TextChanged += UsuarioComponentOnTextChanged; UsuarioTextBox.Caption = "Login"; var cont = false; if (_companyApp.Search().Any()) { if (!_userApp.Search().Any()) { MessageBox.Show(@"Necessário cadastrar um usuário", @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.OK); var fuser = new FUser { StateForm = StateForm.Inserting, ClosedAfterSave = true }; fuser.RefreshControls(); ((User)fuser.CurrentControl).IsAdministrator = true; _splashScreen.Close(); fuser.ShowDialog(); } return; } ; MessageBox.Show(@"Este é o seu primeiro acesso ao sistema, por favor, cadastre sua empresa.", @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.OK); do { var fcompany = new FCompany() { StateForm = StateForm.Inserting, ClosedAfterSave = true }; fcompany.RefreshControls(); _splashScreen.Close(); fcompany.ShowDialog(); if (!_companyApp.Search().Any()) { cont = MessageBox.Show(@"Necessário cadastrar uma empresa, deseja continuar ?", @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes; } } while (cont); if (!_companyApp.Search().Any()) { Close(); } else { if (_userApp.Search().Any()) { return; } MessageBox.Show(@"Necessário cadastrar um usuário", @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.OK); var fuser = new FUser { ClosedAfterSave = true, StateForm = StateForm.Inserting, }; ((User)fuser.CurrentControl).IsAdministrator = true; _splashScreen.Close(); fuser.ShowDialog(); } }