Esempio n. 1
0
        } //PRUEBAS

        private void consultaClientes()
        {
            SqlConnection sql = BDConnect.connection();
            apartados     aps = new apartados();

            tabla_clientes.DataSource = aps.clientes(sql);
        }
Esempio n. 2
0
        private void showAps(object sender, EventArgs e)
        {
            SqlConnection con = BDConnect.connection();
            apartados     aps = new apartados();

            tableCuentas.DataSource = aps.listaApartados(con);
        }
Esempio n. 3
0
        private void delete_Btn_Click(object sender, EventArgs e)
        {
            SqlConnection con    = BDConnect.connection();
            apartados     apds   = new apartados();
            string        nombre = client_List.SelectedItem.ToString();
            bool          result = apds.eliminarClientes(con, nombre);

            if (result)
            {
                MessageBox.Show("Se ha eliminado el cliente");
                //consultaClientes();
            }
            else
            {
                MessageBox.Show("Ha ocurrido un error");
            }
        }
Esempio n. 4
0
        public void buscarVenta()
        {
            apartados ap = new apartados();

            try
            {
                SqlCommand buscar_venta = new SqlCommand("busca_VentaDiaria", conexion);
                buscar_venta.CommandType = CommandType.StoredProcedure;

                buscar_venta.Parameters.AddWithValue("@fecha", Convert.ToDateTime(dateTimePicker1.Text));

                totalApartados.DataSource = ap.listaAnticipos(conexion, dateTimePicker1.Text);
                pagosDiarios.DataSource   = ap.listaPagosfecha(conexion, dateTimePicker1.Text);



                SqlCommand total = new SqlCommand("sumaTotal_Venta", conexion);
                total.CommandType = CommandType.StoredProcedure;
                total.Parameters.AddWithValue("@fecha", Convert.ToDateTime(dateTimePicker1.Text));

                SqlDataAdapter adaptador  = new SqlDataAdapter();
                SqlDataAdapter adap       = new SqlDataAdapter();
                DataTable      tabla      = new DataTable();
                DataTable      totalVenta = new DataTable();
                adaptador.SelectCommand = buscar_venta;
                adap.SelectCommand      = total;
                adaptador.Fill(tabla);
                adap.Fill(totalVenta);
                dataGridView1.DataSource = tabla;
                dataGridTotal.DataSource = totalVenta;

                foreach (DataGridViewRow item in dataGridTotal.Rows)
                {
                    totalDia = item.Cells[0].Value.ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conexion.Close();
            }
        }
Esempio n. 5
0
        private void button3_Click_1(object sender, EventArgs e)
        {
            SqlConnection con = BDConnect.connection();
            apartados     aps = new apartados();
            string        id  = idClienteDelete.Text.Trim();

            this.Hide();
            bool respuesta = MessageBox.Show("El cliente " + nombreClientetxt.Text.ToUpper() + " será eliminado de la base de datos \n esta operacion no se puede revertir", "Advertencia", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes;

            if (respuesta)
            {
                bool queryResult = aps.eliminarClientes(con, id);
                if (queryResult)
                {
                    MessageBox.Show("Cliente eliminado con exito", "Operación Exitosa");
                }
                this.Show();
            }
        }
Esempio n. 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection connection   = BDConnect.connection();
            apartados     objApartados = new apartados();

            bool estado = objApartados.insertar(connection, clname.Text);

            if (estado)
            {
                MessageBox.Show("datos insertados con exito");
                this.Dispose();
                this.Close();
                client_List.Items.Clear();
                interfazApartado ap = new interfazApartado();
                ap.ShowDialog();
            }
            else
            {
                MessageBox.Show("Error con la insercion");
            }
        }
Esempio n. 7
0
        private void button3_Click(object sender, EventArgs e)//Boton para entregar el articulo
        {
            SqlConnection con = BDConnect.connection();
            apartados     aps = new apartados();

            float abonoTotal = Convert.ToSingle(labelMontoAbonado.Text);
            float deuda      = Convert.ToSingle(total_deuda.Text);

            string idProducto = idproducto_label.Text;
            int    cant       = Convert.ToInt32(cantidadProductolabel.Text);

            bajaInventario(idProducto, cant);

            bool result = aps.eliminarPtoApartado(con, idPtoApartadoLabel.Text);

            if (result)
            {
                MessageBox.Show("CAMBIOS REALIZADOS CON EXITO");
            }

            listaPagos.DataSource            = aps.listaPagos(con, idClientLabel.Text);
            listaProductosCliente.DataSource = aps.listaProductosApartados(con, idClientLabel.Text);
        }
Esempio n. 8
0
        private void GetInfoClick(object sender, DataGridViewCellEventArgs e) //Tabla principal de las cuentas
        {
            SqlConnection con = BDConnect.connection();
            apartados     aps = new apartados();

            if (e.RowIndex >= 0)
            {
                try
                {
                    DataGridViewRow fila = tableCuentas.Rows[e.RowIndex];
                    nameClient.Text    = fila.Cells[2].Value.ToString();
                    idApartLabel.Text  = fila.Cells[0].Value.ToString();
                    montoTotaltxt.Text = fila.Cells[7].Value.ToString();
                    idClientLabel.Text = fila.Cells[1].Value.ToString();

                    labelAnticipo.Text = fila.Cells[5].Value.ToString();
                    total_deuda.Text   = fila.Cells[4].Value.ToString();

                    string idCliente = idClientLabel.Text;
                    listaPagos.DataSource            = aps.listaPagos(con, idCliente);
                    listaProductosCliente.DataSource = aps.listaProductosApartados(con, idCliente);

                    float anticipo = Convert.ToSingle(labelAnticipo.Text);
                    sumaAbonos();

                    float res = anticipo + sumaAbonos();

                    labelMontoAbonado.Text = res.ToString();

                    comparaPrecioPts(res);
                }
                catch (Exception e3)
                {
                    MessageBox.Show(e3.Message);
                }
            }
        }
Esempio n. 9
0
        private void guardarInformacion_Click(object sender, EventArgs e)
        {
            //Variables para insertar
            float montoTotal = Convert.ToSingle(totalSumapts.Text);
            float anticipo   = Convert.ToSingle(cajaAnticipotxt.Text);
            float restante   = Convert.ToSingle(cantidadRestante.Text);

            idCte = idClientetxt.Text;

            apartados operacion = new apartados();


            if (idCte != null && codigoProducto != null && nombreProducto != null)
            {
                SqlConnection conectar = BDConnect.connection();
                //operaciones de comprobacion xd

                SqlDataReader lector;
                SqlCommand    command = new SqlCommand(string.Format("SELECT * FROM cuenta_apartado WHERE id_cliente = '{0}'", new string[] { idClientetxt.Text }), conectar);
                lector = command.ExecuteReader();
                try
                {
                    if (lector.Read())
                    {
                        string id         = idClientetxt.Text;
                        string encontrado = lector.GetInt32(1).ToString();
                        if (id == encontrado)
                        {
                            int cantidad_productos = 0;

                            SqlCommand insertar = new SqlCommand("insertarApartados", conectar);
                            insertar.Parameters.Clear();

                            insertar.CommandType = CommandType.StoredProcedure;

                            foreach (DataGridViewRow fila in tablaProductos.Rows)
                            {
                                insertar.Parameters.Clear();
                                insertar.Parameters.AddWithValue("@idCliente", idClientetxt.Text);
                                insertar.Parameters.AddWithValue("@codigo", Convert.ToInt32(fila.Cells[0].Value));
                                insertar.Parameters.AddWithValue("@precio", Convert.ToDouble(fila.Cells[3].Value));
                                insertar.Parameters.AddWithValue("@cantidad", Convert.ToInt32(fila.Cells[1].Value));
                                insertar.Parameters.AddWithValue("@fecha", Convert.ToDateTime(dateTimePicker1.Text));
                                cantidad_productos += Convert.ToInt32(fila.Cells[1].Value);
                                insertar.ExecuteNonQuery();
                                insertar.Parameters.Clear();
                            }
                        }
                    }
                    else
                    {
                        lector.Close();
                        int cantidad_productos = 0;

                        SqlCommand insertar = new SqlCommand("insertarApartados", conectar);
                        insertar.Parameters.Clear();

                        insertar.CommandType = CommandType.StoredProcedure;

                        foreach (DataGridViewRow fila in tablaProductos.Rows)
                        {
                            insertar.Parameters.Clear();
                            insertar.Parameters.AddWithValue("@idCliente", idClientetxt.Text);
                            insertar.Parameters.AddWithValue("@codigo", Convert.ToInt32(fila.Cells[0].Value));
                            insertar.Parameters.AddWithValue("@precio", Convert.ToDouble(fila.Cells[3].Value));
                            insertar.Parameters.AddWithValue("@cantidad", Convert.ToInt32(fila.Cells[1].Value));
                            insertar.Parameters.AddWithValue("@fecha", Convert.ToDateTime(dateTimePicker1.Text));
                            cantidad_productos += Convert.ToInt32(fila.Cells[1].Value);
                            insertar.ExecuteNonQuery();
                            insertar.Parameters.Clear();
                        }
                        bool res = operacion.registraApartado(conectar, idCte, cantidad_productos, montoTotal, anticipo, restante, dateTimePicker1.Text);

                        if (insertar != null && res)
                        {
                            DialogResult resultado = MessageBox.Show("Apartado realizado exitosamente", "INFORMACIÓN", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                            if (resultado == DialogResult.OK)
                            {
                                imprimirComprobante();
                                CrearImpresion.ImprimirTiket();
                            }
                        }
                    }
                }
                catch (Exception msg)
                {
                    MessageBox.Show(msg.Message);
                }
                finally
                {
                    lector.Close();
                }
            }
            else
            {
                MessageBox.Show("Llena los campos faltantes,\n si el error aparece de nuevo comuniquese con su proveedor", "ERROR AL INSERTAR LOS DATOS");
            }
        }
Esempio n. 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            apartados ap      = new apartados();
            float     importe = float.Parse(cajaPagotxt.Text);
            float     abono   = float.Parse(cajaAbonotxt.Text);
            float     total   = float.Parse(montoTotaltxt.Text);

            //restante= total-abono


            pagoClienteLabel.Text = importe.ToString();
            abonoLabel.Text       = abono.ToString();
            cambioLabel.Text      = Convert.ToString(resta(importe, abono));

            if (abono >= total)
            {
                restanteLabel.Text = Convert.ToString(resta(abono, total));
                cambioLabel.Text   = Convert.ToString(resta(abono, total));

                SqlConnection con = BDConnect.connection();


                float  restante = float.Parse(restanteLabel.Text);
                int    idApart  = Convert.ToInt32(idApartLabel.Text);
                int    idClie   = Convert.ToInt32(idClientLabel.Text);
                float  restAnt  = float.Parse(montoTotaltxt.Text);//restante Anterior
                float  pagoNvo  = float.Parse(cajaAbonotxt.Text);
                float  debe     = restante;
                string fecha    = dateTimePicker1.Text;

                if (restante <= total)
                {
                    bool update = ap.ActualizarRestante(con, restante.ToString(), abonoLabel.Text, idApartLabel.Text);
                    bool insert = ap.RegistraPgo(con, idApart, idClie, restAnt, pagoNvo, debe, fecha);
                    if (insert && update)
                    {
                        restanteLabel.Text = "" + 0;
                        MessageBox.Show("Apartado liquidado");
                        tableCuentas.DataSource = ap.listaApartados(con);
                        bajaInventario(idproducto_label.Text, Convert.ToInt32(cantidadProductolabel.Text));
                        ap.eliminarPtoApartado(con, idPtoApartadoLabel.Text);

                        flag = true;
                    }

                    imprimirComprobante();
                    CrearImpresion.ImprimirTiket();

                    //update tabla productos resta cantidad del producto a el producto
                    //delete apartado x id
                    //delete pagos x id
                    //imprimir ticket
                }
                else if (restante >= total)
                {
                    bool update = ap.ActualizarRestante(con, restante.ToString(), abonoLabel.Text, idApartLabel.Text);
                    bool insert = ap.RegistraPgo(con, idApart, idClie, restAnt, pagoNvo, debe, fecha);

                    if (insert && update)
                    {
                        restanteLabel.Text = "" + 0;
                        MessageBox.Show("Apartado liquidado");
                        tableCuentas.DataSource = ap.listaApartados(con);
                    }

                    /*imprimirComprobante();
                     * CrearImpresion.ImprimirTiket();*/
                }
            }
            else if (abono <= total)
            {
                restanteLabel.Text = Convert.ToString(resta(total, abono));
                float restante = float.Parse(restanteLabel.Text);
                //variables insertar
                int    idApart = Convert.ToInt32(idApartLabel.Text);
                int    idClie  = Convert.ToInt32(idClientLabel.Text);
                float  restAnt = float.Parse(montoTotaltxt.Text);//restante Anterior
                float  pagoNvo = float.Parse(cajaAbonotxt.Text);
                float  debe    = restante;
                string fecha   = dateTimePicker1.Text;

                SqlConnection con = BDConnect.connection();

                if (restante < total)
                {
                    try
                    {
                        bool update = ap.ActualizarRestante(con, restante.ToString(), abonoLabel.Text, idApartLabel.Text);
                        bool insert = ap.RegistraPgo(con, idApart, idClie, restAnt, pagoNvo, debe, fecha);
                        if (update && insert)
                        {
                            MessageBox.Show("Actualizacion Exitosa", "PAGO REGISTRADO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tableCuentas.DataSource = ap.listaApartados(con);
                        }
                        else
                        {
                            MessageBox.Show(insert.ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    //registrar el pago
                }
            }

            /*imprimirComprobante();
             * CrearImpresion.ImprimirTiket();*/
        }