public Entidades.Medicamento obtenerMedicamento(decimal idMed)
 {
     Entidades.Medicamento m = new Entidades.Medicamento();
     try
     {
         string        sqlSelect = "SELECT * FROM MEDICAMENTO WHERE ID_MCTOS = " + idMed;
         OracleCommand cmd       = Datos.Conexion.conectar().CreateCommand();
         cmd.CommandText = sqlSelect;
         cmd.CommandType = CommandType.Text;
         OracleDataReader dr = cmd.ExecuteReader();
         while (dr.Read())
         {
             m.idMedicamento     = Convert.ToDecimal(dr["ID_MCTOS"]);
             m.nombreComercial   = dr["NOMBRE_COMERCIAL"].ToString();
             m.laboratorio       = dr["LABORATORIO"].ToString();
             m.ean13             = dr["EAN13"].ToString();
             m.formaFarmaceutica = dr["FORMA_FARMACEUTICA"].ToString();
             m.stock             = Convert.ToDecimal(dr["STOCK"]);
             m.idSucursal        = Convert.ToDecimal(dr["SUCURSAL_ID"]);
         }
         return(m);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Beispiel #2
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";
     }
 }
Beispiel #3
0
        public void enviarCorreo(List <string> emails, Entidades.Medicamento m)
        {
            SmtpClient SmtpServer = new SmtpClient();

            SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "cesfamduoc");
            SmtpServer.Port        = 587;
            SmtpServer.Host        = "smtp.gmail.com";
            SmtpServer.EnableSsl   = true;
            MailMessage mail = new MailMessage();

            try
            {
                mail.From    = new MailAddress("*****@*****.**", "Farmacia Cesfam", System.Text.Encoding.UTF8);
                mail.Subject = "Llegaron Medicamentos!";
                mail.Body    = "Se le informa que el medicamento " + m.nombreComercial + " que tenia reservado acaba de llegar, se pide que valla a retirar lo más pronto posible, antes de que se le de prioridad a otra persona. Este correo fue generado automaticamente, porfavor no intente responderlo, Atte. Cesfam";
                mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
                foreach (var item in emails)
                {
                    mail.Bcc.Add(item);
                }
                mail.Bcc.Add("*****@*****.**");
                SmtpServer.Send(mail);
            }
            catch (Exception)
            {
            }
        }
 public bool consultarSiExiste(Entidades.Medicamento med)
 {
     try
     {
         Entidades.Medicamento m = new Entidades.Medicamento();
         string        sqlInsert = "SELECT * FROM MEDICAMENTO WHERE NOMBRE_COMERCIAL = '" + med.nombreComercial + "' AND LABORATORIO = '" + med.laboratorio + "' AND EAN13 = '" + med.ean13 + "' AND FORMA_FARMACEUTICA = '" + med.formaFarmaceutica + "'";
         OracleCommand cmd       = Datos.Conexion.conectar().CreateCommand();
         cmd.CommandText = sqlInsert;
         cmd.CommandType = CommandType.Text;
         OracleDataReader dr = cmd.ExecuteReader();
         while (dr.Read())
         {
             m.idMedicamento     = Convert.ToDecimal(dr["ID_MCTOS"]);
             m.nombreComercial   = dr["NOMBRE_COMERCIAL"].ToString();
             m.laboratorio       = dr["LABORATORIO"].ToString();
             m.ean13             = dr["EAN13"].ToString();
             m.formaFarmaceutica = dr["FORMA_FARMACEUTICA"].ToString();
             m.stock             = Convert.ToDecimal(dr["STOCK"]);
             m.idSucursal        = Convert.ToDecimal(dr["SUCURSAL_ID"]);
         }
         if (m.nombreComercial.Equals(med.nombreComercial) && m.laboratorio.Equals(med.laboratorio) && m.ean13.Equals(med.ean13) && m.formaFarmaceutica.Equals(med.formaFarmaceutica))
         {
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #5
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";
     }
 }
Beispiel #6
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)
     {
     }
 }
Beispiel #7
0
 public bool consularSiExiste(Entidades.Medicamento med)
 {
     try
     {
         Datos.MedicamentoDB mdb = new Datos.MedicamentoDB();
         if (mdb.consultarSiExiste(med) == true)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #8
0
 public bool agregarMedicamento(Entidades.Medicamento m)
 {
     try
     {
         Datos.MedicamentoDB mdb = new Datos.MedicamentoDB();
         if (mdb.AgregarMed(m))
         {
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         return(false);
     }
 }
 public bool eliminarMed(Entidades.Medicamento med)
 {
     try
     {
         string        sqlInsert = "DELETE FROM MEDICAMENTO WHERE ID_MCTOS = " + med.idMedicamento;
         OracleCommand cmd       = Datos.Conexion.conectar().CreateCommand();
         cmd.CommandText = sqlInsert;
         cmd.CommandType = CommandType.Text;
         cmd.ExecuteNonQuery();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
 public bool modificarMed(Entidades.Medicamento med)
 {
     try
     {
         string        sqlSelect = "UPDATE MEDICAMENTO SET STOCK = " + med.stock + " WHERE ID_MCTOS = " + med.idMedicamento;
         OracleCommand cmd       = Datos.Conexion.conectar().CreateCommand();
         cmd.CommandText = sqlSelect;
         cmd.CommandType = CommandType.Text;
         cmd.ExecuteNonQuery();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #11
0
 private void ExportToPdf(DataGrid grid)
 {
     try
     {
         PdfPTable table       = new PdfPTable(grid.Columns.Count);
         Document  pdfcommande = new Document(iTextSharp.text.PageSize.A4.Rotate(), 6, 3, 3, 3);
         string    Directorio  = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
         PdfWriter writer      = PdfWriter.GetInstance(pdfcommande, new FileStream(Directorio + "\\Informe Medicamentos.pdf", FileMode.Create));
         pdfcommande.Open();
         iTextSharp.text.Paragraph firstpara  = new iTextSharp.text.Paragraph("Informe de Medicamentos");
         iTextSharp.text.Paragraph firstpara2 = new iTextSharp.text.Paragraph(" ");
         foreach (DataGridColumn column in grid.Columns)
         {
             table.AddCell(new Phrase(column.Header.ToString()));
         }
         table.HeaderRows = 1;
         IEnumerable itemsSource = grid.ItemsSource as IEnumerable;
         if (itemsSource != null)
         {
             foreach (var item in itemsSource)
             {
                 Entidades.Medicamento m = new Entidades.Medicamento();
                 m = (Entidades.Medicamento)item;
                 if (m != null)
                 {
                     table.AddCell(new Phrase(m.idMedicamento.ToString()));
                     table.AddCell(new Phrase(m.nombreComercial));
                     table.AddCell(new Phrase(m.laboratorio));
                     table.AddCell(new Phrase(m.ean13));
                     table.AddCell(new Phrase(m.formaFarmaceutica));
                     table.AddCell(new Phrase(m.stock.ToString()));
                     table.AddCell(new Phrase(m.idSucursal.ToString()));
                 }
             }
             pdfcommande.Add(firstpara);
             pdfcommande.Add(firstpara2);
             pdfcommande.Add(table);
             pdfcommande.Close();
             writer.Close();
             MessageBox.Show("Informe creado y enviado a escritorio en formato pdf");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("No se pudo Crear el informe");
     }
 }
 public bool AgregarMed(Entidades.Medicamento med)
 {
     try
     {
         string sqlInsert = "INSERT INTO MEDICAMENTO (ID_MCTOS, NOMBRE_COMERCIAL, LABORATORIO, EAN13, FORMA_FARMACEUTICA, STOCK, SUCURSAL_ID) "
                            + "VALUES (SEQ_MEDICAMENTO.NEXTVAL, '" + med.nombreComercial + "', '" + med.laboratorio + "', '" + med.ean13 + "', '" + med.formaFarmaceutica + "', " + med.stock + ", '10000')";
         OracleCommand cmd = Datos.Conexion.conectar().CreateCommand();
         cmd.CommandText = sqlInsert;
         cmd.CommandType = CommandType.Text;
         cmd.ExecuteNonQuery();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #13
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)
     {
     }
 }
Beispiel #14
0
 private void enviarInformes(Entidades.Medicamento m)
 {
     try
     {
         Negocio.PrescripcionN pn     = new Negocio.PrescripcionN();
         Negocio.Validadores   v      = new Negocio.Validadores();
         List <string>         emails = new List <string>();
         foreach (var item in pn.obtenerReservadas(m.idMedicamento))
         {
             if (item.email.Trim() != string.Empty)
             {
                 emails.Add(item.email);
             }
         }
         v.enviarCorreo(emails, m);
     }
     catch (Exception)
     {
     }
 }
Beispiel #15
0
 public Entidades.Medicamento obtenerMedicamento(decimal idMed)
 {
     try
     {
         Datos.MedicamentoDB   mdb = new Datos.MedicamentoDB();
         Entidades.Medicamento m   = new Entidades.Medicamento();
         m = mdb.obtenerMedicamento(idMed);
         if (m != null)
         {
             return(m);
         }
         else
         {
             return(null);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
Beispiel #16
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";
     }
 }
 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)
     {
     }
 }