void GuardarCompras()
 {
     if (txtNombre.Text == "")
     {
         MessageBox.Show("Ingresa un nombre");
     }
     else
     {
         if (txtComentario.Text == "")
         {
             MessageBox.Show("Ingresa una descripción");
         }
         else
         {
             if (cbbAlmacen.Text == "")
             {
                 MessageBox.Show("Selecciona un tipo de almacén");
             }
             else
             {
                 CATALOGO_MEDICAMENTOS med = new CATALOGO_MEDICAMENTOS()
                 {
                     NOMBRE_MEDI    = txtNombre.Text,
                     COMENTARIO     = txtComentario.Text,
                     ALMACEN        = cbbAlmacen.Text,
                     CANTIDAD       = 0,
                     U_MEDIDA       = txtUMedida.Text,
                     FECHA_CREACION = fechareg,
                     STATUS         = "Activo"
                 };
                 BaseDatos.GetBaseDatos().CATALOGO_MEDICAMENTOS.Add(med);
                 BaseDatos.GetBaseDatos().SaveChanges();
                 limpiar();
                 autoMedicamentos.ItemsSource = (from medi in BaseDatos.GetBaseDatos().CATALOGO_MEDICAMENTOS
                                                 where medi.STATUS == "Activo"
                                                 select new
                 {
                     ID_MEDICAMENTO = medi.ID_MEDICAMENTO,
                     NOMBRE = medi.NOMBRE_MEDI + " " + medi.COMENTARIO + " " + medi.U_MEDIDA
                 });
                 MessageBox.Show("Registro exitoso");
                 this.Close();
             }
         }
     }
 }
 void Guardar()
 {
     if (txtNombre.Text == "")
     {
         MessageBox.Show("Ingresa un nombre");
     }
     else
     {
         if (txtComentario.Text == "")
         {
             MessageBox.Show("Ingresa una descripción");
         }
         else
         {
             if (cbbAlmacen.Text == "")
             {
                 MessageBox.Show("Selecciona un tipo de almacén");
             }
             else
             {
                 CATALOGO_MEDICAMENTOS med = new CATALOGO_MEDICAMENTOS()
                 {
                     NOMBRE_MEDI    = txtNombre.Text,
                     COMENTARIO     = txtComentario.Text,
                     ALMACEN        = cbbAlmacen.Text,
                     CANTIDAD       = 0,
                     U_MEDIDA       = txtUMedida.Text,
                     FECHA_CREACION = fechareg,
                     STATUS         = "Activo"
                 };
                 BaseDatos.GetBaseDatos().CATALOGO_MEDICAMENTOS.Add(med);
                 BaseDatos.GetBaseDatos().SaveChanges();
                 limpiar();
                 MessageBox.Show("Registro exitoso");
             }
         }
     }
 }
Exemplo n.º 3
0
        void GuardarMedicamento()
        {
            if (txtNombre.Text == "")
            {
                MessageBox.Show("Ingresa un medicamento");
            }
            else
            {
                if (txtComentario.Text == "")
                {
                    MessageBox.Show("Ingresa una descripción");
                }
                else
                {
                    if (txtCantidad.Text == "")
                    {
                        MessageBox.Show("Ingresa una cantidad");
                    }
                    else
                    {
                        if (txtCodBarras.Text == "" && txtCodBarras.Text.Length < 13)
                        {
                            MessageBox.Show("Ingresa un código de barras válido");
                        }
                        else
                        {
                            if (txtPCompra.Text == "")
                            {
                                MessageBox.Show("Ingresa el precio de compra");
                            }
                            else
                            {
                                if (txtPVenta.Text == "")
                                {
                                    MessageBox.Show("Ingresa el precio de venta");
                                }
                                else
                                {
                                    if (txtPMedicos.Text == "")
                                    {
                                        MessageBox.Show("Ingresa el precio para médicos");
                                    }
                                    else
                                    {
                                        if (txtUMedida.Text == "")
                                        {
                                            MessageBox.Show("Selecciona una unidad de medida");
                                        }
                                        else
                                        {
                                            if (txtCFDI.Text == "" && txtCFDI.Text.Length < 8)
                                            {
                                                MessageBox.Show("Ingresa un CFDI válido");
                                            }
                                            else
                                            {
                                                if (cbbAlmacen.Text == "")
                                                {
                                                    MessageBox.Show("Selecciona el tipo de almacén");
                                                }
                                                else
                                                {
                                                    DateTime fec = DateTime.Now;


                                                    CATALOGO_MEDICAMENTOS cm = new CATALOGO_MEDICAMENTOS
                                                    {
                                                        NOMBRE_MEDI    = txtNombre.Text,
                                                        CANTIDAD       = Int32.Parse(txtCantidad.Text),
                                                        COMENTARIO     = txtComentario.Text,
                                                        P_VENTA        = Decimal.Parse(txtPVenta.Text),
                                                        P_COMPRA       = Decimal.Parse(txtPCompra.Text),
                                                        P_MEDICOS      = Decimal.Parse(txtPMedicos.Text),
                                                        CADUCIDAD      = dpCaducidad.SelectedDate,
                                                        FECHA_CREACION = fec,
                                                        COD_BARRAS     = txtCodBarras.Text,
                                                        U_MEDIDA       = txtUMedida.Text,
                                                        CFDI           = Int32.Parse(txtCFDI.Text),
                                                        ALMACEN        = cbbAlmacen.Text
                                                    };
                                                    BaseDatos.GetBaseDatos().CATALOGO_MEDICAMENTOS.Add(cm);
                                                    BaseDatos.GetBaseDatos().SaveChanges();
                                                    MessageBoxResult result = MessageBox.Show("Se guardó correctamente el medicamento", "Registro exitoso");
                                                    Limpiar();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }