private void Delete() { if (_IdCFOP == -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 { CFOPP.Delete(_IdCFOP); MessageBox.Show(ConfigMessage.Default.MsgDelete2); Entity = null; GetAllCFOP(); } catch (Exception) { MessageBox.Show(ConfigMessage.Default.MsgDeleteErro); } } } }
private void GetDropCFOP() { try { CFOPColl = CFOPP.ReadCollectionByParameter(null, "CODCFOP"); cbCFOP.DisplayMember = "CODCFOP"; cbCFOP.ValueMember = "IDCFOP"; CFOPEntity CFOPTy = new CFOPEntity(); CFOPTy.CODCFOP = ConfigMessage.Default.MsgDrop; CFOPTy.IDCFOP = -1; CFOPColl.Add(CFOPTy); Phydeaux.Utilities.DynamicComparer <CFOPEntity> comparer = new Phydeaux.Utilities.DynamicComparer <CFOPEntity>(cbCFOP.DisplayMember); CFOPColl.Sort(comparer.Comparer); cbCFOP.DataSource = CFOPColl; cbCFOP.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show("Erro técnico: " + ex.Message); } }
private static CFOPEntity FillEntityObject(ref FbDataReader DataReader) { CFOPEntity entity = new CFOPEntity(); FirebirdGetDbData getData = new FirebirdGetDbData(); entity.IDCFOP = getData.ConvertDBValueToInt32(DataReader, DataReader.GetOrdinal("IDCFOP")); entity.CODCFOP = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("CODCFOP")); entity.DESCRICAO = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("DESCRICAO")); entity.FLAGBAIXAESTOQUE = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("FLAGBAIXAESTOQUE")); entity.OBSERVACAO = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("OBSERVACAO")); return(entity); }
private void DataGriewDados_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (CFOPColl.Count > 0) { int rowindex = e.RowIndex; if (rowindex != -1) { int CodigoSelect = Convert.ToInt32(CFOPColl[rowindex].IDCFOP); Entity = CFOPP.Read(CodigoSelect); tabControlMarca.SelectTab(0); txtCodCFOP.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(); GetAllCFOP(); if (_IdCFOP != -1) { Entity = CFOPP.Read(_IdCFOP); } this.Cursor = Cursors.Default; }
private void DataGriewDados_KeyDown(object sender, KeyEventArgs e) { if (CFOPColl.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(CFOPColl[indice].IDCFOP); if (e.KeyCode == Keys.Enter) { Entity = CFOPP.Read(CodigoSelect); tabControlMarca.SelectTab(0); txtCodCFOP.Focus(); } else if (e.KeyCode == Keys.Delete) { DialogResult dr = MessageBox.Show(ConfigMessage.Default.MsgDelete, ConfigSistema1.Default.NameSytem, MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { try { CFOPP.Delete(CodigoSelect); MessageBox.Show(ConfigMessage.Default.MsgDelete2); GetAllCFOP(); } catch (Exception) { MessageBox.Show(ConfigMessage.Default.MsgDeleteErro); } } } } }
private void TSBNovo_Click(object sender, EventArgs e) { Entity = null; tabControlMarca.SelectTab(0); txtCodCFOP.Focus(); }
private void novoToolStripMenuItem_Click(object sender, EventArgs e) { Entity = null; tabControlMarca.SelectTab(0); txtCodCFOP.Focus(); }
public CFOPEntity Read(int IDCFOP) { 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_CFOP", dbCnn); dbCommand.Transaction = ((FbTransaction)(dbTransaction)); } else { if (dbCnn == null) { dbCnn = ((FbConnection)GetConnectionDB()); } if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand("Rea_CFOP", dbCnn); dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted); } dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.Parameters.AddWithValue("@IDCFOP", IDCFOP); //PrimaryKey reader = dbCommand.ExecuteReader(); CFOPEntity 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(CFOPEntity 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_CFOP", dbCnn); dbCommand.Transaction = ((FbTransaction)(dbTransaction)); } else { if (dbCnn == null) { dbCnn = ((FbConnection)GetConnectionDB()); } if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand("Sav_CFOP", dbCnn); dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted); } dbCommand.CommandType = CommandType.StoredProcedure; if (Entity.IDCFOP != -1) { dbCommand.Parameters.AddWithValue("@IDCFOP", Entity.IDCFOP); //PrimaryKey } else { dbCommand.Parameters.AddWithValue("@IDCFOP", DBNull.Value); //PrimaryKey } dbCommand.Parameters.AddWithValue("@CODCFOP", Entity.CODCFOP); //Coluna dbCommand.Parameters.AddWithValue("@DESCRICAO", Entity.DESCRICAO); //Coluna dbCommand.Parameters.AddWithValue("@FLAGBAIXAESTOQUE", Entity.FLAGBAIXAESTOQUE); //Coluna dbCommand.Parameters.AddWithValue("@OBSERVACAO", Entity.OBSERVACAO); //Coluna //Retorno da Procedure FbParameter returnValue; returnValue = dbCommand.CreateParameter(); dbCommand.Parameters["@IDCFOP"].Direction = ParameterDirection.InputOutput; //Executando consulta dbCommand.ExecuteNonQuery(); result = int.Parse(dbCommand.Parameters["@IDCFOP"].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); }