Example #1
0
        public async Task <IActionResult> PutFarmaco([FromRoute] int id, [FromBody] Farmaco farmaco)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != farmaco.Id)
            {
                return(BadRequest());
            }

            _context.Entry(farmaco).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FarmacoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #2
0
        private void btnconferma_Click(object sender, EventArgs e)
        {
            if (MyLibrary.Posizione(farmaci, num, txbcodice.Text) == -1)
            {
                farmaci[num] = new Farmaco
                {
                    categoria   = txbtipologia.Text,
                    codice      = txbcodice.Text,
                    descrizione = txbdescrizione.Text,
                    età         = int.Parse(txbanni.Text),
                    nome        = txbnome.Text,
                    prezzo      = decimal.Parse(txbprezzo.Text),
                    quantità    = int.Parse(txbquantita.Text),
                    scadenza    = DateTime.Parse(txbdata.Text)
                };

                num++;
            }
            else
            {
                farmaci[MyLibrary.Posizione(farmaci, num, txbcodice.Text)] = new Farmaco
                {
                    categoria   = txbtipologia.Text,
                    codice      = txbcodice.Text,
                    descrizione = txbdescrizione.Text,
                    età         = int.Parse(txbanni.Text) * int.Parse(txbmesi.Text),
                    nome        = txbnome.Text,
                    prezzo      = decimal.Parse(txbprezzo.Text),
                    quantità    = int.Parse(txbquantita.Text),
                    scadenza    = DateTime.Parse(txbdata.Text)
                };
            }

            Clean(this);
        }
Example #3
0
        public IActionResult Edit(int id, [Bind("Id,Nombre_Farmaco,Cantidad_Disponible,Precio_Unitario")] Farmaco farmaco)
        {
            //if (id != farmaco.Id)
            //{
            //    return NotFound();
            //}

            //if (ModelState.IsValid)
            //{
            //    try
            //    {
            //        _context.Update(farmaco);
            //        await _context.SaveChangesAsync();
            //    }
            //    catch (DbUpdateConcurrencyException)
            //    {
            //        if (!FarmacoExists(farmaco.Id))
            //        {
            //            return NotFound();
            //        }
            //        else
            //        {
            //            throw;
            //        }
            //    }
            //    return RedirectToAction(nameof(Index));
            //}
            //return View(farmaco);
            return(RedirectToAction(nameof(Index)));
        }
Example #4
0
        public Farmaco ObtenerFarmaco(int linea)
        {
            Farmaco farmaco = new Farmaco();
            string  line    = File.ReadLines(path).Skip(linea + 1).Take(1).First();

            return(farmaco);
        }
Example #5
0
        public IActionResult AgregarPedido2(int id, [Bind("Id,NombreDelCliente,Dirrecion,Nit,Cantidad")] PedidosFarmacos ProductModel)
        {
            ProductModel.Id = F.id;
            Farmaco nuevo = new Farmaco();

            nuevo = F.List2.Find(m => m.Id == ProductModel.Id);
            if (nuevo.Existencia < ProductModel.Cantidad)
            {
                return(RedirectToAction("ErrorCantidad", "Farmacoes"));
            }

            ProductModel.Nombre = F.nombre;
            F.Nit               = ProductModel.Nit;
            F.Nombrecliente     = ProductModel.NombreDelCliente;
            F.dirrecion         = ProductModel.Dirrecion;
            ProductModel.Precio = nuevo.Precio;
            F.Pedidos.Add(ProductModel);

            F.List2.Find(m => m.Id == ProductModel.Id).Existencia = nuevo.Existencia - ProductModel.Cantidad;
            if (nuevo.Existencia == 0)
            {
                var llave = F.Arbol_Farmacos.Find(new LlaveArbol {
                    Nombre_Farmaco = nuevo.Nombre_Farmaco
                });
                F.Arbol_Farmacos.RemoveAt(llave);
            }
            return(RedirectToAction("Index", "PedidosFarmacos"));
        }
Example #6
0
        private Encargo GenerarEncargo(DTO.Encargo encargo)
        {
            var cliente  = _clientesRepository.GetOneOrDefaultById(encargo.Cliente ?? 0);
            var vendedor = _vendedoresRepository.GetOneOrDefaultById(encargo.Vendedor ?? 0);

            var farmacoEncargado = default(Farmaco);
            var farmaco          = _farmacoRepository.GetOneOrDefaultById(encargo.Farmaco ?? 0);

            if (farmaco != null)
            {
                var pcoste = farmaco.PrecioUnicoEntrada.HasValue && farmaco.PrecioUnicoEntrada != 0
                    ? (decimal)farmaco.PrecioUnicoEntrada.Value * _factorCentecimal
                    : ((decimal?)farmaco.PrecioMedio ?? 0m) * _factorCentecimal;

                //var proveedor = _proveedorRepository.GetOneOrDefaultByCodigoNacional(farmaco.Id);
                var proveedor = _proveedorRepository.GetOneOrDefaultById(encargo.Proveedor);

                var categoria = farmaco.CategoriaId.HasValue
                    ? _categoriaRepository.GetOneOrDefaultById(farmaco.CategoriaId.Value)
                    : null;

                var subcategoria = farmaco.CategoriaId.HasValue && farmaco.SubcategoriaId.HasValue
                    ? _categoriaRepository.GetSubcategoriaOneOrDefaultByKey(
                    farmaco.CategoriaId.Value,
                    farmaco.SubcategoriaId.Value)
                    : null;

                var familia     = _familiaRepository.GetOneOrDefaultById(farmaco.Familia);
                var laboratorio = _laboratorioRepository.GetOneOrDefaultByCodigo(farmaco.Laboratorio);

                farmacoEncargado = new Farmaco
                {
                    Id           = farmaco.Id,
                    Codigo       = encargo.Farmaco.ToString(),
                    PrecioCoste  = pcoste,
                    Proveedor    = proveedor,
                    Categoria    = categoria,
                    Subcategoria = subcategoria,
                    Familia      = familia,
                    Laboratorio  = laboratorio,
                    Denominacion = farmaco.Denominacion,
                    Precio       = farmaco.PVP * _factorCentecimal,
                    Stock        = farmaco.ExistenciasAux ?? 0
                };
            }

            return(new Encargo
            {
                Id = encargo.Id,
                Fecha = encargo.FechaHora ?? DateTime.MinValue,
                FechaEntrega = encargo.FechaHoraEntrega,
                Farmaco = farmacoEncargado,
                Cantidad = encargo.Cantidad,
                Cliente = cliente,
                Vendedor = vendedor,
                Observaciones = encargo.Observaciones
            });
        }
Example #7
0
        public void HasName()
        {
            string name = "nome";

            Farmaco f = new Farmaco();

            f.Nome = name;

            Assert.IsNotNull(f.Nome);
        }
Example #8
0
        public void HasId()
        {
            int id = 1;

            Farmaco f = new Farmaco();

            f.Id = id;

            Assert.IsNotNull(f.Id);
        }
Example #9
0
 public Reporte(int idReporte, Pacient paciente, Service servicio, Farmaco farmaco, Presentacion presentacion, int cantidad, int consumo)
 {
     this.idReporte    = idReporte;
     this.paciente     = paciente;
     this.servicio     = servicio;
     this.farmaco      = farmaco;
     this.presentacion = presentacion;
     this.cantidad     = cantidad;
     this.consumo      = consumo;
 }
Example #10
0
        // METODO DE LISTAR REPORTE
        public List <Reporte> ListReporte()
        {
            List <Reporte> list       = new List <Reporte>();
            SqlConnection  connection = null;
            SqlCommand     command    = null;
            SqlDataReader  reader     = null;

            // instancias
            Pacient      paciente;
            Service      service;
            Farmaco      farmaco;
            Presentacion presentacion;

            try
            {
                connection          = Connection.GetInstance().ConnectionDB();
                command             = new SqlCommand("SP_LISTREPORTES", connection);
                command.CommandType = CommandType.StoredProcedure;
                connection.Open();
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    paciente     = new Pacient();
                    service      = new Service();
                    farmaco      = new Farmaco();
                    presentacion = new Presentacion();

                    Reporte objReporte = new Reporte();
                    objReporte.Paciente     = new Pacient();
                    objReporte.Servicio     = new Service();
                    objReporte.Farmaco      = new Farmaco();
                    objReporte.Presentacion = new Presentacion();

                    objReporte.IdReporte                   = DBHelper.ReadNullSafeInt(reader["idReporte"].ToString());
                    objReporte.Paciente.IdPacient          = DBHelper.ReadNullSafeInt(reader["paciente"].ToString());
                    objReporte.Servicio.IdService          = DBHelper.ReadNullSafeInt(reader["servicio"].ToString());
                    objReporte.Farmaco.idVademecum         = DBHelper.ReadNullSafeInt(reader["farmaco"].ToString());
                    objReporte.Presentacion.idPresentacion = DBHelper.ReadNullSafeInt(reader["presentacion"].ToString());
                    objReporte.Cantidad = DBHelper.ReadNullSafeInt(reader["cantidad"].ToString());

                    // AGREGANDO A LA LISTA
                    list.Add(objReporte);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                connection.Close();
            }
            return(list);
        }
Example #11
0
 public bool InsertFarmaco(Farmaco objFarmaco)
 {
     try
     {
         return(FarmacoConnection.GetInstance().InsertFarmaco(objFarmaco));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #12
0
 public bool InsertFarmaco(Farmaco objFarmaco)
 {
     try
     {
         FarmacoBL internadoBL = new FarmacoBL();
         return(internadoBL.InsertFarmaco(objFarmaco));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #13
0
        public async Task <IActionResult> PostFarmaco([FromBody] Farmaco farmaco)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Farmaco.Add(farmaco);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetFarmaco", new { id = farmaco.Id }, farmaco));
        }
Example #14
0
 public ApresentacaoDTO(Apresentacao a, Medicamento m, Farmaco f, Posologia p)
 {
     id                    = a.ApresentacaoId;
     forma_adm             = a.forma_adm;
     concentracao          = a.dosagem + "mg";
     qtd                   = a.quantidade + "ml";
     farmaco               = f.principio_ativo;
     medicamento           = m.nome;
     dose                  = p.dose.ToString();
     via_administracao     = p.via_administracao;
     intervalo_tempo_horas = p.intervalo_tempo_horas.ToString();
     periodo_tempo_dias    = p.periodo_tempo_dias.ToString();
 }
Example #15
0
        protected void Button1_Click(object sender, EventArgs e)

        {
            int Id = Convert.ToInt32(TextBoxId.Text);

            string Nombre = TextBoxNombre.Text;

            string Descripcion = TextBoxDescripcion.Text;

            int Valor = Convert.ToInt32(TextBoxPrecio.Text);

            int Cantidad = Convert.ToInt32(TextBoxCantidad.Text);



            if (!Id.Equals("") && !Nombre.Equals("") && !Descripcion.Equals("")

                && !Valor.Equals("") && !Cantidad.Equals(""))

            {
                Farmaco farmaco = new Farmaco(Id, Nombre,

                                              Descripcion, Valor, Cantidad);

                if (FarmacoDAO.Agregar(farmaco) == true)

                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Bien, datos agregados correctamente" + "');", true);

                    LabelOk.Text = "Datos agregados correctamente";

                    LabelError.Text = "";
                }

                else

                {
                    LabelOk.Text = "";

                    LabelError.Text = "Error, Farmaco ya existe";
                }
            }

            else

            {
                LabelOk.Text = "";

                LabelError.Text = "Error, hay campos vacios";
            }
        }
Example #16
0
        //GET
        public IActionResult AgregarPedido(int?Id)
        {
            F.id = Convert.ToInt32(Id);
            Farmaco nuevo = new Farmaco();

            nuevo    = F.List2.Find(m => m.Id == Id);
            F.nombre = nuevo.Nombre_Farmaco;

            if (F.Nit == 0)
            {
                return(RedirectToAction("AgregarPedido2", "Farmacoes"));
            }
            return(View());
        }
Example #17
0
        public ActionResult Index(FormCollection collection)
        {
            string         name       = collection["search"];
            List <Farmaco> resultados = new List <Farmaco>();
            Farmaco        resultado  = Storage.Instance.Indice.Search(new Farmaco {
                Nombre = name
            }, Farmaco.CompararNombre);

            if (resultado != null)
            {
                resultados.Add(resultado);
            }
            return(View("Resultados", resultados));
        }
Example #18
0
        private Farmaco GetValues()
        {
            Farmaco objFarmaco = new Farmaco
            {
                idVademecum       = 0,
                num_registro      = DBHelper.ReadNullSafeString(txtNumRegistro.Text),
                nombre_comercial  = DBHelper.ReadNullSafeString(txtNombreComercial.Text),
                nombre_clinico    = DBHelper.ReadNullSafeString(txtNombreClinico.Text),
                compuesto_quimico = DBHelper.ReadNullSafeString(txtCompuestoQuimico.Text),
                ubicacion         = DBHelper.ReadNullSafeString(txtUbicacion.Text),
                proveedor         = DBHelper.ReadNullSafeString(txtProveedor.Text)
            };

            return(objFarmaco);
        }
Example #19
0
        private void btncerca_Click(object sender, EventArgs e)
        {
            int newNum = 0;

            Farmaco[] newFarmaci = new Farmaco[arraySize];
            for (int i = 0; i < num; i++)
            {
                if (farmaci[i].codice.Contains(txbcerca.Text))
                {
                    newFarmaci[newNum] = farmaci[i];
                    newNum++;
                }
            }
            MyLibrary.Aggiorna(newFarmaci, newNum, listView1);
        }
        public Medicamento GenerarMedicamento(Farmaco farmaco)
        {
            var familia      = !string.IsNullOrWhiteSpace(farmaco.Familia?.Nombre) ? farmaco.Familia.Nombre : FAMILIA_DEFAULT;
            var superFamilia = !string.IsNullOrWhiteSpace(farmaco.SuperFamilia?.Nombre) ? farmaco.SuperFamilia.Nombre : FAMILIA_DEFAULT;

            var categoria = farmaco.Categoria?.Nombre;

            if (_verCategorias == "si" && !string.IsNullOrWhiteSpace(categoria) && categoria.ToLower() != "sin categoria" && categoria.ToLower() != "sin categoría")
            {
                if (string.IsNullOrEmpty(superFamilia) || superFamilia == FAMILIA_DEFAULT)
                {
                    superFamilia = categoria;
                }
                else
                {
                    superFamilia = $"{superFamilia} ~~~~~~~~ {categoria}";
                }
            }

            return(new Medicamento
            {
                cod_barras = !string.IsNullOrEmpty(farmaco.CodigoBarras) ? farmaco.CodigoBarras : "847000" + farmaco.Codigo.PadLeft(6, '0'),
                cod_nacional = farmaco.Codigo,
                nombre = farmaco.Denominacion,
                familia = familia,
                superFamilia = superFamilia,
                precio = farmaco.Precio,
                descripcion = farmaco.Denominacion,
                laboratorio = farmaco.Laboratorio?.Codigo ?? "0",
                nombre_laboratorio = farmaco.Laboratorio?.Nombre ?? LABORATORIO_DEFAULT,
                proveedor = farmaco.Proveedor?.Nombre ?? string.Empty,
                pvpSinIva = farmaco.PrecioSinIva(),
                iva = (int)farmaco.Iva,
                stock = farmaco.Stock,
                puc = farmaco.PrecioCoste,
                stockMinimo = farmaco.StockMinimo,
                stockMaximo = farmaco.StockMaximo,
                categoria = farmaco.Categoria?.Nombre ?? string.Empty,
                ubicacion = farmaco.Ubicacion ?? string.Empty,
                presentacion = string.Empty,
                descripcionTienda = string.Empty,
                activoPrestashop = !farmaco.Baja,
                fechaCaducidad = farmaco.FechaCaducidad,
                fechaUltimaCompra = farmaco.FechaUltimaCompra,
                fechaUltimaVenta = farmaco.FechaUltimaVenta,
                baja = farmaco.Baja,
            });
        }
Example #21
0
 public IActionResult Create([Bind("Id,Nombre_Farmaco,Cantidad_Disponible,Precio_Unitario")] Farmaco farmaco)
 {
     if (ModelState.IsValid)
     {
         F.List2.Add(farmaco);
         var numFila    = F.List2.Count() - 1;
         var LlaveArbol = new LlaveArbol
         {
             Nombre_Farmaco = farmaco.Nombre_Farmaco,
             Fila           = numFila
         };
         F.Arbol_Farmacos.Add(LlaveArbol);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(farmaco));
 }
Example #22
0
 //Se debe cambiar la ruta del archivo para que no ocurran errores en la carga.
 public void AbrirArchivo()
 {
     try
     {
         using (StreamReader lector = new StreamReader(Storage.Instance.dir))
         {
             Storage.Instance.Farmacos = lector.ReadToEnd();
         }
         Storage.Instance.ListadoFarmacos = Storage.Instance.Farmacos.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
         string[] text = (string[])Storage.Instance.ListadoFarmacos.Clone();
         Storage.Instance.Indice.Clear();
         for (int i = 1; i < text.Length; i++)
         {
             if (text[i] != "")
             {
                 Farmaco nuevo = new Farmaco
                 {
                     ID = Int32.Parse(text[i].Substring(0, text[i].IndexOf(",")))
                 };
                 text[i] = text[i].Remove(0, text[i].IndexOf(",") + 1);
                 if (text[i].IndexOf('\"') == 0)
                 {
                     text[i]      = text[i].Remove(0, 1);
                     nuevo.Nombre = text[i].Substring(0, text[i].IndexOf('\"'));
                 }
                 else
                 {
                     nuevo.Nombre = text[i].Substring(0, text[i].IndexOf(','));
                 }
                 text[i]        = text[i].Substring(text[i].LastIndexOf(',') + 1);
                 nuevo.Cantidad = Int32.Parse(text[i]);
                 if (nuevo.Cantidad > 0)
                 {
                     Storage.Instance.Indice.Add(nuevo, Farmaco.CompararNombre);
                 }
                 else
                 {
                     Storage.Instance.SinExistencias.Add(nuevo, Farmaco.CompararNombre);
                 }
             }
         }
     }
     catch
     {
     }
 }
Example #23
0
        protected void ButtonModificar_Click(object sender, EventArgs e)

        {
            int Id = Convert.ToInt32(TextBoxId.Text);

            string Nombre = TextBoxNombre.Text;

            string Descripcion = TextBoxDescripcion.Text;

            int Valor = Convert.ToInt32(TextBoxPrecio.Text);

            int Cantidad = Convert.ToInt32(TextBoxCantidad.Text);



            if (!Id.Equals("") && !Nombre.Equals("") && !Descripcion.Equals("")

                && !Valor.Equals("") && !Cantidad.Equals(""))

            {
                Farmaco farmaco = new Farmaco(Id, Nombre,

                                              Descripcion, Valor, Cantidad);



                if (FarmacoDAO.Modificar(farmaco) == true)

                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Bien, datos modificados" + "');", true);

                    LabelOk.Text = "Bien, farmaco modificado exitosamente.";
                }

                else

                {
                    LabelOk.Text = "";

                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Error, datos no modificados" + "');", true);

                    LabelError.Text = "Error, farmaco no existe con ese Id";
                }
            }
        }
Example #24
0
        protected void BtnInsert_Click(object sender, EventArgs e)
        {
            // REGISTRO DE VADEMECUM
            Farmaco   objFarmaco = GetValues();
            WSFarmaco wsfarmaco  = new WSFarmaco();
            bool      response   = wsfarmaco.InsertFarmaco(objFarmaco);

            if (response)
            {
                this.divSuccess.Visible = true;
                this.TextSuccess.Text   = "¡Fármaco creado con éxito!";
            }
            else
            {
                this.divError.Visible = true;
                this.TextError.Text   = "¡El fármaco no fue creado!";
            }
        }
Example #25
0
        public MedicamentoP GenerarMedicamentoP(Farmaco farmaco)
        {
            _clasificacion = !string.IsNullOrWhiteSpace(ConfiguracionPredefinida[Configuracion.FIELD_TIPO_CLASIFICACION])
                ? ConfiguracionPredefinida[Configuracion.FIELD_TIPO_CLASIFICACION]
                : TIPO_CLASIFICACION_DEFAULT;

            var familia    = farmaco.Familia?.Nombre ?? FAMILIA_DEFAULT;
            var familiaAux = _clasificacion == TIPO_CLASIFICACION_CATEGORIA ? familia : string.Empty;

            familia = _clasificacion == TIPO_CLASIFICACION_CATEGORIA ? farmaco.Subcategoria?.Nombre ?? farmaco.Categoria?.Nombre ?? FAMILIA_DEFAULT : familia;

            return(new MedicamentoP
            {
                cod_barras = (farmaco.CodigoBarras ?? "847000" + farmaco.Codigo.PadLeft(6, '0')).Strip(),
                cod_nacional = farmaco.Id.ToString(),
                nombre = farmaco.Denominacion.Strip(),
                familia = familia.Strip(),
                precio = (float)farmaco.Precio,
                descripcion = farmaco.Denominacion.Strip(),
                laboratorio = (farmaco.Laboratorio?.Codigo ?? "0").Strip(),
                nombre_laboratorio = (farmaco.Laboratorio?.Nombre ?? LABORATORIO_DEFAULT).Strip(),
                proveedor = (farmaco.Proveedor?.Nombre ?? string.Empty).Strip(),
                pvpSinIva = (float)farmaco.PrecioSinIva(),
                iva = (int)farmaco.Iva,
                stock = farmaco.Stock,
                puc = (float)farmaco.PrecioCoste,
                stockMinimo = farmaco.StockMinimo,
                stockMaximo = 0,
                categoria = (farmaco.Categoria?.Nombre ?? string.Empty).Strip(),
                subcategoria = (farmaco.Subcategoria?.Nombre ?? string.Empty).Strip(),
                web = farmaco.Web.ToInteger(),
                ubicacion = (farmaco.Ubicacion ?? string.Empty).Strip(),
                presentacion = string.Empty,
                descripcionTienda = string.Empty,
                activoPrestashop = (!farmaco.Baja).ToInteger(),
                familiaAux = familiaAux,
                fechaCaducidad = farmaco.FechaCaducidad?.ToDateInteger("yyyyMM") ?? 0,
                fechaUltimaCompra = farmaco.FechaUltimaCompra.ToIsoString(),
                fechaUltimaVenta = farmaco.FechaUltimaVenta.ToIsoString(),
                baja = farmaco.Baja.ToInteger(),
                actualizadoPS = 1
            });
        }
        public ActionResult Reabastecer(int id)
        {
            try
            {
                for (int i = 0; i < Storage.Instance.ListadoFarmacos.Length; i++)
                {
                    if (Storage.Instance.ListadoFarmacos[i] != "")
                    {
                        if (id == Int32.Parse(Storage.Instance.ListadoFarmacos[i].Substring(0, 1)))
                        {
                            string aux  = Storage.Instance.ListadoFarmacos[i];
                            string aux2 = "";
                            while (aux.Contains(";"))
                            {
                                aux2 += aux.Substring(0, aux.IndexOf(";") + 1);
                                aux   = aux.Remove(0, aux.IndexOf(";") + 1);
                            }
                            if (Int32.Parse(aux) == 0)
                            {
                                Random rnd           = new Random();
                                int    nuevaCantidad = rnd.Next(1, 16);
                                aux2 += nuevaCantidad.ToString();
                                Storage.Instance.ListadoFarmacos[i] = aux2;
                                Farmaco nuevo = new Farmaco();
                                aux2         = aux2.Remove(0, aux2.IndexOf(";") + 1);
                                nuevo.Nombre = aux2.Substring(0, aux2.IndexOf(";"));
                                Farmaco temporal = Storage.Instance.SinExistencias.Remove(nuevo, Farmaco.CompararNombre);
                                temporal.Cantidad = nuevaCantidad;
                                Storage.Instance.Indice.Add(temporal, Farmaco.CompararNombre);
                            }
                        }
                    }
                }
                Sobreescribir();
            }
            catch
            {
            }


            return(RedirectToAction("Index"));
        }
        public void HasFarmaco()
        {
            int     id   = 1;
            string  nome = "n";
            Farmaco f    = new Farmaco();

            f.Id = id;

            f.Nome = nome;

            Apresentacao a = new Apresentacao();

            a.Farmaco = f;

            a.FarmacoId = id;

            Assert.IsNotNull(a.Farmaco);

            Assert.AreEqual(a.FarmacoId, a.Farmaco.Id);
        }
Example #28
0
        public static Boolean Agregar(Farmaco farmaco)

        {
            Boolean estado = true;

            string sCnn;

            try

            {
                Conexion c = new Conexion();

                sCnn = c.conectar();



                string sSel = "insert into FARMACO (ID_FARMACO, NOMBRE_FARMACO, DESC_FARMACO, VALOR_FARMACO, CANTIDAD_FARMACO) values(" +

                              farmaco.Id + ",'" + farmaco.Nombre + "','" + farmaco.Descripcion + "','" + farmaco.Valor +

                              "','" + farmaco.Cantidad + "');";

                SqlDataAdapter da;

                DataTable dt = new DataTable();

                da = new SqlDataAdapter(sSel, sCnn);

                da.Fill(dt);
            }

            catch (Exception e)

            {
                estado = false;
            }



            return(estado);
        }
Example #29
0
        public static Boolean Modificar(Farmaco farmaco)

        {
            Boolean estado = true;

            try

            {
                Conexion c = new Conexion();

                string sCnn = c.conectar();



                string sSel = "update FARMACO set  NOMBRE_FARMACO='" + farmaco.Nombre +

                              "',DESC_FARMACO='" + farmaco.Descripcion + "',VALOR_FARMACO='" + farmaco.Valor +

                              "',CANTIDAD_FARMACO='" + farmaco.Cantidad + "' where ID_FARMACO=" +

                              farmaco.Id + ";";

                SqlDataAdapter da;

                DataTable dt = new DataTable();



                da = new SqlDataAdapter(sSel, sCnn);

                da.Fill(dt);
            }

            catch (Exception e)

            {
                estado = false;
            }

            return(estado);
        }
Example #30
0
        protected void ButtonBuscar_Click(object sender, EventArgs e)

        {
            int Id = Convert.ToInt32(TextBoxId.Text);



            if (!Id.Equals(""))

            {
                Farmaco farmaco = FarmacoDAO.Buscar(Id);



                if (farmaco != null)

                {
                    TextBoxId.Text = farmaco.Id.ToString();

                    TextBoxNombre.Text = farmaco.Nombre;

                    TextBoxDescripcion.Text = farmaco.Descripcion;

                    TextBoxPrecio.Text = farmaco.Valor.ToString();

                    TextBoxCantidad.Text = farmaco.Cantidad.ToString();

                    LabelOk.Text = "Busqueda exitosa";
                }

                else

                {
                    LabelOk.Text = "";

                    LabelError.Text = "Error, farmaco no existe con ese Id";

                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Error, Id no existe" + "');", true);
                }
            }
        }