コード例 #1
0
        public ActionResult InsertarPaquete(FormCollection formCollection)//recolectar toda la informacion que hay dentro del formulario
        {
            DBappWebMexicaERPcontext DbContext = new DBappWebMexicaERPcontext();

            TVenta Venta = new TVenta();

            Venta.fechaRegistro = DateTime.Now;
            Venta.idEmpleado    = 1;
            Venta.fechaVenta    = DateTime.Parse(formCollection["fechaVentap"]);
            Venta.idProducto    = 0; //int.Parse(formCollection["idProducto"]);
            if (formCollection["idTour"] != null)
            {
                Venta.idTour = int.Parse(formCollection["idTour"]);
            }
            else
            {
                Venta.idTour = 0;
            }
            if (formCollection["idPaquete"] != null)
            {
                Venta.idPaquete = int.Parse(formCollection["idPaquete"]);
            }
            else
            {
                Venta.idTour = 0;
            }


            Venta.tipo_costo        = "MEXICA";//formCollection["tipo_costo"];
            Venta.costoVenta        = double.Parse(formCollection["costoVentap"]);
            Venta.costoVendido      = double.Parse(formCollection["costoVendidop"]);
            Venta.adultos           = int.Parse(formCollection["adultosp"]);
            Venta.ninos             = int.Parse(formCollection["ninosp"]);
            Venta.pax               = int.Parse(formCollection["paxp"]);
            Venta.fechaInicio       = DateTime.Parse(formCollection["fechaIniciop"]);
            Venta.fechaFin          = DateTime.Parse(formCollection["fechaFinp"]);
            Venta.cliente           = formCollection["clientep"];
            Venta.telefono          = formCollection["telefonop"];
            Venta.correo            = formCollection["correop"];
            Venta.observaciones     = formCollection["observacionesp"];
            Venta.recoger           = formCollection["recogerp"];
            Venta.idFormaPago       = int.Parse(formCollection["idFormaPagop"]);
            Venta.banco             = "banco_x";//formCollection["banco"];
            Venta.total             = double.Parse(formCollection["totalp"]);
            Venta.anticipo          = double.Parse(formCollection["anticipop"]);
            Venta.saldo             = double.Parse(formCollection["saldop"]);
            Venta.utilidadBruta     = double.Parse("100"); //(formCollection["utilidadBruta"]);
            Venta.comisionPagar     = double.Parse("100"); //(formCollection["comisionPagar"]);
            Venta.utilidadNeta      = double.Parse("100"); //(formCollection["utilidadNeta"]);
            Venta.referencia        = formCollection["referenciap"];
            Venta.fechaModificacion = DateTime.Now;        //DateTime.Parse(formCollection["fechaVenta"]);
            Venta.fechaCancelacion  = DateTime.Now;        //DateTime.Parse(formCollection["fechaVenta"]);
            Venta.motivoCancelacion = "CENCELACION";       // formCollection["motivoCancelacion"];
            Venta.estatus           = 1;
            DbContext.Ventas.Add(Venta);
            DbContext.SaveChanges();
            return(RedirectToAction("Insertar", "Venta"));
        }
コード例 #2
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            TVenta tVenta = await db.TVenta.FindAsync(id);

            db.TVenta.Remove(tVenta);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
コード例 #3
0
        // GET: Ventas/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TVenta tVenta = await db.TVenta.FindAsync(id);

            if (tVenta == null)
            {
                return(HttpNotFound());
            }
            return(View(tVenta));
        }
コード例 #4
0
        public async Task <ActionResult> Edit([Bind(Include = "IdVenta,Monto,Fecha,IdTipoVenta,IdCliente,Saldo,Placa,Interes")] TVenta tVenta)
        {
            if (ModelState.IsValid)
            {
                db.Entry(tVenta).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.IdTipoVenta = new SelectList(db.CTipoVenta, "IdTipoVenta", "Descripcion", tVenta.IdTipoVenta);
            ViewBag.IdCliente   = new SelectList(db.TCliente, "IdCliente", "Identificacion", tVenta.IdCliente);
            ViewBag.Placa       = new SelectList(db.TVehiculo, "Placa", "Estilo", tVenta.Placa);
            return(View(tVenta));
        }
コード例 #5
0
        // POST: Ventas/Create
        // Para protegerse de ataques de publicación excesiva, habilite las propiedades específicas a las que desea enlazarse. Para obtener
        // más información vea https://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public async Task<ActionResult> Create([Bind(Include = "IdVenta,Monto,Fecha,IdTipoVenta,IdCliente,Saldo,Placa,Interes,Financiamiento")] TVenta tVenta)
        //{
        //    if (ModelState.IsValid)
        //    {

        //        //string plazo = tVenta.Financiamiento.Plazo.ToString();

        //        db.TVenta.Add(tVenta);

        //        await db.SaveChangesAsync();

        //        //revisar que el web config este seteado con el mismo idtipofinanciamiento de la BD tabla ctipoVenta (2)
        //        if (tVenta.IdTipoVenta == Int32.Parse(WebConfigurationManager.AppSettings["TipoVentaFinanciamiento"]))
        //            return RedirectToAction("Create", "Financiamientos", new { idVenta = tVenta.IdVenta });

        //        return RedirectToAction("Index");
        //    }

        //    ViewBag.IdTipoVenta = new SelectList(db.CTipoVenta, "IdTipoVenta", "Descripcion", tVenta.IdTipoVenta);
        //    ViewBag.IdCliente = new SelectList(db.TCliente, "IdCliente", "Identificacion", tVenta.IdCliente);
        //    ViewBag.Placa = new SelectList(db.TVehiculo, "Placa", "Estilo", tVenta.Placa);
        //    return View(tVenta);
        //}


        // POST: Ventas/Create
        // Para protegerse de ataques de publicación excesiva, habilite las propiedades específicas a las que desea enlazarse. Para obtener
        // más información vea https://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public async Task<ActionResult> Create(FormCollection formData )
        //{
        //    if (ModelState.IsValid)
        //    {
        //        string saldo = formData["Saldo"];
        //        string plazo = formData["Financiamiento.Plazo"];
        //        //db.TVenta.Add(tVenta);
        //        //await db.SaveChangesAsync();

        //        ////revisar que el web config este seteado con el mismo idtipofinanciamiento de la BD tabla ctipoVenta (2)
        //        //if (tVenta.IdTipoVenta == Int32.Parse(WebConfigurationManager.AppSettings["TipoVentaFinanciamiento"]))
        //        //    return RedirectToAction("Create", "Financiamientos", new { idVenta = tVenta.IdVenta });

        //        //return RedirectToAction("Index");
        //    }

        //    //ViewBag.IdTipoVenta = new SelectList(db.CTipoVenta, "IdTipoVenta", "Descripcion", tVenta.IdTipoVenta);
        //    //ViewBag.IdCliente = new SelectList(db.TCliente, "IdCliente", "Identificacion", tVenta.IdCliente);
        //    //ViewBag.Placa = new SelectList(db.TVehiculo, "Placa", "Estilo", tVenta.Placa);
        //    return View();
        //}

        // GET: Ventas/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TVenta tVenta = await db.TVenta.FindAsync(id);

            if (tVenta == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IdTipoVenta = new SelectList(db.CTipoVenta, "IdTipoVenta", "Descripcion", tVenta.IdTipoVenta);
            //ViewBag.IdCliente = new SelectList(db.TCliente, "IdCliente", "Identificacion", tVenta.IdCliente);
            //ViewBag.Placa = new SelectList(db.TVehiculo, "Placa", "Estilo", tVenta.Placa);
            CargarComboClientes(tVenta.IdCliente);
            CargarComboVehiculos(tVenta.Placa);
            return(View(tVenta));
        }
コード例 #6
0
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public async Task<ActionResult> GetVehiculo( String placa)
        //(Nullable<decimal> monto, Nullable<System.DateTime> fecha, Nullable<int> idTipoVenta, Nullable<int> idCliente, Nullable<decimal> saldo,
        //string placa, Nullable<decimal> interes, Nullable<short> plazo, Nullable<int> idPeriodoPago, string descripcion)
        public async Task <Boolean> InsertarVentaFinanciamiento(string pmonto, string pfecha, string pidTipoVenta, string pidCliente, string psaldo,
                                                                string pplaca, string pinteres, string pplazo)
        {
            //if (placa == null)
            //{
            //    // return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            //    return false;
            //}
            bool inserto = false;

            try
            {
                Decimal  monto       = Convert.ToDecimal(pmonto);
                DateTime fecha       = Convert.ToDateTime(pfecha);
                int      idTipoVenta = Convert.ToInt32(pidTipoVenta);
                int      idCliente   = Convert.ToInt32(pidCliente);

                if (idTipoVenta == 2)
                {//financiamiento
                    if (pplazo != null)
                    {
                        if (pplazo != string.Empty)
                        {
                            pplazo = pplazo.Substring(0, pplazo.IndexOf(" Meses"));
                        }
                    }
                    Decimal saldo   = Convert.ToDecimal(psaldo);
                    Decimal interes = Convert.ToDecimal(pinteres);
                    Int16   plazo   = Convert.ToInt16(pplazo);
                    System.Data.Entity.Core.Objects.ObjectParameter returnId = new System.Data.Entity.Core.Objects.ObjectParameter("idVenta", typeof(int)); //Create Object parameter to receive a output value.It will behave like output parameter

                    int venta = db.InsertarVentaFinanciamiento(monto, fecha, idTipoVenta, idCliente, saldo, pplaca, interes, plazo, 1, " ", returnId);
                    if (int.Parse(returnId.Value.ToString()) > 0)
                    {
                        //RedirectToAction("Index");
                        inserto = true;
                        // return true;
                    }
                }
                else
                {// contado
                    TVenta tVenta = new TVenta();
                    tVenta.Monto       = Convert.ToDecimal(pmonto);
                    tVenta.Fecha       = Convert.ToDateTime(pfecha);
                    tVenta.IdTipoVenta = Convert.ToInt32(pidTipoVenta);
                    tVenta.IdCliente   = Convert.ToInt32(pidCliente);
                    tVenta.Placa       = pplaca;
                    tVenta.Saldo       = tVenta.Monto;

                    db.TVenta.Add(tVenta);
                    await db.SaveChangesAsync();

                    RedirectToAction("Index");
                    inserto = true;
                    //return true;

                    //revisar que el web config este seteado con el mismo idtipofinanciamiento de la BD tabla ctipoVenta (2)
                    //if (tVenta.IdTipoVenta == Int32.Parse(WebConfigurationManager.AppSettings["TipoVentaFinanciamiento"]))
                    //    return RedirectToAction("Create", "Financiamientos", new { idVenta = tVenta.IdVenta });
                }
            }
            catch (Exception e) {
                return(false);
            }

            RedirectToAction("Index");

            return(inserto);
        }