Example #1
0
 private void btnEliminar_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Negocio.MedicamentoN  mn = new Negocio.MedicamentoN();
         Entidades.Medicamento m  = new Entidades.Medicamento();
         //Cargar valores
         m = (Entidades.Medicamento)cboLisElim.SelectedItem;
         if (mn.eliminarMedicamento(m))
         {
             txtNomCoElim.Text        = "";
             txtLabElim.Text          = "";
             txtEANElim.Text          = "";
             txtFFElim.Text           = "";
             txtStockElim.Text        = "";
             cboLisElim.SelectedIndex = -1;
             lblMesjElim.Content      = "";
             MessageBox.Show("Elminado Correctamente");
         }
         else
         {
             lblMesjAgregar.Content = "Error al eliminar, intente de nuevo";
         }
     }
     catch (Exception)
     {
         lblMesjAgregar.Content = "Error al eliminar, informe a soporte";
     }
 }
Example #2
0
 private void btnAumentar_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Entidades.Medicamento  m   = new Entidades.Medicamento();
         Negocio.MedicamentoN   mn  = new Negocio.MedicamentoN();
         Entidades.ControlStock cs  = new Entidades.ControlStock();
         Negocio.ControlStockN  csn = new Negocio.ControlStockN();
         if (txtNomCCAu.Text.Trim() != string.Empty && txtDesCCAu.Text.Trim() != string.Empty && txtCanCCAu.Text.Trim() != string.Empty)
         {
             //Se carga Medicamento
             m.idMedicamento     = Convert.ToDecimal(lblIdMedAu.Content);
             m.nombreComercial   = txtNomCoAu.Text.ToLower();
             m.laboratorio       = txtLabAu.Text.ToLower();
             m.ean13             = txtEANAu.Text.ToLower();
             m.formaFarmaceutica = txtFFAu.Text.ToLower();
             m.stock             = Convert.ToDecimal(txtStockAu.Text);
             m.idSucursal        = 10000;
             //Se carga Control Stock
             cs.nombre        = txtNomCCAu.Text;
             cs.descripcion   = txtDesCCAu.Text;
             cs.fecha         = System.DateTime.Now;
             cs.cantidad      = Convert.ToDecimal(txtCanCCAu.Text);
             cs.idMedicamento = m.idMedicamento;
             cs.idUsuario     = this.rut;
             //Enviar datos
             decimal cantidad = m.stock + cs.cantidad;
             m.stock = cantidad;
             if (csn.insertarCS(cs))
             {
                 if (mn.modificarMedicamento(m))
                 {
                     MessageBox.Show("Aumentado correctamente");
                     txtNomCoAu.Text        = "";
                     txtLabAu.Text          = "";
                     txtEANAu.Text          = "";
                     txtFFAu.Text           = "";
                     txtStockAu.Text        = "";
                     cboAuMed.SelectedIndex = -1;
                     txtCanCCAu.Text        = "";
                     txtDesCCAu.Text        = "";
                     txtNomCCAu.Text        = "";
                     lblMsjAumen.Content    = "";
                     enviarInformes(m);
                 }
             }
         }
         else
         {
             lblMsjAumen.Content = "No pueden haber campos vacíos";
         }
     }
     catch (Exception)
     {
         lblMsjAumen.Content = "Error al Aumentar";
     }
 }
Example #3
0
 private void listarMedicamentos()
 {
     try
     {
         Negocio.MedicamentoN mn = new Negocio.MedicamentoN();
         dgListarMed.ItemsSource = mn.listarTodos();
     }
     catch (Exception)
     {
         MessageBox.Show("Ocurrio un error al listar");
     }
 }
Example #4
0
 private void llenarcboMedElim()
 {
     Negocio.MedicamentoN  mn = new Negocio.MedicamentoN();
     Entidades.Medicamento m  = new Entidades.Medicamento();
     try
     {
         cboLisElim.ItemsSource       = mn.listarTodos();
         cboLisElim.DisplayMemberPath = "nombreComercial";
         cboLisElim.SelectedValuePath = "idMedicamento";
     }
     catch (Exception)
     {
     }
 }
Example #5
0
 private void cboLisElim_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         Negocio.MedicamentoN  mn = new Negocio.MedicamentoN();
         Entidades.Medicamento m  = new Entidades.Medicamento();
         m = (Entidades.Medicamento)cboLisElim.SelectedItem;
         //Cargar datos txt
         m = mn.obtenerMedicamento(m.idMedicamento);
         txtNomCoElim.Text = m.nombreComercial;
         txtLabElim.Text   = m.laboratorio;
         txtEANElim.Text   = m.ean13;
         txtFFElim.Text    = m.formaFarmaceutica;
         txtStockElim.Text = m.stock.ToString();
     }
     catch (Exception)
     {
     }
 }
Example #6
0
 private void btnAgregar_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Negocio.MedicamentoN  mn = new Negocio.MedicamentoN();
         Entidades.Medicamento m  = new Entidades.Medicamento();
         //Cargar valores
         if (txtNomCoAgre.Text.Trim() != string.Empty && txtLabAgre.Text.Trim() != string.Empty && txtEANAgre.Text.Trim() != string.Empty && txtFFAgre.Text.Trim() != string.Empty && txtStockAgre.Text.Trim() != string.Empty)
         {
             m.nombreComercial   = txtNomCoAgre.Text.ToLower();
             m.laboratorio       = txtLabAgre.Text.ToLower();
             m.ean13             = txtEANAgre.Text.ToLower();
             m.formaFarmaceutica = txtFFAgre.Text.ToLower();
             m.stock             = Convert.ToDecimal(txtStockAgre.Text);
             m.idSucursal        = 10000;
             if (mn.consularSiExiste(m) != true)
             {
                 mn.agregarMedicamento(m);
                 txtNomCoAgre.Text = "";
                 txtLabAgre.Text   = "";
                 txtEANAgre.Text   = "";
                 txtFFAgre.Text    = "";
                 txtStockAgre.Text = "";
                 MessageBox.Show("Agregado Correctamente");
             }
             else
             {
                 lblMesjAgregar.Content = "Este medicamento ya existe";
             }
         }
         else
         {
             lblMesjAgregar.Content = "No puede dejar campos vacíos";
         }
     }
     catch (Exception)
     {
         lblMesjAgregar.Content = "Error al agregar, informe a soporte";
     }
 }
Example #7
0
 private void btnGuardarPres_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Entidades.PrescripcionPersonalizada pr = new Entidades.PrescripcionPersonalizada();
         Negocio.PrescripcionN  pn = new Negocio.PrescripcionN();
         Entidades.Prescripcion p  = new Entidades.Prescripcion();
         Negocio.MedicamentoN   mn = new Negocio.MedicamentoN();
         Entidades.Medicamento  m  = new Entidades.Medicamento();
         pr       = (Entidades.PrescripcionPersonalizada)dgPrescrip.SelectedItem;
         p        = pn.obtenerPres(pr.idPrescripcion);
         p.estado = valorDgCboEstado;
         if (p != null && p.estado != "Emitido" && valorDgCboEstado.Trim() != string.Empty)
         {
             if (p.estado == "Completado")
             {
                 m = mn.obtenerMedicamento(p.idMedicamento);
                 if (m.stock >= p.cantidad)
                 {
                     if (pn.modificarPres(p))
                     {
                         decimal cantidad = m.stock - pr.cantidad;
                         m.stock = cantidad;
                         if (mn.modificarMedicamento(m) == true)
                         {
                             MessageBox.Show("Exito al Completar");
                             valorDgCboEstado = "";
                             llenarGrid();
                         }
                     }
                 }
                 else
                 {
                     MessageBox.Show("No se puede completar porque el medicamento no tiene la cantidad requerida, recomiende reservar");
                     valorDgCboEstado = "";
                     llenarGrid();
                 }
             }
             else if (p.estado == "Reservar")
             {
                 if (pn.modificarPres(p))
                 {
                     MessageBox.Show("Exito al reservar");
                     valorDgCboEstado = "";
                     llenarGrid();
                 }
             }
             else if (p.estado == "Cancelar")
             {
                 if (pn.modificarPres(p))
                 {
                     MessageBox.Show("Exito al Cancelar");
                     valorDgCboEstado = "";
                     llenarGrid();
                 }
             }
         }
     }
     catch (Exception)
     {
     }
 }