Пример #1
0
        public string Buscar(Diario d)
        {
            try
            {
                OpenConnection();

                Cmd = new SqlCommand("BuscarDia", Con);
                Cmd.CommandType = CommandType.StoredProcedure;

                Cmd.Parameters.AddWithValue("@Data", d.Data.Replace("00:00:00", ""));

                Dr = Cmd.ExecuteReader();

                List<Diario> dados = new List<Diario>();

                while (Dr.Read())
                {
                    d.Diary = Dr.GetString(0);
                    dados.Add(d);
                }

                return d.Diary;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                CloseConnection();
            }
        }
Пример #2
0
        private void opcao(options enmOptions)
        {
            Diario d = new Diario();
            DiarioDAL dd = new DiarioDAL();

            d.Diary = txtDiario.Text;
            d.Data = txtBusca.Text;

            switch (enmOptions)
            {
                case options.Insert:
                    if (!dd.Editar(d))
                    {
                        dd.Salvar(d);
                        lblRetorno.Text = "Salvo com sucesso";
                    }
                    else
                    {
                        dd.Editar(d);
                        lblRetorno.Text = "Alterado com sucesso";
                    }
                    break;
                case options.Search:
                    txtDiario.Text = dd.Buscar(d);
                    break;
                default:
                    lblRetorno.Text = "Ocorreu um erro no sistema!!!";
                    break;
            }
        }
Пример #3
0
        public bool Salvar(Diario d)
        {
            try
            {
                OpenConnection();

                Cmd = new SqlCommand("SalvarDia", Con);
                Cmd.CommandType = CommandType.StoredProcedure;

                Cmd.Parameters.AddWithValue("@Diario", d.Diary);
                Cmd.Parameters.AddWithValue("@Data", d.Data.Replace("00:00:00", ""));

                return Cmd.ExecuteNonQuery() > 0;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                CloseConnection();
            }
        }