private void Delete() { if (_IDLOCALCOBRANCA == -1) { MessageBox.Show(ConfigMessage.Default.MsgSelecRegistro); tabControlLocalCobranca.SelectTab(1); } else if (!Util.Apaga_Registro(this.Name, FrmLogin._IdNivel)) { } else { DialogResult dr = MessageBox.Show(ConfigMessage.Default.MsgDelete, ConfigSistema1.Default.NameSytem, MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { try { LOCALCOBRANCAP.Delete(_IDLOCALCOBRANCA); MessageBox.Show(ConfigMessage.Default.MsgDelete2); Entity = null; GetAllLocalCobranca(); } catch (Exception) { MessageBox.Show(ConfigMessage.Default.MsgDeleteErro); } } } }
private static LOCALCOBRANCAEntity FillEntityObject(ref FbDataReader DataReader) { LOCALCOBRANCAEntity entity = new LOCALCOBRANCAEntity(); FirebirdGetDbData getData = new FirebirdGetDbData(); entity.IDLOCALCOBRANCA = getData.ConvertDBValueToInt32(DataReader, DataReader.GetOrdinal("IDLOCALCOBRANCA")); entity.CODIGOCOBRANCA = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("CODIGOCOBRANCA")); entity.NOME = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("NOME")); entity.OBSERVACAO = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("OBSERVACAO")); return(entity); }
private void DataGriewDados_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (LOCALCOBRANCAColl.Count > 0) { int rowindex = e.RowIndex; if (rowindex != -1) { int CodigoSelect = Convert.ToInt32(LOCALCOBRANCAColl[rowindex].IDLOCALCOBRANCA); Entity = LOCALCOBRANCAP.Read(CodigoSelect); tabControlLocalCobranca.SelectTab(0); txtCodigo.Focus(); } } }
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(); GetAllLocalCobranca(); VerificaAcesso(); if (_IDLOCALCOBRANCA != -1) { Entity = LOCALCOBRANCAP.Read(_IDLOCALCOBRANCA); } this.Cursor = Cursors.Default; }
private void DataGriewDados_KeyDown(object sender, KeyEventArgs e) { if (LOCALCOBRANCAColl.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(LOCALCOBRANCAColl[indice].IDLOCALCOBRANCA); if (e.KeyCode == Keys.Enter) { Entity = LOCALCOBRANCAP.Read(CodigoSelect); tabControlLocalCobranca.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 { LOCALCOBRANCAP.Delete(CodigoSelect); MessageBox.Show(ConfigMessage.Default.MsgDelete2); GetAllLocalCobranca(); } catch (Exception) { MessageBox.Show(ConfigMessage.Default.MsgDeleteErro); } } } } }
private void GetDropLocalCobranca() { LOCALCOBRANCAProvider LOCALCOBRANCAP = new LOCALCOBRANCAProvider(); LOCALCOBRANCAColl = LOCALCOBRANCAP.ReadCollectionByParameter(null, "NOME"); cbLocalCobranca.DisplayMember = "NOME"; cbLocalCobranca.ValueMember = "IDLOCALCOBRANCA"; LOCALCOBRANCAEntity LOCALCOBRANCATy = new LOCALCOBRANCAEntity(); LOCALCOBRANCATy.NOME = ConfigMessage.Default.MsgDrop; LOCALCOBRANCATy.IDLOCALCOBRANCA = -1; LOCALCOBRANCAColl.Add(LOCALCOBRANCATy); Phydeaux.Utilities.DynamicComparer <LOCALCOBRANCAEntity> comparer = new Phydeaux.Utilities.DynamicComparer <LOCALCOBRANCAEntity>(cbLocalCobranca.DisplayMember); LOCALCOBRANCAColl.Sort(comparer.Comparer); cbLocalCobranca.DataSource = LOCALCOBRANCAColl; cbLocalCobranca.SelectedIndex = 0; }
private void TSBNovo_Click(object sender, EventArgs e) { Entity = null; tabControlLocalCobranca.SelectTab(0); txtCodigo.Focus(); }
private void novoToolStripMenuItem_Click(object sender, EventArgs e) { Entity = null; tabControlLocalCobranca.SelectTab(0); txtCodigo.Focus(); }
public LOCALCOBRANCAEntity Read(int IDLOCALCOBRANCA) { 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_LOCALCOBRANCA", dbCnn); dbCommand.Transaction = ((FbTransaction)(dbTransaction)); } else { if (dbCnn == null) { dbCnn = ((FbConnection)GetConnectionDB()); } if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand("Rea_LOCALCOBRANCA", dbCnn); dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted); } dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.Parameters.AddWithValue("@IDLOCALCOBRANCA", IDLOCALCOBRANCA); //PrimaryKey reader = dbCommand.ExecuteReader(); LOCALCOBRANCAEntity 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; } }
public int Save(LOCALCOBRANCAEntity 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_LOCALCOBRANCA", dbCnn); dbCommand.Transaction = ((FbTransaction)(dbTransaction)); } else { if (dbCnn == null) { dbCnn = ((FbConnection)GetConnectionDB()); } if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand("Sav_LOCALCOBRANCA", dbCnn); dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted); } dbCommand.CommandType = CommandType.StoredProcedure; if (Entity.IDLOCALCOBRANCA != -1) { dbCommand.Parameters.AddWithValue("@IDLOCALCOBRANCA", Entity.IDLOCALCOBRANCA); //PrimaryKey } else { dbCommand.Parameters.AddWithValue("@IDLOCALCOBRANCA", DBNull.Value); //PrimaryKey } dbCommand.Parameters.AddWithValue("@CODIGOCOBRANCA", Entity.CODIGOCOBRANCA); //Coluna dbCommand.Parameters.AddWithValue("@NOME", Entity.NOME); //Coluna dbCommand.Parameters.AddWithValue("@OBSERVACAO", Entity.OBSERVACAO); //Coluna //Retorno da Procedure FbParameter returnValue; returnValue = dbCommand.CreateParameter(); dbCommand.Parameters["@IDLOCALCOBRANCA"].Direction = ParameterDirection.InputOutput; //Executando consulta dbCommand.ExecuteNonQuery(); result = int.Parse(dbCommand.Parameters["@IDLOCALCOBRANCA"].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); }