Ejemplo n.º 1
0
        private void GetDropGrupo()
        {
            try
            {
                GRUPOFORMLARIOCollection GRUPOFORMLARIOColl = new GRUPOFORMLARIOCollection();
                GRUPOFORMLARIOProvider   GRUPOFORMLARIOP    = new GRUPOFORMLARIOProvider();
                GRUPOFORMLARIOColl = GRUPOFORMLARIOP.ReadCollectionByParameter(null, "NOME");

                cbGrupo.DisplayMember = "NOME";
                cbGrupo.ValueMember   = "IDGRUPOFORMLARIO";

                GRUPOFORMLARIOEntity GRUPOFORMLARIOTy = new GRUPOFORMLARIOEntity();
                GRUPOFORMLARIOTy.NOME             = ConfigMessage.Default.MsgDrop;
                GRUPOFORMLARIOTy.IDGRUPOFORMLARIO = -1;
                GRUPOFORMLARIOColl.Add(GRUPOFORMLARIOTy);

                Phydeaux.Utilities.DynamicComparer <GRUPOFORMLARIOEntity> comparer = new Phydeaux.Utilities.DynamicComparer <GRUPOFORMLARIOEntity>(cbGrupo.DisplayMember);

                GRUPOFORMLARIOColl.Sort(comparer.Comparer);
                cbGrupo.DataSource = GRUPOFORMLARIOColl;

                cbGrupo.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro técnico: " + ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void Delete()
        {
            if (_IDGRUPOFORMLARIO == -1)
            {
                MessageBox.Show(ConfigMessage.Default.MsgSelecRegistro);
                tabControlMarca.SelectTab(1);
            }
            else
            {
                DialogResult dr = MessageBox.Show(ConfigMessage.Default.MsgDelete,
                                                  ConfigSistema1.Default.NameSytem, MessageBoxButtons.YesNo);

                if (dr == DialogResult.Yes)
                {
                    try
                    {
                        //Deleta os controle de acesso referente ao nivel
                        DeleteControleAcesso(_IDGRUPOFORMLARIO);

                        GRUPOFORMLARIOP.Delete(_IDGRUPOFORMLARIO);
                        Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue");
                        Entity = null;
                        GetAllMarca();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show(ConfigMessage.Default.MsgDeleteErro);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private static GRUPOFORMLARIOEntity FillEntityObject(ref FbDataReader DataReader)
        {
            GRUPOFORMLARIOEntity entity = new GRUPOFORMLARIOEntity();

            FirebirdGetDbData getData = new FirebirdGetDbData();

            entity.IDGRUPOFORMLARIO = getData.ConvertDBValueToInt32(DataReader, DataReader.GetOrdinal("IDGRUPOFORMLARIO"));
            entity.NOME             = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("NOME"));


            return(entity);
        }
Ejemplo n.º 4
0
        private void DataGriewDados_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (GRUPOFORMLARIOColl.Count > 0)
            {
                int rowindex = e.RowIndex;
                if (rowindex != -1)
                {
                    int CodigoSelect = Convert.ToInt32(GRUPOFORMLARIOColl[rowindex].IDGRUPOFORMLARIO);

                    Entity = GRUPOFORMLARIOP.Read(CodigoSelect);

                    tabControlMarca.SelectTab(0);
                    txtNome.Focus();
                }
            }
        }
Ejemplo n.º 5
0
        private void FrmTipoRegiao_Load(object sender, EventArgs e)
        {
            CreaterCursor Cr = new CreaterCursor();

            this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0);

            this.MinimizeBox     = false;
            this.FormBorderStyle = FormBorderStyle.FixedDialog;

            GetToolStripButtonCadastro();
            GetAllMarca();

            if (_IDGRUPOFORMLARIO != -1)
            {
                Entity = GRUPOFORMLARIOP.Read(_IDGRUPOFORMLARIO);
            }

            this.Cursor = Cursors.Default;
        }
Ejemplo n.º 6
0
        private void DataGriewDados_KeyDown(object sender, KeyEventArgs e)
        {
            if (GRUPOFORMLARIOColl.Count > 0)
            {
                //Obter a linha da célula selecionada
                DataGridViewRow linhaAtual = DataGriewDados.CurrentRow;

                //Exibir o índice da linha atual
                int indice       = linhaAtual.Index;
                int CodigoSelect = Convert.ToInt32(GRUPOFORMLARIOColl[indice].IDGRUPOFORMLARIO);

                if (e.KeyCode == Keys.Enter)
                {
                    Entity = GRUPOFORMLARIOP.Read(CodigoSelect);

                    tabControlMarca.SelectTab(0);
                    txtNome.Focus();
                }
                else if (e.KeyCode == Keys.Delete)
                {
                    DialogResult dr = MessageBox.Show(ConfigMessage.Default.MsgDelete,
                                                      ConfigSistema1.Default.NameSytem, MessageBoxButtons.YesNo);

                    if (dr == DialogResult.Yes)
                    {
                        try
                        {
                            GRUPOFORMLARIOP.Delete(CodigoSelect);
                            Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue");
                            GetAllMarca();
                        }
                        catch (Exception)
                        {
                            MessageBox.Show(ConfigMessage.Default.MsgDeleteErro);
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private void GetGrupoFormulario()
        {
            GRUPOFORMLARIOCollection GRUPOFORMLARIOColl = new GRUPOFORMLARIOCollection();
            GRUPOFORMLARIOProvider   GRUPOFORMLARIOP    = new GRUPOFORMLARIOProvider();

            GRUPOFORMLARIOColl = GRUPOFORMLARIOP.ReadCollectionByParameter(null, "NOME");

            cbGrupoTelas.DisplayMember = "NOME";
            cbGrupoTelas.ValueMember   = "IDGRUPOFORMLARIO";

            GRUPOFORMLARIOEntity GRUPOFORMLARIOTy = new GRUPOFORMLARIOEntity();

            GRUPOFORMLARIOTy.NOME             = ConfigMessage.Default.MsgDrop;
            GRUPOFORMLARIOTy.IDGRUPOFORMLARIO = -1;
            GRUPOFORMLARIOColl.Add(GRUPOFORMLARIOTy);

            Phydeaux.Utilities.DynamicComparer <GRUPOFORMLARIOEntity> comparer = new Phydeaux.Utilities.DynamicComparer <GRUPOFORMLARIOEntity>(cbGrupoTelas.DisplayMember);

            GRUPOFORMLARIOColl.Sort(comparer.Comparer);
            cbGrupoTelas.DataSource = GRUPOFORMLARIOColl;

            cbGrupoTelas.SelectedIndex = 0;
        }
Ejemplo n.º 8
0
 private void TSBNovo_Click(object sender, EventArgs e)
 {
     Entity = null;
     tabControlMarca.SelectTab(0);
     txtNome.Focus();
 }
Ejemplo n.º 9
0
 private void novoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Entity = null;
     tabControlMarca.SelectTab(0);
     txtNome.Focus();
 }
Ejemplo n.º 10
0
        public GRUPOFORMLARIOEntity Read(int IDGRUPOFORMLARIO)
        {
            FbDataReader reader = null;

            try
            {
                //Verificando a existência de um transação aberta
                if (dbTransaction != null)
                {
                    if (dbCnn.State == ConnectionState.Closed)
                    {
                        dbCnn.Open();
                    }

                    dbCommand             = new FbCommand("Rea_GRUPOFORMLARIO", dbCnn);
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = ((FbConnection)GetConnectionDB());
                    }

                    if (dbCnn.State == ConnectionState.Closed)
                    {
                        dbCnn.Open();
                    }

                    dbCommand             = new FbCommand("Rea_GRUPOFORMLARIO", dbCnn);
                    dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted);
                }

                dbCommand.CommandType = CommandType.StoredProcedure;

                dbCommand.Parameters.AddWithValue("@IDGRUPOFORMLARIO", IDGRUPOFORMLARIO);                //PrimaryKey


                reader = dbCommand.ExecuteReader();

                GRUPOFORMLARIOEntity entity = null;
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        entity = FillEntityObject(ref reader);
                    }
                }

                // Deleta reader
                if (reader != null)
                {
                    reader.Close();
                    reader.Dispose();
                }

                // Fecha conexão
                if (dbTransaction == null)
                {
                    dbCommand.Transaction.Commit();
                    if (dbCnn.State == ConnectionState.Open)
                    {
                        dbCnn.Close();
                    }
                }

                return(entity);
            }
            catch (Exception ex)
            {
                // Deleta reader
                if (reader != null)
                {
                    reader.Close();
                    reader.Dispose();
                }

                if (dbTransaction != null)
                {
                    this.RollbackTransaction();
                }
                else
                {
                    if (dbCommand.Transaction != null)
                    {
                        dbCommand.Transaction.Rollback();
                    }
                    if (dbCnn.State == ConnectionState.Open)
                    {
                        dbCnn.Close();
                    }
                }

                throw ex;
            }
        }
Ejemplo n.º 11
0
        public int Save(GRUPOFORMLARIOEntity Entity)
        {
            int result = 0;

            try
            {
                //Verificando a existência de um transação aberta
                if (dbTransaction != null)
                {
                    if (dbCnn.State == ConnectionState.Closed)
                    {
                        dbCnn.Open();
                    }

                    dbCommand             = new FbCommand("Sav_GRUPOFORMLARIO", dbCnn);
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = ((FbConnection)GetConnectionDB());
                    }

                    if (dbCnn.State == ConnectionState.Closed)
                    {
                        dbCnn.Open();
                    }

                    dbCommand             = new FbCommand("Sav_GRUPOFORMLARIO", dbCnn);
                    dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted);
                }

                dbCommand.CommandType = CommandType.StoredProcedure;

                //PrimaryKey com valor igual a null, indica um novo registro,
                //o valor da chave será fornecido pelo banco. Qualquer outro valor indicará edição do registro.
                if (Entity.IDGRUPOFORMLARIO == -1)
                {
                    dbCommand.Parameters.AddWithValue("@IDGRUPOFORMLARIO", DBNull.Value);
                }
                else
                {
                    dbCommand.Parameters.AddWithValue("@IDGRUPOFORMLARIO", Entity.IDGRUPOFORMLARIO);
                }

                dbCommand.Parameters.AddWithValue("@NOME", Entity.NOME);                         //Coluna



                //Retorno da Procedure
                FbParameter returnValue;
                returnValue = dbCommand.CreateParameter();

                dbCommand.Parameters["@IDGRUPOFORMLARIO"].Direction = ParameterDirection.InputOutput;


                //Executando consulta
                dbCommand.ExecuteNonQuery();

                result = int.Parse(dbCommand.Parameters["@IDGRUPOFORMLARIO"].Value.ToString());


                if (dbTransaction == null)
                {
                    dbCommand.Transaction.Commit();
                    dbCnn.Close();
                }
            }
            catch (Exception ex)
            {
                if (dbTransaction != null)
                {
                    this.RollbackTransaction();
                }
                else
                {
                    if (dbCommand.Transaction != null)
                    {
                        dbCommand.Transaction.Rollback();
                    }
                    if (dbCnn.State == ConnectionState.Open)
                    {
                        dbCnn.Close();
                    }
                }

                throw ex;
            }

            return(result);
        }