private void button1_Click(object sender, EventArgs e) { { if (!string.IsNullOrEmpty(tbccodigo.Text) || !string.IsNullOrWhiteSpace(tbccodigo.Text)) { operacion oper = new operacion(); string id, nombre, apellidos, cedula, telefono, direccion; id = tbccodigo.Text; nombre = tbcnombre.Text; nombre = nombre.Trim(new Char[] { ' ', '*', '.' }); //Limpiar el nombre de puntos y carácteres raros apellidos = tbcapellidos.Text; apellidos = apellidos.Trim(new Char[] { ' ', '*', '.' }); cedula = tbccedula.Text; cedula = cedula.Trim(new Char[] { ' ', '*', '.' }); telefono = tbctelefono.Text; telefono = telefono.Trim(new Char[] { ' ', '*', '.' }); direccion = tbcdireccion.Text; if (nuevo) { oper.Sqlsinconsulta("INSERT INTO cliente(nombre, apellidos, cedula, telefono, direccion) VALUES('" + nombre + "', '" + apellidos + "', '" + cedula + "', '" + telefono + "', '" + direccion + "');"); MessageBox.Show("Se agregó el Cliente", "Cliente"); nuevo = false; } else { oper.Sqlsinconsulta("UPDATE cliente SET nombre = '" + nombre + "', apellidos = '" + apellidos + "', cedula = '" + cedula + "', telefono = '" + telefono + "', direccion = '" + direccion + "' WHERE id = '" + id + "';"); MessageBox.Show("Se Modificó el Cliente", "Cliente"); } } else { MessageBox.Show("Rellene por lo menos los campos de Nombre y Teléfono", "Guardar"); } } }
private void button1_Click(object sender, EventArgs e) { { if (!string.IsNullOrEmpty(tbpcodigo.Text) || !string.IsNullOrWhiteSpace(tbpcodigo.Text)) { operacion oper = new operacion(); string id, nombre, costo, precio, existencia, suplidor; id = tbpcodigo.Text; nombre = tbpnombre.Text; nombre = nombre.Trim(new Char[] { ' ', '*', '.' }); //Limpiar Nombre de carácteres estraños costo = tbpcosto.Text; precio = tbpprecio.Text; existencia = tbpexistencia.Text; suplidor = tbpsuplidor.Text; if (nuevo) { oper.Sqlsinconsulta("INSERT INTO producto(nombre, costo, precio, existencia, suplidor) VALUES('" + nombre + "', '" + costo + "', '" + precio + "', '" + existencia + "', '" + suplidor + "');"); MessageBox.Show("Se agregó el Producto", "Nuevo"); nuevo = false; } else { oper.Sqlsinconsulta("UPDATE producto SET nombre = '" + nombre + "', costo = '" + costo + "', precio = '" + precio + "', existencia = '" + existencia + "', suplidor = '" + suplidor + "' WHERE id = '" + id + "';"); MessageBox.Show("Se Modificó el Producto", "Guardar"); } } else { MessageBox.Show("Rellene todos los campos", "Guardar"); } } }
private void btcsave_Click(object sender, EventArgs e) { { if (!string.IsNullOrEmpty(tbccodigo.Text) || !string.IsNullOrWhiteSpace(tbccodigo.Text)) { operacion oper = new operacion(); string id, nombre, tipo, telefono1, telefono2, direccion; id = tbccodigo.Text; nombre = tbcnombre.Text; tipo = tbstipo.Text; telefono1 = tbstel1.Text; telefono2 = tbstel2.Text; direccion = tbcdireccion.Text; if (nuevo) { oper.Sqlsinconsulta("INSERT INTO suplidores (nombre, tipo, telefono1, telefono2, direccion) VALUES('" + nombre + "', '" + tipo + "', '" + telefono1 + "', '" + telefono2 + "', '" + direccion + "');"); MessageBox.Show("Se agregó el Suplidor", "Suplidor"); nuevo = false; } else { oper.Sqlsinconsulta("UPDATE suplidores SET nombre = '" + nombre + "', tipo = '" + tipo + "', telefono1 = '" + telefono1 + "', telefono2 = '" + telefono2 + "', direccion = '" + direccion + "' WHERE id = '" + id + "';"); MessageBox.Show("Se Modificó el Suplidor", "Suplidor"); } } else { MessageBox.Show("Rellene por lo menos los campos de Nombre y Teléfono 1", "Guardar"); } } }
private void btnbuscar_Click(object sender, EventArgs e) { //Para coloar la fecha en formato correcto int mmes = DateTime.Now.Month; int ddia = DateTime.Now.Day; string mes; string dia; if (mmes < 10) { mes = ("0" + mmes.ToString()); } else { mes = mmes.ToString(); } if (ddia < 10) { dia = ("0" + mmes.ToString()); } else { dia = ddia.ToString(); } //Luego de hacer las revisiones necesarias en día y mes, formatear con guiones la fecha. string año = DateTime.Now.Year.ToString(); string fecha = (año + "-" + mes + "-" + dia); oper.Sqlsinconsulta("UPDATE registro SET estado = '" + Proceso + "', " + montodbname + " = '" + monto + "', " + fechadbname + " = '" + fecha + "' WHERE id = '" + id + "';"); this.Close(); //if (!String.IsNullOrEmpty(tbmonto.Text)) //{ // try // { // Registrar.bbuscar = true; // Registrar.buscar = tbmonto.Text; // this.Close(); // } // catch (Exception) // { // } //} //else //{ // MessageBox.Show("Por favor ingrese un número de registro válido","Buscar"); //} }
private void btpdelete_Click(object sender, EventArgs e) { DialogResult boton = MessageBox.Show("Seguro que desea eliminar este producto", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (boton == DialogResult.No) { return; } else if (!string.IsNullOrEmpty(tbpcodigo.Text) || !string.IsNullOrWhiteSpace(tbpcodigo.Text)) { operacion oper = new operacion(); string id; id = tbpcodigo.Text; oper.Sqlsinconsulta("DELETE FROM producto WHERE id = '" + id + "'"); MessageBox.Show("Se eliminó el Producto", "Eliminar"); tbpnombre.Text = ""; tbpcosto.Text = ""; tbpprecio.Text = ""; tbpexistencia.Text = ""; tbpsuplidor.Text = ""; int lid; DataTable dt = new DataTable(); dt = oper.ExtraeData("SELECT seq FROM sqlite_sequence WHERE name = 'producto';"); dataGridView1.DataSource = dt; dataGridView1.Refresh(); dataGridView1.SelectAll(); foreach (DataGridViewRow fila in dataGridView1.SelectedRows) { try { tbpcodigo.Text = fila.Cells[0].Value.ToString(); lid = Convert.ToInt32(tbpcodigo.Text); lid++; tbpcodigo.Text = Convert.ToString(lid); } catch (Exception) { } } nuevo = true; } else { MessageBox.Show("No ha seleccionado ningún producto para eliminar", "Eliminar"); } }
private void reset_Click(object sender, EventArgs e) { if (tbpass.Text == "zxccxz1") { operacion oper = new operacion(); oper.Sqlsinconsulta("DELETE FROM factura; DELETE FROM detalle; DELETE FROM sqlite_sequence WHERE name = 'factura'; DELETE FROM sqlite_sequence WHERE name = 'detalle';"); MessageBox.Show("Campos reiniciados", "Enhorabuena", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); tbpass.Clear(); } else { MessageBox.Show("Clave Incorrecta", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); tbpass.Clear(); } }
private void btnguardar_Click(object sender, EventArgs e) { operacion oper = new operacion(); int maxid; //Este boton hace que sea posible guardar los datos que se encuentran en el datagridbiew string id, nombre, tipo, telefono1, telefono2, direccion; maxid = dataGridView1.RowCount; maxid--; for (int i = 0; i < maxid; i++) { id = dataGridView1.Rows[i].Cells[0].Value.ToString(); nombre = dataGridView1.Rows[i].Cells[1].Value.ToString(); tipo = dataGridView1.Rows[i].Cells[2].Value.ToString(); telefono1 = dataGridView1.Rows[i].Cells[3].Value.ToString(); telefono2 = dataGridView1.Rows[i].Cells[4].Value.ToString(); direccion = dataGridView1.Rows[i].Cells[5].Value.ToString(); oper.Sqlsinconsulta("UPDATE suplidores SET nombre = '" + nombre + "', tipo = '" + tipo + "', telefono1 = '" + telefono1 + "', telefono2 = '" + telefono2 + "', direccion = '" + direccion + "' WHERE id = '" + id + "';"); } }
private void button2_Click(object sender, EventArgs e) { operacion oper = new operacion(); int maxid; //Este boton hace que sea posible guardar los datos que se encuentran en datagridview string id, nombre, apellidos, cedula, telefono, direccion; maxid = dataGridView1.RowCount; maxid--; for (int i = 0; i < maxid; i++) { id = dataGridView1.Rows[i].Cells[0].Value.ToString(); nombre = dataGridView1.Rows[i].Cells[1].Value.ToString(); apellidos = dataGridView1.Rows[i].Cells[2].Value.ToString(); cedula = dataGridView1.Rows[i].Cells[3].Value.ToString(); telefono = dataGridView1.Rows[i].Cells[4].Value.ToString(); direccion = dataGridView1.Rows[i].Cells[5].Value.ToString(); //MessageBox.Show(id + " " + nombre + " " + apellidos + " " + cedula + " " + telefono + " " + direccion); oper.Sqlsinconsulta("UPDATE cliente SET nombre = '" + nombre + "', apellidos = '" + apellidos + "', cedula = '" + cedula + "', telefono = '" + telefono + "', direccion = '" + direccion + "' WHERE id = '" + id + "';"); } }
private void btnguardar_Click(object sender, EventArgs e) { operacion oper = new operacion(); int maxid; //Este boton hace que sea posible guardar los datos que se encuentran en datagridbiew string id, nombre, costo, precio, existencia, suplidor; maxid = dataGridView1.RowCount; for (int i = 0; i < maxid; i++) { id = dataGridView1.Rows[i].Cells[0].Value.ToString(); nombre = dataGridView1.Rows[i].Cells[1].Value.ToString(); costo = dataGridView1.Rows[i].Cells[2].Value.ToString(); precio = dataGridView1.Rows[i].Cells[3].Value.ToString(); existencia = dataGridView1.Rows[i].Cells[4].Value.ToString(); suplidor = dataGridView1.Rows[i].Cells[5].Value.ToString(); //MessageBox.Show(id + " " + nombre + " " + apellidos + " " + cedula + " " + telefono + " " + direccion); oper.Sqlsinconsulta("UPDATE producto SET nombre = '" + nombre + "', costo = '" + costo + "', precio = '" + precio + "', existencia = '" + existencia + "', suplidor = '" + suplidor + "' WHERE id = '" + id + "';"); } btnguardar.Enabled = false; }
private void btcsave_Click(object sender, EventArgs e) { { if (!string.IsNullOrEmpty(tbnombre.Text) || !string.IsNullOrWhiteSpace(tbnombre.Text)) { operacion oper = new operacion(); DataTable dt = new DataTable(); int mmes = 0, ddia = 0; string id = numregistro; string nombrecliente, equipo, modelo, proceso, detalle, memoria, chip, año, mes, dia, fecha; nombrecliente = tbnombre.Text; equipo = tbequipo.Text; modelo = tbmodelo.Text; proceso = tbproceso.Text; detalle = tbdetalle.Text; memoria = tbmemoria.Text; chip = tbchip.Text; //Para coloar la fecha en formato correcto mmes = DateTime.Now.Month; ddia = DateTime.Now.Day; if (mmes < 10) { mes = ("0" + mmes.ToString()); } else { mes = mmes.ToString(); } if (ddia < 10) { dia = ("0" + mmes.ToString()); } else { dia = ddia.ToString(); } //Luego de hacer las revisiones necesarias en día y mes, formatear con guiones la fecha. año = DateTime.Now.Year.ToString(); fecha = (año + "-" + mes + "-" + dia); if (nuevo) { oper.Sqlsinconsulta("INSERT INTO registro (nombrecliente, equipo, modelo, proceso, detalle, memoria, chip, fecha, estado) VALUES('" + nombrecliente + "', '" + equipo + "', '" + modelo + "', '" + proceso + "', '" + detalle + "', '" + memoria + "', '" + chip + "', '" + fecha + "', 'PROCESO');"); MessageBox.Show("Se agregó el registro Correctamente", "Registrar"); //Para hacer que si el cliente hacer algún cambio este se modifique nuevo = false; //Para que se habilite la opción imprimir imprimir = true; btimprimir.Enabled = true; btimprimir.Focus(); } else { oper.Sqlsinconsulta("UPDATE registro SET nombrecliente = '" + nombrecliente + "', equipo = '" + equipo + "', modelo = '" + modelo + "', proceso = '" + proceso + "', detalle = '" + detalle + "', memoria = '" + memoria + "', chip = '" + chip + "' WHERE id = '" + numregistro + "';"); MessageBox.Show("Se Modificó el Cliente", "Guardar"); //Para que se habilite la opción imprimir imprimir = true; btimprimir.Enabled = true; } } else { MessageBox.Show("Rellene Todos los Campos", "Guardar"); } } }
private void ptbflecha_Click(object sender, EventArgs e) { //Para coloar la fecha en formato correcto int mmes = DateTime.Now.Month; int ddia = DateTime.Now.Day; string mes; string dia; if (mmes < 10) { mes = ("0" + mmes.ToString()); } else { mes = mmes.ToString(); } if (ddia < 10) { dia = ("0" + mmes.ToString()); } else { dia = ddia.ToString(); } //Luego de hacer las revisiones necesarias en día y mes, formatear con guiones la fecha. string año = DateTime.Now.Year.ToString(); string fechaen = (año + "-" + mes + "-" + dia); //Devolver el registro a un lugar anterior try { if (servicioestado == "PROCESO") { int idcancel = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value); DialogResult Cancelar = MessageBox.Show("¿Desea Eliminar el registro No.: " + dataGridView1.CurrentRow.Cells[0].Value.ToString() + "?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (Cancelar == DialogResult.No) { return; } else { //Eliminar Registro oper.Sqlsinconsulta("UPDATE registro SET estado = 'ELIMINADO', fechaentregado = '" + fechaen + "' WHERE id = '" + idcancel + "';"); } MostrarTodo(); } else { if (servicioestado == "TERMINADO") { int idcancel = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value); DialogResult Cancelar = MessageBox.Show("¿Desea devolver el registro No.: " + dataGridView1.CurrentRow.Cells[0].Value.ToString() + " a trabajos en proceso?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (Cancelar == DialogResult.No) { return; } else { //Devolver Registro oper.Sqlsinconsulta("UPDATE registro SET estado = 'PROCESO', preciotrabajo = '', fechaterminado = '' WHERE id = '" + idcancel + "';"); } MostrarTodo(); } else { int idcancel = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value); DialogResult Cancelar = MessageBox.Show("¿Desea coloar el registro No.: " + dataGridView1.CurrentRow.Cells[0].Value.ToString() + " en trabajos sin entregar?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (Cancelar == DialogResult.No) { return; } else { //Devolver Registro oper.Sqlsinconsulta("UPDATE registro SET estado = 'TERMINADO', cobrado = '', fechaentregado = '' WHERE id = '" + idcancel + "';"); } MostrarTodo(); } } } catch (Exception) { MessageBox.Show("Seleccione un solo registro para Facturar...", "Aviso"); } }
private void btmodificar_Click(object sender, EventArgs e) { DialogResult boton = MessageBox.Show("¿Desea guardar los cambios realizados?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (boton == DialogResult.No) { return; } else if (credito && idcliente != 0.ToString() || !credito) { //Variables necesarias para el detalle string idf, idp, nombre, cantidad, precio, total; idf = numfactura; int maxrow = dataGridView1detalle.RowCount; for (int i = 0; i < maxrow; i++) { detalleguardado = true; try { idp = dataGridView1detalle.Rows[i].Cells[0].Value.ToString(); nombre = dataGridView1detalle.Rows[i].Cells[1].Value.ToString(); cantidad = dataGridView1detalle.Rows[i].Cells[2].Value.ToString(); precio = dataGridView1detalle.Rows[i].Cells[3].Value.ToString(); total = dataGridView1detalle.Rows[i].Cells[4].Value.ToString(); dt = oper.ExtraeData("SELECT existencia FROM producto WHERE id = '" + idp + "';"); dataGridView1.DataSource = dt; dataGridView1.Refresh(); currentproductocantidad = dataGridView1.Rows[0].Cells[0].Value.ToString(); nuevacantidad = (Convert.ToInt32(currentproductocantidad) - Convert.ToInt32(cantidad)).ToString(); oper.Sqlsinconsulta("INSERT INTO detalle(idf, idp, nombre, cantidad, precio, total) VALUES('" + idf + "', '" + idp + "', '" + nombre + "', '" + cantidad + "', '" + precio + "', '" + total + "');"); oper.Sqlsinconsulta("UPDATE producto SET existencia = '" + nuevacantidad + "' WHERE id = '" + idp + "';"); } catch (Exception) { MessageBox.Show("Error al Guardar la Factura", "Guardar"); detalleguardado = false; //Para detener el guardado si hubo algún error en el guardado } } if (detalleguardado) { //Variables necesarias para la factura string idc, nombrec, fechaf; nombrec = tbcliente.Text; if (credito) { try { idc = Convert.ToInt32(tbidcliente.Text).ToString(); } catch (Exception) { MessageBox.Show("Elija el cliente nuevamente", "Error"); return; } } else { idc = ""; } //Para coloar la fecha en formato correcto int mmes = 0, ddia = 0; string mes, dia, año; mmes = DateTime.Now.Month; ddia = DateTime.Now.Day; if (mmes < 10) { mes = ("0" + mmes.ToString()); } else { mes = mmes.ToString(); } if (ddia < 10) { dia = ("0" + mmes.ToString()); } else { dia = ddia.ToString(); } //Luego de hacer las revisiones necesarias en día y mes, formatear con guiones la fecha. año = DateTime.Now.Year.ToString(); fechaf = (año + "-" + mes + "-" + dia); total = totalfactura.ToString(); oper.Sqlsinconsulta("INSERT INTO factura(idc, nombrec, fecha, total) VALUES('" + idc + "', '" + nombrec + "', '" + fechaf + "', '" + total + "');"); facturaguardada = true; dataGridView1detalle.ReadOnly = true; if (detalleguardado && facturaguardada) { DialogResult Guardar = MessageBox.Show("Factura Guardada, Desea imprimirla", "Guardar", MessageBoxButtons.YesNo); if (boton == DialogResult.Yes) { ImprimirFactura(); // Método de impresión de Factura //Bloquear Factura btbuscar.Enabled = false; tbproducto.Enabled = false; btnsearch.Enabled = false; chkbcontado.Enabled = false; chkbcredito.Enabled = false; tbcliente.Enabled = false; btnguardar.Enabled = false; btnimprimir.Enabled = true; btneliminiar.Enabled = false; ptbcliente.Enabled = false; btnimprimir.Select(); return; } else { //Bloquear Factura btbuscar.Enabled = false; } tbproducto.Enabled = false; btnsearch.Enabled = false; chkbcontado.Enabled = false; chkbcredito.Enabled = false; tbcliente.Enabled = false; btnguardar.Enabled = false; btnimprimir.Enabled = true; btneliminiar.Enabled = false; ptbcliente.Enabled = false; btnimprimir.Select(); } } } else { MessageBox.Show("La facura es a Crédito por favor seleccione un cliente válido", "Aviso"); } }