public string DatoNegocioupdate(negocio n, string inm, List<acuerdo_pago> ac, List<acuerdo_pago_banco> acg) { BLLnegocio hn = new BLLnegocio(); foreach (var item in ac) { item.NO_ACUERDO = n.ID_NEGOCIO; item.FECHA_PAGO = item.FECHA_PAGO; item.CUOTA = item.CUOTA; decimal a; if (decimal.TryParse(item.VALOR_CUOTA.ToString(), NumberStyles.Number, CultureInfo.InvariantCulture, out a)) { // NumberStyles.Number: AllowLeadingWhite, AllowTrailingWhite, AllowLeadingSign, // AllowTrailingSign, AllowDecimalPoint, AllowThousands item.VALOR_CUOTA = a; } } foreach (var item in acg) { item.NO_ACUERDO = n.ID_NEGOCIO; item.FECHA_PAGO = item.FECHA_PAGO; item.CUOTA = item.CUOTA; decimal a; if (decimal.TryParse(item.VALOR_CUOTA.ToString(), NumberStyles.Number, CultureInfo.InvariantCulture, out a)) { // NumberStyles.Number: AllowLeadingWhite, AllowTrailingWhite, AllowLeadingSign, // AllowTrailingSign, AllowDecimalPoint, AllowThousands item.VALOR_CUOTA = a; } } return hn.Updatenegocio(n, inm, ac,acg); }
public string Updatenegocio(negocio n, string inm, List<acuerdo_pago> ac, List<acuerdo_pago_banco> acg) { try { var ctx = bd.negocio.First(t => t.ID_NEGOCIO == n.ID_NEGOCIO); //ctx.FECHA_NEGOCIO = n.FECHA_NEGOCIO; ctx.PROPIETARIO = n.PROPIETARIO; ctx.CEDULA_P = n.CEDULA_P; ctx.EXPEDICION = n.EXPEDICION; ctx.ESTADO_C = n.ESTADO_C; ctx.FECHA_NACI = n.FECHA_NACI; ctx.LUGAR = n.LUGAR; ctx.DIRECCION_R = n.DIRECCION_R; ctx.TELEFONO_P = n.TELEFONO_P; ctx.EMPRESA = n.EMPRESA; ctx.TELFONO_EMP = n.TELFONO_EMP; ctx.CARGO = n.CARGO; ctx.PROFESION = n.PROFESION; ctx.DIRECCION_EMPR = n.DIRECCION_EMPR; ctx.ANTIGUEDAD = n.ANTIGUEDAD; ctx.CORREO = n.CORREO; ctx.NOMBRE_CONY = n.NOMBRE_CONY; ctx.CEDULA_CUY = n.CEDULA_CUY; ctx.TELE_CONY = n.TELE_CONY; ctx.N_HIJO = n.N_HIJO; ctx.INTERES_COM = n.INTERES_COM; ctx.VALOR_CASA = n.VALOR_CASA; ctx.INICIAL = n.INICIAL; ctx.CREDITO = n.CREDITO; ctx.BANCO = n.BANCO; ctx.NO_CREDITO = n.NO_CREDITO; ctx.FECHA_ES = n.FECHA_ES; ctx.FECHA_ENT = n.FECHA_ENT; ctx.FECHA_SUBRO = n.FECHA_SUBRO; ctx.ASESOR_INFO = n.ASESOR_INFO; ctx.MEDIO_ENT = n.MEDIO_ENT; ctx.ASOCIADO = n.ASOCIADO; ctx.CLASE_INMU = n.CLASE_INMU; ctx.SEPARACION = n.SEPARACION; ctx.USER_CARTERA = n.USER_CARTERA; ctx.INGRESO = n.INGRESO; ctx.PARQUEADERO = n.PARQUEADERO; ctx.AREAS_COMUNES = n.AREAS_COMUNES; ctx.AREA_PRIVADA = n.AREA_PRIVADA; ctx.AREA_CONSTRUIDA = n.AREA_CONSTRUIDA; ctx.TIPO_DOCUMENTO_CONY = n.TIPO_DOCUMENTO_CONY; ctx.LUGAR_EXPEDICION = n.LUGAR_EXPEDICION; ctx.FECHA_EXPEDICION_CUY = n.FECHA_EXPEDICION_CUY; ctx.ADICIONES_EXCLUSIONES = n.ADICIONES_EXCLUSIONES; ctx.SUBSIDIO = n.SUBSIDIO; ctx.GARAJE = n.GARAJE; //ctx.SALDO_FINANCIAR = n.SALDO_FINANCIAR; ctx.VALOR_SERVICIOGAS = n.VALOR_SERVICIOGAS; ctx.INTERESES_SUBROGACION = n.INTERESES_SUBROGACION; ctx.AUT_MENSAJE = n.AUT_MENSAJE; ctx.AUT_CORREO = n.AUT_CORREO; ctx.OBSERVACIONES = n.OBSERVACIONES; ctx.DESCUENTO = n.DESCUENTO; ctx.DOMICILIO = n.DOMICILIO; bd.SaveChanges(); AcuerdopagoUpdate(ac, n.ID_NEGOCIO); AcuerdopagoUpdateGas(acg, n.ID_NEGOCIO); return "1"; } catch (Exception) { throw; } }
/// <summary> /// Metodo para alamacenar hoja de negocio en el sistema /// </summary> /// <param name="n"></param> /// <param name="inm"></param> /// <param name="ac"></param> /// <returns></returns> public string Hojanegocio(negocio n,string inm, List<acuerdo_pago> ac, List<acuerdo_pago_banco> acg) { try { var _CodS = bd.VCod_SP.Where(sp => sp.COD == n.SEPARACION).ToList(); string Cod_Sp = ""; foreach (var item2 in _CodS) { Cod_Sp = item2.COD + item2.INMU; } user = Membership.GetUser().ToString(); n.ID_NEGOCIO = Convert.ToString(n.FECHA_NACI.Value.Day) + Convert.ToString(n.FECHA_NACI.Value.Month) + Convert.ToString(DateTime.Now.Year) + Convert.ToString(DateTime.Now.Second) + n.CEDULA_P; n.USER_CREO = user; n.CODIGO_F = Cod_Sp; n.FECHA_NEGOCIO = DateTime.Now; bd.negocio.Add(n); Acuerdopago(ac, n.ID_NEGOCIO); Acuerdopagogas(acg, n.ID_NEGOCIO); ProcesoCompra(inm); UpdateSepracion(n.SEPARACION); HistorialCliente(n.CEDULA_P, inm); HistorialInmu(n.CEDULA_P, inm); bd.SaveChanges(); return Cod_Sp + "-" + n.ID_NEGOCIO; } catch (DbEntityValidationException ex) { foreach (var eve in ex.EntityValidationErrors) { /* Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); }*/ // Retrieve the error messages as a list of strings. var errorMessages = ex.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); // Join the list to a single string. var fullErrorMessage = string.Join("; ", errorMessages); // Combine the original exception message with the new one. var exceptionMessage = string.Concat(ex.Message, " el error esta en: ", fullErrorMessage); // Throw a new DbEntityValidationException with the improved exception message. throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors); } throw; return "ER"; } }