Esempio n. 1
0
        private void Delete()
        {
            if (_IDHELPDESK == -1)
            {
                MessageBox.Show(ConfigMessage.Default.MsgSelecRegistro);
                tabControlHelpDesk.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
                    {
                        HELPDESKP.Delete(_IDHELPDESK);
                        Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue");
                        Entity = null;
                        btnPesquisa_Click(null, null);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show(ConfigMessage.Default.MsgDeleteErro);
                    }
                }
            }
        }
Esempio n. 2
0
        private void txtCodAtendimento_KeyDown(object sender, KeyEventArgs e)
        {
            if ((Control.ModifierKeys == Keys.Control) &&
                (e.KeyCode == Keys.E))
            {
                if (!ValidacoesLibrary.ValidaTipoInt32(txtCodAtendimento.Text))
                {
                    errorProvider1.SetError(txtCodAtendimento, ConfigMessage.Default.FieldErro);
                    MessageBox.Show(ConfigMessage.Default.FieldErro);
                    txtCodAtendimento.Focus();
                }
                else
                {
                    errorProvider1.SetError(txtCodAtendimento, "");

                    HELPDESKEntity HELPDESKCons = new HELPDESKEntity();
                    HELPDESKCons = HELPDESKP.Read(Convert.ToInt32(txtCodAtendimento.Text));

                    if (HELPDESKCons != null)
                    {
                        Entity = HELPDESKCons;
                        MessageBox.Show(ConfigMessage.Default.MsgSearchSucess);
                    }
                    else
                    {
                        MessageBox.Show(ConfigMessage.Default.MsgSearchErro);
                    }
                }

                e.SuppressKeyPress = true;
            }
        }
Esempio n. 3
0
        private void DataGriewDados_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (LIS_HELPDESKColl.Count > 0)
            {
                int rowindex = e.RowIndex;
                if (rowindex != -1)
                {
                    int CodigoSelect = Convert.ToInt32(LIS_HELPDESKColl[rowindex].IDHELPDESK);

                    Entity = HELPDESKP.Read(CodigoSelect);

                    tabControlHelpDesk.SelectTab(0);
                    txtCodAtendimento.Focus();
                }
            }
        }
Esempio n. 4
0
        private void DataGriewDados_KeyDown(object sender, KeyEventArgs e)
        {
            if (LIS_HELPDESKColl.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_HELPDESKColl[indice].IDHELPDESK);

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

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

                    if (dr == DialogResult.Yes)
                    {
                        try
                        {
                            HELPDESKP.Delete(CodigoSelect);
                            Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue");
                            btnPesquisa_Click(null, null);
                        }
                        catch (Exception)
                        {
                            MessageBox.Show(ConfigMessage.Default.MsgDeleteErro);
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        private static HELPDESKEntity FillEntityObject(ref FbDataReader DataReader)
        {
            HELPDESKEntity entity = new HELPDESKEntity();

            FirebirdGetDbData getData = new FirebirdGetDbData();

            entity.IDHELPDESK          = getData.ConvertDBValueToInt32(DataReader, DataReader.GetOrdinal("IDHELPDESK"));
            entity.DATAINCLUSAO        = getData.ConvertDBValueToDateTimeNullable(DataReader, DataReader.GetOrdinal("DATAINCLUSAO"));
            entity.DATASOLUCAO         = getData.ConvertDBValueToDateTimeNullable(DataReader, DataReader.GetOrdinal("DATASOLUCAO"));
            entity.IDTIPOSOLICITANTE   = getData.ConvertDBValueToInt32Nullable(DataReader, DataReader.GetOrdinal("IDTIPOSOLICITANTE"));
            entity.IDDEPARTAMENTO      = getData.ConvertDBValueToInt32Nullable(DataReader, DataReader.GetOrdinal("IDDEPARTAMENTO"));
            entity.IDSTATUS            = getData.ConvertDBValueToInt32Nullable(DataReader, DataReader.GetOrdinal("IDSTATUS"));
            entity.IDPRIORIDADE        = getData.ConvertDBValueToInt32Nullable(DataReader, DataReader.GetOrdinal("IDPRIORIDADE"));
            entity.IDFUNCIONARIO       = getData.ConvertDBValueToInt32Nullable(DataReader, DataReader.GetOrdinal("IDFUNCIONARIO"));
            entity.NOMESOLICITANTE     = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("NOMESOLICITANTE"));
            entity.EMAILSOLICITANTE    = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("EMAILSOLICITANTE"));
            entity.TELEFONESOLICITANTE = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("TELEFONESOLICITANTE"));
            entity.SOLICITACAO         = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("SOLICITACAO"));
            entity.SOLUCAO             = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("SOLUCAO"));


            return(entity);
        }
Esempio n. 6
0
 private void TSBNovo_Click(object sender, EventArgs e)
 {
     Entity = null;
     tabControlHelpDesk.SelectTab(0);
     txtnomeSolicitante.Focus();
 }
Esempio n. 7
0
 private void novoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Entity = null;
     tabControlHelpDesk.SelectTab(0);
     txtnomeSolicitante.Focus();
 }
Esempio n. 8
0
        public HELPDESKEntity Read(int IDHELPDESK)
        {
            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_HELPDESK", dbCnn);
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = ((FbConnection)GetConnectionDB());
                    }

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

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

                dbCommand.CommandType = CommandType.StoredProcedure;

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


                reader = dbCommand.ExecuteReader();

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

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

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

                dbCommand.CommandType = CommandType.StoredProcedure;


                if (Entity.IDHELPDESK != -1)
                {
                    dbCommand.Parameters.AddWithValue("@IDHELPDESK", Entity.IDHELPDESK); //PrimaryKey
                }
                else
                {
                    dbCommand.Parameters.AddWithValue("@IDHELPDESK", DBNull.Value);                    //PrimaryKey
                }
                dbCommand.Parameters.AddWithValue("@DATAINCLUSAO", Entity.DATAINCLUSAO);               //Coluna
                dbCommand.Parameters.AddWithValue("@DATASOLUCAO", Entity.DATASOLUCAO);                 //Coluna
                dbCommand.Parameters.AddWithValue("@IDTIPOSOLICITANTE", Entity.IDTIPOSOLICITANTE);     //Coluna
                dbCommand.Parameters.AddWithValue("@IDDEPARTAMENTO", Entity.IDDEPARTAMENTO);           //Coluna
                dbCommand.Parameters.AddWithValue("@IDSTATUS", Entity.IDSTATUS);                       //Coluna
                dbCommand.Parameters.AddWithValue("@IDPRIORIDADE", Entity.IDPRIORIDADE);               //Coluna
                dbCommand.Parameters.AddWithValue("@IDFUNCIONARIO", Entity.IDFUNCIONARIO);             //Coluna
                dbCommand.Parameters.AddWithValue("@NOMESOLICITANTE", Entity.NOMESOLICITANTE);         //Coluna
                dbCommand.Parameters.AddWithValue("@EMAILSOLICITANTE", Entity.EMAILSOLICITANTE);       //Coluna
                dbCommand.Parameters.AddWithValue("@TELEFONESOLICITANTE", Entity.TELEFONESOLICITANTE); //Coluna
                dbCommand.Parameters.AddWithValue("@SOLICITACAO", Entity.SOLICITACAO);                 //Coluna
                dbCommand.Parameters.AddWithValue("@SOLUCAO", Entity.SOLUCAO);                         //Coluna



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

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


                //Executando consulta
                dbCommand.ExecuteNonQuery();

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