private void btnProcesar_Click(object sender, EventArgs e) { if (this.dtgPrestamosCuotas.Rows.Count != 0) { PrestamosCL prestamosCL = new PrestamosCL(); Prestamos_CuotasCL prestamos_CuotasCL = new Prestamos_CuotasCL(); Abonos_CuotasCL abonos_CuotasCL = new Abonos_CuotasCL(); PlanillaCL planillaCL = new PlanillaCL(); if (this.ValidarPago()) { if (this.ObtenerFechaPago()) { foreach (DataGridViewRow dataGridViewRow in dtgPrestamosCuotas.Rows) { int num = Convert.ToInt32(dataGridViewRow.Cells["Prestamos_cuotas_id"].Value.ToString()); int id = Convert.ToInt32(dataGridViewRow.Cells["Prestamo"].Value.ToString()); DataSet dataSet = prestamosCL.TraerPrestamoSaldo(id.ToString()); DataTable dataTable = dataSet.Tables[0]; DataRow dataRow = dataTable.Rows[0]; double num2 = (double)Convert.ToInt32(dataRow.ItemArray.GetValue(0).ToString()); DataSet dataSet2 = abonos_CuotasCL.TraerSuma_Abonos(dataGridViewRow.Cells["Prestamos_cuotas_id"].Value.ToString()); DataTable dataTable2 = dataSet2.Tables[0]; DataRow dataRow2 = dataTable2.Rows[0]; if (!string.IsNullOrEmpty(dataRow2.ItemArray.GetValue(0).ToString())) { double num3 = Convert.ToDouble(dataRow2.ItemArray.GetValue(0).ToString()); double monto = (double)Convert.ToInt32(dataGridViewRow.Cells["Monto"].Value.ToString()) - num3; abonos_CuotasCL.InsertarAbono_Cuotas(num, monto, this.fechaPago); num2 -= (double)Convert.ToInt32(dataGridViewRow.Cells["Monto"].Value.ToString()) - num3; } else { num2 -= (double)Convert.ToInt32(dataGridViewRow.Cells["Monto"].Value.ToString()); } prestamosCL.EditarPrestamo(id, num2); prestamos_CuotasCL.EditarPrestamoCuotas(num, this.fechaPago, true, ""); } planillaCL.EditarPlanilla(Convert.ToInt32(this.numPlanilla), true); if (planillaCL.IsError) { MessageBox.Show(planillaCL.ErrorDescripcion, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { MessageBox.Show("Planilla procesada con exito", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.iPlanilla.CargarPlanilla(""); base.Dispose(); } } } else { MessageBox.Show(this.errores, "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } else { MessageBox.Show("No hay cuotas que procesar", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
// CARGA LAS CUOTAS DE LA PLANILLA public void CargarDetallePlanilla(string planilla) { PlanillaCL oPlanilla = new PlanillaCL(); DataSet oDatos = oPlanilla.TraerPlanillaDetalle(planilla); dtgPrestamosCuotas.DataSource = oDatos.Tables[0]; TotalPlanilla(); }
// CARGAR LAS PLANILLAS public void CargarPlanilla(string fecha) { PlanillaCL oPlanilla = new PlanillaCL(); DataSet oDatos; oDatos = oPlanilla.TraerPlanilla(fecha); // ASIGNA LOS DATOS AL DATAGRID dtgPlanilla.DataSource = oDatos.Tables[0]; OrdenarColumnas(); }
//ELIMINA LAS CUOTAS DE LA PLANILLA private void dtgPrestamosCuotas_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 1 && e.RowIndex != -1) { PlanillaCL oPlanilla = new PlanillaCL(); string idCuota = dtgPrestamosCuotas.Rows[e.RowIndex].Cells["Prestamos_cuotas_id"].Value.ToString(); string idPlanilla = numPlanilla; oPlanilla.EliminarPlanillaDetalle(idCuota, idPlanilla); dtgPrestamosCuotas.Rows.RemoveAt(e.RowIndex); TotalPlanilla(); } }
private void eliminarPlanillaToolStripMenuItem_Click(object sender, EventArgs e) { string idPlanilla = dtgPlanilla.CurrentRow.Cells[0].Value.ToString(); PlanillaCL oPlanilla = new PlanillaCL(); oPlanilla.EliminarPlanillaTodas(idPlanilla); oPlanilla.EliminarPlanilla(idPlanilla); if (oPlanilla.IsError) { MessageBox.Show(oPlanilla.ErrorDescripcion, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Planilla eliminada con exito", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); CargarPlanilla(null); } }
private void btnGuardar_Click(object sender, EventArgs e) { if (dtgPrestamosCuotas.Rows.Count != 0) { DialogResult opcion = MessageBox.Show("Desea guardar la planilla con estas cuotas", "Informacion", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (opcion == DialogResult.OK) { if (txtDetalle.Text == "") { MessageBox.Show("Escriba un detalle para esta planilla", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { // INSTANCIAS PlanillaCL oPlanilla = new PlanillaCL(); oPlanilla.InsertarPlanilla(numPlanilla, Convert.ToDateTime(lblFecha.Text), txtDetalle.Text, false); foreach (DataGridViewRow row in dtgPrestamosCuotas.Rows) { int idCuota = Convert.ToInt32(row.Cells["Prestamos_cuotas_id"].Value.ToString()); oPlanilla.InsertarPlanillaDetalle(numPlanilla, idCuota); } // COMPRUEBA SI HAY ERROR if (oPlanilla.IsError) { MessageBox.Show(oPlanilla.ErrorDescripcion, "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Planilla creada con exito ", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult imprimir = MessageBox.Show("Desea imprimir los ticket de esta planilla? ", "Informacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (imprimir == DialogResult.Yes) { int cRows = 0; for (int i = 0; i < dtgPrestamosCuotas.Rows.Count; i++) { ImprimirTickets.Print(); cRows++; } } iPlanilla.CargarPlanilla(""); this.Dispose(); } } } } else { MessageBox.Show("No puede procesar una planilla sin cuotas", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnGuardar_Click(object sender, EventArgs e) { var dia = dtFechaInicial.Value.Day; var mes = dtFechaInicial.Value.Month; var ano = dtFechaInicial.Value.Year; var tipo = ValidacionesCL.ValidarDiaPagoIndex(cmbDiaPago.SelectedItem.ToString()); var validacionQuincena = ValidacionesCL.validarQuincena(dia, mes, ano, tipo); if (_dCuotasGeneradas == null || _dCuotasGeneradas.Rows.Count == 0) { MessageBox.Show("Debe hacer clic en Generar previsualización para poder procesar la edición", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (validacionQuincena == false) { var countErrors = 0; var oCuotas = new Prestamos_CuotasCL(); var oPlanilla = new PlanillaCL(); var oAbonosCuotas = new Abonos_CuotasCL(); foreach (DataRow item in _dCuotas.Rows) { var id = item["id"].ToString(); // ELIMINAR ABONOS DE UNA CUOTA oAbonosCuotas.EliminarAbono_Cuotas_Id_Cuota(id); // ELIMINA DETALLE DE PLANILLA REFERENTE A UNA CUOTA oPlanilla.EliminarPlanillaDetalle(id); // ELIMINAR LA CUOTA oCuotas.EliminarCuota(id); if (oCuotas.IsError) { countErrors++; } } foreach (DataRow item in _dCuotasGeneradas.Rows) { // INSERTA NUEVAS CUOTAS oCuotas.InsertarPrestamo_Cuotas( _prestamoId, Convert.ToInt32(item["Numero couta"].ToString()), Convert.ToDateTime(item["Fecha de pago"].ToString()), Convert.ToDouble(item["Monto"].ToString()), Convert.ToDouble(item["Saldo"].ToString())); if (oCuotas.IsError) { countErrors++; } } if (countErrors > 0) { MessageBox.Show("Se presentaron errores al editar las cuotas", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Préstamo modificado con éxito", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Dispose(); } } }