public int modificarConCon(bool mensaje) { int id_guardado = 0; operaciones op = new operaciones(); StringBuilder sentencia = new StringBuilder(); sentencia.Append(@"UPDATE usuarios SET usuario='" + usuario + @"', contrasena=md5('" + contrasena + @"'), idempleado_sucursal='" + idempleado_sucursal + @"', idgrupo='" + idgrupo + @"', estado='" + estado + @"' WHERE idusuario='" + idusuario + "';"); Console.WriteLine(sentencia.ToString()); id_guardado = op.actualizar(sentencia.ToString()); if (mensaje) { if (id_guardado > 0) { MessageBox.Show("El registro se ingreso correctamente", "Registro ingresado", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No se pudo ingresar el registro", "No se pudo agregar", MessageBoxButtons.OK, MessageBoxIcon.Error); } } return(id_guardado); }
private void button1_Click(object sender, EventArgs e) { ingreso = new operaciones(); ingreso.Val1 = double.Parse(val1.Text); ingreso.Val2 = double.Parse(val2.Text); resultado.Text = ingreso.calcular().ToString(); }
static void Main(string[] args) { Console.WriteLine("valores para X=10 y Y=2"); operaciones del = (int x, int y) => { return(x + y); }; Console.WriteLine("Suma"); Console.WriteLine(del(10, 2)); del = (int a, int b) => { return(a - b); }; Console.WriteLine("Reta"); Console.WriteLine(del(10, 2)); del = (int a, int b) => { return(a * b); }; Console.WriteLine("Multiplicaion"); Console.WriteLine(del(10, 2)); del = (int a, int b) => { return(a / b); }; Console.WriteLine("Division"); Console.WriteLine(del(10, 2)); Console.ReadKey(); }
public static DataTable facturas_ingresadas_sin_anular(string idsucursal, string num_fac) { DataTable Datos = new DataTable(); String Consulta; Consulta = @"select c.fecha_ingreso, fc.numero_factura, tf.nombre, u.usuario, p.nombre_proveedor, fc.monto_total_neto, fc.descuento_iva, fc.monto_total, prese.nombre_presentacion, pp.nom_producto, dt.cantidad, dt.cantidad_paquete, dt.precio_compra_m, dt.precio_compra_d, sp.idsucursal_producto, s.numero_de_sucursal, dt.total, sp.existencias, c.idcompra from compras c, facturas_compras fc, detalles_compras dt, tipos_facturas tf, usuarios u, proveedores p, sucursales_productos sp, productos pp, presentaciones_productos prp, presentaciones prese, sucursales s where c.idfactura=fc.idfactura_compra and dt.idfactura_compra=fc.idfactura_compra and fc.idtipofactura=tf.idtipo_factura and fc.idusuario=u.idusuario and fc.idproveedor=p.idproveedor and dt.idsucursal_producto=sp.idsucursal_producto and sp.idproducto=pp.idproducto and dt.presentacion_producto=prp.idpresentacion_producto and prp.idpresentacion=prese.idpresentacion and c.idsucursal=s.idsucursal and c.anulacion=1 and fc.numero_factura='" + num_fac + @"' and c.idsucursal='" + idsucursal + @"' ;"; operaciones oOperacion = new operaciones(); try { Datos = oOperacion.Consultar(Consulta); } catch { Datos = new DataTable(); } return(Datos); }
private void btn_buscar_Click(object sender, EventArgs e) { string tabla = "bodega"; operaciones op = new operaciones(); op.ejecutar(dvg_bodega, tabla); }
public void Dividiendo() { lista.Add(primervalor); lista.Add(int.Parse(textBox1.Text)); if (resultado != 0) { double cociente = 0; cociente = resultado / int.Parse(textBox1.Text); resultado = cociente; textBox1.Text = resultado.ToString(); lista2.Clear(); operacion = operaciones.nada; } else { double cociente; //for (int i = 0; i < lista.Count; i++) //{ cociente = lista[0] / lista[1]; //} resultado = cociente; textBox1.Text = resultado.ToString(); lista2.Clear(); operacion = operaciones.nada; } }
private void restar_Click(object sender, EventArgs e) { if (textBox1.Text != 0.ToString()) { if (textBox1.Text == resultado.ToString()) { operacion = operaciones.resta; textBox2.Text = textBox1.Text + " - "; /* if (textBox2.Text == "") * { * * * } * else * { * * }*/ } else { /* { * operacion = operaciones.resta; * primervalor = (double.Parse(textBox1.Text)); * }*/ operacion = operaciones.resta; } if (textBox2.Text == "") { primervalor = (double.Parse(textBox1.Text)); //lista3.Add(primervalor); textBox2.Text = textBox1.Text; } else { if (textBox2.Text == resultado.ToString() + " - ") { //textBox2.Text = textBox2.Text + textBox1.Text; Restando(); //igual.PerformClick(); primervalor = resultado; } else if (textBox2.Text != resultado.ToString() + " - ") { textBox2.Text = textBox2.Text + " - " + textBox1.Text; Restando(); //igual.PerformClick(); primervalor = resultado; } } } else { textBox1.Text = "-"; } this.ActiveControl = null; }
public override long guardar(bool mensaje, bool cr) { long id_guardado = 0; operaciones op = new operaciones(); op.Conexion_remota = cr; StringBuilder sentencia = new StringBuilder(); sentencia.Append(@"INSERT INTO usuarios (usuario, contrasena, idempleado_sucursal, idgrupo, fecha_creacion, estado) VALUES ('" + usuario + "', md5('" + contrasena + "'), '" + idempleado_sucursal + "', '" + idgrupo + "', now(), '" + estado + "');"); Console.WriteLine(sentencia.ToString()); id_guardado = op.insertar(sentencia.ToString()); if (mensaje) { if (id_guardado > 0) { MessageBox.Show("El registro se ingreso correctamente", "Registro ingresado", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No se pudo ingresar el registro", "No se pudo agregar", MessageBoxButtons.OK, MessageBoxIcon.Error); } } return(id_guardado); }
static void Main(string[] args) { operaciones Factorial = delegate(int n) { int fact = 1; for (int i = 2; i <= n; i++) { fact *= i; } return(fact); }; operaciones Sumatoria = delegate(int n) { int sum = 0; for (int i = 1; i <= n; i++) { sum += i; } return(sum); }; Console.WriteLine(Factorial(5)); Console.WriteLine(Sumatoria(5)); Console.ReadKey(); }
private void BResta_Click(object sender, EventArgs e) { int num1, num2, resultado; operaciones op1 = new operaciones(); if (TBnum1.Text == "" && MessageBox.Show("Introduzca un numero en el cuadro numero 1", "OPERACION", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { } else if (TBnum2.Text == "" && MessageBox.Show("Introduzca un numero en el cuadro numero 2", "OPERACION", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { } else { num1 = Convert.ToInt32(TBnum1.Text); num2 = Convert.ToInt32(TBnum2.Text); resultado = op1.Resta(num1, num2); Lresult.Text = Convert.ToString(resultado); TBnum1.Text = ""; TBnum2.Text = ""; } }
private void bnDOperacionClick(object sender, RoutedEventArgs e) { var option = ((MenuFlyoutItem)sender).Tag.ToString(); switch (option) { case "1": oper = operaciones.suma; break; case "2": oper = operaciones.resta; break; case "3": oper = operaciones.multiplicacion; break; case "4": oper = operaciones.division; break; } string[] textBoton = { "#", "+", "-", "*", "/" }; btnOperacion.Content = textBoton[(int)oper]; }
private double EjecutaCalculo(double op1, double op2, operaciones oper) { double resul = 0.0; try { switch (oper) { case operaciones.suma: resul = op1 + op2; break; case operaciones.resta: resul = op1 - op2; break; case operaciones.multiplicacion: resul = op1 * op2; break; case operaciones.division: resul = op1 / op2; break; } } catch (Exception ex) { var dialog = new MessageDialog("Error en la conversion" + ex.Message); //return resul; } return(resul); }
private void btn_buscar_Click(object sender, EventArgs e) { string tabla = "bien"; operaciones op = new operaciones(); op.ejecutar(dgw_bienes, tabla); }
private void btn_buscar_Click(object sender, EventArgs e) { string tabla = "empleado"; operaciones op = new operaciones(); op.ejecutar(dataGridView1, tabla); }
public static DataTable datos_Usuario(String usuario, String contra) { DataTable datos = new DataTable(); String consulta = @"select u.idusuario, u.usuario, u.contrase, concat(e.nombres,' ',e.apellidos) as nombre, e.telefono, g.idgrupo, g.nombre_grupo, e.idempleado from usuarios u, empleados e, grupos g where u.idempleado = e.idempleado and u.idgrupo = g.idgrupo and u.usuario = '" + usuario + @"' and u.contrase = md5('" + contra + @"') and u.estado = 1 ;"; operaciones bd = new operaciones(); try { datos = bd.mostrarTabla(consulta); } catch { datos = new DataTable(); } return(datos); }
public bool actualizarCliente() { bool actualiza = false; StringBuilder sentencia = new StringBuilder("UPDATE clientes SET "); sentencia.Append("nombre_cliente ='" + this.Nombre_cliente + "', "); sentencia.Append("apellidos_cliente ='" + this.apellidos_cliente + "', "); sentencia.Append("direccion ='" + this.direccion + "', "); sentencia.Append("genero='" + this.genero + "',"); sentencia.Append("estado ='" + this.estado + "' WHERE(idcliente='" + idcliente + "');"); conexiones_BD.operaciones op = new operaciones(); Console.WriteLine(sentencia.ToString()); if (op.actualizar(sentencia.ToString()) > 0) { actualiza = true; } else { actualiza = false; } return(actualiza); }
public static DataTable factura_ingresadas(string fecha) { DataTable Datos = new DataTable(); String Consulta; Consulta = @"select c.idfactura as id, c.fecha_ingreso, c.anulacion, c.idcaja, fc.numero_factura, fc.idtipofactura, tf.nombre, fc.monto_total as subtotal, fc.descuento_iva as iva, fc.monto_total_neto as total, fc.fecha_factura, fc.idproveedor, p.nombre_proveedor from compras c INNER JOIN facturas_compras fc on c.idfactura=fc.idfactura_compra INNER JOIN tipos_facturas tf on fc.idtipofactura=tf.idtipo_factura INNER JOIN proveedores p on fc.idproveedor=p.idproveedor WHERE c.anulacion=1 and fc.fecha_factura between '" + fecha + @" 00:00:00' and '" + fecha + @" 23:59:59' ;"; operaciones oOperacion = new operaciones(); oOperacion.Conexion_remota = false; try { Datos = oOperacion.Consultar(Consulta); } catch { Datos = new DataTable(); } return(Datos); }
public void Multiplicando() { lista.Add(primervalor); lista.Add(int.Parse(textBox1.Text)); if (resultado != 0) { double producto = 0; producto = resultado * int.Parse(textBox1.Text); resultado = producto; textBox1.Text = resultado.ToString(); lista2.Clear(); operacion = operaciones.nada; } else { double producto = 1; for (int i = 0; i < lista.Count; i++) { producto = producto * lista[i]; } resultado = producto; textBox1.Text = resultado.ToString(); lista2.Clear(); operacion = operaciones.nada; } }
private void sumar_Click(object sender, EventArgs e) { //if (lista3.Count == 0) { if (textBox1.Text == resultado.ToString()) { operacion = operaciones.suma; //textBox2.Text = textBox2.Text +" + "+ textBox1.Text; textBox2.Text = textBox1.Text + " + "; } else { //if (lista3.Count == 0) { operacion = operaciones.suma; if (textBox2.Text == "") { primervalor = (double.Parse(textBox1.Text)); //lista3.Add(primervalor); textBox2.Text = textBox1.Text; } else { if (textBox2.Text == resultado.ToString() + " + ") { textBox2.Text = textBox2.Text + textBox1.Text; Sumando(); //igual.PerformClick(); primervalor = resultado; } else { textBox2.Text = textBox2.Text + " + " + textBox1.Text; Sumando(); //igual.PerformClick(); primervalor = resultado; } } //} } // }/*else //{ /*double suma = 0; * for(int i = 0; i < lista3.Count; i++) * { * if (i == lista.Count - 1) * { * suma = suma + lista[i]; * } * * } * /resultado = suma; * textBox1.Text = resultado.ToString();*/ //} this.ActiveControl = null; }
public ActionResult DeleteConfirmed(int id) { operaciones operaciones = db.operaciones.Find(id); db.operaciones.Remove(operaciones); db.SaveChanges(); return(RedirectToAction("Index")); }
public static operaciones getInstancia() //singleton { if (Instancia == null) { Instancia = new operaciones(); } return(Instancia); }
private void button1_Click(object sender, EventArgs e) { operaciones opera = new operaciones(); // Creamos el objeto de la clase que existe en el dll Herramientas int a = Convert.ToInt32(textBox1.Text); // Conviertiendo los textbox a numeros enteros int b = Convert.ToInt32(textBox2.Text); String resultado = label3.Text + " " + opera.suma(a, b); // Llamamos al método almacenado en la clase operaciones y enviamos como paramtros los números ingresados label3.Text = resultado; // Mostramos el resultado de la suma }
private void bnOperacionClick(object sender, RoutedEventArgs e) { oper = oper + 1; if (oper > operaciones.division) { oper = operaciones.suma; } string[] textBoton = { "#", "+", "-", "*", "/" }; btnOperacion.Content = textBoton[(int)oper]; }
public ActionResult Edit([Bind(Include = "id,Nombre,Modulos_Id")] operaciones operaciones) { if (ModelState.IsValid) { db.Entry(operaciones).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Modulos_Id = new SelectList(db.modulos, "id", "descripcion", operaciones.Modulos_Id); return(View(operaciones)); }
private void clear_Click(object sender, EventArgs e) { textBox1.Text = 0.ToString(); resultado = 0; operacion = operaciones.nada; opporcentaje = operaciones.nada; primervalor = 0; lista.Clear(); lista2.Clear(); this.ActiveControl = null; }
private void dividir_Click(object sender, EventArgs e) { if (textBox1.Text == resultado.ToString()) { operacion = operaciones.division; } else { operacion = operaciones.division; primervalor = (double.Parse(textBox1.Text)); } this.ActiveControl = null; }
// GET: operaciones/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } operaciones operaciones = db.operaciones.Find(id); if (operaciones == null) { return(HttpNotFound()); } return(View(operaciones)); }
// GET: operaciones/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } operaciones operaciones = db.operaciones.Find(id); if (operaciones == null) { return(HttpNotFound()); } ViewBag.Modulos_Id = new SelectList(db.modulos, "id", "descripcion", operaciones.Modulos_Id); return(View(operaciones)); }
public static DataTable datosCaja(string idcaja) { string sentencia = @"select total_ventas_tickets as vt, total_ventas_facturas as vf, total_ventas_anuladas as anula_v, total_compras_anuladas as anula_c, gastos_operativos as gastos, total_compras as compra, total_ganancia as gana from cortes_diarios where idcaja='" + idcaja + "';"; operaciones op = new operaciones(); try { return(op.Consultar(sentencia)); } catch { return(new DataTable()); } }
public bool validarCodigoActualizar() { operaciones op = new operaciones(); bool valido = false; string sentencia = "SELECT * FROM codigos WHERE codigo='" + this.codigo + "';"; int reg = op.Consultar(sentencia).Rows.Count; Console.WriteLine(reg); if (reg > 1) { valido = true; } return(valido); }