Exemple #1
0
        public async Task <ActionResult> Create([Bind(Include = "id_cliente_nit,id_sucursal")] ENCABEZADO_FACTURA eNCABEZADO_FACTURA)
        {
            if (ModelState.IsValid)
            {
                comando             = new SqlCommand();
                comando.CommandType = CommandType.Text;
                comando.CommandText = " SELECT TOP 1 * FROM ENCABEZADO_FACTURA ORDER BY id_encabezado_factura DESC";
                informacion         = conexion.EjecutarComandosInformacion(comando);
                if (informacion.Rows.Count > 1)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                else
                {
                    foreach (DataRow row in informacion.Rows)
                    {
                        eNCABEZADO_FACTURA.id_encabezado_factura = Convert.ToInt32(row["id_encabezado_factura"]) + 1;
                    }
                }
                eNCABEZADO_FACTURA.fecha_venta = DateTime.Now.Date;
                eNCABEZADO_FACTURA.iva         = 0;
                eNCABEZADO_FACTURA.total_venta = 0;
                db.ENCABEZADO_FACTURA.Add(eNCABEZADO_FACTURA);
                await db.SaveChangesAsync();

                return(RedirectToAction("Create"));
            }

            ViewBag.id_cliente_nit = new SelectList(db.CLIENTEs, "id_cliente_nit", "nombre", eNCABEZADO_FACTURA.id_cliente_nit);
            ViewBag.id_sucursal    = new SelectList(db.SUCURSALs, "id_sucursal", "nombre", eNCABEZADO_FACTURA.id_sucursal);
            return(View(eNCABEZADO_FACTURA));
        }
Exemple #2
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            ENCABEZADO_FACTURA eNCABEZADO_FACTURA = await db.ENCABEZADO_FACTURA.FindAsync(id);

            db.ENCABEZADO_FACTURA.Remove(eNCABEZADO_FACTURA);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemple #3
0
        public async Task <ActionResult> Edit([Bind(Include = "id_encabezado_factura,fecha_venta,id_cliente_nit,id_sucursal,iva,total_venta")] ENCABEZADO_FACTURA eNCABEZADO_FACTURA)
        {
            if (ModelState.IsValid)
            {
                db.Entry(eNCABEZADO_FACTURA).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.id_cliente_nit = new SelectList(db.CLIENTEs, "id_cliente_nit", "nombre", eNCABEZADO_FACTURA.id_cliente_nit);
            ViewBag.id_sucursal    = new SelectList(db.SUCURSALs, "id_sucursal", "nombre", eNCABEZADO_FACTURA.id_sucursal);
            return(View(eNCABEZADO_FACTURA));
        }
Exemple #4
0
        // GET: VENTAS/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ENCABEZADO_FACTURA eNCABEZADO_FACTURA = await db.ENCABEZADO_FACTURA.FindAsync(id);

            if (eNCABEZADO_FACTURA == null)
            {
                return(HttpNotFound());
            }
            return(View(eNCABEZADO_FACTURA));
        }
Exemple #5
0
        // GET: VENTAS/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ENCABEZADO_FACTURA eNCABEZADO_FACTURA = await db.ENCABEZADO_FACTURA.FindAsync(id);

            if (eNCABEZADO_FACTURA == null)
            {
                return(HttpNotFound());
            }
            ViewBag.id_cliente_nit = new SelectList(db.CLIENTEs, "id_cliente_nit", "nombre", eNCABEZADO_FACTURA.id_cliente_nit);
            ViewBag.id_sucursal    = new SelectList(db.SUCURSALs, "id_sucursal", "nombre", eNCABEZADO_FACTURA.id_sucursal);
            return(View(eNCABEZADO_FACTURA));
        }