public static Presentaciones Get(System.Int32 presentacionID)
    {
        DataSet        ds;
        Database       db;
        string         sqlCommand;
        DbCommand      dbCommand;
        Presentaciones instance;


        instance = new Presentaciones();

        db         = DatabaseFactory.CreateDatabase();
        sqlCommand = "[dbo].gspPresentaciones_SELECT";
        dbCommand  = db.GetStoredProcCommand(sqlCommand, presentacionID);

        // Get results.
        ds = db.ExecuteDataSet(dbCommand);
        // Verification.
        if (ds == null || ds.Tables[0].Rows.Count == 0)
        {
            throw new ApplicationException("Could not get Presentaciones ID:" + presentacionID.ToString() + " from Database.");
        }
        // Return results.
        ds.Tables[0].TableName = TABLE_NAME;

        instance.MapFrom(ds.Tables[0].Rows[0]);
        return(instance);
    }
Exemple #2
0
        public async Task <IActionResult> Edit(int id, [Bind("IdPresentacion,Cantidad,IdUniMed,Status,Observaciones")] Presentaciones presentacion)
        {
            if (id != presentacion.IdPresentacion)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(presentacion);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PresentacionesExists(presentacion.IdPresentacion))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Details", new { id = presentacion.IdPresentacion }));
            }
            ViewData["IdUniMed"] = new SelectList(_context.UnidadesMedida, "IdUniMed", "DescripcionUniMed", presentacion.IdUniMed);
            ViewData["Status"]   = new SelectList(_context.Status, "Status1", "DescripcionStatus", presentacion.Status);
            return(View(presentacion));
        }
        /// <summary>
        /// Método para la realización de las transacciones con las presentaciones.
        /// </summary>
        /// <param name="opcion"></param>
        /// <param name="Id"></param>
        /// <param name="Nombre"></param>
        /// <returns></returns>
        public bool Trasaccion_Presentacion(int opcion, int Id = 0, string Nombre = "")
        {
            bool Resultado = false;

            try
            {
                this.presentacion        = new Presentaciones(this.BaseDatos.Obtener_Conexion());
                this.presentacion.Id     = Id;
                this.presentacion.Nombre = Nombre;

                switch (opcion)
                {
                case 1: /*this.DatosActuales = */ this.presentacion.Agregar_Presentacion();
                    break;

                case 2: /*this.DatosActuales = */ this.presentacion.Leer_Presentacion();
                    break;

                case 3: /*this.DatosActuales = */ this.presentacion.Actualizar_Presentacion();
                    break;

                case 4: /*this.DatosActuales = */ this.presentacion.Borrar_Presentacion();
                    break;
                }

                Resultado = true;
            }
            catch (SqlException ex)
            {
                throw ex;
            }

            return(Resultado);
        }
Exemple #4
0
 public void InitializePresentaciones()
 {
     foreach (Competidor c in Participantes)
     {
         Presentacion p = new Presentacion(c);
         Presentaciones.Add(p);
     }
 }
Exemple #5
0
        // PUT: api/Presentaciones
        public void Put([FromBody] Presentaciones Datos)
        {
            if (Datos == null)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            ClassBD.ActualizarPresentacion(Datos);
        }
Exemple #6
0
        // POST: api/Presentaciones
        public ID Post([FromBody] Presentaciones Datos)
        {
            if (Datos == null)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            int ret = -1;

            ret = ClassBD.AgregarPresentacion(Datos);

            return(new ID(ret));
        }
Exemple #7
0
        public async Task <IActionResult> Create([Bind("Cantidad,IdUniMed,Status,Observaciones")] Presentaciones presentacion)
        {
            if (ModelState.IsValid)
            {
                presentacion.Status = "D";
                _context.Add(presentacion);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", new { id = presentacion.IdPresentacion }));
            }
            ViewData["IdUniMed"] = new SelectList(_context.UnidadesMedida, "IdUniMed", "DescripcionUniMed", presentacion.IdUniMed);
            ViewData["Status"]   = new SelectList(_context.Status, "Status1", "DescripcionStatus", presentacion.Status);
            return(View(presentacion));
        }
Exemple #8
0
        protected void imgBtnEdit_Click(object sender, ImageClickEventArgs e)
        {
            GridViewRow row = (GridViewRow)((ImageButton)sender).NamingContainer;

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

            Presentaciones obj = uow.PresentacionesBL.GetByID(int.Parse(_ElId.Text));

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


            _Accion.Text = "Modificar";
            ModoForma(true);
        }
    public static Presentaciones[] Search(System.Int32?presentacionID, System.String presentacion, System.Double?peso)
    {
        DataSet   ds;
        Database  db;
        string    sqlCommand;
        DbCommand dbCommand;


        db         = DatabaseFactory.CreateDatabase();
        sqlCommand = "[dbo].gspPresentaciones_SEARCH";
        dbCommand  = db.GetStoredProcCommand(sqlCommand, presentacionID, presentacion, peso);

        ds = db.ExecuteDataSet(dbCommand);
        ds.Tables[0].TableName = TABLE_NAME;
        return(Presentaciones.MapFrom(ds));
    }
Exemple #10
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Farmacia contexto = new Farmacia();
            List <Presentaciones> presentaciones = contexto.Presentaciones.ToList();
            Presentaciones        present        = new Presentaciones()
            {
                ID_PRESENTACION = 0, DETALLE_PRESENTACION = ""
            };

            presentaciones.Insert(0, present);
            cmbPresentacion.DataSource     = presentaciones;
            cmbPresentacion.DisplayMember  = "DETALLE_PRESENTACION";
            cmbPresentacion.ValueMember    = "ID_PRESENTACION";
            dataGridView1.Columns[1].Width = 300;
            dataGridView1.Columns[2].Width = 200;
            dataGridView1.Columns[3].Width = 70;
            dataGridView1.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns[3].DefaultCellStyle.Format    = "N2";
            dataGridView1.Columns[0].Visible = false;
            dataGridView1.DataSource         = Buscar();
        }
    public static Presentaciones[] MapFrom(DataSet ds)
    {
        List <Presentaciones> objects;


        // Initialise Collection.
        objects = new List <Presentaciones>();

        // Validation.
        if (ds == null)
        {
            throw new ApplicationException("Cannot map to dataset null.");
        }
        else if (ds.Tables[TABLE_NAME].Rows.Count == 0)
        {
            return(objects.ToArray());
        }

        if (ds.Tables[TABLE_NAME] == null)
        {
            throw new ApplicationException("Cannot find table [dbo].[Presentaciones] in DataSet.");
        }

        if (ds.Tables[TABLE_NAME].Rows.Count < 1)
        {
            throw new ApplicationException("Table [dbo].[Presentaciones] is empty.");
        }

        // Map DataSet to Instance.
        foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows)
        {
            Presentaciones instance = new Presentaciones();
            instance.MapFrom(dr);
            objects.Add(instance);
        }

        // Return collection.
        return(objects.ToArray());
    }
Exemple #12
0
 public List <Presentacion> PresentacionesCalificadas()
 {
     return(Presentaciones.FindAll(p => p.IsDone() == true));
 }
Exemple #13
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;
            }

            Presentaciones obj = uow.PresentacionesBL.GetByID(int.Parse(_ElId.Text));



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

            lista = uow.ArticulosBL.Get(p => p.PresentacionId == 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.PresentacionesBL.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");
            }
        }
Exemple #14
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            Presentaciones obj;

            List <Presentaciones> lista;

            String mensaje = "";


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


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



            //validaciones
            uow.Errors.Clear();

            if (_Accion.Text == "Nuevo")
            {
                lista = uow.PresentacionesBL.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.PresentacionesBL.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.PresentacionesBL.Insert(obj);
                mensaje = "El registro se ha  almacenado correctamente";
            }
            else
            { //update
                int xid;

                xid = int.Parse(_ElId.Text);

                lista = uow.PresentacionesBL.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.PresentacionesBL.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.PresentacionesBL.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");
            }
        }
 public static void Update(Presentaciones presentaciones)
 {
     presentaciones.Update();
 }
Exemple #16
0
 public List <Presentacion> PresentacionesRestantes()
 {
     return(Presentaciones.FindAll(p => p.IsDone() == false));
 }
 public static void Update(Presentaciones presentaciones, DbTransaction transaction)
 {
     presentaciones.Update(transaction);
 }
Exemple #18
0
 public Presentacion BuscarPresentacion(Competidor c)
 {
     return(Presentaciones.Find(p => p.Competidor == c));
 }
 public static Presentaciones[] Search(Presentaciones searchObject)
 {
     return(Search(searchObject.PresentacionID, searchObject.Presentacion, searchObject.Peso));
 }
        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());
                }
            }
        }