private void AsentarPlan() { string cuit = dgv_EmpresaAfectada.CurrentRow.Cells["cuit"].Value.ToString(); if (MessageBox.Show("Esta seguro de Asentar el Plan de Pago? ", "¡¡¡ ATENCION !!!", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (!ExistePlanVigente(cuit, NroDeAsignacion)) { using (var context = new lts_sindicatoDataContext()) { var NroDePlan = context.PlanesDePago.ToList().Count() == 0 ? 1 : context.PlanesDePago.Max(x => x.NroDePlan) + 1; PlanesDePago Insert = new PlanesDePago(); Insert.Fecha = DateTime.Now; Insert.CUIT = dgv_EmpresaAfectada.CurrentRow.Cells["cuit"].Value.ToString(); Insert.NroDeAsignacion = NroDeAsignacion; Insert.NroDePlan = NroDePlan; Insert.Estado = 1; Insert.DeudaInicial = Convert.ToDecimal(txt_DeudaInicial.Text); context.PlanesDePago.InsertOnSubmit(Insert); context.SubmitChanges(); CargarPlanDetalle(dgv_PlanDePagos, NroDePlan); Novedades InsertNovedad = new Novedades(); InsertNovedad.Fecha = DateTime.Now; InsertNovedad.Usuario = UserId; InsertNovedad.NumeroDeAsignacion = NroDeAsignacion; InsertNovedad.CUIT = cuit; if (txt_CantidadDeCuotas.Text == "1") { InsertNovedad.Novedad = "Se Confirma Plan de Pago bajo las siguientes condiciones: " + "Deuda Inical: $" + txt_DeudaInicial.Text + " - Compromiso de pago hasta el dia " + dtp_VencCuota.Value.Date.ToString("dd-MM-yyyy") + " - el importe a abonar es de: $" + txt_DeudaInicial.Text + " - NOTA IMPORTANTE !!! ->>> En caso de NO ABONAR dentro de la fecha pactada" + ", El plan CAERA hasta llegar a un nuevo acuerdo." ; } else { InsertNovedad.Novedad = "Se Confirma Plan de Pago bajo las siguientes condiciones: " + "Deuda Inical: $" + txt_DeudaInicial.Text + " - Anticipo: $" + txt_Anticipo.Text + " - Abonar Anticipo hasta el dia " + dtp_VencAnticipo.Value.Date + " - Una vez Abonado el Anticipo Toma Vigencia el PLan de Pago de " + txt_CantidadDeCuotas.Text + " Cuotas de $" + txt_ImporteDeCuota.Text + " Con vencimiento de la 1ª cuota el dia " + dtp_VencCuota.Value.Date.ToString("dd-MM-yyyy") + " - NOTA IMPORTANTE !!! ->>> En caso NO ABONAR el anticipo dentro de la fecha pactada, El plan CAERA hasta nuevo acuerdo." ; } context.Novedades.InsertOnSubmit(InsertNovedad); context.SubmitChanges(); MostrarNovedades(cuit, NroDeAsignacion); } } else { MessageBox.Show("Ya esiste un plan vigente para esta Empresa !!!!!"); } } }
public static int AsentarPlan(string cuit, int NroDeActa, List <mdlCuadroAmortizacion> _PlanDePago) { int NroDePlan = 0; using (var context = new lts_sindicatoDataContext()) { NroDePlan = context.PlanesDePago.ToList().Count() == 0 ? 1 : context.PlanesDePago.Max(x => x.NroDePlan) + 1; PlanesDePago Insert = new PlanesDePago(); Insert.Fecha = DateTime.Now; Insert.CUIT = cuit; // dgv_EmpresaAfectada.CurrentRow.Cells["cuit"].Value.ToString(); Insert.NroDeAsignacion = 0; Insert.NroDePlan = NroDePlan; Insert.Estado = 1; Insert.DeudaInicial = _PlanDePago.First().DeudaInicial; Insert.Acta = NroDeActa; context.PlanesDePago.InsertOnSubmit(Insert); context.SubmitChanges(); CargarPlanDetalle(_PlanDePago, NroDePlan); } return(NroDePlan); }