Exemplo n.º 1
0
        private void Delete()
        {
            if (_IDTIPODUPLICATA == -1)
            {
                MessageBox.Show(ConfigMessage.Default.MsgSelecRegistro);
                tabControlTipoDuplicata.SelectTab(1);
            }
            else
            {
                DialogResult dr = MessageBox.Show(ConfigMessage.Default.MsgDelete,
                                                  ConfigSistema1.Default.NameSytem, MessageBoxButtons.YesNo);

                if (dr == DialogResult.Yes)
                {
                    try
                    {
                        TIPODUPLICATAP.Delete(_IDTIPODUPLICATA);
                        Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue");
                        Entity = null;
                        GetAllTipoDuplicata();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show(ConfigMessage.Default.MsgDeleteErro);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static TIPODUPLICATAEntity FillEntityObject(ref FbDataReader DataReader)
        {
            TIPODUPLICATAEntity entity = new TIPODUPLICATAEntity();

            FirebirdGetDbData getData = new FirebirdGetDbData();

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


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

                    Entity = TIPODUPLICATAP.Read(CodigoSelect);

                    tabControlTipoDuplicata.SelectTab(0);
                    txtNome.Focus();
                }
            }
        }
Exemplo n.º 4
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();
            GetAllTipoDuplicata();

            if (_IDTIPODUPLICATA != 1)
            {
                Entity = TIPODUPLICATAP.Read(_IDTIPODUPLICATA);
            }

            this.Cursor = Cursors.Default;
        }
Exemplo n.º 5
0
        private void GetDropTipoDuplicata()
        {
            TIPODUPLICATAProvider TIPODUPLICATAP = new TIPODUPLICATAProvider();

            TIPODUPLICATAColl = TIPODUPLICATAP.ReadCollectionByParameter(null, "NOME");

            cbTipo.DisplayMember = "NOME";
            cbTipo.ValueMember   = "IDTIPODUPLICATA";

            TIPODUPLICATAEntity TIPODUPLICATATy = new TIPODUPLICATAEntity();

            TIPODUPLICATATy.NOME            = ConfigMessage.Default.MsgDrop;
            TIPODUPLICATATy.IDTIPODUPLICATA = -1;
            TIPODUPLICATAColl.Add(TIPODUPLICATATy);

            Phydeaux.Utilities.DynamicComparer <TIPODUPLICATAEntity> comparer = new Phydeaux.Utilities.DynamicComparer <TIPODUPLICATAEntity>(cbTipo.DisplayMember);

            TIPODUPLICATAColl.Sort(comparer.Comparer);
            cbTipo.DataSource = TIPODUPLICATAColl;

            cbTipo.SelectedIndex = 0;
        }
Exemplo n.º 6
0
        private void DataGriewDados_KeyDown(object sender, KeyEventArgs e)
        {
            if (TIPODUPLICATAColl.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(TIPODUPLICATAColl[indice].IDTIPODUPLICATA);

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

                    tabControlTipoDuplicata.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
                        {
                            TIPODUPLICATAP.Delete(CodigoSelect);
                            Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue");
                            GetAllTipoDuplicata();
                        }
                        catch (Exception)
                        {
                            MessageBox.Show(ConfigMessage.Default.MsgDeleteErro);
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        public TIPODUPLICATAEntity Read(int IDTIPODUPLICATA)
        {
            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_TIPODUPLICATA", dbCnn);
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = ((FbConnection)GetConnectionDB());
                    }

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

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

                dbCommand.CommandType = CommandType.StoredProcedure;

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


                reader = dbCommand.ExecuteReader();

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

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

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

                dbCommand.CommandType = CommandType.StoredProcedure;


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



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

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


                //Executando consulta
                dbCommand.ExecuteNonQuery();

                result = int.Parse(dbCommand.Parameters["@IDTIPODUPLICATA"].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);
        }
Exemplo n.º 9
0
 private void TSBNovo_Click(object sender, EventArgs e)
 {
     Entity = null;
     tabControlTipoDuplicata.SelectTab(0);
     txtNome.Focus();
 }
Exemplo n.º 10
0
 private void novoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Entity = null;
     tabControlTipoDuplicata.SelectTab(0);
     txtNome.Focus();
 }