private void TSBNovo_Click(object sender, EventArgs e) { if (VerificaPlanos()) { Entity = null; tabControlUsuario.SelectTab(0); cbFuncionario.Focus(); } }
private void DataGriewDados_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (LIS_USUARIOColl.Count > 0) { int rowindex = e.RowIndex; if (rowindex != -1) { int CodigoSelect = Convert.ToInt32(LIS_USUARIOColl[rowindex].IDUSUARIO); Entity = USUARIOP.Read(CodigoSelect); tabControlUsuario.SelectTab(0); txtNome.Focus(); } } }
private static USUARIOEntity FillEntityObject(ref FbDataReader DataReader) { USUARIOEntity entity = new USUARIOEntity(); FirebirdGetDbData getData = new FirebirdGetDbData(); entity.IDUSUARIO = getData.ConvertDBValueToInt32(DataReader, DataReader.GetOrdinal("IDUSUARIO")); entity.IDFUNCIONARIO = getData.ConvertDBValueToInt32Nullable(DataReader, DataReader.GetOrdinal("IDFUNCIONARIO")); entity.IDNIVELUSUARIO = getData.ConvertDBValueToInt32Nullable(DataReader, DataReader.GetOrdinal("IDNIVELUSUARIO")); entity.FLAGATIVO = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("FLAGATIVO")); entity.NOMEUSUARIO = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("NOMEUSUARIO")); entity.SENHAUSUARIO = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("SENHAUSUARIO")); entity.OBSERVACAO = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("OBSERVACAO")); return(entity); }
private void FrmProdutosMaisVendidos_Load(object sender, EventArgs e) { this.FormBorderStyle = FormBorderStyle.FixedDialog; btnPesquisa.Image = Util.GetAddressImage(20); btnImprimir.Image = Util.GetAddressImage(19); btnSair.Image = Util.GetAddressImage(21); bntDateSelecFinal.Image = Util.GetAddressImage(11); bntDateSelecInicial.Image = Util.GetAddressImage(11); msktDataInicial.Text = DateTime.Now.ToString("dd/MM/yyyy"); msktDataFinal.Text = DateTime.Now.ToString("dd/MM/yyyy"); GetFuncionario(); //Busca o Funcionario logado USUARIOEntity USUARIOTY = new USUARIOEntity(); USUARIOProvider USUARIOP = new USUARIOProvider(); USUARIOTY = USUARIOP.Read(FrmLogin._IdUsuario); cbFuncionario.SelectedValue = USUARIOTY.IDFUNCIONARIO; }
private void DataGriewDados_KeyDown(object sender, KeyEventArgs e) { if (LIS_USUARIOColl.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_USUARIOColl[indice].IDUSUARIO); if (e.KeyCode == Keys.Enter) { Entity = USUARIOP.Read(CodigoSelect); tabControlUsuario.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 { USUARIOP.Delete(CodigoSelect); Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue"); GetAllUsuario(); } catch (Exception) { MessageBox.Show(ConfigMessage.Default.MsgDeleteErro); } } } } }
private void Delete() { if (_IDUSUARIO == -1) { MessageBox.Show(ConfigMessage.Default.MsgSelecRegistro); tabControlUsuario.SelectTab(1); } else if (_IDUSUARIO == 1) { MessageBox.Show("O Usuário Administrador não é possível excluir!"); tabControlUsuario.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 { USUARIOP.Delete(_IDUSUARIO); Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue"); Entity = null; GetAllUsuario(); } catch (Exception ex) { MessageBox.Show(ConfigMessage.Default.MsgDeleteErro); MessageBox.Show("Erro técnico: " + ex.Message); } } } }
private void FrmServicoCliente_Load(object sender, EventArgs e) { this.MinimizeBox = false; this.FormBorderStyle = FormBorderStyle.FixedDialog; bntDateSelec.Image = Util.GetAddressImage(11); bntDateSelecFinal.Image = Util.GetAddressImage(11); btnPesquisa.Image = Util.GetAddressImage(20); btnImprimir.Image = Util.GetAddressImage(19); btnSair.Image = Util.GetAddressImage(21); btnpdf.Image = Util.GetAddressImage(17); btnExcel.Image = Util.GetAddressImage(18); btnPrint.Image = Util.GetAddressImage(19); btnpdf2.Image = Util.GetAddressImage(17); btnExcel2.Image = Util.GetAddressImage(18); btnPrint2.Image = Util.GetAddressImage(19); GetDropProdutos(); GetDropGrupoCategoria(); GetDropMarca(); GetDropCliente(); GetFuncionario(); mkdDataInicial.Text = DateTime.Now.ToString("dd/MM/yyyy"); mkdDataFinal.Text = DateTime.Now.ToString("dd/MM/yyyy"); //Busca o Funcionario logado USUARIOEntity USUARIOTY = new USUARIOEntity(); USUARIOProvider USUARIOP = new USUARIOProvider(); USUARIOTY = USUARIOP.Read(FrmLogin._IdUsuario); cbFuncionario.SelectedValue = USUARIOTY.IDFUNCIONARIO; }
public USUARIOEntity Read(int IDUSUARIO) { 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_USUARIO", dbCnn); dbCommand.Transaction = ((FbTransaction)(dbTransaction)); } else { if (dbCnn == null) { dbCnn = ((FbConnection)GetConnectionDB()); } if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand("Rea_USUARIO", dbCnn); dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted); } dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.Parameters.AddWithValue("@IDUSUARIO", IDUSUARIO); //PrimaryKey reader = dbCommand.ExecuteReader(); USUARIOEntity 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(USUARIOEntity 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_USUARIO", dbCnn); dbCommand.Transaction = ((FbTransaction)(dbTransaction)); } else { if (dbCnn == null) { dbCnn = ((FbConnection)GetConnectionDB()); } if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand("Sav_USUARIO", dbCnn); dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted); } dbCommand.CommandType = CommandType.StoredProcedure; if (Entity.IDUSUARIO != -1) { dbCommand.Parameters.AddWithValue("@IDUSUARIO", Entity.IDUSUARIO); //PrimaryKey } else { dbCommand.Parameters.AddWithValue("@IDUSUARIO", DBNull.Value); //PrimaryKey } dbCommand.Parameters.AddWithValue("@IDFUNCIONARIO", Entity.IDFUNCIONARIO); //Coluna dbCommand.Parameters.AddWithValue("@IDNIVELUSUARIO", Entity.IDNIVELUSUARIO); //Coluna dbCommand.Parameters.AddWithValue("@FLAGATIVO", Entity.FLAGATIVO); //Coluna dbCommand.Parameters.AddWithValue("@NOMEUSUARIO", Entity.NOMEUSUARIO); //Coluna dbCommand.Parameters.AddWithValue("@SENHAUSUARIO", Entity.SENHAUSUARIO); //Coluna dbCommand.Parameters.AddWithValue("@OBSERVACAO", Entity.OBSERVACAO); //Coluna //Retorno da Procedure FbParameter returnValue; returnValue = dbCommand.CreateParameter(); dbCommand.Parameters["@IDUSUARIO"].Direction = ParameterDirection.InputOutput; //Executando consulta dbCommand.ExecuteNonQuery(); result = int.Parse(dbCommand.Parameters["@IDUSUARIO"].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); }