// VERIFICA CONTA and CONGREGACAO INICIAL //================================================================================================= private objConta VerificaAndGet_ContaAndCongregacao() { objConta conta = new objConta(null); if (!CheckContaPadrao(ref conta)) { MessageBox.Show("Ainda não foi encontrada nenhuma CONTA PADRÃO no sistema...\n\n" + "Favor inserir e escolher uma CONTA padrão no arquivo do sistema", "Conta Padrão", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // abre o form de config Config.frmConfig frmC = new Config.frmConfig(this); frmC.ShowDialog(); // testa novamente if (!CheckContaPadrao(ref conta)) { MessageBox.Show("Ainda não foi encontrado nenhuma Conta Padrão no sistema!\n" + "A aplicação será fechada...", "Conta Inespecífica", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(null); } } return(conta); }
private void btnFechar_Click(object sender, EventArgs e) { //Close(); frmConfig f = Application.OpenForms.OfType <frmConfig>().FirstOrDefault(); f.FormNoPanelClosed(this); }
// TITULO VALIDATING //------------------------------------------------------------------------------------------------------------ private void txtIgrejaTitulo_Validating(object sender, System.ComponentModel.CancelEventArgs e) { try { frmConfig fConfig = Application.OpenForms.OfType <frmConfig>().FirstOrDefault(); frmPrincipal f = Application.OpenForms.OfType <frmPrincipal>().FirstOrDefault(); f.AplicacaoTitulo = txtIgrejaTitulo.Text; } catch (Exception ex) { AbrirDialog("Houve uma execeção ao salvar Config... \n" + ex.Message, "Exceção", DialogType.OK, DialogIcon.Exclamation); } }
//--- VERIFICA CONFIG //================================================================================================= private bool VerificaConfig() { if (File.Exists(Application.StartupPath + "\\Config.xml")) { return(true); } else { if (Program.usuarioAtual.UsuarioAcesso > 1) // não é administrador do sistema { AbrirDialog("Arquivo de Configuração não foi encontrado! \n" + "Seu LOGIN não tem acesso à Configuração... \n" + "Comunique-se com o administrador do sistema.", "Erro de Arquivo", DialogType.OK, DialogIcon.Warning); return(false); } } AbrirDialog("Arquivo de Configuração não foi encontrado!", "Gerar CONFIG", DialogType.OK, DialogIcon.Warning); //--- abre o form de config Config.frmConfig frmC = new Config.frmConfig(this); frmC.ShowDialog(); //--- se não existe o config, então fecha a aplicação if (File.Exists(Application.StartupPath + "\\Config.xml")) { return(true); } else { AbrirDialog("Arquivo de Configuração ainda não foi encontrado! \n" + "Sem CONFIGURAÇÃO não será possível continuar... \n" + "Comunique-se com o administrador do Sistema.", "Erro de Arquivo", DialogType.OK, DialogIcon.Warning); return(false); } }
// ALTERAR CONTA //------------------------------------------------------------------------------------------------------------ private void btnContaAlterar_Click(object sender, EventArgs e) { frmConfig config = Application.OpenForms.OfType <frmConfig>().First(); frmContaProcura frm = new frmContaProcura(this, _Conta?.IDConta); // disable forms this.lblTitulo.BackColor = Color.Silver; config.panel1.BackColor = Color.Silver; // show frm.ShowDialog(); // return this.lblTitulo.BackColor = Color.SlateGray; config.panel1.BackColor = Color.Goldenrod; if (frm.DialogResult == DialogResult.OK) { Application.OpenForms.OfType <frmPrincipal>().First().propContaPadrao = frm.propEscolha; _Conta = frm.propEscolha; txtContaPadrao.Text = frm.propEscolha.Conta; // check SETOR if (_Setor != null) { if (_Setor.IDCongregacao != _Conta.IDCongregacao) { // user message AbrirDialog("A CONTA escolhida pertence a uma congregação diferente do SETOR padrão escolhido:\n" + _Setor.Setor.ToUpper() + "\nO Setor padrão atual será descartado. Favor definir um novo Setor...", "Redefinir Setor", DialogType.OK, DialogIcon.Exclamation); // clear controls txtSetorPadrao.Clear(); _Setor = null; Application.OpenForms.OfType <frmPrincipal>().First().propSetorPadrao = null; } } } // focus control txtContaPadrao.Focus(); }
// OPEN CONFIG // ============================================================================= private void btnConfig_Click(object sender, EventArgs e) { try { // --- Ampulheta ON Cursor.Current = Cursors.WaitCursor; Form f = new Config.frmConfig(this); MenuEnabled(false); f.MdiParent = this; f.Show(); } catch (Exception ex) { AbrirDialog("Uma exceção ocorreu ao Abrir o formulário de Configuração..." + "\n" + ex.Message, "Exceção", DialogType.OK, DialogIcon.Exclamation); } finally { // --- Ampulheta OFF Cursor.Current = Cursors.Default; } }
// ALTERAR SETOR //------------------------------------------------------------------------------------------------------------ private void btnSetorAlterar_Click(object sender, EventArgs e) { frmConfig config = Application.OpenForms.OfType <frmConfig>().First(); frmSetorProcura fProc = new frmSetorProcura(this, _IDCongregacao); // disable forms this.lblTitulo.BackColor = Color.Silver; config.panel1.BackColor = Color.Silver; // show fProc.ShowDialog(); // return this.lblTitulo.BackColor = Color.SlateGray; config.panel1.BackColor = Color.Goldenrod; if (fProc.DialogResult == DialogResult.OK) { // check SETOR if (_Conta != null && fProc.propEscolha.IDCongregacao != _Conta.IDCongregacao) { // user message AbrirDialog("O SETOR escolhido pertence a uma congregação diferente da CONTA padrão atual:\n" + _Conta.Conta.ToUpper() + "\nO Setor escolhido será descartado. Favor escolher um novo Setor...", "Redefinir Setor", DialogType.OK, DialogIcon.Exclamation); } else { Application.OpenForms.OfType <frmPrincipal>().First().propSetorPadrao = fProc.propEscolha; txtSetorPadrao.Text = fProc.propEscolha.Setor; _Setor = fProc.propEscolha; } } // focus control txtSetorPadrao.Focus(); }