Esempio n. 1
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            int id_med = int.Parse(lstMedicamentos.SelectedValue.ToString());

            medicine = new MedicamentoHelper().getByID(id_med);
            dgvMedicamentos.Rows.Add(id_med, medicine.Monodroga, medicine.Farmaco, txtFrecuencia.Text, txtDuracion.Text, medicine.Laboratorio);
        }
        public bool agregarMedicamento(clsMedicamento medicine)
        {
            string sql = "Insert into Medicamentos (monodroga, farmaco, laboratorio) "
                         + "values ('" + medicine.Monodroga + "', '" + medicine.Farmaco + "', '" + medicine.Laboratorio + "')";

            return(helper.consultaSQL(sql) == 1);
        }
        private clsMedicamento map_Medicamento(DataRow row)
        {
            clsMedicamento med = new clsMedicamento();

            med.Monodroga   = row["monodroga"].ToString();
            med.Farmaco     = row["farmaco"].ToString();
            med.Laboratorio = row["laboratorio"].ToString();
            return(med);
        }
        public clsMedicamento getByID(int id_med)
        {
            string    sql      = "Select * from Medicamentos where id=" + id_med.ToString();
            DataTable medicine = new DataTable();

            medicine = helper.consultaTabla_parametros(sql);
            if (medicine.Rows.Count > 0)
            {
                clsMedicamento medic = new clsMedicamento();
                medic = map_Medicamento(medicine.Rows[0]);
                return(medic);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 5
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (nv)
            {
                clsMedicamento medic = new clsMedicamento(txtMonodroga.Text, txtFarmaco.Text, txtLaboratorio.Text);
                if (medhelp.agregarMedicamento(medic))
                {
                    MessageBox.Show("Medicamento agregado", "Nuevo Medicamento", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            if (md)
            {
                new BDHelper().consultaSQL("UPDATE Medicamentos SET monodroga='" + txtMonodroga.Text + "',farmaco='" + txtFarmaco.Text + "',laboratorio='" + txtLaboratorio.Text + "' WHERE id=" + lstMedicamentos.SelectedValue.ToString());
            }

            nv = false;
            md = false;
            btnNuevo.Enabled     = true;
            btnModificar.Enabled = true;
            txtFarmaco.ResetText();
            deshabilitarBotones();
            new FunctionHelper().cargarListaSinEstado(lstMedicamentos, "Medicamentos", "id", "farmaco");
        }