Exemplo n.º 1
0
        public int RetirarMedicamento(MedicamentoRetirado medRetirado)
        {
            SqlCommand command = new SqlCommand();

            command.Connection  = Conexao.connection;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "retirarMedicamento";

            command.Parameters.AddWithValue("@Nome_Med", medRetirado.Nome_Med);
            command.Parameters.AddWithValue("@Qtde_Reti_Med", medRetirado.Qtde_Reti_Med);
            command.Parameters.AddWithValue("@Id_Med", medRetirado.Id_Med);
            command.Parameters.AddWithValue("@Id_Usuario", medRetirado.Id_Usuario);

            Conexao.Conectar();

            int ver = 0;

            try
            {
                ver = command.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                Conexao.Desconectar();
            }

            return(ver);
        }
Exemplo n.º 2
0
        public List <MedicamentoRetirado> ListarMedicamentosRetirados(int id)
        {
            SqlCommand command = new SqlCommand();

            command.Connection  = Conexao.connection;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "listarMedicamentosRetirados";

            command.Parameters.AddWithValue("@Id_Usuario", id);

            try
            {
                Conexao.Conectar();

                var reader       = command.ExecuteReader();
                var medRetirados = new List <MedicamentoRetirado>();

                while (reader.Read())
                {
                    var medRetirado = new MedicamentoRetirado();

                    medRetirado.Nome_Med      = reader["Nome_Med"].ToString();
                    medRetirado.Qtde_Reti_Med = Convert.ToInt32(reader["Qtde_Reti_Med"]);

                    medRetirados.Add(medRetirado);
                }

                return(medRetirados);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                Conexao.Desconectar();
            }
        }
Exemplo n.º 3
0
        private void btnRetirar_Click(object sender, EventArgs e)
        {
            if (txtQtde.Text == "" || string.IsNullOrEmpty(txtQtde.Text))
            {
                MessageBox.Show("Preencha o campo corretamente!");
                return;
            }

            medRetiradoController = new MedicamentoRetiradoController();

            int qtdeMedReti = Convert.ToInt32(txtQtde.Text);

            if (qtdeMed - qtdeMedReti < 0)
            {
                MessageBox.Show("Quantidade de remédios insuficiente. Quantidade restante: " + qtdeMed);
                return;
            }

            medRetirado = new MedicamentoRetirado
            {
                Nome_Med      = txtNomeMed.Text,
                Qtde_Reti_Med = qtdeMedReti,
                Id_Med        = idMed,
                Id_Usuario    = idUsu
            };

            if (medRetiradoController.RetirarMedicamento(medRetirado) != 0)
            {
                MessageBox.Show("Retirada feita com sucesso!");
                frmPrincipal.CarregarMedicamentos();
                frmPrincipal.Focus();
                this.Close();
            }
            else
            {
            }
        }
Exemplo n.º 4
0
        private string ConstruirLinha(MedicamentoRetirado med)
        {
            string qtde = med.Qtde_Reti_Med.ToString();

            return(med.Nome_Med + new string(' ', 30 - med.Nome_Med.Length - qtde.Length) + qtde);
        }