private void btnCerrar_Click(object sender, EventArgs e) { Caja c = new Caja(); CajaGastos g = new CajaGastos(); CajaBilletes b = new CajaBilletes(); CajaSueldos s = new CajaSueldos(); //Datos de conexión a BD NpgsqlConnection conn = new NpgsqlConnection("Server = localhost; Port = 5432; User Id = postgres; Password = TomiMati2005; Database = Rava"); //Abrir BD conn.Open(); //Crear objeto de comandos NpgsqlCommand comm = new NpgsqlCommand(); //Crear objeto conexión comm.Connection = conn; //No se que hace xd comm.CommandType = CommandType.Text; //Actualiza el producto comm.CommandText = "INSERT into caja(fecha, rut_planchero, nombre_planchero, rut_cajero, nombre_cajero, cuadre_caja, total_ventas, descripcion_gastos, gastos, sueldo_cajero, sueldo_planchero, billetes_monedas )" + "VALUES('" + DTP_CerrarTurno.Value.ToString("d") + "','" + s.getRutPlanchero() + "', '" + s.getNombrePlanchero() + "','" + s.getRutCajero() + "','" + s.getNombreCajero() + "'," + aux + "," + c.getTotalVenta() + ",'" + g.getDescripcionGastos() + "'," + g.getTotalGastos() + "," + s.getSueldoCajero() + ", " + s.getSueldoPlanchero() + "," + b.getTotal() + ")"; //Leer BD NpgsqlDataReader dr = comm.ExecuteReader(); MessageBox.Show("Se ha cerrado la caja", "Caja cerrada", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); //Cerrar comandos comm.Dispose(); //Desconectar BD conn.Close(); GestionarPersonal gp = new GestionarPersonal(); gp.Show(); this.Close(); }
private void btnGastos_Click(object sender, EventArgs e) { CajaGastos cg = new CajaGastos(); cg.Show(); this.Close(); }
public Caja() { InitializeComponent(); //Fecha actual: String fecha = DateTime.Now.ToString("d"); //Datos de conexión a BD NpgsqlConnection conn = new NpgsqlConnection("Server = localhost; Port = 5432; User Id = postgres; Password = TomiMati2005; Database = Rava"); //Abrir BD conn.Open(); //Crear objeto de comandos NpgsqlCommand comm = new NpgsqlCommand(); //Crear objeto conexión comm.Connection = conn; //No se que hace xd comm.CommandType = CommandType.Text; //Consulta comm.CommandText = "SELECT tipo_pago, subtotal, fecha, descuento, pedido from ventas"; //Leer BD NpgsqlDataReader dr = comm.ExecuteReader(); while (dr.Read())//Si la tabla tiene 1 o más filas... { if (dr.GetString(2).Contains(fecha)) { listVentas.Items.Add("-" + dr.GetString(0) + " " + dr.GetInt16(1)); //Clasifica las cuentas para calcular el total de cada una if (dr.GetString(0) == "Efectivo") { totalEfectivo = totalEfectivo + dr.GetInt16(1); } if (dr.GetString(0) == "Transbank") { totalTransbank = totalTransbank + dr.GetInt16(1); } if (dr.GetString(0) == "Consumo Local") { totalCreditos = totalCreditos + dr.GetInt16(1); } if (dr.GetString(0).Contains("Pedidos Ya")) { totalPedidosYa = totalPedidosYa + dr.GetInt16(1); if (dr.GetString(4).Contains("Sandwich")) { totalSobre = totalSobre + 1510; subTotalPedidosYa = subTotalPedidosYa + 1510 + dr.GetInt32(1); } if (dr.GetString(4).Contains("Manso")) { if (dr.GetString(4).Contains("MS")) { totalSobre = totalSobre + 1610; subTotalPedidosYa = subTotalPedidosYa + 1610 + dr.GetInt32(1); } if (dr.GetString(4).Contains("MT1") || dr.GetString(4).Contains("MT2") || dr.GetString(4).Contains("MT3")) { totalSobre = totalSobre + 1710; subTotalPedidosYa = subTotalPedidosYa + 1710 + dr.GetInt32(1); } if (dr.GetString(4).Contains("MT5")) { totalSobre = totalSobre + 1810; subTotalPedidosYa = subTotalPedidosYa + 1710 + dr.GetInt32(1); } if (dr.GetString(4).Contains("EG") || dr.GetString(4).Contains("MV") || dr.GetString(4).Contains("MC") || dr.GetString(4).Contains("MN")) { totalSobre = totalSobre + 1710; subTotalPedidosYa = subTotalPedidosYa + 1710 + dr.GetInt32(1); } else { totalSobre = totalSobre + 1510; subTotalPedidosYa = subTotalPedidosYa + 1510 + dr.GetInt32(1); } } if (dr.GetString(0).Equals("Pedidos Ya, efectivo") || (dr.GetString(0).Equals("Pedidos Ya, con descuento"))) { totaldescuentos = totaldescuentos + dr.GetInt32(3); } if (dr.GetString(0).Equals("Pedidos Ya, online")) { totalPYOnline = totalPYOnline + dr.GetInt32(1); } } } } //Cerrar comandos comm.Dispose(); //Desconectar BD conn.Close(); //Muestra los totales calculados en los textbox que corresponden txtVtasEfec.Text = totalEfectivo + ""; txtVtasTransbank.Text = totalTransbank + ""; txtVtasCredito.Text = totalCreditos + ""; txtVtasPedidosYa.Text = subTotalPedidosYa + ""; tv = totalCreditos + totalEfectivo + totalTransbank + totalPedidosYa; //total vtas = efectivo + transbank + pedidosya listVentas.Items.Add("\nTotal Ventas: \n" + tv); txtSobre.Text = totalSobre + ""; txtDescuentos.Text = (totaldescuentos + totalPYOnline) + ""; CajaGastos g = new CajaGastos(); CajaSueldos s = new CajaSueldos(); txtGastosSueldos.Text = (g.getTotalGastos() + s.getSueldoCajero() + s.getSueldoPlanchero()) + ""; }