public ActionResult NuevoLaboratorioPOST(Laboratorios infoLaboratorio)
        {
            string mensajesLaboratorios          = string.Empty;
            MensajesLaboratorios msjLaboratorios = new MensajesLaboratorios();

            try
            {
                LaboratoriosAccDatos objLaboratoriosActivosAccDatos = new LaboratoriosAccDatos((string)Session["NickUsuario"]);
                msjLaboratorios = objLaboratoriosActivosAccDatos.RegistrarLaboratorio(infoLaboratorio);
                if (msjLaboratorios.OperacionExitosa)
                {
                    mensajesLaboratorios = string.Format("El laboratorio \"{0}\" ha sido registrado exitosamente.", infoLaboratorio.NombreLaboratorio);
                    TempData["Mensaje"]  = mensajesLaboratorios;
                    Logs.Info(mensajesLaboratorios);
                }
                else
                {
                    mensajesLaboratorios     = string.Format("No se ha podido registrar el laboratorio \"{0}\": {1}", infoLaboratorio.NombreLaboratorio, msjLaboratorios.MensajeError);
                    TempData["MensajeError"] = mensajesLaboratorios;
                    Logs.Error(mensajesLaboratorios);
                }
            }
            catch (Exception e)
            {
                Logs.Error(string.Format("{0}: {1}", mensajesLaboratorios, e.Message));
                return(View());
            }
            return(RedirectToAction("ModificarLaboratorio", "Laboratorios"));
        }
예제 #2
0
        private void GuardarButton_Click(object sender, EventArgs e)
        {
            if (Validacion())
            {
                var lab = new Laboratorios();

                lab.FechaIngreso = DateTime.Now;
                lab.Nombre       = nombreTextBox.Text;
                if (LaboratoriosBLL.GetLista(Utilidades.StringToInt(laboratorioIdTextBox.Text)).Count() == 0)
                {
                    if (LaboratoriosBLL.Insertar(lab))
                    {
                        MessageBox.Show("Se guardo el laboratorio");
                    }

                    else
                    {
                        MessageBox.Show("Error al guardar");
                    }
                }
                else
                {
                    LaboratoriosBLL.Modificar(Utilidades.StringToInt(laboratorioIdTextBox.Text), lab);
                    MessageBox.Show("Se modifico el laboratorio");
                }
            }
        }
        public ActionResult ModificarEstadoLaboratorio(Laboratorios infoLaboratorio)
        {
            string mensajesLaboratorios          = string.Empty;
            MensajesLaboratorios msjLaboratorios = new MensajesLaboratorios();

            try
            {
                LaboratoriosAccDatos objLaboratoriosAccDatos = new LaboratoriosAccDatos((string)Session["NickUsuario"]);
                msjLaboratorios = objLaboratoriosAccDatos.ActualizarLaboratorio(infoLaboratorio, true);
                if (msjLaboratorios.OperacionExitosa)
                {
                    mensajesLaboratorios = string.Format("El laboratorio con ID: {0} ha sido modificado correctamente.", infoLaboratorio.IdLaboratorio);
                    Logs.Info(mensajesLaboratorios);
                }
                else
                {
                    mensajesLaboratorios = string.Format("No se ha podido actualizar el laboratorio con ID: {0}: {1}", infoLaboratorio.IdLaboratorio, msjLaboratorios.MensajeError);
                    Logs.Error(mensajesLaboratorios);
                }
            }
            catch (Exception e)
            {
                Logs.Error(string.Format("{0}: {1}", mensajesLaboratorios, e.Message));
            }
            return(Json(msjLaboratorios, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("LaboratorioId,Nombre")] Laboratorios laboratorios)
        {
            if (id != laboratorios.LaboratorioId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(laboratorios);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LaboratoriosExists(laboratorios.LaboratorioId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(laboratorios));
        }
예제 #5
0
        public async Task <IActionResult> Post([FromBody] Laboratorios model)
        {
            try
            {
                var currentUser = await userManager.FindByNameAsync(User.Identity.Name);

                var newModel = new Laboratorios()
                {
                    Id            = model.Id,
                    pacienteId    = model.pacienteId,
                    Fecharegistro = DateTime.Now,
                    Tipolabo      = model.Tipolabo,
                    user          = currentUser
                };
                clinicaRepositorio.AddLaboratorio(newModel);
                if (clinicaRepositorio.SaveAll())
                {
                    /*   return Created($"/api/order/{Newmodel.Id}", Newmodel);*/
                    var results = new
                    {
                        ruta = $"{newModel.Id}"
                    };
                    return(Created("", results));
                }
            }
            catch (Exception ex)
            {
                logger.LogError($"Fallo al Guardar Paciente:{ex}");
            }

            return(BadRequest("Fallo al Guardar Paciente"));
        }
예제 #6
0
        /// <summary>
        /// Método para actualizar un Laboratorio en la base de datos.
        /// </summary>
        /// <param name="infoLaboratorio"></param>
        /// <returns></returns>
        public MensajesLaboratorios ActualizacionLaboratorio(Laboratorios infoLaboratorio)
        {
            MensajesLaboratorios msjLaboratorios = new MensajesLaboratorios();

            try
            {
                NpgsqlTransaction tran = conn_BD.BeginTransaction();
                using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE dcicc_laboratorios set nombre_laboratorio = @nl,descripcion_laboratorio=@dl,ubicacion_laboratorio=@ul,habilitado_laboratorio = @hl where id_laboratorio = @il", conn_BD))
                {
                    cmd.Parameters.Add("nl", NpgsqlTypes.NpgsqlDbType.Varchar).Value = infoLaboratorio.NombreLaboratorio.Trim();
                    cmd.Parameters.Add("ul", NpgsqlTypes.NpgsqlDbType.Varchar).Value = infoLaboratorio.UbicacionLaboratorio.Trim();
                    cmd.Parameters.Add("dl", NpgsqlTypes.NpgsqlDbType.Varchar).Value = !string.IsNullOrEmpty(infoLaboratorio.DescripcionLaboratorio) ? (object)infoLaboratorio.DescripcionLaboratorio.Trim() : DBNull.Value;
                    cmd.Parameters.Add("hl", NpgsqlTypes.NpgsqlDbType.Boolean).Value = infoLaboratorio.HabilitadoLaboratorio;
                    cmd.Parameters.Add("il", NpgsqlTypes.NpgsqlDbType.Integer).Value = infoLaboratorio.IdLaboratorio;
                    cmd.ExecuteNonQuery();
                }
                tran.Commit();
                conn_BD.Close();
                msjLaboratorios.OperacionExitosa = true;
            }
            catch (Exception e)
            {
                conn_BD.Close();
                msjLaboratorios.OperacionExitosa = false;
                msjLaboratorios.MensajeError     = e.Message;
            }
            return(msjLaboratorios);
        }
예제 #7
0
        /// <summary>
        /// Método para actualizar el estado de un Laboratorio en la base de datos.
        /// </summary>
        /// <param name="infoLaboratorio"></param>
        /// <returns></returns>
        public MensajesLaboratorios ActualizacionEstadoLaboratorio(Laboratorios infoLaboratorio)
        {
            MensajesLaboratorios msjLaboratorios = new MensajesLaboratorios();

            try
            {
                NpgsqlTransaction tran = conn_BD.BeginTransaction();
                using (NpgsqlCommand cmd = new NpgsqlCommand("UPDATE dcicc_laboratorios set habilitado_laboratorio = @hl where id_laboratorio = @il", conn_BD))
                {
                    cmd.Parameters.Add("hl", NpgsqlTypes.NpgsqlDbType.Boolean).Value = infoLaboratorio.HabilitadoLaboratorio;
                    cmd.Parameters.Add("il", NpgsqlTypes.NpgsqlDbType.Integer).Value = infoLaboratorio.IdLaboratorio;
                    cmd.ExecuteNonQuery();
                }
                tran.Commit();
                conn_BD.Close();
                msjLaboratorios.OperacionExitosa = true;
            }
            catch (Exception e)
            {
                conn_BD.Close();
                msjLaboratorios.OperacionExitosa = false;
                msjLaboratorios.MensajeError     = e.Message;
            }
            return(msjLaboratorios);
        }
예제 #8
0
        private void Buscarbutton_Click(object sender, EventArgs e)
        {
            Laboratorios lab = new Laboratorios();

            if (ValidarId("Ingrese el id de el laboratorio quiere buscar") && Search())
            {
                Fill(LaboratoriosBLL.Buscar(Utilidades.StringToInt(laboratorioIdTextBox.Text)));
            }
        }
예제 #9
0
 public void CrearLaboratorio(Laboratorios laboratorios)
 {
     using (var ctx = new DB_A66D31_intratecPrbEntities1())
     {
         laboratorios.FechaCreacion = DateTime.Now;
         ctx.Laboratorios.Add(laboratorios);
         ctx.SaveChanges();
     }
 }
예제 #10
0
        public async Task <IActionResult> Create([Bind("LaboratorioId,Nombre")] Laboratorios laboratorios)
        {
            if (ModelState.IsValid)
            {
                _context.Add(laboratorios);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(laboratorios));
        }
예제 #11
0
        public static void Modificar(int id, Laboratorios laboratorio)
        {
            using (var db = new FarmaciaDb())
            {
                var lab = new Laboratorios();
                lab = db.Laboratorio.Find(id);

                lab.Nombre = laboratorio.Nombre;
                db.SaveChanges();
            }
        }
예제 #12
0
        public static void Eliminar(int id)
        {
            using (var db = new FarmaciaDb())
            {
                var laboratorio = new Laboratorios();

                laboratorio = db.Laboratorio.Find(id);

                db.Laboratorio.Remove(laboratorio);
                db.SaveChanges();
            }
        }
예제 #13
0
        protected void imgBtnEdit_Click(object sender, ImageClickEventArgs e)
        {
            GridViewRow row = (GridViewRow)((ImageButton)sender).NamingContainer;

            _ElId.Text = grid.DataKeys[row.RowIndex].Values["Id"].ToString();

            Laboratorios obj = uow.LaboratoriosBL.GetByID(int.Parse(_ElId.Text));

            txtClave.Value  = obj.Clave;
            txtNombre.Value = obj.Nombre;


            _Accion.Text = "Modificar";
            ModoForma(true);
        }
예제 #14
0
        public MensajesLaboratorios ActualizarLaboratorio([FromBody] Laboratorios infoLaboratorio)
        {
            MensajesLaboratorios        msjLaboratorios = new MensajesLaboratorios();
            ActualizacionesLaboratorios objActualizacionesLaboratoriosActBD = new ActualizacionesLaboratorios();

            msjLaboratorios = objActualizacionesLaboratoriosActBD.ActualizacionLaboratorio(infoLaboratorio);
            if (msjLaboratorios.OperacionExitosa)
            {
                Logs.Info(string.Format("Actualización de Laboratorio con ID: {0} realizada exitosamente.", infoLaboratorio.IdLaboratorio));
            }
            else
            {
                Logs.Error(msjLaboratorios.MensajeError);
            }
            return(msjLaboratorios);
        }
예제 #15
0
        public MensajesLaboratorios RegistrarLaboratorio([FromBody] Laboratorios infoLaboratorio)
        {
            MensajesLaboratorios    msjLaboratorios = new MensajesLaboratorios();
            InsercionesLaboratorios objInsercionesLaboratoriosBD = new InsercionesLaboratorios();

            msjLaboratorios = objInsercionesLaboratoriosBD.RegistroLaboratorio(infoLaboratorio);
            if (msjLaboratorios.OperacionExitosa)
            {
                Logs.Info(string.Format("Registro de Laboratorio \"{0}\" realizado exitosamente.", infoLaboratorio.NombreLaboratorio));
            }
            else
            {
                Logs.Error(msjLaboratorios.MensajeError);
            }
            return(msjLaboratorios);
        }
예제 #16
0
        /// <summary>
        /// Método para actualizar un Laboratorio en la base de datos.
        /// </summary>
        /// <param name="infoLaboratorio"></param>
        /// <param name="actEstado">Boolean para definir si se actualizará solo el estado o todo el registro</param>
        /// <returns></returns>
        public MensajesLaboratorios ActualizarLaboratorio(Laboratorios infoLaboratorio, bool actEstado)
        {
            MensajesLaboratorios msjLaboratorios = new MensajesLaboratorios();

            try
            {
                var response = client_Service.PostAsJsonAsync(actEstado ? "Laboratorios/ActualizarEstadoLaboratorio" : "Laboratorios/ActualizarLaboratorio", infoLaboratorio).Result;
                if (response.IsSuccessStatusCode)
                {
                    var catJson = response.Content.ReadAsStringAsync().Result;
                    msjLaboratorios = JsonConvert.DeserializeObject <MensajesLaboratorios>(catJson);
                }
            }
            catch (Exception e)
            {
                Logs.Error(string.Format("Error en la conexión para actualizar un laboratorio: {0}" + e.Message));
            }
            return(msjLaboratorios);
        }
예제 #17
0
        public static bool Insertar(Laboratorios laboratorio)
        {
            bool retorno = false;

            try
            {
                using (var db = new FarmaciaDb())
                {
                    db.Laboratorio.Add(laboratorio);
                    db.SaveChanges();
                    db.Dispose();

                    retorno = true;
                }
            }catch (Exception)
            {
                throw;
            }

            return(retorno);
        }
예제 #18
0
        /// <summary>
        /// Método para obtener los Laboratorios de la base de datos.
        /// </summary>
        /// <param name="nombreFuncion">Tipo de función a llamar: consultalaboratorios o laboratorioshabilitados</param></param>
        /// <returns></returns>
        public MensajesLaboratorios ObtenerLaboratorios(string nombreFuncion)
        {
            List <Laboratorios>  lstLaboratorios = new List <Laboratorios>();
            MensajesLaboratorios msjLaboratorios = new MensajesLaboratorios();

            try
            {
                using (NpgsqlCommand cmd = new NpgsqlCommand(nombreFuncion, conn_BD))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    using (NpgsqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            Laboratorios objLaboratorios = new Laboratorios
                            {
                                IdLaboratorio          = (int)dr[0],
                                NombreLaboratorio      = dr[1].ToString().Trim(),
                                UbicacionLaboratorio   = dr[2].ToString().Trim(),
                                DescripcionLaboratorio = dr[3].ToString().Trim(),
                                HabilitadoLaboratorio  = (bool)dr[4]
                            };
                            lstLaboratorios.Add(objLaboratorios);
                        }
                        conn_BD.Close();
                        msjLaboratorios.ListaObjetoInventarios = lstLaboratorios;
                        msjLaboratorios.OperacionExitosa       = true;
                    }
                }
            }
            catch (Exception e)
            {
                conn_BD.Close();
                msjLaboratorios.OperacionExitosa = false;
                msjLaboratorios.MensajeError     = e.Message;
            }
            return(msjLaboratorios);
        }
예제 #19
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            Laboratorios obj;

            List <Laboratorios> lista;

            String mensaje = "";


            if (_Accion.Text == "Nuevo")
            {
                obj = new Laboratorios();
            }
            else
            {
                obj = uow.LaboratoriosBL.GetByID(int.Parse(_ElId.Text));
            }


            obj.Clave  = txtClave.Value;
            obj.Nombre = txtNombre.Value;



            //validaciones
            uow.Errors.Clear();

            if (_Accion.Text == "Nuevo")
            {
                lista = uow.LaboratoriosBL.Get(p => p.Clave == obj.Clave).ToList();
                if (lista.Count > 0)
                {
                    uow.Errors.Add("La Clave que capturo ya ha sido registrada anteriormente, verifique su información");
                }

                lista = uow.LaboratoriosBL.Get(p => p.Nombre == obj.Nombre).ToList();
                if (lista.Count > 0)
                {
                    uow.Errors.Add("La Descripción que capturo ya ha sido registrada anteriormente, verifique su información");
                }

                uow.LaboratoriosBL.Insert(obj);
                mensaje = "El registro se ha  almacenado correctamente";
            }
            else
            { //update
                int xid;

                xid = int.Parse(_ElId.Text);

                lista = uow.LaboratoriosBL.Get(p => p.Clave == obj.Clave && p.Id != xid).ToList();
                if (lista.Count > 0)
                {
                    uow.Errors.Add("La Clave que capturo ya ha sido registrada anteriormente, verifique su información");
                }



                lista = uow.LaboratoriosBL.Get(p => p.Nombre == obj.Nombre && p.Id != xid).ToList();
                if (lista.Count > 0)
                {
                    uow.Errors.Add("La Descripción que capturo ya ha sido registrada anteriormente, verifique su información");
                }


                uow.LaboratoriosBL.Update(obj);
            }



            if (uow.Errors.Count == 0)
            {
                uow.SaveChanges();
            }



            if (uow.Errors.Count == 0)//Integrando el nuevo nodo en el arbol
            {
                BindGrid();
                ModoForma(false);

                lblMensajeSuccess.Text = "El registro se guardo correctamente";
                divMsgSuccess.Style.Add("display", "block");
                divMsg.Style.Add("display", "none");
            }
            else
            {
                mensaje = string.Empty;
                foreach (string cad in uow.Errors)
                {
                    mensaje = mensaje + cad + "<br>";
                }

                lblMensajes.Text = mensaje;
                divMsg.Style.Add("display", "block");
                divMsgSuccess.Style.Add("display", "none");
            }
        }
예제 #20
0
 public void AddLaboratorio(Laboratorios newModel)
 {
     AddEntity(newModel);
 }
예제 #21
0
 public void CrearLaboratorio(Laboratorios laboratorios)
 {
     new DAL.TE.AdministracionTE().CrearLaboratorio(MapperConfig.Config.MapperAdministracion.Map <DAL.Laboratorios>(laboratorios));
 }
예제 #22
0
 private void Fill(Laboratorios lab)
 {
     nombreTextBox.Text       = lab.Nombre;
     FechaIngresotextBox.Text = lab.FechaIngreso.ToString();
 }
예제 #23
0
        protected void imgBtnEliminar_Click(object sender, ImageClickEventArgs e)
        {
            GridViewRow row = (GridViewRow)((ImageButton)sender).NamingContainer;

            _ElId.Text = grid.DataKeys[row.RowIndex].Values["Id"].ToString();


            if (_ElId.Text == "")
            {
                return;
            }

            Laboratorios obj = uow.LaboratoriosBL.GetByID(int.Parse(_ElId.Text));



            uow.Errors.Clear();
            List <Articulos> lista;

            lista = uow.ArticulosBL.Get(p => p.LaboratorioId == obj.Id).ToList();



            if (lista.Count > 0)
            {
                uow.Errors.Add("El registro no puede eliminarse porque ya ha sido usado en el sistema");
            }



            //Se elimina el objeto
            if (uow.Errors.Count == 0)
            {
                uow.LaboratoriosBL.Delete(obj);
                uow.SaveChanges();
                BindGrid();
            }



            if (uow.Errors.Count == 0)
            {
                lblMensajeSuccess.Text = "El registro se ha eliminado correctamente";
                divMsg.Style.Add("display", "none");
                divMsgSuccess.Style.Add("display", "block");
            }

            else
            {
                string mensaje;

                mensaje = string.Empty;
                foreach (string cad in uow.Errors)
                {
                    mensaje = mensaje + cad + "<br>";
                }

                lblMensajes.Text = mensaje;
                divMsg.Style.Add("display", "block");
                divMsgSuccess.Style.Add("display", "none");
            }
        }
        private void Bgw_DoWork(object sender, DoWorkEventArgs e)
        {
            if (Bgw.CancellationPending)
            {
                e.Cancel = true;
                return;
            }
            else
            {
                try
                {
                    using (var db = new DymContext())
                    {
                        ClavesSat      = db.CClaveProdServ.AsNoTracking().ToList();
                        Laboratorios   = db.Laboratorio.AsNoTracking().ToList();
                        UnidadMedidas  = db.UnidadMedida.AsNoTracking().ToList();
                        Presentaciones = db.Presentacion.AsNoTracking().ToList();
                        Categorias     = db.Categoria.AsNoTracking().ToList();
                    }

                    //Opening an existing Excel file
                    if (Ruta.Length == 0)
                    {
                        Ambiente.Mensaje("Archivo invalido. \nProceso abortado");
                        return;
                    }

                    fi = new FileInfo(Ruta);
                    using (ExcelPackage excelPackage = new ExcelPackage(fi))
                    {
                        //Get a WorkSheet by index. Note that EPPlus indexes are base 1, not base 0!
                        //Get a WorkSheet by name. If the worksheet doesn't exist, throw an exeption

                        workSheet = excelPackage.Workbook.Worksheets[1];

                        var start = workSheet.Dimension.Start;
                        var end   = workSheet.Dimension.End;



                        bool    succes    = false;
                        int     nIntValue = 0;
                        decimal nDecValue = 1m;

                        for (row = start.Row + 1; row <= end.Row; row++)
                        { // Row by row...
                            var producto = new Producto();

                            for (col = start.Column; col <= end.Column; col++)
                            {
                                switch (col)
                                {
                                case 1:
                                    //ProductoId
                                    producto.ProductoId = workSheet.Cells[row, col].Text.Trim();
                                    break;

                                case 2:
                                    //Descripcion
                                    producto.Descripcion = workSheet.Cells[row, col].Text.Trim();
                                    break;

                                case 3:
                                    //Stock
                                    succes = false;
                                    succes = int.TryParse(workSheet.Cells[row, col].Text.Trim(), out nIntValue);
                                    if (succes)
                                    {
                                        producto.Stock = nIntValue;
                                    }
                                    else
                                    {
                                        producto.Stock = 0;
                                    }
                                    break;

                                case 4:
                                    //Contenido
                                    producto.Contenido = workSheet.Cells[row, col].Text.Trim().Length == 0 ? "" : workSheet.Cells[row, col].Text.Trim();
                                    break;

                                case 5:
                                    //CategoriaId
                                    var Categoria = Categorias.FirstOrDefault(x => x.CategoriaId == workSheet.Cells[row, col].Text.Trim());
                                    if (Categoria != null)
                                    {
                                        producto.CategoriaId = Categoria.CategoriaId;
                                    }
                                    else
                                    {
                                        producto.CategoriaId = "SYS";
                                    }


                                    break;

                                case 6:
                                    //PresentacionId
                                    var Presentacion = Presentaciones.FirstOrDefault(x => x.PresentacionId == workSheet.Cells[row, col].Text.Trim());
                                    if (Presentacion != null)
                                    {
                                        producto.PresentacionId = Presentacion.PresentacionId;
                                    }
                                    else
                                    {
                                        producto.PresentacionId = "SYS";
                                    }

                                    break;

                                case 7:
                                    //LaboratorioId
                                    var Laboratorio = Laboratorios.FirstOrDefault(x => x.LaboratorioId == workSheet.Cells[row, col].Text.Trim());
                                    if (Laboratorio != null)
                                    {
                                        producto.LaboratorioId = Laboratorio.LaboratorioId;
                                    }
                                    else
                                    {
                                        producto.LaboratorioId = "SYS";
                                    }

                                    break;

                                case 8:
                                    //Unidades
                                    producto.Unidades = workSheet.Cells[row, col].Text.Trim().Length == 0 ? "" : workSheet.Cells[row, col].Text.Trim();
                                    break;

                                case 9:
                                    //PrecioCompra
                                    succes = false;
                                    succes = decimal.TryParse(workSheet.Cells[row, col].Text.Trim(), out nDecValue);
                                    if (succes)
                                    {
                                        producto.PrecioCompra = nDecValue;
                                    }
                                    else
                                    {
                                        producto.PrecioCompra = 1M;
                                    }

                                    break;

                                case 10:
                                    //PrecioCaja
                                    succes = false;
                                    succes = decimal.TryParse(workSheet.Cells[row, col].Text.Trim(), out nDecValue);
                                    if (succes)
                                    {
                                        producto.PrecioCaja = nDecValue;
                                    }
                                    else
                                    {
                                        producto.PrecioCaja = 1M;
                                    }

                                    break;

                                case 11:
                                    //Precio1
                                    succes = false;
                                    succes = decimal.TryParse(workSheet.Cells[row, col].Text.Trim(), out nDecValue);
                                    if (succes)
                                    {
                                        producto.Precio1 = nDecValue;
                                    }
                                    else
                                    {
                                        producto.Precio1 = 1M;
                                    }

                                    break;

                                case 12:
                                    //Precio2
                                    succes = false;
                                    succes = decimal.TryParse(workSheet.Cells[row, col].Text.Trim(), out nDecValue);
                                    if (succes)
                                    {
                                        producto.Precio2 = nDecValue;
                                    }
                                    else
                                    {
                                        producto.Precio2 = 1M;
                                    }

                                    break;

                                case 13:
                                    //Utilidad1
                                    succes = false;
                                    succes = decimal.TryParse(workSheet.Cells[row, col].Text.Trim(), out nDecValue);
                                    if (succes)
                                    {
                                        producto.Utilidad1 = nDecValue;
                                    }
                                    else
                                    {
                                        producto.Utilidad1 = 1M;
                                    }

                                    break;

                                case 14:
                                    //Utilidad2
                                    succes = false;
                                    succes = decimal.TryParse(workSheet.Cells[row, col].Text.Trim(), out nDecValue);
                                    if (succes)
                                    {
                                        producto.Utilidad2 = nDecValue;
                                    }
                                    else
                                    {
                                        producto.Utilidad2 = 1M;
                                    }

                                    break;

                                case 15:
                                    //TieneLote
                                    if (workSheet.Cells[row, col].Text.Trim().Equals("VERDADERO"))
                                    {
                                        producto.TieneLote = true;
                                    }
                                    else
                                    {
                                        producto.TieneLote = false;
                                    }

                                    break;

                                case 16:
                                    //UnidadMedidaId
                                    var UnidadMedida = UnidadMedidas.FirstOrDefault(x => x.UnidadMedidaId == workSheet.Cells[row, col].Text.Trim());
                                    if (UnidadMedida != null)
                                    {
                                        producto.UnidadMedidaId = UnidadMedida.UnidadMedidaId;
                                    }
                                    else
                                    {
                                        producto.UnidadMedidaId = "SYS";
                                    }

                                    break;

                                case 17:
                                    //ClaveCfdiId

                                    var ClaveProdServ = ClavesSat.FirstOrDefault(x => x.ClaveProdServId == workSheet.Cells[row, col].Text.Trim());
                                    if (ClaveProdServ != null)
                                    {
                                        producto.ClaveProdServId = ClaveProdServ.ClaveProdServId;
                                    }
                                    else
                                    {
                                        producto.ClaveUnidadId = "01010101";
                                    }

                                    break;

                                case 18:
                                    //UnidadCfdi
                                    producto.ClaveUnidadId = workSheet.Cells[row, col].Text.Trim().Length == 0 ? "H87" : workSheet.Cells[row, col].Text.Trim();

                                    break;

                                case 19:
                                    //RutaImg
                                    producto.RutaImg   = workSheet.Cells[row, col].Text.Trim().Length == 0 ? null : (Ambiente.Empresa.DirectorioImg + workSheet.Cells[row, col].Text.Trim());
                                    producto.CratedAt  = DateTime.Now;
                                    producto.UpdatedAt = DateTime.Now;
                                    producto.CratedBy  = Ambiente.LoggedUser.UsuarioId;

                                    if (producto.ProductoId == null || producto.ProductoId.Length == 0)
                                    {
                                        Errores.Add("SE OMITIÓ, " + producto.ProductoId + ", A CAUSA DE FILA: " + row + " COLUMNA: " + col + "\n");
                                    }
                                    else
                                    {
                                        Productos.Add(producto);
                                    }

                                    break;

                                default:
                                    MessageBox.Show("Columna no encontrada");
                                    break;
                                }
                                Bgw.ReportProgress(row);
                            }
                        }
                        excelPackage.Save();
                    }
                    if (new ProductoController().InsertRange(Productos))
                    {
                        exito = true;
                    }
                }
                catch (Exception ex)
                {
                    Ambiente.Mensaje(" ALGO SALIO MAL EN FILA: " + row + " COLUMNA: " + col + "\n" + ex.ToString());
                }
            }
        }