Exemple #1
0
        private void Delete()
        {
            if (_IDBANCO == -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
                    {
                        BANCOP.Delete(_IDBANCO);
                        Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue");
                        Entity = null;
                        GetAllBanco();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show(ConfigMessage.Default.MsgDeleteErro);
                    }
                }
            }
        }
Exemple #2
0
        private static BANCOEntity FillEntityObject(ref FbDataReader DataReader)
        {
            BANCOEntity entity = new BANCOEntity();

            FirebirdGetDbData getData = new FirebirdGetDbData();

            entity.IDBANCO     = getData.ConvertDBValueToInt32(DataReader, DataReader.GetOrdinal("IDBANCO"));
            entity.NOMEBANCO   = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("NOMEBANCO"));
            entity.NUMEROBANCO = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("NUMEROBANCO"));


            return(entity);
        }
Exemple #3
0
        private void DataGriewDados_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (BANCOColl.Count > 0)
            {
                int rowindex = e.RowIndex;
                if (rowindex != -1)
                {
                    int CodigoSelect = Convert.ToInt32(BANCOColl[rowindex].IDBANCO);

                    Entity = BANCOP.Read(CodigoSelect);

                    tabControlMarca.SelectTab(0);
                    txtNumeroBanco.Focus();
                }
            }
        }
Exemple #4
0
        private void DataGriewDados_KeyDown(object sender, KeyEventArgs e)
        {
            if (BANCOColl.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(BANCOColl[indice].IDBANCO);

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

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

                    if (dr == DialogResult.Yes)
                    {
                        try
                        {
                            BANCOP.Delete(CodigoSelect);
                            Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue");
                            GetAllBanco();
                        }
                        catch (Exception)
                        {
                            MessageBox.Show(ConfigMessage.Default.MsgDeleteErro);
                        }
                    }
                }
            }
        }
Exemple #5
0
        private void GetDropBanco()
        {
            BANCOProvider BANCOP = new BANCOProvider();

            BANCOColl = BANCOP.ReadCollectionByParameter(null, "NOMEBANCO");

            cbBanco.DisplayMember = "NOMEBANCO";
            cbBanco.ValueMember   = "IDBANCO";

            BANCOEntity BANCOTy = new BANCOEntity();

            BANCOTy.NOMEBANCO = ConfigMessage.Default.MsgDrop;
            BANCOTy.IDBANCO   = -1;
            BANCOColl.Add(BANCOTy);

            Phydeaux.Utilities.DynamicComparer <BANCOEntity> comparer = new Phydeaux.Utilities.DynamicComparer <BANCOEntity>(cbBanco.DisplayMember);

            BANCOColl.Sort(comparer.Comparer);
            cbBanco.DataSource = BANCOColl;

            cbBanco.SelectedIndex = 0;
        }
Exemple #6
0
 private void TSBNovo_Click(object sender, EventArgs e)
 {
     Entity = null;
     tabControlMarca.SelectTab(0);
     txtNumeroBanco.Focus();
 }
Exemple #7
0
 private void novoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Entity = null;
     tabControlMarca.SelectTab(0);
     txtNumeroBanco.Focus();
 }
Exemple #8
0
        public BANCOEntity Read(int IDBANCO)
        {
            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_BANCO", dbCnn);
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = ((FbConnection)GetConnectionDB());
                    }

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

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

                dbCommand.CommandType = CommandType.StoredProcedure;

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


                reader = dbCommand.ExecuteReader();

                BANCOEntity 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;
            }
        }
Exemple #9
0
        public int Save(BANCOEntity 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_BANCO", dbCnn);
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = ((FbConnection)GetConnectionDB());
                    }

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

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

                dbCommand.CommandType = CommandType.StoredProcedure;


                if (Entity.IDBANCO != -1)
                {
                    dbCommand.Parameters.AddWithValue("@IDBANCO", Entity.IDBANCO); //PrimaryKey
                }
                else
                {
                    dbCommand.Parameters.AddWithValue("@IDBANCO", DBNull.Value);       //PrimaryKey
                }
                dbCommand.Parameters.AddWithValue("@NOMEBANCO", Entity.NOMEBANCO);     //Coluna
                dbCommand.Parameters.AddWithValue("@NUMEROBANCO", Entity.NUMEROBANCO); //Coluna



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

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


                //Executando consulta
                dbCommand.ExecuteNonQuery();

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