//MIGRADA public void CompraProducto(UEUVenta venta, String modif) { NpgsqlConnection conection = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["Postgresql"].ConnectionString); try { conection.Open(); NpgsqlCommand command = new NpgsqlCommand("sp_comprar_producto", conection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("_modif", NpgsqlTypes.NpgsqlDbType.Text).Value = modif; command.Parameters.Add("_idproducto", NpgsqlTypes.NpgsqlDbType.Integer).Value = venta.IdProducto; command.Parameters.Add("_canventa", NpgsqlTypes.NpgsqlDbType.Integer).Value = venta.Cantidad; command.Parameters.Add("_valorventa", NpgsqlTypes.NpgsqlDbType.Integer).Value = venta.Valor; command.Parameters.Add("_idusr", NpgsqlTypes.NpgsqlDbType.Integer).Value = venta.IdUsr; command.Parameters.Add("_estadoventa", NpgsqlTypes.NpgsqlDbType.Integer).Value = venta.EstadoVenta; command.ExecuteNonQuery(); } catch (Exception e) { throw e; } finally { conection.Close(); } }
public void CompraProducto(UEUVenta venta, string modif) { using (var db = new Mapeo("public")) { venta.modified_by = modif; db.ventas.Add(venta); db.SaveChanges(); DBAuditoria.insert(venta, crearAcceso(), "dbo", "Venta"); } }
//pendiente public void CalificarCliente(double rango, String comentario, int idEmpresa, int idCliente, int idVenta, String modif) { using (var db = new Mapeo("public")) { //PÁSO 1 INSERTAR EN RANGO UEURango rang = new UEURango(); rang.Rango = rango; rang.Comentario = comentario; rang.Calificador = 1; rang.FechaRango = DateTime.Now; rang.IdEmp = idEmpresa; rang.IdUsr = idCliente; rang.ModifiBy = modif; db.rangos.Add(rang); db.SaveChanges(); //PASO 2 OBTENER EL ID DEL RANGO var idRango = (from rangods in db.rangos select rangods.IdRango).OrderByDescending(x => x).Take(1); int idrang = idRango.First(); //PASO 3 ACTUALIZAR LAS VENTAS UEUVenta vent = db.ventas.Find(idVenta); vent.CalEmp = idrang; vent.EstadoVenta = 5; vent.modified_by = modif; db.SaveChanges(); //PASO 4 OBTENER CALIFICACION CUENTA Double cal = (from ra in db.rangos where ra.IdUsr == idCliente && ra.Calificador == 1 select ra.Rango).Sum(); int cuenta = (from ra in db.rangos where ra.IdUsr == idCliente && ra.Calificador == 1 select ra.Rango).Count(); Double califi = (cal / cuenta); califi = Math.Round(califi); //PASO 5 ACTUALIZAR EL USUARIO UEUsuario user = db.user.Find(idCliente); user.Calificacion2 = califi; user.ModifBy = modif; db.SaveChanges(); //PASO 6 PREGNTAR SI SE DEBE BLOQUEAR EL USUARIOI if (califi < 3) { UEUsuario updateUsr = db.user.Find(idCliente); updateUsr.EstUsr = 2; updateUsr.ModifBy = modif; db.SaveChanges(); UEUBloqueo bloq = new UEUBloqueo(); bloq.fechaInicio = DateTime.Now; bloq.fechaFinal = DateTime.Now.AddDays(90); bloq.idUsuario = idCliente; bloq.modified_by = modif; db.bloqueos.Add(bloq); db.SaveChanges(); } } }
public void ConfirmarRecibido(int idVenta, int estado, string modif) { using (var db = new Mapeo("public")) { var update = db.ventas.Find(idVenta); UEUVenta old_Vent = (UEUVenta)update.Clone(); update.EstadoVenta = estado; update.FechaEntr = DateTime.Now; update.modified_by = modif; db.SaveChanges(); DBAuditoria.update(update, old_Vent, crearAcceso(), "dbo", "Venta"); } }
public void BTN_Yes_Click(Object Session, Object VerProducto, String TB_CantidadVenta) { DataTable user = (DataTable)Session; DataTable producto = (DataTable)VerProducto; UEUVenta venta = new UEUVenta(); venta.IdUsr = int.Parse(user.Rows[0]["idUsuario"].ToString()); venta.Cantidad = int.Parse(TB_CantidadVenta); int valor = int.Parse(TB_CantidadVenta) * int.Parse(producto.Rows[0]["precioProducto"].ToString()); venta.Valor = valor; venta.IdProducto = int.Parse(producto.Rows[0]["idProducto"].ToString()); venta.EstadoVenta = 1; DB_Producto daoProducto = new DB_Producto(); //DDAOProducto compra = new DDAOProducto(); daoProducto.CompraProducto(venta, user.Rows[0]["nomUsuario"].ToString()); }
public UAuxVenta BTN_ComprarProducto_Click(Object Session, Object VerProducto, String tb_CantidadVenta, String LB_CantidadProducto, bool post) { UAuxVenta reponde = new UAuxVenta(); if (post) { if (Session == null) { reponde.Valido = true; reponde.Msg = "Tienes que iniciar sesion para comprar."; //BTN_Modal.Visible = true; //Modal("Tienes que iniciar sesion para comprar."); } else { DataTable user = (DataTable)Session; DataTable producto = (DataTable)VerProducto; if (tb_CantidadVenta.Length == 0) { reponde.Valido = false; reponde.Msg = "Tienes que especificar la cantidad de productos a comprar."; //Modal("Tienes que especificar la cantidad de productos a comprar."); } else if (user.Rows[0]["idTipo"].ToString() != "3") { reponde.Valido = false; reponde.Msg = "Solo los clientes pueden hacer petición de compra."; //Modal("Solo los clientes pueden hacer petición de compra."); } else if ((int.Parse(tb_CantidadVenta)) > (int.Parse(LB_CantidadProducto))) { reponde.Valido = false; reponde.Msg = "Solicitaste una cantidad que excede nuestro límite de inventario, reduce tu cantidad de productos a comprar."; //Modal("Solicitaste una cantidad que excede nuestro límite de inventario, reduce tu cantidad de productos a comprar."); } else if (int.Parse(LB_CantidadProducto) == 0) { reponde.Valido = false; reponde.Msg = "El producto está agotado, intentalo después."; //Modal("El producto está agotado, intentalo después."); } else { UEUVenta venta = new UEUVenta(); venta.IdUsr = int.Parse(user.Rows[0]["idUsuario"].ToString()); int valor = int.Parse(tb_CantidadVenta) * int.Parse(producto.Rows[0]["precioProducto"].ToString()); reponde.Valido = false; reponde.BtnYes = true; reponde.Msg = "Tu solicitud de compra ha sido enviada, por valor de $" + valor.ToString() + ", la empresa revisará los parámetros y decidirá aceptar o rechazar tu compra. Deseas confirmar esta compra?"; //BTN_Yes.Visible = true; //Modal("Tu solicitud de compra ha sido enviada, por valor de $" + valor.ToString() + ", la empresa revisará los parámetros y decidirá aceptar o rechazar tu compra. Deseas confirmar esta compra?"); } } } else { reponde = null; } return(reponde); }