Ejemplo n.º 1
0
        private void Delete()
        {
            if (_IDLABELTELA == -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(_IDLABELTELA);

                        LABELTELAP.Delete(_IDLABELTELA);
                        Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue");
                        Entity = null;
                        GetAllFormulario();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show(ConfigMessage.Default.MsgDeleteErro);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static LABELTELAEntity FillEntityObject(ref FbDataReader DataReader)
        {
            LABELTELAEntity entity = new LABELTELAEntity();

            FirebirdGetDbData getData = new FirebirdGetDbData();

            entity.IDLABELTELA  = getData.ConvertDBValueToInt32(DataReader, DataReader.GetOrdinal("IDLABELTELA"));
            entity.NOMELABEL    = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("NOMELABEL"));
            entity.TEXTOLABEL   = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("TEXTOLABEL"));
            entity.IDFORMULARIO = getData.ConvertDBValueToInt32Nullable(DataReader, DataReader.GetOrdinal("IDFORMULARIO"));


            return(entity);
        }
Ejemplo n.º 3
0
        private void DataGriewDados_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int rowindex = e.RowIndex;

            if (LIS_LABELTELAColl.Count > 0 && rowindex > -1)
            {
                int ColumnSelecionada = e.ColumnIndex;
                int CodigoSelect      = -1;

                if (ColumnSelecionada == 0) //Editar
                {
                    CodigoSelect = Convert.ToInt32(LIS_LABELTELAColl[rowindex].IDLABELTELA);
                    Entity       = LABELTELAP.Read(CodigoSelect);
                    tabControlMarca.SelectTab(0);
                }
                else if (ColumnSelecionada == 1) //Excluir
                {
                    if (Util.Apaga_Registro(this.Name, FrmLogin._IdNivel))
                    {
                        DialogResult dr = MessageBox.Show(ConfigMessage.Default.MsgDelete,
                                                          ConfigSistema1.Default.NameSytem, MessageBoxButtons.YesNo);

                        if (dr == DialogResult.Yes)
                        {
                            try
                            {
                                CodigoSelect = Convert.ToInt32(LIS_LABELTELAColl[rowindex].IDLABELTELA);
                                LABELTELAP.Delete(CodigoSelect);
                                Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue");
                                GetAllFormulario();
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("Erro técnico: " + ex.Message);
                                MessageBox.Show(ConfigMessage.Default.MsgDeleteErro);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void DataGriewDados_KeyDown(object sender, KeyEventArgs e)
        {
            if (LIS_LABELTELAColl.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(LIS_LABELTELAColl[indice].IDFORMULARIO);

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

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

                    if (dr == DialogResult.Yes)
                    {
                        try
                        {
                            LABELTELAP.Delete(CodigoSelect);
                            Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue");
                            GetAllFormulario();
                        }
                        catch (Exception)
                        {
                            MessageBox.Show(ConfigMessage.Default.MsgDeleteErro);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
 private void TSBNovo_Click(object sender, EventArgs e)
 {
     Entity = null;
     tabControlMarca.SelectTab(0);
     txtNomeLabel.Focus();
 }
Ejemplo n.º 6
0
 private void novoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Entity = null;
     tabControlMarca.SelectTab(0);
     txtNomeLabel.Focus();
 }
Ejemplo n.º 7
0
        public LABELTELAEntity Read(int IDLABELTELA)
        {
            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_LABELTELA", dbCnn);
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = ((FbConnection)GetConnectionDB());
                    }

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

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

                dbCommand.CommandType = CommandType.StoredProcedure;

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


                reader = dbCommand.ExecuteReader();

                LABELTELAEntity 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.º 8
0
        public int Save(LABELTELAEntity 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_LABELTELA", dbCnn);
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = ((FbConnection)GetConnectionDB());
                    }

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

                    dbCommand             = new FbCommand("Sav_LABELTELA", 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.IDLABELTELA == -1)
                {
                    dbCommand.Parameters.AddWithValue("@IDLABELTELA", DBNull.Value);
                }
                else
                {
                    dbCommand.Parameters.AddWithValue("@IDLABELTELA", Entity.IDLABELTELA);
                }

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

                if (Entity.IDFORMULARIO != null)
                {
                    dbCommand.Parameters.AddWithValue("@IDFORMULARIO", Entity.IDFORMULARIO);                             //ForeignKey
                }
                else
                {
                    dbCommand.Parameters.AddWithValue("@IDFORMULARIO", DBNull.Value);                             //ForeignKey 5
                }
                //Retorno da Procedure
                FbParameter returnValue;
                returnValue = dbCommand.CreateParameter();

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


                //Executando consulta
                dbCommand.ExecuteNonQuery();

                result = int.Parse(dbCommand.Parameters["@IDLABELTELA"].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);
        }