Пример #1
0
        public List <ItemConformidade> Listar()
        {
            try
            {
                using (MySqlCommand comando = _connection.Buscar().CreateCommand())
                {
                    List <ItemConformidade> items = new List <ItemConformidade>();
                    comando.CommandType = CommandType.Text;
                    comando.CommandText = "SELECT COD_ITEM,ITEM,COD_CHECKLIST,STATUS FROM ITEM_CONFORMIDADE WHERE STATUS <> 9;";
                    MySqlDataReader leitor = comando.ExecuteReader();

                    while (leitor.Read())
                    {
                        ItemConformidade item = new ItemConformidade();
                        item.CodigoItem      = Int16.Parse(leitor["COD_ITEM"].ToString());
                        item.Item            = leitor["ITEM"].ToString();
                        item.CodigoCheckList = Int16.Parse(leitor["COD_CHECKLIST"].ToString());
                        item.Status          = Int16.Parse(leitor["STATUS"].ToString());

                        items.Add(item);
                    }

                    return(items);
                }
            }
            catch (MySqlException)
            {
                throw;
            }
            finally
            {
                _connection.Fechar();
            }
        }
Пример #2
0
        public long Inserir(ItemConformidade item)
        {
            try
            {
                using (MySqlCommand comando = _connection.Buscar().CreateCommand())
                {
                    comando.CommandType = CommandType.Text;
                    comando.CommandText = "INSERT INTO ITEM_CONFORMIDADE (ITEM,COD_CHECKLIST) VALUES (@ITEM,@COD_CHECKLIST);";

                    comando.Parameters.Add("@ITEM", MySqlDbType.Text).Value           = item.Item;
                    comando.Parameters.Add("@COD_CHECKLIST", MySqlDbType.Int16).Value = item.CodigoCheckList;

                    if (comando.ExecuteNonQuery() > 0)
                    {
                        return(comando.LastInsertedId);
                    }
                    return(-1);
                }
            }
            catch (MySqlException)
            {
                throw;
            }
            finally
            {
                _connection.Fechar();
            }
        }