public async Task <Response> modificarTodo(Descuento param)
 {
     try
     {
         // localhost:8080/admeli/xcore2/xcore/services.php/descuento/editar/todo
         return(await webService.POST <Descuento, Response>("descuento", "editar/todo", param));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public async Task <Response> guardar(Descuento param)
 {
     try
     {
         // localhost:8080/admeli/xcore2/xcore/services.php/descuento/guardar
         return(await webService.POST <Descuento, Response>("descuento", "guardar", param));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #3
0
        public static Descuento rowToDto(DescuentoDS.DiscountsRow row)
        {
            Descuento objDescuento = new Descuento();

            objDescuento.pkDescuento     = row.pkDescuento;
            objDescuento.txtNombre       = row.txtNombre;
            objDescuento.dateFechaInicio = row.dateFechaInicio;
            objDescuento.dateFechaFin    = row.dateFechaFin;
            objDescuento.descuento       = row.intDescuento;
            objDescuento.descripcion     = row.txtDescripcion;
            return(objDescuento);
        }
Exemple #4
0
 public VerDescuentoDetallePage()
 {
     InitializeComponent();
     if (descuento == null)
     {
         descuento = new Descuento();
     }
     if (consumidor == null)
     {
         consumidor = new Consumidor();
     }
 }
 public async Task <Response> desactivar(Descuento param)
 {
     try
     {
         // localhost:8080/admeli/xcore2/xcore/services.php/desccascasuento/elicascsminar
         return(await webService.POST <Descuento, Response>("catecascascasgoria", "dascascasesactivar", param));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public ReservasController_vistaSeleccionHabitacionReserva_test()
        {
            _contextOptions = CreateNewContextOptions();
            context         = new ApplicationDbContext(_contextOptions);
            // Insert seed data into the database using one instance of the context
            Cliente cliente1     = (new Cliente {
                idPersona = 1, nombre = "Prueba1", apellidos = "Prueba1 Prueba1", telefono = "666666666", correoElectronico = "*****@*****.**", nif = "12345678A", numeroTarjeta = "4444333322221111"
            });
            Cliente cliente2     = (new Cliente {
                idPersona = 2, nombre = "Prueba2", apellidos = "Prueba2 Prueba2", telefono = "777777777", correoElectronico = "*****@*****.**", nif = "87654321B", numeroTarjeta = "4444333322221111"
            });
            Descuento descuento1 = new Descuento {
                idDescuento = 1, fechaInicio = new DateTime(2016, 11, 20), fechaFin = new DateTime(2016, 11, 29)
            };
            Descuento descuento2 = new Descuento {
                idDescuento = 2, fechaInicio = new DateTime(2016, 11, 27), fechaFin = new DateTime(2016, 11, 28)
            };
            Habitacion habitacion1 = new Habitacion {
                precio = 20
            };
            Habitacion habitacion2 = new Habitacion {
                precio = 40
            };
            Reserva reserva1 = new Reserva {
                fechaInicio = new DateTime(2016, 11, 25), fechaFin = new DateTime(2016, 11, 27)
            };
            Reserva reserva2 = new Reserva {
                fechaInicio = new DateTime(2016, 11, 10), fechaFin = new DateTime(2016, 11, 12)
            };
            ReservaHabitacion reservaHabitacion1 = new ReservaHabitacion();
            ReservaHabitacion reservaHabitacion2 = new ReservaHabitacion();



            reservaHabitacion1.Reserva    = reserva1;
            reservaHabitacion1.Habitacion = habitacion1;
            reservaHabitacion2.Reserva    = reserva2;
            reservaHabitacion2.Habitacion = habitacion2;

            context.Cliente.Add(cliente1);
            context.Cliente.Add(cliente2);
            context.Descuento.Add(descuento1);
            context.Descuento.Add(descuento2);
            context.Habitacion.Add(habitacion1);
            context.Habitacion.Add(habitacion2);
            context.Reserva.Add(reserva1);
            context.Reserva.Add(reserva2);
            context.ReservaHabitacion.Add(reservaHabitacion1);
            context.ReservaHabitacion.Add(reservaHabitacion2);

            context.SaveChanges();
        }
Exemple #7
0
 public bool Save(Descuento entity)
 {
     try
     {
         context.Add(entity);
         context.SaveChanges();
     }
     catch (System.Exception)
     {
         return(false);
     }
     return(true);
 }
        public Descuento MapearEntrada()
        {
            var descuento = new Descuento
            {
                Codigo         = Codigo,
                Porcentaje     = Porcentaje,
                CodProducto    = CodProducto,
                IdPersona      = IdPersona,
                NombreProducto = NombreProducto
            };

            return(descuento);
        }
Exemple #9
0
        private Descuento GenerarCodigo(Descuento descuento)
        {
            var    random = new Random();
            string codigo = random.Next().ToString();

            if (ValidarCodigo(codigo))
            {
                descuento.Codigo = codigo;
                return(descuento);
            }
            GenerarCodigo(descuento);
            return(null);
        }
Exemple #10
0
        private async void executeGuardar()
        {
            if (!validarCampos())
            {
                return;
            }
            try
            {
                crearObjetoSucursal();
                if (nuevo)
                {
                    currentDescuento = new Descuento();

                    string dateFin = String.Format("{0:u}", dtpFechaFin.Value);
                    dateFin = dateFin.Substring(0, dateFin.Length - 1);

                    string dateInicio = String.Format("{0:u}", dtpFechaInicio.Value);
                    dateInicio = dateInicio.Substring(0, dateInicio.Length - 1);


                    // asignar al decuento
                    currentDescuento.cantidadMaxima   = textMaximaVenta.Text.Trim();
                    currentDescuento.cantidadMinima   = textMinimaVenta.Text.Trim();
                    currentDescuento.codigo           = textCodigo.Text.Trim();
                    currentDescuento.descuento        = textDescuento.Text.Trim();
                    currentDescuento.estado           = 1;
                    currentDescuento.fechaFin         = dateFin;
                    currentDescuento.fechaInicio      = dateInicio;
                    currentDescuento.idAfectoProducto = 0;
                    currentDescuento.tipo             = "General";
                    currentDescuento.idGrupoCliente   = (int)cbxGrupoCliente.SelectedValue;
                    currentDescuento.idSucursal       = (int)cbxSucursal.SelectedValue;
                    currentDescuento.idPresentacion   = formProductoNuevo.currentIDProducto;

                    Response response = await descuentoModel.guardar(currentDescuento);

                    MessageBox.Show(response.msj, "Guardar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    //Response response = await descuentoModel.modificar(currentDescuento);
                    Response response = null;
                    MessageBox.Show(response.msj, "Modificar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Guardar", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemple #11
0
        public Descuento Get(int id)
        {
            var result = new Descuento();

            try
            {
                result = context.Descuentos.Single(x => x.Id == id);
            }
            catch (System.Exception)
            {
                throw;
            }
            return(result);
        }
Exemple #12
0
        // GET: Descuentoes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Descuento descuento = db.Descuento.Find(id);

            if (descuento == null)
            {
                return(HttpNotFound());
            }
            return(View(descuento));
        }
Exemple #13
0
        public static List <Descuento> SelectAll()
        {
            List <Descuento> listadeDescuentos = new List <Descuento>();

            AppSales.DAL.DescuentoDSTableAdapters.DiscountsTableAdapter objDataSet = new AppSales.DAL.DescuentoDSTableAdapters.DiscountsTableAdapter();
            DescuentoDS.DiscountsDataTable dtDescuentos = objDataSet.GetAllDiscounts();

            foreach (DescuentoDS.DiscountsRow row in dtDescuentos)
            {
                Descuento objDescuento = rowToDto(row);
                listadeDescuentos.Add(objDescuento);
            }
            return(listadeDescuentos);
        }
Exemple #14
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            Descuento descuento = new Descuento();

            descuento.IdDescuentos = Convert.ToInt32(cboTipoDescuento.SelectedValue);
            descuento.Porcentaje   = Convert.ToInt32(txtDescuento.Text);

            if (ValidarDescuento(descuento.IdDescuentos))
            {
                string mensaje = Descuento.Modificar(descuento);
                ObtenerDescuentosMaximosActuales();
                MessageBox.Show(mensaje);
            }
        }
Exemple #15
0
    // Método que calcula el total de la factura
    public double CalcularTotal()
    {
        // Calculamos el descuento
        Descuento descuento = new Descuento(Subtotal, CantidadDescuento);

        DescuentoTotal = descuento.CalcularDescuento();
        // Calculamos el IVA
        IvaNormal iva = new IvaNormal();

        Iva = iva.CalcularIVA(Subtotal);
        // Calculamos el total
        Total = (DescuentoTotal) + Iva;

        return(Total);
    }
Exemple #16
0
 /// <summary>
 /// Funcion encargada de guardar un nuevo registro en la base de datos
 /// </summary>
 /// <param name="nDescuento">variable de tipo modelo desccuento</param>
 public static void RegistrarNuevoDescuento(Descuento nDescuento)
 {
     try
     {
         using (var ctx = new DataModel())
         {
             ctx.Descuentos.Add(nDescuento);
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #17
0
        public Descuento Convert_DescuentoCmd_To_Descuento(DescuentoCmd descuentoCmd)
        {
            Descuento d = null;

            if (descuentoCmd != null)
            {
                d              = new Descuento();
                d.Nombre       = descuentoCmd.Nombre;
                d.Descripcion  = descuentoCmd.Descripcion;
                d.Porcentaje   = descuentoCmd.Porcentaje;
                d.MediosDePago = descuentoCmd.MediosDePago;
            }

            return(d);
        }
Exemple #18
0
        //          [Descuento]     -------------------------

        #region Descuento

        public DescuentoQuery Convert_Descuento_To_DescuentoQuery(Descuento descuento)
        {
            DescuentoQuery d = null;

            if (descuento != null)
            {
                d              = new DescuentoQuery();
                d.Nombre       = descuento.Nombre;
                d.Descripcion  = descuento.Descripcion;
                d.Porcentaje   = descuento.Porcentaje;
                d.MediosDePago = descuento.MediosDePago;
            }

            return(d);
        }
Exemple #19
0
        public List <Descuento> listarDescuentos()
        {
            try
            {
                Consumidor       consumidor;
                Descuento        descuento;
                List <Descuento> listaDescuentos = new List <Descuento>();
                OracleCommand    cmd             = new OracleCommand();
                cmd.Connection  = conexion.Obtener();
                cmd.CommandText = "SP_SELECT_DESCUENTOS_MENU";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new OracleParameter("p_CURSOR", OracleDbType.RefCursor)).Direction = ParameterDirection.Output;
                if (conexion.Obtener().State.Equals(ConnectionState.Closed))
                {
                    conexion.Obtener().Open();
                }
                OracleDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    descuento  = new Descuento();
                    consumidor = new Consumidor();

                    descuento.IdDescuento  = dr.GetInt32(0);
                    descuento.Puntos       = dr.GetInt32(2);
                    descuento.Descuentos   = dr.GetFloat(3);
                    descuento.Tope         = dr.GetInt32(4);
                    descuento.FechaEmision = dr.GetDateTime(5);
                    descuento.Rubros       = dr.GetString(1);
                    descuento.Condiciones  = dr.GetString(14);
                    //DATOS CONSUMIDOR
                    consumidor.IdConsumidor = dr.GetInt32(8);
                    consumidor.Nombre       = dr.GetString(9);
                    consumidor.Apellidos    = dr.GetString(10);
                    consumidor.Correo       = dr.GetString(11);
                    consumidor.Rut          = dr.GetInt32(12);
                    descuento.Consumidor    = consumidor;

                    listaDescuentos.Add(descuento);
                }
                conexion.Obtener().Close();
                return(listaDescuentos);
            }
            catch (Exception e)
            {
                conexion.Obtener().Close();
                return(null);
            }
        }
Exemple #20
0
        internal bool Create(Descuento oDescuento)
        {
            //CON PARAMETROS
            //string str_sql = "     INSERT INTO Usuarios (usuario, password, email, id_perfil, estado, borrado)" +
            //                 "     VALUES (@usuario, @password, @email, @id_perfil, 'S', 0)";

            // var parametros = new Dictionary<string, object>();
            //parametros.Add("usuario", oUsuario.NombreUsuario);
            //parametros.Add("password", oUsuario.Password);
            //parametros.Add("email", oUsuario.Email);
            //parametros.Add("id_perfil", oUsuario.Perfil.IdPerfil);

            // Si una fila es afectada por la inserción retorna TRUE. Caso contrario FALSE
            //con parametros
            //return (DBHelper.GetDBHelper().EjecutarSQLConParametros(str_sql, parametros) == 1);

            DataManager dm = new DataManager();

            try
            {
                dm.Open();
                dm.BeginTransaction();
                //SIN PARAMETROS

                string str_sql = "INSERT INTO Descuentos (n_descuento, monto, borrado)" +
                                 " VALUES (" +

                                 "'" + oDescuento.N_descuento + "'" + "," +
                                 "'" + oDescuento.Monto + "'" + "," + "0)";


                //return (DBHelper.GetDBHelper().EjecutarSQL(str_sql)==1);
                dm.EjecutarSQL(str_sql);
                dm.Commit();
            }

            catch (Exception ex)
            {
                dm.Rollback();
                throw ex;
            }
            finally
            {
                // Cierra la conexión
                dm.Close();
            }
            return(true);
        }
Exemple #21
0
        public JsonResult DeleteDescuento(int DescuentoId)
        {
            string    result    = "";
            Descuento descuento = db.Descuento.Find(DescuentoId);

            if (descuento != null)
            {
                clsdescue.eliminar(DescuentoId);
                result = "Eliminado";
            }
            else
            {
                result = "Registro no encontrado";
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #22
0
        public HttpResponseMessage Delete(FormDataCollection form)
        {
            Descuento descuento = new Descuento();

            descuento.MontoDescuento1     = Convert.ToDecimal(form.Get("Monto"));
            descuento.NaturalezaDescuento = form.Get("Naturaleza");

            string[] respuesta = new string[3];
            respuesta[0] = descuento.Delete_Descuento();
            respuesta[1] = form.Get("Monto");
            respuesta[2] = form.Get("Naturaleza");

            HttpResponseMessage response = Request.CreateResponse <string[]>(HttpStatusCode.Created, respuesta);

            return(response);
        }
 public ActionResult Editar(Descuento descuento)
 {
     try
     {
         Descuento d = db.Descuento.Find(descuento.id);
         d.nombre = descuento.nombre;
         d.numero = descuento.numero;
         d.valor  = descuento.valor;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Crear(Descuento descuento)
 {
     try
     {
         descuento.fecha_registro = DateTime.Now;
         descuento.estado         = 1;
         db.Descuento.Add(descuento);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("Error al agregar descuento", ex);
         return(View());
     }
 }
Exemple #25
0
 /// <summary>
 /// Funcion encargada de modificar un registro de la base de datos
 /// </summary>
 /// <param name="nDescuentos"></param>
 public static void Modificar(Descuento nDescuentos)
 {
     try
     {
         using (var ctx = new DataModel())
         {
             ctx.Descuentos.Attach(nDescuentos);
             ctx.Entry(nDescuentos).State = EntityState.Modified;
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        public async Task <IActionResult> Edit(int id, [Bind("DescuentoID,NombreDelDescuento,TipoDeDescuento,MontoDeDescuento,PrecioConDesc,ProductoID")] Descuento descuento)
        {
            if (id != descuento.DescuentoID)
            {
                return(NotFound());
            }
            double desc = descuento.MontoDeDescuento;

            descuento.EstaActivo = true;
            foreach (var producto in _context.Producto)
            {
                if (descuento.ProductoID == producto.ProductoID)
                {
                    if (descuento.TipoDeDescuento == true)
                    {
                        descuento.PrecioConDesc = Math.Round((producto.PrecioUnitario * (1 - (desc * 0.01))), 2);
                    }
                    else
                    {
                        descuento.PrecioConDesc = Math.Round((producto.PrecioUnitario - desc), 2);
                    }
                }
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(descuento);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DescuentoExists(descuento.DescuentoID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("IndexVendedor", "Productos"));
            }

            return(View(descuento));
        }
Exemple #27
0
        public override bool ConsultarDescuentos()
        {
            DataManager.DataManager datos = new DataManager.DataManager(App.CadenaConexion(IDEmpresa), App.ProveedorDatos(IDEmpresa));
            DbDataReader            reader;

            try
            {
                List <DbParameter> listParams = new List <DbParameter>();
                DbCommand          cmd        = datos.Connection.CreateCommand();

                DbParameter IdCliente = cmd.CreateParameter();
                IdCliente.DbType        = DbType.Int32;
                IdCliente.ParameterName = "@Cliente";
                IdCliente.Value         = this.IDDireccionEntrega;
                listParams.Add(IdCliente);

                reader = datos.Data.LoadData("spSCConsultaDescuentoCliente", CommandType.StoredProcedure, listParams.ToArray());

                while (reader.Read())
                {
                    Descuento descuento = new Descuento();
                    descuento.FInicial         = Convert.ToDateTime(reader["FInicial"]);
                    descuento.FFinal           = Convert.ToDateTime(reader["FFinal"]);
                    descuento.ImporteDescuento = Convert.ToDecimal(reader["ValorDescuento"]);
                    descuento.TipoDescuento    = reader["TipoDescuento"].ToString();
                    descuento.Status           = reader["Status"].ToString();

                    this.Descuentos.Add(descuento);
                }
                this.Success = true;
            }
            catch (Exception ex)
            {
                this.Success           = false;
                this.Message           = "Ocurrió un error:" + ex.Message;
                this.internalException = ex;
            }
            finally
            {
                datos.Data.CloseConnection();
                datos.Connection.Dispose();
                datos = null;
            }

            return(this.Success);
        }
        public async Task <IActionResult> Create([Bind("ProductoID,NombreProducto,PrecioUnitario,Existencia,Codigo,Imagen,SubcategoriaID,detalleVendedorID, estadoProducto,existenciaSinActivacion")] Producto producto, IFormFile Imagen)
        {
            if (ModelState.IsValid)
            {
                Agrega(Imagen);
                producto.Imagen = Imagen.FileName;

                //generador random de codigo
                var chars     = Enumerable.Repeat("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 10);
                var randomStr = new string(chars.SelectMany(str => str)
                                           .OrderBy(c => Guid.NewGuid())
                                           .Take(10).ToArray());
                //setzy codiguito wapo
                producto.Codigo = randomStr;


                //Asignando el producto al vendedor que ha iniciado sesion
                var user = await _userManager.GetUserAsync(User);

                var vendedor = _context.DetalleVendedor.Single(d => d.tiendaOnlineUser == user);
                producto.detalleVendedorID       = vendedor.DetalleVendedorID;
                producto.existenciaSinActivacion = producto.Existencia;
                producto.Existencia     = 0;
                producto.estadoProducto = false;
                _context.Add(producto);
                //crea un descuento para cada producto
                var descuento = new Descuento()
                {
                    EstaActivo         = false,
                    NombreDelDescuento = "",
                    MontoDeDescuento   = 0,
                    TipoDeDescuento    = true,
                    PrecioConDesc      = 0,
                    ProductoID         = producto.ProductoID
                };
                _context.Add(descuento);

                await _context.SaveChangesAsync();

                return(RedirectToAction("Create", "DetalleProductos"));
            }
            ViewData["CategoriaID"] = new SelectList(_context.Categoria, "CategoriaID", "nombre_categoria");

            return(View(producto));
        }
        public int contarBusquedaDescuento(Descuento obj)
        {
            int cantidad = -1;

            try {
                DescuentoDao dao = new DescuentoDao();
                conn     = conexion.conectar();
                cantidad = dao.countSearchMatching(conn, obj);
            } catch (Exception e) {
                cantidad = -1;
            } finally {
                if (conn != null && conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(cantidad);
        }
Exemple #30
0
        /// <summary>
        /// Funcion encargada de eliminar un registro de la base de datos mediante una id
        /// </summary>
        /// <param name="pkImpuesto"></param>
        public static void Eliminar(int pkImpuesto)
        {
            try
            {
                using (var ctx = new DataModel())
                {
                    Descuento nDescuento = ManejoDescuento.getById(pkImpuesto);
                    nDescuento.bStatus = false;

                    ctx.Entry(nDescuento).State = EntityState.Modified;
                    ctx.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #31
0
    public static Descuento ObtenerDescuentos(int TipoConsulta, string CodArticulo, decimal Descuento)
    {
        Descuento Codigo = new Descuento();


        SqlConnection connection = new SqlConnection(connectionStringPJ);

        SqlCommand command = new SqlCommand("PJ_CalculoUtilidad", connection);
        command.CommandType = CommandType.StoredProcedure;
        command.Parameters.AddWithValue("@TipoConsulta", TipoConsulta);
        command.Parameters.AddWithValue("@Articulo", CodArticulo);
        command.Parameters.AddWithValue("@PrecioCompra", 0.0);
        command.Parameters.AddWithValue("@Desc", Descuento);

        connection.Open();
        using (SqlDataReader sdr = command.ExecuteReader())
        {
            while (sdr.Read())
            {
                Codigo.PrecioCompraMXP = Convert.ToDecimal(sdr["PrecioDescMXP"]).ToString("C2");
                Codigo.PrecionVentaMXP = decimal.Round((Convert.ToDecimal(sdr["UtilidadDescMXP"])) * 100, 2).ToString() + " %";
                
                Codigo.PrecioCompraUSD = Convert.ToDecimal(sdr["PrecioDescUSD"]).ToString("C2");
                Codigo.PrecionVentaUSD = decimal.Round((Convert.ToDecimal(sdr["UtilidadDescUSD"])) * 100, 2).ToString() + " %";
            }
        }

        return Codigo;
    }