Example #1
0
        public int ModificarDetalleByID(string producto_cod_detalle, string producto_cod, int cant_min, int cant_actual, int valor)
        {
            int     resultado = 0;
            DETALLE detalle   = new DETALLE();
            Detalle d         = new Detalle();

            d.Producto_cod_detalle = producto_cod_detalle;
            d.Producto_cod         = producto_cod;
            d.Cantidad_minima      = cant_min;
            d.Cantidad_actual      = cant_actual;
            d.Valor = valor;
            detalle.PRODUCTO_COD_DETALLE = d.Producto_cod_detalle;
            detalle.PRODUCTO_COD         = d.Producto_cod;
            detalle.CANTIDAD_MINIMA      = d.Cantidad_minima;
            detalle.CANTIDAD_ACTUAL      = d.Cantidad_actual;
            detalle.VALOR = d.Valor;
            EntityKey key = ModeloEntidades.CreateEntityKey("SIAFEntities.DETALLE", detalle);
            Object    ActualizaDetalle; // se crea esta variable segun actualizacion, ahora es usuario, luego puede ser ActualizaProducto

            if (ModeloEntidades.TryGetObjectByKey(key, out ActualizaDetalle))
            {
                ModeloEntidades.ApplyCurrentValues(key.EntitySetName, detalle);
                resultado = ModeloEntidades.SaveChanges();
            }
            return(resultado);
        }
Example #2
0
        public int BorrarProductoOT(int ID_PRODUCTO_OT)
        {
            PRODUCTOS_OT proot = new PRODUCTOS_OT();

            proot = MostrarProductoOTByID(ID_PRODUCTO_OT);
            int        ID_OT        = int.Parse(proot.ID_OT.ToString());
            string     PRODUCTO_COD = proot.PRODUCTO_COD;
            int        CANTIDAD     = int.Parse(proot.CANTIDAD.ToString());
            int        VALOR_TOTAL  = int.Parse(proot.VALOR_TOTAL.ToString());
            DetalleNeg detalle      = new DetalleNeg();
            DETALLE    newDetalle   = new DETALLE();

            newDetalle = detalle.MostrarDetalleByIDProducto(PRODUCTO_COD);
            int    CANTIDAD_ACTUAL      = int.Parse(newDetalle.CANTIDAD_ACTUAL.ToString());
            string PRODUCTO_COD_DETALLE = newDetalle.PRODUCTO_COD_DETALLE;
            int    CANTIDAD_MINIMA      = int.Parse(newDetalle.CANTIDAD_MINIMA.ToString());
            int    VALOR          = int.Parse(newDetalle.VALOR.ToString());
            int    CANTIDAD_NUEVA = CANTIDAD_ACTUAL + CANTIDAD;
            OTNeg  otneg          = new OTNeg();
            OT     newOT          = new OT();

            newOT = otneg.MostrarOTByID(ID_OT);
            int      NETO_OT     = int.Parse(newOT.NETO_OT.ToString());
            int      NETO_OT_NEW = NETO_OT - VALOR_TOTAL;
            int      ID_SUCURSAL = int.Parse(newOT.ID_SUCURSAL.ToString());
            int      ID_CLIENTE  = int.Parse(newOT.ID_CLIENTE.ToString());
            DateTime FECHA_OT    = DateTime.Parse(newOT.FECHA_OT.ToString());
            string   ESTADO      = newOT.ESTADO;

            detalle.ModificarDetalleByID(PRODUCTO_COD_DETALLE, PRODUCTO_COD, CANTIDAD_MINIMA, CANTIDAD_NUEVA, VALOR);

            otneg.ModificarOTByID(ID_OT, ID_SUCURSAL, ID_CLIENTE, NETO_OT_NEW, FECHA_OT, ESTADO);

            return(ModeloEntidades.spBorrarProductoOT(ID_PRODUCTO_OT));
        }
Example #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            DETALLE dETALLE = db.DETALLE.Find(id);

            db.DETALLE.Remove(dETALLE);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #4
0
 public ActionResult Edit([Bind(Include = "id,nombre,descripcion,auxiliar")] DETALLE dETALLE)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dETALLE).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(dETALLE));
 }
Example #5
0
        public ActionResult Create([Bind(Include = "id,nombre,descripcion,auxiliar")] DETALLE dETALLE)
        {
            if (ModelState.IsValid)
            {
                dETALLE.id = db.DETALLE.Max(x => x.id) + 1;
                db.DETALLE.Add(dETALLE);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dETALLE));
        }
        public ActionResult EditarFactura(FacturaCLS FacturaCLS)
        {
            if (!ModelState.IsValid)
            {
                return(View(FacturaCLS));
            }
            else
            {
                using (var bd = new DBPruebaEntities())
                {
                    //objecto factura
                    FACTURA oFactura = bd.FACTURAs.Where(p => p.IIDFACTURA.Equals(FacturaCLS.IIDFACTURA)).First();
                    oFactura.IIDPERSONA = FacturaCLS.IIDPERSONA;
                    oFactura.FECHA      = FacturaCLS.FECHA;
                    oFactura.NUMFACTURA = FacturaCLS.NUMFACTURA;
                    oFactura.IVA        = FacturaCLS.IVA;
                    oFactura.ESTADO     = int.Parse(FacturaCLS.ESTADO);
                    bd.SaveChanges();

                    DETALLE oDetalle = new DETALLE();

                    foreach (var x in FacturaCLS.DETALLE)
                    {
                        DETALLE oDet = bd.DETALLEs.Where(p => p.IIDDETALLE.Equals(x.IIDDETALLE)).FirstOrDefault();
                        if (oDet != null)
                        {
                            // update information
                            oDet.NOMBREPRODUCTO  = x.NOMBREPRODUCTO;
                            oDet.CANTIDAD        = x.CANTIDAD;
                            oDet.PRECIO_UNITARIO = x.PRECIO_UNITARIO;
                            oDet.TOTAL           = x.TOTAL;
                            oDet.ESTADO          = x.ESTADO;
                            bd.SaveChanges();
                        }
                        else
                        {
                            // insert new data
                            oDetalle.IIDFACTURA      = FacturaCLS.IIDFACTURA;
                            oDetalle.NOMBREPRODUCTO  = x.NOMBREPRODUCTO;
                            oDetalle.CANTIDAD        = x.CANTIDAD;
                            oDetalle.PRECIO_UNITARIO = x.PRECIO_UNITARIO;
                            oDetalle.TOTAL           = x.TOTAL;
                            oDetalle.ESTADO          = 1;
                            bd.DETALLEs.Add(oDetalle);
                            bd.SaveChanges();
                        }
                    }
                }
            }

            return(Json(new { factura = FacturaCLS }));
        }
Example #7
0
        // GET: DETALLEs/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DETALLE dETALLE = db.DETALLE.Find(id);

            if (dETALLE == null)
            {
                return(HttpNotFound());
            }
            return(View(dETALLE));
        }
Example #8
0
    protected void btnAgregar_Click(object sender, EventArgs e)
    {
        /*ProductosOT.aspx?id_ot=1*/
        int    ID_OT        = Convert.ToInt32(lbl_idot.Text);
        string PRODUCTO_COD = dd_productoCod.SelectedValue;
        int    CANTIDAD     = Convert.ToInt32(txtCantidad.Text);

        servicioWeb.WCFTrans servicio = new servicioWeb.WCFTrans();
        DETALLE detalle = servicio.MostrarDetalleByIDProducto(PRODUCTO_COD);

        int VALOR_DEL_PRODUCTO = int.Parse(detalle.VALOR.ToString());
        int TOTAL_PRODUCTO     = CANTIDAD * VALOR_DEL_PRODUCTO;

        servicio.AgregarProductoOt(PRODUCTO_COD, ID_OT, CANTIDAD, TOTAL_PRODUCTO);

        Response.Redirect("ProductosOT.aspx?id_ot=" + ID_OT + "");
    }
Example #9
0
        public int AgregarDetalle(string PRODUCTO_COD_DETALLE, string PRODUCTO_COD, int CANTIDAD_MINIMA, int CANTIDAD_ACTUAL, int VALOR)
        {
            Detalle d  = new Detalle();
            DETALLE dd = new DETALLE();

            d.Producto_cod_detalle = PRODUCTO_COD_DETALLE;
            d.Producto_cod         = PRODUCTO_COD;
            d.Cantidad_minima      = CANTIDAD_MINIMA;
            d.Cantidad_actual      = CANTIDAD_ACTUAL;
            d.Valor = VALOR;

            dd.PRODUCTO_COD_DETALLE = d.Producto_cod_detalle;
            dd.PRODUCTO_COD         = d.Producto_cod;
            dd.CANTIDAD_MINIMA      = d.Cantidad_minima;
            dd.CANTIDAD_ACTUAL      = d.Cantidad_actual;
            dd.VALOR = d.Valor;

            ModeloEntidades.AddToDETALLE(dd);
            return(ModeloEntidades.SaveChanges());
        }
        // GET: Factura/Create
        public ActionResult CrearFactura(FacturaCLS FacturaCLS)
        {
            int IID = 0;

            if (!ModelState.IsValid)
            {
                return(View(FacturaCLS));
            }
            else
            {
                using (var bd = new DBPruebaEntities())
                {
                    //objecto factura
                    FACTURA oFactura = new FACTURA();
                    oFactura.IIDPERSONA = FacturaCLS.IIDPERSONA;
                    oFactura.FECHA      = FacturaCLS.FECHA;
                    oFactura.NUMFACTURA = FacturaCLS.NUMFACTURA;
                    oFactura.IVA        = FacturaCLS.IVA;
                    oFactura.ESTADO     = int.Parse(FacturaCLS.ESTADO);
                    bd.FACTURAs.Add(oFactura);
                    bd.SaveChanges();
                    IID = oFactura.IIDFACTURA;

                    DETALLE oDetalle = new DETALLE();

                    foreach (var x in FacturaCLS.DETALLE)
                    {
                        oDetalle.IIDFACTURA      = IID;
                        oDetalle.NOMBREPRODUCTO  = x.NOMBREPRODUCTO;
                        oDetalle.CANTIDAD        = x.CANTIDAD;
                        oDetalle.PRECIO_UNITARIO = x.PRECIO_UNITARIO;
                        oDetalle.TOTAL           = x.TOTAL;
                        oDetalle.ESTADO          = 1;
                        bd.DETALLEs.Add(oDetalle);
                        bd.SaveChanges();
                    }
                }
            }

            return(Json(new { draw = IID, factura = FacturaCLS }));
        }
Example #11
0
        public int AgregarProductosOt(string PRODUCTO_COD, int ID_OT, int CANTIDAD, int VALOR_TOTAL)
        {
            Productos_ot prot    = new Productos_ot();
            PRODUCTOS_OT prott   = new PRODUCTOS_OT();
            OT           ot      = new OT();
            OTNeg        otneg   = new OTNeg();
            DETALLE      detalle = new DETALLE();
            DetalleNeg   detneg  = new DetalleNeg();

            ot = otneg.MostrarOTByID(ID_OT);

            int      NETO_ANTIGUO = int.Parse(ot.NETO_OT.ToString());
            int      NETO_NUEVO   = VALOR_TOTAL + NETO_ANTIGUO;
            int      ID_SUCURSAL  = int.Parse(ot.ID_SUCURSAL.ToString());
            int      ID_CLIENTE   = int.Parse(ot.ID_CLIENTE.ToString());
            DateTime FECHA_OT     = DateTime.Parse(ot.FECHA_OT.ToString());
            string   ESTADO       = ot.ESTADO;

            otneg.ModificarOTByID(ID_OT, ID_SUCURSAL, ID_CLIENTE, NETO_NUEVO, FECHA_OT, ESTADO);
            detalle = detneg.MostrarDetalleByIDProducto(PRODUCTO_COD);
            int    CANTIDAD_ANTIGUA     = int.Parse(detalle.CANTIDAD_ACTUAL.ToString());
            int    CANTIDAD_NUEVA       = CANTIDAD_ANTIGUA - CANTIDAD;
            string PRODUCTO_COD_DETALLE = detalle.PRODUCTO_COD_DETALLE;
            int    CANTIDAD_MINIMA      = int.Parse(detalle.CANTIDAD_MINIMA.ToString());
            int    VALOR = int.Parse(detalle.VALOR.ToString());

            detneg.ModificarDetalleByID(PRODUCTO_COD_DETALLE, PRODUCTO_COD, CANTIDAD_MINIMA, CANTIDAD_NUEVA, VALOR);

            prot.Producto_cod = PRODUCTO_COD;
            prot.Id_ot        = ID_OT;
            prot.Cantidad     = CANTIDAD;
            prot.Valor_total  = VALOR_TOTAL;

            prott.PRODUCTO_COD = prot.Producto_cod;
            prott.ID_OT        = prot.Id_ot;
            prott.CANTIDAD     = prot.Cantidad;
            prott.VALOR_TOTAL  = prot.Valor_total;

            ModeloEntidades.AddToPRODUCTOS_OT(prott);
            return(ModeloEntidades.SaveChanges());
        }