Ejemplo n.º 1
0
        private void btn_altaCredito_Click(object sender, EventArgs e)
        {
            if (txt_monto.Text != "" && cmb_TipoPago.Text != "")
            {
                long   monto;
                long   tarjetaNum;
                String tarjeta = txt_tarjeta.Text;
                bool   montoEsNumerico;
                montoEsNumerico = long.TryParse(txt_monto.Text, out monto);
                bool tarjetaEsNumerica;
                tarjetaEsNumerica = long.TryParse(txt_tarjeta.Text, out tarjetaNum);
                string tipoPago = "";
                if (montoEsNumerico)
                {
                    switch (cmb_TipoPago.Text)
                    {
                    case "Efectivo":
                        tipoPago = "E";
                        tarjeta  = "0";
                        break;

                    case "Credito":
                        if (tarjetaEsNumerica)
                        {
                            tipoPago = "C";
                        }
                        else
                        {
                            MessageBox.Show("Tarjeta no numerica");
                            return;
                        }
                        break;

                    case "Debito":
                        if (tarjetaEsNumerica)
                        {
                            tipoPago = "D";
                        }

                        else
                        {
                            MessageBox.Show("Tarjeta no numerica");
                            return;
                        }
                        break;
                    }

                    RepoCliente.instance().cargarCredito(tipoPago, long.Parse(tarjeta), monto, currentUserID);
                }
                else
                {
                    MessageBox.Show("Los campos monto y/o tarjeta no son validos");
                }
            }
            else
            {
                MessageBox.Show("Todos los campos deben tener informacion");
            }
        }
Ejemplo n.º 2
0
 public void habilitarProveedor(string p)
 {
     try
     {
         RepoCliente.instance().habilitarProveedor(p);
         MessageBox.Show("Proveedor Habilitado Correctamente");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error al habilitar Proveedor \n" + ex.Message);
     }
 }
Ejemplo n.º 3
0
 public void deshabilitarCliente(String clie_id)
 {
     try
     {
         RepoCliente.instance().deshabilitarCliente(clie_id);
         MessageBox.Show("Cliente Deshabilitado Correctamente");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error al deshabilitar Cliente \n" + ex.Message);
     }
 }
Ejemplo n.º 4
0
 public void modificarCliente(String clie_id, String nombre, String apellido, String dni, String mail, String telefono, String saldo, String direccion, String ciudad, String codPostal, String fechaNac)
 {
     try
     {
         Cliente nuevoCliente = new Cliente(-1, nombre, apellido, Convert.ToInt64(dni), -1, mail, telefono, direccion, Convert.ToDouble(saldo), Convert.ToInt32(codPostal), ciudad, Convert.ToDateTime(fechaNac));
         RepoCliente.instance().modificarCliente(clie_id, nuevoCliente);
         MessageBox.Show("Cliente Modificado Correctamente");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error al modificar Cliente \n" + ex.Message);
     }
 }
Ejemplo n.º 5
0
        private void Comprar_Load(object sender, EventArgs e)
        {
            this.dataGridView1.SelectionMode =
                DataGridViewSelectionMode.FullRowSelect;
            this.dataGridView1.MultiSelect = false;
            var bindingList = new BindingList <Oferta>(RepoOferta.instance().traerOfertasDisponibles());
            var source      = new BindingSource(bindingList, null);

            dataGridView1.DataSource = source;
            saldo = RepoCliente.instance().traerSaldo(currentUserID);

            /*  listBox1.DisplayMember = "ofer_descripcion";
             * listBox1.ValueMember = "ofer_id";
             */
        }
Ejemplo n.º 6
0
        private void btn_comprar_Click(object sender, EventArgs e)
        {
            int             selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;
            DataGridViewRow selectedRow      = dataGridView1.Rows[selectedrowindex];
            int             stock            = Convert.ToInt32(selectedRow.Cells["ofer_disponible"].Value);
            int             maximoPorCliente = Convert.ToInt32(selectedRow.Cells["ofer_maxDisponible"].Value);

            if (txt_cantidad.Value > 0)
            {
                if (txt_cantidad.Value <= maximoPorCliente && stock - txt_cantidad.Value >= 0)
                {
                    /*
                     * int selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;
                     * DataGridViewRow selectedRow = dataGridView1.Rows[selectedrowindex];
                     */
                    string a = Convert.ToString(selectedRow.Cells["ofer_id"].Value);

                    if (saldo - (Convert.ToInt32(selectedRow.Cells["ofer_precioOferta"].Value) * Convert.ToInt32(txt_cantidad.Value)) >= 0)
                    {
                        RepoCliente.instance().generarCompra(currentUserID, a, Convert.ToInt32(txt_cantidad.Value));

                        this.dataGridView1.SelectionMode =
                            DataGridViewSelectionMode.FullRowSelect;
                        this.dataGridView1.MultiSelect = false;
                        var bindingList = new BindingList <Oferta>(RepoOferta.instance().traerOfertasDisponibles());
                        var source      = new BindingSource(bindingList, null);
                        dataGridView1.DataSource = source;

                        saldo = RepoCliente.instance().traerSaldo(currentUserID);
                        btn_comprar.Enabled  = false;
                        txt_cantidad.Enabled = false;
                    }
                    else
                    {
                        MessageBox.Show("No hay saldo suficiente, su saldo actual es de " + saldo.ToString() + " pesos.");
                    }
                }
                else
                {
                    MessageBox.Show("El stock no es suficiente o la cantidad supera al maximo por cliente");
                }
            }
            else
            {
                MessageBox.Show("La cantidad debe ser mayor a 0");
            }
        }
Ejemplo n.º 7
0
        private void Cupones_Load(object sender, EventArgs e)
        {
            this.dataGridView1.SelectionMode =
                DataGridViewSelectionMode.FullRowSelect;
            this.dataGridView1.MultiSelect = false;
            var bindingList = new BindingList <Cupon>(RepoCliente.instance().traerCuponesPropios(currentUserID));
            var source      = new BindingSource(bindingList, null);

            dataGridView1.DataSource = source;

            var listaBind      = new BindingList <Cliente>(RepoCliente.instance().traerClientes());
            var sourceClientes = new BindingSource(listaBind, null);

            cmb_Clientes.DataSource    = sourceClientes;
            cmb_Clientes.DisplayMember = "nombreYApellido";
            cmb_Clientes.ValueMember   = "clie_id";
        }
Ejemplo n.º 8
0
        private void btn_Regalar_Click(object sender, EventArgs e)
        {
            if (cmb_Clientes.Text != "")
            {
                int             selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;
                DataGridViewRow selectedRow      = dataGridView1.Rows[selectedrowindex];
                int             idCupon          = Convert.ToInt32(selectedRow.Cells["cupo_id"].Value);


                RepoCliente.instance().regalarCupon(idCupon, Convert.ToInt32(cmb_Clientes.SelectedValue));
                var bindingList = new BindingList <Cupon>(RepoCliente.instance().traerCuponesPropios(currentUserID));
                var source      = new BindingSource(bindingList, null);
                dataGridView1.DataSource = source;

                btn_Regalar.Enabled  = false;
                cmb_Clientes.Enabled = false;
            }
            else
            {
                MessageBox.Show("Debe ingresar un cliente");
            }
        }