private void showAps(object sender, EventArgs e) { SqlConnection con = BDConnect.connection(); apartados aps = new apartados(); tableCuentas.DataSource = aps.listaApartados(con); }
private void button1_Click(object sender, EventArgs e) { apartados ap = new apartados(); float importe = float.Parse(cajaPagotxt.Text); float abono = float.Parse(cajaAbonotxt.Text); float total = float.Parse(montoTotaltxt.Text); //restante= total-abono pagoClienteLabel.Text = importe.ToString(); abonoLabel.Text = abono.ToString(); cambioLabel.Text = Convert.ToString(resta(importe, abono)); if (abono >= total) { restanteLabel.Text = Convert.ToString(resta(abono, total)); cambioLabel.Text = Convert.ToString(resta(abono, total)); SqlConnection con = BDConnect.connection(); float restante = float.Parse(restanteLabel.Text); int idApart = Convert.ToInt32(idApartLabel.Text); int idClie = Convert.ToInt32(idClientLabel.Text); float restAnt = float.Parse(montoTotaltxt.Text);//restante Anterior float pagoNvo = float.Parse(cajaAbonotxt.Text); float debe = restante; string fecha = dateTimePicker1.Text; if (restante <= total) { bool update = ap.ActualizarRestante(con, restante.ToString(), abonoLabel.Text, idApartLabel.Text); bool insert = ap.RegistraPgo(con, idApart, idClie, restAnt, pagoNvo, debe, fecha); if (insert && update) { restanteLabel.Text = "" + 0; MessageBox.Show("Apartado liquidado"); tableCuentas.DataSource = ap.listaApartados(con); bajaInventario(idproducto_label.Text, Convert.ToInt32(cantidadProductolabel.Text)); ap.eliminarPtoApartado(con, idPtoApartadoLabel.Text); flag = true; } imprimirComprobante(); CrearImpresion.ImprimirTiket(); //update tabla productos resta cantidad del producto a el producto //delete apartado x id //delete pagos x id //imprimir ticket } else if (restante >= total) { bool update = ap.ActualizarRestante(con, restante.ToString(), abonoLabel.Text, idApartLabel.Text); bool insert = ap.RegistraPgo(con, idApart, idClie, restAnt, pagoNvo, debe, fecha); if (insert && update) { restanteLabel.Text = "" + 0; MessageBox.Show("Apartado liquidado"); tableCuentas.DataSource = ap.listaApartados(con); } /*imprimirComprobante(); * CrearImpresion.ImprimirTiket();*/ } } else if (abono <= total) { restanteLabel.Text = Convert.ToString(resta(total, abono)); float restante = float.Parse(restanteLabel.Text); //variables insertar int idApart = Convert.ToInt32(idApartLabel.Text); int idClie = Convert.ToInt32(idClientLabel.Text); float restAnt = float.Parse(montoTotaltxt.Text);//restante Anterior float pagoNvo = float.Parse(cajaAbonotxt.Text); float debe = restante; string fecha = dateTimePicker1.Text; SqlConnection con = BDConnect.connection(); if (restante < total) { try { bool update = ap.ActualizarRestante(con, restante.ToString(), abonoLabel.Text, idApartLabel.Text); bool insert = ap.RegistraPgo(con, idApart, idClie, restAnt, pagoNvo, debe, fecha); if (update && insert) { MessageBox.Show("Actualizacion Exitosa", "PAGO REGISTRADO", MessageBoxButtons.OK, MessageBoxIcon.Information); tableCuentas.DataSource = ap.listaApartados(con); } else { MessageBox.Show(insert.ToString()); } } catch (Exception ex) { MessageBox.Show(ex.Message); } //registrar el pago } } /*imprimirComprobante(); * CrearImpresion.ImprimirTiket();*/ }