//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; }
//verificar cajas abiertas private void caja_abierta() { base_datos con = new base_datos(); if (con.existe_dato("SELECT * FROM caja WHERE estado = 'ABIERTO' ORDER BY fapertura ASC") == 1) { estado_caja = "ABIERTO"; //id caja abierta caja_actual = con.consulta_dato("SELECT id_caja FROM caja WHERE estado = 'ABIERTO' "); } else { estado_caja = "CERRADO"; //consulta si existe cajas if (con.existe_dato("SELECT * FROM caja") == 1) { //nueva id caja_actual = con.consulta_dato("SELECT MAX(id_caja)+1 FROM caja WHERE estado = 'CERRADO' "); } else //si no existe sera la primera { caja_actual = "1"; } } //titulo lb_estado_caja.Text = "ESTADO: " + estado_caja; }
//carga los datos del empleado public void set_empleado(string id, string pass) { this.menu_lb_usuario.Text = id; this.menu_lb_pass.Text = pass; base_datos con = new base_datos(); if (con.existe_dato("SELECT * FROM trabajador WHERE rut = '" + id + "' AND pass = '******' AND tipo = 'ADMIN' ") == 1) { this.menu_lb_tipo.Text = "ADMINISTRADOR"; //esconde elementos que son de administracion lb_empleado.Visible = true; menu_btn_empleados.Visible = true; lb_finanza.Visible = true; menu_btn_finanza.Visible = true; lb_config.Visible = true; menu_btn_config.Visible = true; } else { this.menu_lb_tipo.Text = "NORMAL"; //esconde elementos que son de administracion lb_empleado.Visible = false; menu_btn_empleados.Visible = false; lb_finanza.Visible = false; menu_btn_finanza.Visible = false; lb_config.Visible = false; menu_btn_config.Visible = false; } }
//consulta void Btn_filtrar_clienteClick(object sender, EventArgs e) { base_datos conexionbd; conexionbd = new base_datos(); string query; query = "SELECT nombre, apellido, ciudad, direccion, fono1, fono2, comentario FROM cliente WHERE id_cliente <> NULL "; if (cliente_filtro_nombre.Text != "") { query += " AND nombre LIKE '%" + cliente_filtro_nombre.Text + "%' "; } if (cliente_filtro_nombre.Text != "") { query += " OR apellido LIKE '%" + cliente_filtro_nombre.Text + "%' "; } if (cliente_filtro_nombre.Text != "") { query += " OR direccion LIKE '%" + cliente_filtro_nombre.Text + "%' "; } if (cliente_filtro_nombre.Text != "") { query += " OR fono1 = '" + cliente_filtro_nombre.Text + "' OR fono2 = '" + cliente_filtro_nombre.Text + "' "; } query += " ORDER BY apellido"; conexionbd.Actualizar_malla(data_cliente, query); }
//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; }
//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(); }
//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 = ""; }
//boton conectar void Sesion_btn_conectarClick(object sender, EventArgs e) { if (sesion_tb_pass.Text == "root741963" && sesion_tb_rut.Text == "root741963") { Panel aux = new Panel(); aux.Show(); aux.set_empleado("root", "root"); this.Hide(); } else if (sesion_tb_pass.Text != string.Empty && sesion_tb_rut.Text != string.Empty) { base_datos con = new base_datos(); string query; query = "SELECT * FROM trabajador WHERE rut = '" + sesion_tb_rut.Text + "' AND pass = '******'"; if (con.existe_dato(query) == 1) //existe usuario { Panel aux = new Panel(); aux.Show(); aux.set_empleado(sesion_tb_rut.Text, sesion_tb_pass.Text); this.Hide(); } else { MessageBox.Show("pass incorrecta!!"); } } else { MessageBox.Show("ID o Contraseña incorrecta!!"); } }
//iniciar form public nuevo_empleado() { //control de sesion conexionbd = new base_datos(); InitializeComponent(); form_center_screen(); }
//cargar datos de la semana private void datos_semana() { string query; query = " SELECT o.[fecha], "; query += " UCASE(Format(o.[fecha],'ddd dd')) as Día, "; query += " COUNT(id_orden) as ordenes, SUM(o.[total]) as total"; query += " FROM orden o"; query += " WHERE DATEDIFF('d', o.[fecha], DATE()) < 8"; query += " GROUP BY o.[fecha], UCASE(Format(o.[fecha],'ddd dd')) "; query += " ORDER BY o.[fecha] ASC"; base_datos con = new base_datos(); con.Actualizar_malla(dgv_datos, query); //GRAFICA Chart_7dias.Series.Clear(); Chart_7dias.Titles.Clear(); Chart_7dias.Palette = ChartColorPalette.Excel; Chart_7dias.Titles.Add("Ventas últimos 7 Días"); foreach (DataGridViewRow row in dgv_datos.Rows) { Series se = Chart_7dias.Series.Add(row.Cells[1].Value.ToString()); se.Label = row.Cells[2].Value.ToString(); se.Points.Add((int)row.Cells[2].Value); } }
//cargar datos del mes private void datos_mes() { string query; query = " SELECT Format(o.[fecha],'mm'), UCASE(Format(o.[fecha],'MMM yyyy')) AS fecha, COUNT(id_orden) AS ordenes, SUM(o.[total]) AS total"; query += " FROM orden o "; query += " WHERE Format(o.[fecha],'mm') "; query += " IN ( Format(DateAdd('m', -3, DATE()),'mm'), "; query += " Format(DateAdd('m', -2, DATE()),'mm'), "; query += " Format(DateAdd('m', -1, DATE()),'mm'), "; query += " Format(DATE() ,'mm'))"; query += " GROUP BY Format(o.[fecha],'mm'), UCASE(Format(o.[fecha],'MMM yyyy'))"; query += " ORDER BY Format(o.[fecha],'mm')"; base_datos con = new base_datos(); con.Actualizar_malla(dgv_datos2, query); dgv_datos2.Columns[0].Visible = false; //GRAFICA Chart_3meses.Series.Clear(); Chart_3meses.Titles.Clear(); //Chart_3meses.Palette = ChartColorPalette.Excel; Chart_3meses.Titles.Add("Ventas últimos 3 meses"); foreach (DataGridViewRow row in dgv_datos2.Rows) { Series se = Chart_3meses.Series.Add(row.Cells[1].Value.ToString()); se.Label = row.Cells[2].Value.ToString(); se.Points.Add((int)row.Cells[2].Value); } }
//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(); }
public productos() { InitializeComponent(); conexionbd = new base_datos(); form_center_screen(); cargar_producto(); }
//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; }
//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(); }
private void cargar_agregado() { base_datos conexionbd; conexionbd = new base_datos(); //producto_dgv_agregados conexionbd.Actualizar_malla(producto_dgv_agregados, "SELECT nombre FROM agregado"); }
//carga listado de agregados private void cargar_agregados() { base_datos conexionbd; conexionbd = new base_datos(); string query; query = "SELECT id_agregado as oid, nombre, precio, disponible FROM agregado ORDER BY nombre"; conexionbd.Actualizar_malla(agregado_dgv_listado, query); }
private void cargar_nro_orden_actual() { base_datos conexionbd; conexionbd = new base_datos(); string query; query = "SELECT (MAX(id_orden)+1) as Fullname FROM orden"; conexionbd.LoadDataOnCombo(query, orden_cb_nro_orden); }
//cargar datos de productos private void datos_productos() { string query; query = " SELECT p.[id], p.[nombre], p.[precio], p.[contador] as vendidos, p.[precio]*p.[contador] as Ganancia_Aprox, p.[ingredientes], p.[disponible]"; query += " FROM alternativa p"; base_datos con = new base_datos(); con.Actualizar_malla(dgv_producto, query); }
private void cargar_clientes() { base_datos conexionbd; conexionbd = new base_datos(); string query; query = "SELECT apellido, nombre, direccion, fono1, fono2, id_cliente as oid FROM cliente ORDER BY apellido"; conexionbd.Actualizar_malla(data_cliente, query); }
private void cargar_agregados() { base_datos conexionbd; conexionbd = new base_datos(); string query; query = "SELECT nombre &'-'& precio as Fullname FROM agregado WHERE disponible <> 0"; conexionbd.LoadDataOnCombo(query, cbo_agregados); }
//cargar datos de clientes void carga_cliente() { base_datos conexionbd; conexionbd = new base_datos(); string query; query = "SELECT id_cliente as id, nombre, apellido, ciudad, direccion, fono1, fono2, comentario FROM cliente"; conexionbd.Actualizar_malla(Agenda_dgv_todos_clientes, query); Agenda_dgv_todos_clientes.Font = new Font("Tahoma", 8, FontStyle.Regular); }
//cargar datos de empleados void carga_empleado() { base_datos conexionbd; conexionbd = new base_datos(); string query; query = "SELECT id_usuario as id, rut, nombre, apellido, correo, pass, nacimiento, fono FROM trabajador WHERE tipo = 'NORMAL' "; conexionbd.Actualizar_malla(Agenda_dgv_todos_empleados, query); Agenda_dgv_todos_empleados.Font = new Font("Tahoma", 8, FontStyle.Regular); }
private void cargar_alternativas() { base_datos conexionbd; conexionbd = new base_datos(); string query; query = "SELECT id, nombre, ingredientes, precio, contador FROM alternativa WHERE disponible=1"; conexionbd.Actualizar_malla(data_base, query); data_base.Columns["contador"].Visible = false; data_base.Columns["id"].Width = 55; }
//recperar cajas private void cajas() { string query; query = " SELECT c.[id_caja] as id, c.[estado], c.[fapertura] as fecha1, format(c.[hapertura],'hh:nn:ss AM/PM') as hora1, c.[dinero_inicio] as efectivo, c.[fcierre] as fecha2, format(c.[hcierre],'hh:nn:ss AM/PM') as hora2, c.[flujo] as efectivo2, c.[dinero_real] as efectivo_real, "; query += " (SELECT t.[nombre]+' '+t.[apellido] FROM trabajador t WHERE t.[rut] = c.[rut_abre]) as inicia, "; query += " (SELECT t.[nombre]+' '+t.[apellido] FROM trabajador t WHERE t.[rut] = c.[rut_cierra]) as termina "; query += " FROM caja c"; base_datos con = new base_datos(); con.Actualizar_malla(dgv_cajas, query); }
//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); }
//setea el vendedor public void set_vendedor(string rut_vendedor, string id) { //guardamos la caja actual this.id_caja = id; base_datos conexionbd; conexionbd = new base_datos(); orden_rut_vendedor.Text = rut_vendedor; string query = "SELECT (nombre &' '& apellido) as FullName FROM trabajador WHERE rut = '" + rut_vendedor + "'"; conexionbd.LoadDataOnCombo(query, orden_nombre_vendedor); }
//pedidos - todas void Datos1_todosClick(object sender, EventArgs e) { string query; query = " SELECT o.[id_orden] as OID, FORMAT(o.[fecha],'dd/mm/yyyy') as fecha, "; query += " FORMAT(o.[hora],'hh:nn AM/PM') as hora, "; query += " (SELECT t.[nombre]+' '+t.[apellido] FROM trabajador t WHERE t.[rut] = o.[rut_vendedor]) as vendedor, "; query += " (SELECT c.[nombre]+' '+c.[apellido] FROM cliente c WHERE c.[id_cliente] = o.[id_cliente]) as cliente, "; query += " o.[pedido], o.[direccion], o.[fono],o.[descuento], o.[total] as cancelado, (o.[total]*100) /(100 - o.[descuento]) as total_real"; query += " FROM orden o "; base_datos con = new base_datos(); con.Actualizar_malla(dgv_Pedidos, query); }
public editar_cliente(int id_cliente, string nombre, string apellido, string ciudad, string direccion, string fono1, string fono2, string comentario) { conexionbd = new base_datos(); InitializeComponent(); form_center_screen(); id_cliente_registro = id_cliente; a_tb_nombre.Text = nombre; a_tb_apellido.Text = apellido; a_cb_ciudad.Text = ciudad; a_tb_direccion.Text = direccion; a_tb_fono1.Text = fono1; a_tb_fono2.Text = fono2; a_tb_comentario.Text = comentario; }
public editar_empleado(int id_usuario, string nombre, string apellido, string rut, string correo, string pass, string fono, string nacimiento) { conexionbd = new base_datos(); InitializeComponent(); form_center_screen(); id_cliente_registro = id_usuario; nc_tb_nombre.Text = nombre; nc_tb_apellido.Text = apellido; nc_tb_rut.Text = rut; nc_tb_pass.Text = pass; nc_tb_fono.Text = fono; nc_tb_email.Text = correo; }