public JsonResult Pagar()
        {
            string res = "false";

            try
            {
                if (Session["carro"] == null)
                {
                    Session["carro"] = new List <Productos>();
                    res = "no hay productos";
                }
                else
                {
                    List <Productos>  lista = (List <Productos>)Session["carro"];
                    OperacionesVentas oprod = new OperacionesVentas();
                    int id = (int)Session["idUsuario"];
                    foreach (Productos prod in lista)
                    {
                        if (!oprod.Guardar(id, prod.idProducto, DateTime.Now))
                        {
                            throw new Exception("Error al guardar");
                        }
                    }
                    Session["carro"] = new List <Productos>();
                    res = "true";
                }
            }
            catch (Exception ex)
            {
                res = ex.Message;
            }
            return(Json(res));
        }
示例#2
0
        private void CargarGrillaVentas()
        {   //carco combo cliente
            cbxListadoCliente.DataSource    = OperacionesClientes.TraerClientes();
            cbxListadoCliente.DisplayMember = "ApeyNom";
            cbxListadoCliente.ValueMember   = "DNI";
            cbxListadoCliente.Text          = "Seleccione...";

            //cargo combo marcas
            cbxListadoMarca.DataSource    = OperacionesVehiculos.TraerMarcas();
            cbxListadoMarca.DisplayMember = "Marca";
            cbxListadoMarca.ValueMember   = "Marca";
            cbxListadoMarca.Text          = "Seleccione...";


            dgvVentasRealizadas.DataSource = OperacionesVentas.TraerVentas();
            dgvVentasRealizadas.Columns["FECHA DE VENTA"].DefaultCellStyle.Format = "dd/MM/yyyy";


            cantVentas.Text            = "-"; //inicializa los label que contienen resultados(vtas confirmadas,anuadas etc)
            cantVentasConfirmadas.Text = "-";
            cantVentasAnuladas.Text    = "-";
            importeTotal.Text          = "-";
            importeConfirmado.Text     = "-";
            importeAnulado.Text        = "-";
        }
示例#3
0
        private void CargarGrillaSegunOpcion(int opcion)
        {
            switch (opcion)
            {
            case 0:    //Clases Vehiculo
                dgvGestion.DataSource = OperacionesVehiculos.TraerClasesVehiculo();
                dgvGestion.AutoResizeColumns();
                break;

            case 1:    //Tipos Vehiculo
                dgvGestion.DataSource = OperacionesVehiculos.TraerTiposVehiculo();
                dgvGestion.AutoResizeColumns();
                break;

            case 2:    //Formas Pago
                dgvGestion.DataSource = OperacionesVentas.TraerFormasPago();
                dgvGestion.AutoResizeColumns();
                break;

            default:
                dgvGestion.DataSource = OperacionesVehiculos.TraerClasesVehiculo();
                break;
            }
            cbxVer.SelectedIndex = opcion;
        }
示例#4
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (dgvClientes.CurrentRow != null)
            {
                //Valida si está en uso
                int nroVenta = OperacionesVentas.TraerNROVentaSegunParametro(txtDNI.Text, "DNI");
                if (nroVenta == 0)
                {
                    var respuesta = MessageBox.Show("¿Desea eliminar el cliente seleccionado?", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (respuesta.ToString() == "Yes")
                    {
                        string dni = txtDNI.Text;
                        OperacionesClientes.EliminarCliente(dni);
                    }

                    CargarGrillaClientes();
                }
                else
                {
                    MessageBox.Show("El cliente seleccionado NO se puede eliminar!\n" +
                                    "\nSe encuentra en uso en la Venta NRO: " + nroVenta
                                    , "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
示例#5
0
        private void btnConfirmarCompra_Click(object sender, EventArgs e)
        {
            if (cmbCliente.SelectedValue != null && cmbVehiculo.SelectedValue != null && cmbFormaDePago.SelectedValue != null && cmbPrecioFinal.Text != "")
            {
                Venta oVenta = new Venta();

                oVenta.Clie_dni        = (string)cmbCliente.SelectedValue;
                oVenta.Veh_matricula   = (string)cmbVehiculo.SelectedValue;
                oVenta.Usu_id          = myUser.Usu_id;
                oVenta.Vta_fecha       = dtpFechaDeCompra.Value;
                oVenta.Vta_formaPago   = (int)cmbFormaDePago.SelectedValue;
                oVenta.Vta_precioFinal = int.Parse(cmbPrecioFinal.Text);
                oVenta.Vta_estado      = "ACTIVA";

                OperacionesVentas.AgregarVenta(oVenta);

                var respuesta = MessageBox.Show("Venta registrada exitosamente!\n"
                                                + "\n¿Desea registrar otra Venta?", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (respuesta.ToString() == "Yes")
                {
                    InicializarCombos();
                    LimpiarCampos();
                }
                else
                {
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Debe completar todos los datos");
            }
        }
示例#6
0
 private void btnAnularVentaSeleccionada_Click(object sender, EventArgs e)
 {
     if (dgvVentasRealizadas.CurrentRow != null)
     {
         var respuesta = MessageBox.Show("¿Desea ANULAR la venta selecionada?", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (respuesta.ToString() == "Yes")
         {
             int idVenta = (int)dgvVentasRealizadas.CurrentRow.Cells[0].Value;//VTA_ID
             OperacionesVentas.AnularVenta(idVenta);
             CargarGrillaVentas();
         }
     }
 }
示例#7
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            if (txtDescripcion.Text != "")
            {
                switch (cbxVer.SelectedIndex)
                {
                case 0:    //Clases Vehiculo
                    idExistente = OperacionesVehiculos.TraerIDsegunParametro(txtDescripcion.Text, "CLASE");
                    if (idExistente == 0)
                    {
                        OperacionesVehiculos.AgregarClaseVehiculo(txtDescripcion.Text);
                        CargarGrillaSegunOpcion(cbxVer.SelectedIndex);
                    }
                    else
                    {
                        MessageBox.Show("La descripcion de Clase ingresada ya existe en ID: " + idExistente + "!\n\nPor favor ingrese una diferente.");
                    }
                    break;

                case 1:    //Tipos Vehiculo
                    idExistente = OperacionesVehiculos.TraerIDsegunParametro(txtDescripcion.Text, "TIPO");
                    if (idExistente == 0)
                    {
                        OperacionesVehiculos.AgregarTipoVehiculo(txtDescripcion.Text);
                        CargarGrillaSegunOpcion(cbxVer.SelectedIndex);
                    }
                    else
                    {
                        MessageBox.Show("La descripcion de Tipo ingresada ya existe en ID: " + idExistente + "!\n\nPor favor ingrese una diferente.");
                    }
                    break;

                case 2:    //Formas Pago
                    idExistente = OperacionesVentas.TraerIDsegunParametro(txtDescripcion.Text);
                    if (idExistente == 0)
                    {
                        OperacionesVentas.AgregarFormaPago(txtDescripcion.Text);
                        CargarGrillaSegunOpcion(cbxVer.SelectedIndex);
                    }
                    else
                    {
                        MessageBox.Show("La descripcion de Forma de Pago ingresada ya existe en ID: " + idExistente + "!\n\nPor favor ingrese una diferente.");
                    }
                    break;
                }
            }
            else
            {
                MessageBox.Show("Debe ingresar una descripción!");
            }
        }
示例#8
0
        private void cbxListadoMarca_SelectedIndexChanged(object sender, EventArgs e)
        {
            InfoVenta infoVenta = new InfoVenta();  //pto 6

            dgvVentasRealizadas.DataSource = OperacionesVentas.TraerVentasPorMarca(cbxListadoMarca.SelectedValue.ToString(), out infoVenta);

            cantVentas.Text            = infoVenta.CantidadVentas.ToString(); //asigno valores
            cantVentasAnuladas.Text    = infoVenta.CantidadVentasAnuladas.ToString();
            cantVentasConfirmadas.Text = (infoVenta.CantidadVentas - infoVenta.CantidadVentasAnuladas).ToString();
            importeTotal.Text          = (infoVenta.ImporteTotalVentasConfirmadas + infoVenta.ImporteTotalVentasAnuladas).ToString("N0");
            importeConfirmado.Text     = infoVenta.ImporteTotalVentasConfirmadas.ToString("N0");
            importeAnulado.Text        = infoVenta.ImporteTotalVentasAnuladas.ToString("N0");

            dgvVentasRealizadas.Columns["FECHA DE VENTA"].DefaultCellStyle.Format = "dd/MM/yyyy";
            cbxListadoCliente.Text = "Seleccione...";
        }
示例#9
0
        private void btnListarFecha_Click(object sender, EventArgs e)
        {
            InfoVenta infoVenta = new InfoVenta();  //pto 6
            DateTime  inicio    = dtpFechaInicio.Value.Date;
            DateTime  fin       = dtpFechaFin.Value.Date;

            dgvVentasRealizadas.DataSource = OperacionesVentas.TraerVentasPorFecha(inicio, fin, out infoVenta);

            cantVentas.Text            = infoVenta.CantidadVentas.ToString();
            cantVentasAnuladas.Text    = infoVenta.CantidadVentasAnuladas.ToString();
            cantVentasConfirmadas.Text = (infoVenta.CantidadVentas - infoVenta.CantidadVentasAnuladas).ToString();
            importeTotal.Text          = (infoVenta.ImporteTotalVentasConfirmadas + infoVenta.ImporteTotalVentasAnuladas).ToString("N0");
            importeConfirmado.Text     = infoVenta.ImporteTotalVentasConfirmadas.ToString("N0");
            importeAnulado.Text        = infoVenta.ImporteTotalVentasAnuladas.ToString("N0");

            dgvVentasRealizadas.Columns["FECHA DE VENTA"].DefaultCellStyle.Format = "dd/MM/yyyy";
            cbxListadoCliente.Text = "Seleccione...";
            cbxListadoMarca.Text   = "Seleccione...";
        }
        public string Borrar(int id, string bd)
        {
            string res = "false";

            try
            {
                if (bd == "Mensajes")
                {
                    OperacionesMensajes opmen = new OperacionesMensajes();
                    opmen.Borrar(id);
                }
                else if (bd == "Noticias")
                {
                    OperacionesNoticias opnot = new OperacionesNoticias();
                    opnot.Borrar(id);
                }
                else if (bd == "Productos")
                {
                    OperacionesProductos oprod = new OperacionesProductos();
                    oprod.Borrar(id);
                }
                else if (bd == "Usuarios")
                {
                    OperacionesUsuarios opusu = new OperacionesUsuarios();
                    opusu.Borrar(id);
                }
                else if (bd == "Ventas")
                {
                    OperacionesVentas opven = new OperacionesVentas();
                    opven.Borrar(1);
                }
                else
                {
                    res = "no hay ningun valor";
                }
                res = "true";
            }
            catch (Exception e)
            {
            }
            return(res);
        }
示例#11
0
        private void InicializarCombos()
        {
            cmbCliente.DataSource    = OperacionesClientes.TraerClientesCombo();
            cmbCliente.DisplayMember = "CLI_ayn";
            cmbCliente.ValueMember   = "CLI_DNI";

            cmbVehiculo.DataSource    = OperacionesVehiculos.TraerVehiculosCombo();
            cmbVehiculo.DisplayMember = "VEH_Info";
            cmbVehiculo.ValueMember   = "VEH_Matricula";

            cmbPrecioFinal.DataSource    = OperacionesVehiculos.TraerVehiculosCombo();
            cmbPrecioFinal.DisplayMember = "VEH_Precio";
            cmbPrecioFinal.ValueMember   = "VEH_Matricula";

            cmbFormaDePago.DataSource    = OperacionesVentas.TraerFormasPago();
            cmbFormaDePago.DisplayMember = "DESCRIPCION DE FORMA DE PAGO";
            cmbFormaDePago.ValueMember   = "Id";

            dtpFechaDeCompra.Value = DateTime.Today;
        }
示例#12
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (dgvUsuarios.CurrentRow != null)
            {
                //Valida si está en uso - En este caso solo avisa pero deja seguir
                int nroVenta = OperacionesVentas.TraerNROVentaSegunParametro(txtID.Text, "USUARIO");
                if (nroVenta != 0)
                {
                    MessageBox.Show("El usuario seleccionado se encuentra en uso en la Venta N°: " + nroVenta
                                    , "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

                var respuesta = MessageBox.Show("¿Desea ELIMINAR el usuario seleccionado?\n(Baja Logica - Estado:INACTIVO)", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (respuesta.ToString() == "Yes")
                {
                    int id = int.Parse(txtID.Text);
                    OperacionesUsuarios.EliminarUsuario(id);
                    CargarGrilla();
                }
            }
        }
示例#13
0
        private void btnEliminarSeleccionado_Click(object sender, EventArgs e)
        {
            string matricula = "";

            switch (cbxVer.SelectedIndex)
            {
            case 0:    //Clases Vehiculo
                //Valida si está en uso
                matricula = OperacionesVehiculos.TraerMatriculaSegunParametro(txtId.Text, "CLASE");
                if (matricula == "")
                {
                    var respuesta = MessageBox.Show("¿Desea eliminar la Clase de Vehiculo seleccionada?", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (respuesta.ToString() == "Yes")
                    {
                        OperacionesVehiculos.EliminarClaseVehiculo(txtId.Text);
                    }
                }
                else
                {
                    MessageBox.Show("La Clase de Vehiculo seleccionada NO se puede eliminar!\n" +
                                    "\nSe encuentra en uso en el Vehiculo con Matricula: " + matricula
                                    , "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                break;

            case 1:    //Tipos Vehiculo
                //Valida si está en uso
                matricula = OperacionesVehiculos.TraerMatriculaSegunParametro(txtId.Text, "TIPO");
                if (matricula == "")
                {
                    var respuesta = MessageBox.Show("¿Desea eliminar Tipo de Vehiculo seleccionado?", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (respuesta.ToString() == "Yes")
                    {
                        OperacionesVehiculos.EliminarTipoVehiculo(txtId.Text);
                    }
                }
                else
                {
                    MessageBox.Show("El Tipo de Vehiculo seleccionado NO se puede eliminar!\n" +
                                    "\nSe encuentra en uso en el Vehiculo con Matricula: " + matricula
                                    , "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                break;

            case 2:    //Formas Pago
                //Valida si está en uso
                int nroVenta = OperacionesVentas.TraerNROVentaSegunParametro(txtId.Text, "FORMAPAGO");
                if (nroVenta == 0)
                {
                    var respuesta = MessageBox.Show("¿Desea eliminar la Forma de Pago seleccionada?", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (respuesta.ToString() == "Yes")
                    {
                        OperacionesVentas.EliminarFormaPago(txtId.Text);
                    }
                }
                else
                {
                    MessageBox.Show("La Forma de Pago seleccionada NO se puede eliminar!\n" +
                                    "\nSe encuentra en uso en la Venta NRO: " + nroVenta
                                    , "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                break;
            }
            CargarGrillaSegunOpcion(cbxVer.SelectedIndex);
        }
        public JsonResult Guardar()
        {
            string res = "false";

            try
            {
                string bd = Request["bd"];

                if (bd == "Mensajes")
                {
                    string texto              = texto = Request["textoMensaje"];
                    string date               = DateTime.Now.ToString();
                    string emailR             = Request["emailRemitente"];
                    OperacionesMensajes opmen = new OperacionesMensajes();
                    opmen.Guardar(texto, date, emailR);
                }
                else if (bd == "Productos")
                {
                    string nom    = Request["nombreProducto"];
                    int    precio = int.Parse(Request["precio"]);
                    int    stock  = int.Parse(Request["stock"]);
                    OperacionesProductos opprod = new OperacionesProductos();
                    opprod.Guardar(nom, precio, stock);
                }
                else if (bd == "Noticias")
                {
                    DateTime            fecha   = DateTime.Now;
                    string              texto   = Request["textoNoticia"];
                    int                 idAutor = int.Parse(Request["idAutor"]);
                    OperacionesNoticias opnot   = new OperacionesNoticias();
                    opnot.Guardar(fecha, texto, idAutor);
                }
                else if (bd == "Usuarios")
                {
                    string   nomusu   = Request["nombreUsuario"];
                    string   password = Request["password"];
                    string   pnombre  = Request["pnombre"];
                    string   snombre  = Request["snombre"];
                    string   apat     = Request["apat"];
                    string   apmat    = Request["apmat"];
                    DateTime fecha    = DateTime.Now;
                    int      tipo     = 0;
                    if (Request["tipo"].ToString() == "Administrador")
                    {
                        tipo = 1;
                    }
                    else if (Request["tipo"].ToString() == "Cliente")
                    {
                        tipo = 2;
                    }
                    else
                    {
                        throw new Exception("tipo de usuario no valido");
                    }
                    string email = Request["email"];
                    OperacionesUsuarios opusu = new OperacionesUsuarios();
                    opusu.Guardar(nomusu, password, pnombre, snombre, apat, apmat, fecha, tipo, email);
                }
                else if (bd == "Ventas")
                {
                    OperacionesVentas opven = new OperacionesVentas();
                    int iduser   = int.Parse(Request["idUsuario"]);
                    int producto = int.Parse(Request["idProducto"]);
                    if (!opven.Guardar(iduser, producto, DateTime.Now))
                    {
                        throw new Exception("no se guardo");
                    }
                }
                res = "true";
            }
            catch (Exception e)
            {
                res = e.Message;
            }
            return(Json(res));
        }
        public JsonResult Actualizar()
        {
            string res = "false";

            try
            {
                string bd = Request["bd"];
                if (bd == "Mensajes")
                {
                    int    id    = int.Parse(Request["idMensaje"]);
                    string texto = Request["textoMensaje"];
                    string fecha = Request["fecha"].ToString();
                    string email = Request["emailRemitente"].ToString();;
                    OperacionesMensajes opmen = new OperacionesMensajes();
                    opmen.Modificar(id, texto, fecha, email);
                }
                else if (bd == "Noticias")
                {
                    int                 id    = int.Parse(Request["idNoticia"]);
                    string              texto = Request["textoNoticia"].ToString();
                    DateTime            fecha = DateTime.Parse(Request["FechaNoticia"].ToString());
                    int                 idAut = int.Parse(Request["idAutor"]);
                    OperacionesNoticias opnot = new OperacionesNoticias();
                    if (!opnot.Modificar(id, fecha, texto, idAut))
                    {
                        throw new Exception("Error al actualizar");
                    }
                }
                else if (bd == "Productos")
                {
                    int    id     = int.Parse(Request["idProducto"]);
                    string nom    = Request["nombreProducto"];
                    int    precio = int.Parse(Request["precio"]);
                    int    stock  = int.Parse(Request["stock"]);
                    OperacionesProductos oprod = new OperacionesProductos();
                    oprod.Modificar(id, nom, precio, stock);
                }
                else if (bd == "Usuarios")
                {
                    int                 id            = int.Parse(Request["idUsuario"]);
                    string              nom           = Request["nombreUsuario"].ToString();
                    string              password      = Request["password"].ToString();
                    string              pnombre       = Request["pnombre"].ToString();
                    string              snombre       = Request["snombre"].ToString();
                    string              apat          = Request["apat"].ToString();
                    string              amat          = Request["amat"].ToString();
                    DateTime            fechaRegistro = DateTime.Parse(Request["fecha"].ToString());
                    int                 tipoUsuario   = int.Parse(Request["tipoUsuario"]);
                    string              email         = Request["email"].ToString();
                    OperacionesUsuarios opusu         = new OperacionesUsuarios();
                    opusu.Modificar(id, nom, password, pnombre, snombre, apat, amat, fechaRegistro, tipoUsuario, email);
                }
                else if (bd == "Ventas")
                {
                    int               id        = int.Parse(Request["idVenta"]);
                    int               idUsuario = int.Parse(Request["idUsuario"]);
                    int               idProd    = int.Parse(Request["idProducto"]);
                    DateTime          dt        = DateTime.Parse(Request["fecha"].ToString());
                    OperacionesVentas opven     = new OperacionesVentas();
                    if (!opven.Modificar(id, idUsuario, idProd, dt))
                    {
                        throw new Exception("problema en modificar");
                    }
                }
                else
                {
                    res = "no hay ningun valor";
                }
                res = "true";
            }
            catch (Exception ex)
            {
                res = ex.Message;
            }
            return(Json(res));
        }