//origen conexion bd void Button6Click(object sender, EventArgs e) { base_datos con = new base_datos(); con.update("UPDATE trabajador SET pass ='******' WHERE tipo = 'ADMIN' AND editable = 0"); MessageBox.Show("contraseña cambiada con exito!","Administración"); bd_tb_pass.Text = string.Empty; }
//eliminar cliente seleccionado void Btn_eliminar_clienteClick(object sender, EventArgs e) { if (Agenda_dgv_todos_clientes.RowCount > 0) { if (id_row != -1) { var closeMsg = MessageBox.Show("Eliminar Usuario?", "Advertencia!!", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (closeMsg == DialogResult.Yes) { DataGridViewRow row = Agenda_dgv_todos_clientes.Rows[id_row]; //total filas //id del cliente que se eliminara id_cliente = Int32.Parse(row.Cells[0].Value.ToString()); //columna apellido cliente //eliminar base_datos conexionbd; conexionbd = new base_datos(); string query = "DELETE FROM cliente WHERE id_cliente = " + id_cliente + " "; conexionbd.update(query); } } else { MessageBox.Show("Selecione un usuario"); } } else { MessageBox.Show("No Existen Usuarios"); } //liveramos linea del cliente id_row = -1; }
//LIMPIA LAS LISTAS DE INGREDIENTES, PRECIOS Y PEDIDOS void Btn_limpiar_todoClick(object sender, EventArgs e) { //resta contador a item foreach (object item in lista_pedidos_armado.SelectedItems) { string[] pedido; pedido = item.ToString().Split(':'); base_datos con = new base_datos(); string contador = con.consulta_dato("SELECT contador FROM alternativa WHERE nombre = '" + pedido[0] + "'"); con.update("UPDATE alternativa SET contador = " + contador + "-1 WHERE nombre = '" + pedido[0] + "'"); } //limpia todo lista_ingredientes.Items.Clear(); lista_pedidos_armado.Items.Clear(); tb_precio_espera.Text = "0"; label_precio_total.Text = "0"; label_precio_total2.Text = "0"; label_precio_total3.Text = "0"; label_precio_real.Text = "0"; precio_total_orden_valor = 0; orden_lista_pedidos.Text = ""; }
//eliminar elemento void Producto_btn_borrarClick(object sender, EventArgs e) { if (producto_dgv_prod.RowCount > 0) { if (id_row != -1) { var closeMsg = MessageBox.Show("Eliminar Producto?", "Advertencia!!", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (closeMsg == DialogResult.Yes) { DataGridViewRow row = producto_dgv_prod.Rows[id_row]; //total filas //eliminar base_datos conexionbd = new base_datos(); string query = " DELETE FROM alternativa WHERE id = " + row.Cells[0].Value.ToString() + " "; conexionbd.update(query); } } else { MessageBox.Show("Selecione un producto"); } } else { MessageBox.Show("No Existen productos"); } //liveramos linea del cliente id_row = -1; }
//CREA UN ARTICULO private void Btn_listo_ingredienteClick(object sender, EventArgs e) { if (lista_ingredientes.Items.Count > 0) { //aumenta el contador base_datos con = new base_datos(); con.update("UPDATE alternativa SET contador = 1+" + tb_contador_pedido.Text + " WHERE id = " + tb_id_pedido.Text); //agrega pedido string elementos; elementos = tb_nombre_pedido.Text + ":"; precio_total_orden_valor += Int32.Parse(tb_precio_espera.Text); foreach (object item in lista_ingredientes.CheckedItems) { string[] aux = item.ToString().Split('-'); elementos = elementos + aux[0] + ", "; precio_total_orden_valor += Int32.Parse(aux[1]); actualizar_precio_pedido(precio_total_orden_valor); } orden_lista_pedidos.Text += string.Format("\n{0} ({1}) ", " ", elementos, Environment.NewLine); lista_pedidos_armado.Items.Insert(0, elementos); lista_pedidos_armado.SetItemChecked(0, true); } lista_ingredientes.Items.Clear(); }
//abrir caja void Btn_abrir_cajaClick(object sender, EventArgs e) { //base datos abrimos caja base_datos con = new base_datos(); con.update(" INSERT INTO caja (estado, fapertura, hapertura, dinero_inicio, flujo, rut_abre) VALUES ('ABIERTO' , '"+DateTime.Now.ToShortDateString()+"', '"+DateTime.Now.ToShortTimeString()+"', "+num_dinero.Value+", "+num_dinero.Value+",'"+rut_empleado+"')"); this.Close(); }
//abrir caja void Btn_abrir_cajaClick(object sender, EventArgs e) { //base datos cerramos caja base_datos con = new base_datos(); con.update("UPDATE caja SET estado = 'CERRADO', fcierre = '" + DateTime.Now.ToShortDateString() + "', hcierre = '" + DateTime.Now.ToShortTimeString() + "', dinero_real = " + num_dinero.Value + ", rut_cierra = '" + rut_empleado + "' WHERE id_caja = " + id_caja); this.Close(); }
//click agrega o actualiza elemento void Btn_agregarClick(object sender, EventArgs e) { if (tipo == "insertar") { //insertar if (tb_nombre.Text != "" && tb_precio.Text != "" && nmu_disponible.Text != "") { string query; query = "INSERT INTO agregado (nombre,precio,disponible)" + "VALUES( '" + tb_nombre.Text + "' , '" + tb_precio.Text + "' , '" + nmu_disponible.Text + "');"; conexionbd.update(query); this.Close(); } else { MessageBox.Show("Llene los campos obligatorios (*)."); } } else { //actualizar if (tb_nombre.Text != "" && tb_precio.Text != "" && cb_id.Text != "" && nmu_disponible.Text != "") { string query; query = " UPDATE agregado "; query += " SET cantidad = 10 , nombre = '" + tb_nombre.Text + "' , precio = " + tb_precio.Text + " , disponible = " + nmu_disponible.Text + " "; query += " WHERE id_agregado = " + cb_id.Text + " "; conexionbd.update(query); this.Close(); } else { MessageBox.Show("Llene los campos obligatorios (*)."); } } }
//actualiza ingreso a caja private void flujo_caja(int entrada, string id) { base_datos con = new base_datos(); string flujo; flujo = con.consulta_dato("SELECT flujo FROM caja WHERE id_caja=" + id); int total = Int32.Parse(flujo) + entrada; string query; query = "UPDATE caja SET flujo = " + total + " WHERE id_caja = " + id; con.update(query); }
void Nc_btn_agregarClick(object sender, EventArgs e) { if (nc_tb_rut.Text != "" && nc_tb_apellido.Text != "" && nc_tb_nombre.Text != "" && nc_tb_email.Text != "" && nc_tb_pass.Text != "") { string query; query = "INSERT INTO trabajador (nombre, apellido, rut, correo, pass, fono, nacimiento)" + "VALUES( '" + nc_tb_nombre.Text + "' , '" + nc_tb_apellido.Text + "' , UCase('" + nc_tb_rut.Text + "') , '" + nc_tb_email.Text + "' , '" + nc_tb_pass.Text + "','" + nc_tb_fono.Text + "','" + fecha.Value.ToShortDateString() + "');"; conexionbd.update(query); this.Close(); } else { MessageBox.Show("Llene los campos obligatorios (*)."); } }
void Nc_btn_agregarClick(object sender, EventArgs e) { if (nc_cb_ciudad.Text != "" && nc_tb_apellido.Text != "" && nc_tb_nombre.Text != "" && nc_tb_direccion.Text != "" && nc_tb_fono1.Text != "") { string query; query = "INSERT INTO cliente (nombre,apellido,ciudad,direccion,fono1,fono2,comentario)" + "VALUES( '" + nc_tb_nombre.Text + "' , '" + nc_tb_apellido.Text + "' , UCase('" + nc_cb_ciudad.Text + "') , '" + nc_tb_direccion.Text + "' , '" + nc_tb_fono1.Text + "','" + nc_tb_fono2.Text + "','" + nc_tb_comentario.Text + "');"; conexionbd.update(query); this.Close(); } else { MessageBox.Show("Llene los campos obligatorios (*)."); } }
//editar ARREGLAR!!!! void Btn_agregarClick(object sender, EventArgs e) { if (nc_tb_nombre.Text != "" && nc_tb_apellido.Text != "" && nc_tb_rut.Text != "" && nc_tb_email.Text != "" && nc_tb_fono.Text != "") { string query; query = " UPDATE trabajador " + " SET nombre = '" + nc_tb_nombre.Text + "' , apellido = '" + nc_tb_apellido.Text + "' , rut = UCase('" + nc_tb_rut.Text + "'), correo = '" + nc_tb_email.Text + "', fono = '" + nc_tb_fono.Text + "' , pass = '******' WHERE id_usuario = " + id_cliente_registro; conexionbd.update(query); this.Close(); } else { MessageBox.Show("Llene los campos obligatorios (*)."); } }
//editar ARREGLAR!!!! void Btn_agregarClick(object sender, EventArgs e) { if (a_tb_nombre.Text != "" && a_tb_apellido.Text != "" && a_tb_nombre.Text != "" && a_tb_direccion.Text != "" && a_tb_fono1.Text != "") { string query; query = " UPDATE cliente " + " SET nombre = '" + a_tb_nombre.Text + "' , apellido = '" + a_tb_apellido.Text + "' , ciudad = UCase('" + a_cb_ciudad.Text + "'), direccion = '" + a_tb_direccion.Text + "', fono1 = '" + a_tb_fono1.Text + "' , fono2 = '" + a_tb_fono2.Text + "' , comentario = '" + a_tb_comentario.Text + "' WHERE id_cliente = " + id_cliente_registro; conexionbd.update(query); this.Close(); } else { MessageBox.Show("Llene los campos obligatorios (*)."); } }
//crea la orden void Btn_generar_pedidoClick(object sender, EventArgs e) { if (orden_nombrecliente.Text != "" && orden_telefonocliente.Text != "" && orden_direcioncliente.Text != "" && orden_idcliente.Text != "" && orden_lista_pedidos.Text != "") { string mediopago; if (rb_efectivo.Checked) { mediopago = "EFECTIVO"; } else { mediopago = "CREDITO"; } base_datos conexionbd; conexionbd = new base_datos(); //variables tiempo DateTime ahora = DateTime.Now; string hora = String.Format("{0:HH:mm:ss}", ahora); string fecha = String.Format("{0:dd/MM/yyyy}", ahora); if (id_caja == string.Empty) { id_caja = conexionbd.consulta_dato("SELECT MAX(id_caja) FROM caja WHERE estado = 'ABIERTO' "); } //query string query; query = " INSERT INTO orden (id_cliente , rut_vendedor, total, fecha, hora, pedido, direccion, fono, descuento, mediopago, id_caja)"; query += " VALUES ( " + orden_idcliente.Text + " , '" + orden_rut_vendedor.Text + "' , '" + label_precio_total2.Text + "' , '" + fecha + "' , '" + hora + "' , '" + orden_lista_pedidos.Text + "', '" + orden_direcioncliente.Text + "', '" + orden_telefonocliente.Text + "', " + num_descuento.Value + ",'" + mediopago + "', " + id_caja + ")"; conexionbd.update(query); //actualiza flujo caja flujo_caja(Int32.Parse(label_precio_total2.Text), id_caja); /*impresion PrintReceipt(bool cocina, bool caja, bool repartidor)*/ PrintReceipt(true, true, true); //PrintReceipt(false,true,false); this.Close(); } else { MessageBox.Show("Llene los campos obligatorios (*)."); } }
void Producto_btn_agregarClick(object sender, EventArgs e) { string ingredientes = string.Empty; foreach (object itemChecked in producto_lb_ingredientes.CheckedItems) { ingredientes += itemChecked.ToString() + "-"; } string query = " INSERT INTO alternativa (nombre, ingredientes, precio, disponible)"; query += " VALUES ('" + producto_tb_nombre.Text + "', '" + ingredientes + "', '" + producto_num_precio.Value.ToString() + "', " + producto_num_disponible.Value.ToString() + ")"; base_datos conexionbd = new base_datos(); conexionbd.update(query); this.Close(); }