private void CrearNivelesSuperiores(Cuentas cuenta) { var id = cuenta.id; var currentLevel = GetCurrentLevel(id) == 0 ? _totalNivelesSupercuentas + 1 : GetCurrentLevel(id); for (var i = currentLevel; i > 1; i--, currentLevel--) { var step = currentLevel > _totalNivelesSupercuentas ? (_totalLongitud - _totalNivelesSupercuentas) : 1;//la logitud del identificador del nivel var subCuenta = id.Substring(0, id.Length - step); id = subCuenta; if (!_db.Cuentas.Any(f => f.id == subCuenta && f.empresa == cuenta.empresa)) { var fmodel = new FModel(); var descripcion = GetDescripcionSubcuenta(subCuenta, cuenta.empresa, (currentLevel - 1).ToString()); var descripcion2 = descripcion; var cuentaService = FService.Instance.GetService(typeof(CuentasModel), Context, _db); var cuentaModel = new CuentasModel(); cuentaModel.Empresa = cuenta.empresa; cuentaModel.Id = subCuenta; cuentaModel.Descripcion = descripcion; cuentaModel.Descripcion2 = descripcion2; cuentaModel.UsuarioId = cuenta.fkUsuarios.ToString(); cuentaModel.Nif = new NifCifModel(); cuentaModel.BloqueoModel = new BloqueoEntidadModel() { Entidad = RCuentas.TituloEntidadSingular }; cuentaService.create(cuentaModel); } } }
public void Editar(string id, string razonsocial, string dni, string fkpais, string razonsocial2, string dni2, string fkpais2, bool result) { using (var db = MarfilEntities.ConnectToSqlServer(_fixture.DbName)) { using (var service = FService.Instance.GetService(typeof(CuentasModel), _fixture.Context, db)) { try { var model = new CuentasModel() { Empresa = _fixture.Empresa, Id = id, Descripcion = razonsocial, Nif = new NifCifModel() { Nif = dni, TipoNif = "1" }, FkPais = fkpais, UsuarioId = Guid.Empty.ToString() }; service.create(model); } catch (Exception ex) { Assert.False(result); } } } using (var db = MarfilEntities.ConnectToSqlServer(_fixture.DbName)) using (var service = FService.Instance.GetService(typeof(CuentasModel), _fixture.Context, db)) { try { var cuenta = service.get(id) as CuentasModel; cuenta.Descripcion = razonsocial2; cuenta.Nif.Nif = dni2; cuenta.FkPais = fkpais2; service.edit(cuenta); } catch (Exception ex) { Assert.False(result); } } using (var db = MarfilEntities.ConnectToSqlServer(_fixture.DbName)) using (var service = FService.Instance.GetService(typeof(CuentasModel), _fixture.Context, db)) { try { var cuenta = service.get(id) as CuentasModel; Assert.True(razonsocial2 == cuenta.Descripcion && dni2 == cuenta.Nif.Nif && fkpais2 == cuenta.FkPais); } catch (Exception ex) { Assert.False(result); } } }
private void buscarPrestamo(List <PrestamosModel> objetos) { string[][] orden = new string[6][]; orden[0] = new string[] { "Id", "Codigo", "60" }; orden[1] = new string[] { "Cuenta", "Cuenta", "180" }; orden[2] = new string[] { "Fechaprestamo", "Fecha de Prestamo", "150" }; orden[3] = new string[] { "Montoprestamo", "Monto", "100" }; orden[4] = new string[] { "Plazomeses", "Meses", "80" }; orden[5] = new string[] { "Usuario_creador", "Aprobado por", "100" }; if (objetos != null) { using (Ayuda.FormHelp2 formHelp1 = new Ayuda.FormHelp2()) { formHelp1.setList(objetos, orden); formHelp1.ShowDialog(); if (formHelp1.EstaAceptado()) { var dato = formHelp1.getObject <PrestamosModel>(); if (dato != null) { this.clearForm(); this.gPrestamo = this.BLPrestamo.Prestamo_ObtenerUno(dato.Id); this.gCuenta = this.BLCuenta.Cuenta_ObtenerUno(dato.Cuenta); this.prestamo2gui(this.gPrestamo); this.modoNuevo(); this.modoEdicion(); } } } } }
public void CrearModel(string linea, EmpresaModel empresa) { var newContext = new ContextLogin() { BaseDatos = ContextService.BaseDatos, Empresa = empresa.Id, Id = ContextService.Id, RoleId = ContextService.RoleId }; var vector = linea.Split(';'); var model = new CuentasModel() { Empresa = empresa.Id, Id = vector[0], Descripcion2 = vector[1], Descripcion = vector[2], Nivel = int.Parse(vector[3]), FkPais = empresa.Fkpais, UsuarioId = Guid.Empty.ToString(), Nif = new NifCifModel(), Fechaalta = DateTime.Now, FechaModificacion = DateTime.Now }; var service = new CuentasService(newContext); service.create(model); }
private void dgvCuentas_CellEnter(object sender, DataGridViewCellEventArgs e) { modoInicial(); String numeroCuenta = dgvCuentas.Rows[e.RowIndex].Cells[0].Value.ToString().Replace(" ", ""); cuentaUsuario = this.BLCuenta.cuentaSelectbyNroCuenta(numeroCuenta)[0]; if (cuentaUsuario.Id_tarjeta == 0) { txtTarjeta.Text = ""; btnTarjeta.Enabled = true; } else { txtTarjeta.Text = cuentaUsuario.Id_tarjeta.ToString(); btnTarjeta.Enabled = false; } if (e.ColumnIndex == 4) { if (String.IsNullOrEmpty(cuentaUsuario.Id_tarjeta.ToString())) { txtTarjeta.Enabled = true; btnTarjeta.Enabled = true; } } }
private void cuenta2gui(CuentasModel acuenta) { if (this.gCuenta == null) { return; } var persona = this.BLPersona.Persona_ObtenerUno(this.gCuenta.Cliente); if (persona == null) { return; } this.persona2gui(persona); this.txtCodigo.Text = acuenta.Nrocuenta; this.cboMoneda.SelectedValue = acuenta.Tipomoneda; this.cboTipoCuenta.SelectedValue = acuenta.Tipocuenta; this.chkEstado.Checked = acuenta.Estado; this.SlblUsuario_creador.Text = acuenta.Usuario_creador; this.SlblFecha_creacion.Text = acuenta.Fecha_creacion.ToString(); this.SlblUsuario_modificador.Text = acuenta.Usuario_modificador; this.SlblFecha_modificacion.Text = acuenta.Fecha_modificacion.ToString(); }
private void buscarCuenta(List <CuentasModel> objetos) { string[][] orden = new string[7][]; orden[0] = new string[] { "NroCuenta", "Numero Cuenta", "130" }; orden[1] = new string[] { "TipoCuenta", "Tipo Cuenta", "100" }; orden[2] = new string[] { "SaldoContable", "Saldo Contable", "100" }; orden[3] = new string[] { "SaldoDisponible", "Saldo Disponible", "80" }; orden[4] = new string[] { "FECHA_CREACION", "Creado", "120" }; orden[5] = new string[] { "FECHA_MODIFICACION", "Modificado", "120" }; orden[6] = new string[] { "Estado", "Activo", "60" }; if (objetos != null) { using (Ayuda.FormHelp2 formHelp1 = new Ayuda.FormHelp2()) { formHelp1.setList(objetos, orden); formHelp1.ShowDialog(); if (formHelp1.EstaAceptado()) { var dato = formHelp1.getObject <CuentasModel>(); if (dato != null) { this.clearForm(); this.gCuenta = this.BLCuenta.Cuenta_ObtenerUno(dato.Nrocuenta); this.cuenta2gui(this.gCuenta); this.modoNuevo(); this.modoEdicion(); } } } } }
private void buscarCuenta(List <CuentasModel> objetos) { string[][] orden = new string[4][]; orden[0] = new string[] { "NroCuenta", "Numero Cuenta", "150" }; orden[1] = new string[] { "TipoCuenta", "Tipo Cuenta", "100" }; orden[2] = new string[] { "SaldoContable", "Saldo Contable", "90" }; orden[3] = new string[] { "SaldoDisponible", "Saldo Disponible", "90" }; if (objetos != null) { using (Ayuda.FormHelp2 formHelp1 = new Ayuda.FormHelp2()) { formHelp1.setList(objetos, orden); formHelp1.ShowDialog(); if (formHelp1.EstaAceptado()) { var dato = formHelp1.getObject <CuentasModel>(); if (dato != null) { this.gCuenta = BLCuenta.Getcuenta(dato.Nrocuenta); if (gCuenta == null) { return; } this.cuenta2gui(gCuenta); } } } } }
private void buscarCuenta(List <CuentasModel> objetos) { string[][] orden = new string[7][]; orden[0] = new string[] { "NroCuenta", "Numero Cuenta", "130" }; orden[1] = new string[] { "TipoCuenta", "Tipo Cuenta", "100" }; orden[2] = new string[] { "SaldoContable", "Saldo Contable", "100" }; orden[3] = new string[] { "SaldoDisponible", "Saldo Disponible", "80" }; orden[4] = new string[] { "FECHA_CREACION", "Creado", "120" }; orden[5] = new string[] { "FECHA_MODIFICACION", "Modificado", "120" }; orden[6] = new string[] { "Estado", "Activo", "60" }; if (objetos != null) { using (Ayuda.FormHelp2 formHelp1 = new Ayuda.FormHelp2()) { formHelp1.setList(objetos, orden); formHelp1.ShowDialog(); if (formHelp1.EstaAceptado()) { CuentasModel dato = formHelp1.getObject <CuentasModel>(); if (dato != null) { this.clearForm(); this.gCuenta = this.BLCuenta.Cuenta_ObtenerUno(dato.Nrocuenta); if (this.modo == "modoInicial") { if (this.gCuenta == null) { return; } List <PrestamosModel> Prestamos = this.BLPrestamo.Prestamo_SelecionarPorCuenta(this.gCuenta.Nrocuenta).ToList(); if (Prestamos == null || Prestamos.Count == 0) { MessageBox.Show("No tiene prestamos asociados a esta cuenta"); return; } this.buscarPrestamo(Prestamos); } else { if (gCuenta.Estado == true) { this.clearForm(); this.cuenta2gui(this.gCuenta); } else { MessageBox.Show("No puede usar una cuenta inactiva para esta transacción"); } } } } } } }
/// <summary> /// Saves a record to the cuenta table. /// returns True if value saved successfully else false /// Throw exception with message value EXISTS if the data is duplicate /// </summary> public bool Insert(CuentasModel acuenta) { try { using (var connection = Util.ConnectionFactory.conexion()) { connection.Open(); SqlTransaction sqlTran = connection.BeginTransaction(); SqlCommand command = connection.CreateCommand(); command.Transaction = sqlTran; command.Parameters.AddWithValue("@NroCuenta", CrearCuenta(acuenta.Tipocuenta, acuenta.Tipomoneda));//acuenta.Nrocuenta); command.Parameters.AddWithValue("@Estado", acuenta.Estado); command.Parameters.AddWithValue("@SaldoContable", acuenta.Saldocontable); command.Parameters.AddWithValue("@SaldoDisponible", acuenta.Saldodisponible); command.Parameters.AddWithValue("@SobreGiro", acuenta.Sobregiro == null ? (object)DBNull.Value : acuenta.Sobregiro); command.Parameters.AddWithValue("@TipoCuenta", acuenta.Tipocuenta); command.Parameters.AddWithValue("@TipoMoneda", acuenta.Tipomoneda); command.Parameters.AddWithValue("@Id_Tarjeta", acuenta.Id_tarjeta == null ? (object)DBNull.Value : acuenta.Id_tarjeta); command.Parameters.AddWithValue("@ContChequeRebote1", acuenta.Contchequerebote1 == null ? (object)DBNull.Value : acuenta.Contchequerebote1); command.Parameters.AddWithValue("@ContChequeRebote2", acuenta.Contchequerebote2 == null ? (object)DBNull.Value : acuenta.Contchequerebote2); command.Parameters.AddWithValue("@USUARIO_CREADOR", acuenta.Usuario_creador); command.Parameters.AddWithValue("@Cliente", acuenta.Cliente); command.Parameters.AddWithValue("@FECHA_CREACION", acuenta.Fecha_creacion); command.Parameters.AddWithValue("@FECHA_MODIFICACION", acuenta.Fecha_modificacion == null ? (object)DBNull.Value : acuenta.Fecha_modificacion); command.Parameters.AddWithValue("@USUARIO_MODIFICADOR", acuenta.Usuario_modificador == null ? (object)DBNull.Value : acuenta.Usuario_modificador); command.CommandType = CommandType.StoredProcedure; command.CommandText = "CuentasInsert"; int afectados = command.ExecuteNonQuery(); // Commit the transaction. sqlTran.Commit(); connection.Close(); connection.Dispose(); if (afectados == -1) { return(true); } else { return(false); } } } catch (Exception) { //throw; return(false); } }
/// <summary> /// Updates a record to the CuentasModel table. /// returns True if value saved successfully else false /// Throw exception with message value EXISTS if the data is duplicate /// </summary> public bool Update(CuentasModel aCuentasModel) { try { using (var connection = Util.ConnectionFactory.conexion()) { connection.Open(); SqlTransaction sqlTran = connection.BeginTransaction(); SqlCommand command = connection.CreateCommand(); command.Transaction = sqlTran; //command.Parameters.AddWithValue("@NroCuentasModel", aCuentasModel.NroCuentasModel); command.Parameters.AddWithValue("@Estado", aCuentasModel.Estado); command.Parameters.AddWithValue("@SaldoContable", aCuentasModel.Saldocontable); command.Parameters.AddWithValue("@SaldoDisponible", aCuentasModel.Saldodisponible); command.Parameters.AddWithValue("@SobreGiro", aCuentasModel.Sobregiro); //command.Parameters.AddWithValue("@TipoCuentasModel", aCuentasModel.TipoCuentasModel); command.Parameters.AddWithValue("@TipoMoneda", aCuentasModel.Tipomoneda); command.Parameters.AddWithValue("@Id_Tarjeta", aCuentasModel.Id_tarjeta == null ? (object)DBNull.Value : aCuentasModel.Id_tarjeta); command.Parameters.AddWithValue("@USUARIO_CREADOR", aCuentasModel.Usuario_creador); command.Parameters.AddWithValue("@Cliente", aCuentasModel.Cliente); command.Parameters.AddWithValue("@FECHA_CREACION", aCuentasModel.Fecha_creacion); command.Parameters.AddWithValue("@FECHA_MODIFICACION", aCuentasModel.Fecha_modificacion == null ? (object)DBNull.Value : aCuentasModel.Fecha_modificacion); command.Parameters.AddWithValue("@USUARIO_MODIFICADOR", aCuentasModel.Usuario_modificador == null ? (object)DBNull.Value : aCuentasModel.Usuario_modificador); command.CommandType = CommandType.StoredProcedure; command.CommandText = "CuentasModelUpdate"; int afectados = command.ExecuteNonQuery(); // Commit the transaction. sqlTran.Commit(); connection.Close(); connection.Dispose(); if (afectados > 0) { return(true); } else { return(false); } } } catch (Exception) { return(false); } }
public void AltaDoble(string id, string razonsocial, string dni, string fkpais, int cuentastotales, string id2, string razonsocial2, string dni2, string fkpais2, bool result) { using (var db = MarfilEntities.ConnectToSqlServer(_fixture.DbName)) { using (var service = FService.Instance.GetService(typeof(CuentasModel), _fixture.Context, db)) { try { var model = new CuentasModel() { Empresa = _fixture.Empresa, Id = id, Descripcion = razonsocial, Nif = new NifCifModel() { Nif = dni, TipoNif = "1" }, FkPais = fkpais, UsuarioId = Guid.Empty.ToString() }; var model2 = new CuentasModel() { Empresa = _fixture.Empresa, Id = id2, Descripcion = razonsocial2, Nif = new NifCifModel() { Nif = dni2, TipoNif = "1" }, FkPais = fkpais2, UsuarioId = Guid.Empty.ToString() }; service.create(model); service.create(model2); } catch (Exception ex) { Assert.False(result); } } } using (var db = MarfilEntities.ConnectToSqlServer(_fixture.DbName)) using (var service = FService.Instance.GetService(typeof(CuentasModel), _fixture.Context, db)) { try { Assert.True(service.getAll().OfType <CuentasModel>().Count(f => f.Id.StartsWith(id.ToCharArray()[0].ToString()) || f.Id.StartsWith(id2.ToCharArray()[0].ToString())) == cuentastotales); } catch (Exception ex) { Assert.False(result); } } }
private void tarjeta2gui(TarjetaModel atarjeta) { this.gcuenta = this.BLCuenta.Getcuenta(atarjeta.Id_cuenta); this.txtCodigo.Text = atarjeta.Numero.ToString(); this.txtCodigoControl.Text = atarjeta.Codcontrol.ToString(); this.txtPassword.Text = atarjeta.Password.ToString(); this.dtpFechaVencimiento.Value = (DateTime)atarjeta.Fechavencimiento; this.chkEstado.Checked = atarjeta.Estado; this.txtCuenta.Text = this.gcuenta.Nrocuenta; this.SlblUsuario_creador.Text = atarjeta.Usuario_creador; this.SlblFecha_creacion.Text = atarjeta.Fecha_creacion.ToLongDateString(); this.SlblUsuario_modificador.Text = atarjeta.Usuario_modificador; this.SlblFecha_modificacion.Text = atarjeta.Fecha_modificacion.ToString(); }
private void clearForm() { this.gcuenta = null; this.txtCodigo.Text = default(string); this.txtCuenta.Text = default(string); this.txtCodigoControl.Text = default(string); this.txtPassword.Text = default(string); this.dtpFechaVencimiento.Value = DateTime.Now; this.chkEstado.Checked = false; this.SlblUsuario_creador.Text = "*"; this.SlblFecha_creacion.Text = "*"; this.SlblUsuario_modificador.Text = "*"; this.SlblFecha_modificacion.Text = "*"; }
public bool DepositarPrestamo(CuentasModel acuenta) { try { using (var connection = Util.ConnectionFactory.conexion()) { connection.Open(); SqlTransaction sqlTran = connection.BeginTransaction(); SqlCommand command = connection.CreateCommand(); command.Transaction = sqlTran; command.Parameters.AddWithValue("@NroCuenta", acuenta.Nrocuenta); command.Parameters.AddWithValue("@SaldoContable", acuenta.Saldocontable); command.Parameters.AddWithValue("@FECHA_MODIFICACION", acuenta.Fecha_modificacion == null ? (object)DBNull.Value : acuenta.Fecha_modificacion); command.Parameters.AddWithValue("@USUARIO_MODIFICADOR", acuenta.Usuario_modificador == null ? (object)DBNull.Value : acuenta.Usuario_modificador); command.CommandType = CommandType.StoredProcedure; command.CommandText = "CuentasDepositoCredito"; int afectados = command.ExecuteNonQuery(); // Commit the transaction. sqlTran.Commit(); connection.Close(); connection.Dispose(); if (afectados > 0) { return(true); } else { return(false); } } } catch (Exception) { return(false); } }
public void Eliminar(string id, string razonsocial, string dni, string fkpais, string id2, bool result) { using (var db = MarfilEntities.ConnectToSqlServer(_fixture.DbName)) { using (var service = FService.Instance.GetService(typeof(CuentasModel), _fixture.Context, db)) { try { var model = new CuentasModel() { Empresa = _fixture.Empresa, Id = id, Descripcion = razonsocial, Nif = new NifCifModel() { Nif = dni, TipoNif = "1" }, FkPais = fkpais, UsuarioId = Guid.Empty.ToString() }; service.create(model); } catch (Exception ex) { Assert.False(result); } } } using (var db = MarfilEntities.ConnectToSqlServer(_fixture.DbName)) using (var service = FService.Instance.GetService(typeof(CuentasModel), _fixture.Context, db)) { try { var cuenta = service.get(id2) as CuentasModel; service.delete(cuenta); Assert.True(!db.Cuentas.Any(f => f.id == id && f.empresa == _fixture.Context.Empresa) && result); } catch (Exception ex) { Assert.False(result); } } }
private void CrearModel(string linea) { var vector = linea.Split(';'); var model = new CuentasModel() { Empresa = _empresa, Id = vector[0], Descripcion2 = vector[1], Descripcion = vector[2], Nivel = int.Parse(vector[3]), FkPais = _pais, UsuarioId = Guid.Empty.ToString(), Nif = new NifCifModel(), Fechaalta = DateTime.Now, FechaModificacion = DateTime.Now }; _cuentasServices.create(model); }
private void chequera2gui(ChequerasModel achequera) { this.gCuenta = this.BLCuenta.Getcuenta(achequera.Id_cuenta); if (gCuenta == null) { return; } this.txtCodigo.Text = achequera.Numero.ToString(); this.txtCuenta.Text = this.gCuenta.Nrocuenta.ToString(); this.dtpFechaRegistro.Value = (DateTime)achequera.Fecharegistro; this.cboCantidadCheques.SelectedValue = achequera.Cantidad_cheques; this.nudChequeInicial.Value = achequera.Inicio; this.cboEstado.SelectedValue = achequera.Estado; this.SlblUsuario_creador.Text = achequera.Usuario_creador; this.SlblFecha_creacion.Text = achequera.Fecha_creacion.ToLongDateString(); this.SlblUsuario_modificador.Text = achequera.Usuario_modificador; this.SlblFecha_modificacion.Text = achequera.Fecha_modificacion.ToString(); }
private void btnCuenta_Click(object sender, EventArgs e) { CuentasModel cuenta = new CuentasModel(); cuentas = new CuentasMethods(); List <CuentasPersona> cuentasUsuario = cuentas.ListaCuentas(txtDNI.Text).Where(x => x.TipoCuenta == "CORRIENTE").ToList(); if (cuentasUsuario == null && cuentasUsuario.Count <= 0) { return; } frmLista = new FrmListaDatos(); frmLista.CrearLista <CuentasPersona>(cuentasUsuario); if (frmLista.ShowDialog() == DialogResult.OK) { string numeroCuenta = frmLista.val1; this.clearForm(); txtCuenta.Text = numeroCuenta; gCuenta = BLCuenta.cuentaSelectbyNroCuenta(numeroCuenta)[0]; this.cuenta2gui(gCuenta); } ; }
/// <summary> /// Selects the Single object of cuenta table. /// </summary> public CuentasModel Getcuenta(string aNroCuenta) { CuentasModel cuenta = null; try { using (var connection = Util.ConnectionFactory.conexion()) { connection.Open(); SqlCommand command = connection.CreateCommand(); command.Parameters.AddWithValue("@NroCuenta", aNroCuenta); command.CommandType = CommandType.StoredProcedure; command.CommandText = "CuentasSelect"; SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { string NroCuenta = (string)(reader["NroCuenta"]); bool Estado = (bool)(reader["Estado"]); decimal SaldoContable = (decimal)(reader["SaldoContable"]); decimal SaldoDisponible = (decimal)(reader["SaldoDisponible"]); decimal? SobreGiro = reader["SobreGiro"] as decimal?; string TipoCuenta = (string)(reader["TipoCuenta"]); int TipoMoneda = (int)(reader["TipoMoneda"]); int? Id_Tarjeta = String.IsNullOrEmpty(reader["Id_Tarjeta"].ToString()) ? 0 : reader["Id_Tarjeta"] as int?; byte? ContChequeRebote1 = reader["ContChequeRebote1"] as byte?; byte? ContChequeRebote2 = reader["ContChequeRebote2"] as byte?; string USUARIO_CREADOR = (string)(reader["USUARIO_CREADOR"]); int Cliente = (int)(reader["Cliente"]); DateTime FECHA_CREACION = (DateTime)(reader["FECHA_CREACION"]); DateTime?FECHA_MODIFICACION = reader["FECHA_MODIFICACION"] as DateTime?; string USUARIO_MODIFICADOR = reader["USUARIO_MODIFICADOR"] as string; cuenta = new CuentasModel { Nrocuenta = NroCuenta, Estado = Estado, Saldocontable = SaldoContable, Saldodisponible = SaldoDisponible, Sobregiro = SobreGiro, Tipocuenta = TipoCuenta, Tipomoneda = TipoMoneda, Id_tarjeta = Id_Tarjeta, Contchequerebote1 = ContChequeRebote1, Contchequerebote2 = ContChequeRebote2, Usuario_creador = USUARIO_CREADOR, Cliente = Cliente, Fecha_creacion = FECHA_CREACION, Fecha_modificacion = FECHA_MODIFICACION, Usuario_modificador = USUARIO_MODIFICADOR, }; } } } return(cuenta); } catch (Exception) { return(null); } }
private void cuenta2gui(CuentasModel acuenta) { this.txtCuenta.Text = acuenta.Nrocuenta.ToUpper(); }
public void GenerarMovimiento(MovsModel model, TipoOperacionMaes tipo)// short multiplo) // multiplo 1 para alta -1 para baja { // nivel 0 foreach (var item in model.Lineas.GroupBy(l => l.Fkcuentas)) { string fkcuentas = item.Key; //Creamos la cuenta en caso de que no exista en el proceso de asignar a cartera if(!_db.Cuentas.Any(f => f.empresa == model.Empresa && f.id == fkcuentas) && model.Generar == GenerarMovimientoAPartirDe.AsignarCartera) { var nuevacuenta = new CuentasModel(_context); nuevacuenta.Empresa = model.Empresa; nuevacuenta.Id = fkcuentas; nuevacuenta.Descripcion = "**ALTA CUENTA AUTOMÁTICA**"; nuevacuenta.Descripcion2 = "**ALTA CUENTA AUTOMÁTICA**"; nuevacuenta.UsuarioId = _db.Usuarios.Where(f => f.usuario == _context.Usuario).Select(f => f.id.ToString()).SingleOrDefault() ?? ""; nuevacuenta.Nivel = 0; var id = model.Lineas[1].Fkcuentas.ToString(); var newNif = new NifCifModel { Nif = _db.Cuentas.Where(f => f.empresa == Empresa && f.id == id).Select(f => f.nif).SingleOrDefault() ?? "" }; nuevacuenta.Nif = newNif; nuevacuenta.FkPais = _db.Cuentas.Where(f => f.empresa == Empresa && f.id == id).Select(f => f.fkPais).SingleOrDefault() ?? ""; nuevacuenta.Fechaalta = DateTime.Now; var cuentaService = new CuentasService(_context); cuentaService.create(nuevacuenta); } var itemmaes = _db.Maes.SingleOrDefault(f => f.empresa == model.Empresa && f.fkcuentas == fkcuentas && f.fkejercicio == model.Fkejercicio) ?? _db.Maes.Create(); if (string.IsNullOrWhiteSpace(itemmaes.empresa)) { itemmaes.empresa = model.Empresa; itemmaes.fkcuentas = fkcuentas; itemmaes.fkejercicio = model.Fkejercicio; } int multiplo = (tipo == TipoOperacionMaes.Alta ? 1 : -1); itemmaes.debe = (itemmaes.debe ?? 0) + (item.Where(l=>l.Esdebe == 1).Sum(l=> l.Importe) * (multiplo)); itemmaes.haber = (itemmaes.haber ?? 0) + (item.Where(l => l.Esdebe == -1).Sum(l => l.Importe) * (multiplo)); itemmaes.saldo = (itemmaes.debe ?? 0) - (itemmaes.haber ?? 0); _db.Maes.AddOrUpdate(itemmaes); } // nivel 0 - 4 for (int nivel = 4; nivel > 0; nivel--) { foreach (var item in model.Lineas.GroupBy(l=> l.Fkcuentas.Substring(0, nivel))) { string fkcuentas = item.Key;//.Substring(0, nivel); var itemmaes = _db.Maes.SingleOrDefault(f => f.empresa == model.Empresa && f.fkcuentas == fkcuentas && f.fkejercicio == model.Fkejercicio) ?? _db.Maes.Create(); if(string.IsNullOrWhiteSpace(itemmaes.empresa)) { itemmaes.empresa = model.Empresa; itemmaes.fkcuentas = fkcuentas; itemmaes.fkejercicio = model.Fkejercicio; } int multiplo = (tipo == TipoOperacionMaes.Alta ? 1 : -1); itemmaes.debe = (itemmaes.debe ?? 0) + (item.Where(l => l.Esdebe == 1).Sum(l => l.Importe) * (multiplo)); itemmaes.haber = (itemmaes.haber ?? 0) + (item.Where(l => l.Esdebe == -1).Sum(l => l.Importe) * (multiplo)); itemmaes.saldo = (itemmaes.debe ?? 0) - (itemmaes.haber ?? 0); _db.Maes.AddOrUpdate(itemmaes); } } }
public bool Cuenta_Crear(CuentasModel aCuenta) { return(BLCuenta.Insert(aCuenta)); }
public bool Cuenta_Editar(CuentasModel aCuenta) { return(BLCuenta.Update(aCuenta)); }
private void BTProceder_Click(object sender, EventArgs e) { //Evento Click del boton proceder //Comprobaciones if (Session == null) { MessageBox.Show("La sesión ha expirado"); this.Dispose(); } cliente = datosPersona1.ObtenerPersona(); moneda = tipoCuenta1.ObtenerMoneda(); tipoCuenta = tipoCuenta1.ObtenerTipoCuenta(); int t_cuenta = 0; switch (tipoCuenta) { case ("AHORROS"): t_cuenta = 1; break; case ("CORRIENTE"): t_cuenta = 2; break; case ("CREDITO"): t_cuenta = 3; break; } if (cliente == null) { MessageBox.Show("Selecciona un cliente"); return; } if (moneda == null) { MessageBox.Show("Selecciona una moneda"); return; } if (string.IsNullOrEmpty(tipoCuenta)) { MessageBox.Show("Selecciona un tipo de cuenta"); return; } Random rd = new Random(); string NumeroCuenta = string.Concat("00451", Session.SucursalCodigo, rd.Next(100000, 999999), moneda.Id, t_cuenta); CuentasModel cuenta_nueva = new CuentasModel() { Cliente = cliente.Id, Estado = true, Nrocuenta = NumeroCuenta, Tipocuenta = tipoCuenta, Saldocontable = 0, Saldodisponible = 0, Sobregiro = 0, Tipomoneda = moneda.Id, Usuario_creador = Session.UserCodigo }; using (WsSistemaBancario.CuentaServiceClient _Cuenta = new WsSistemaBancario.CuentaServiceClient()) { bool result = _Cuenta.Cuenta_Crear(cuenta_nueva); if (result) { MessageBox.Show("Cuenta Creada Correctamente"); } else { MessageBox.Show("Error"); } } }
/// <summary> /// Saves a record to the cuenta table. /// returns True if value saved successfully else false /// Throw exception with message value EXISTS if the data is duplicate /// </summary> public bool Insert(CuentasModel acuenta) { return(this.managerCuenta.Insert(acuenta)); }
/// <summary> /// Updates a record to the cuenta table. /// returns True if value saved successfully else false /// Throw exception with message value EXISTS if the data is duplicate /// </summary> public bool UpdateCuenta(CuentasModel acuenta) { return(this.managerCuenta.UpdateCuenta(acuenta)); }
private void cuenta2gui(CuentasModel acuenta) { this.txtCuenta.Text = acuenta.Nrocuenta.ToUpper(); this.cboMoneda.SelectedIndex = acuenta.Tipomoneda; this.cboMoneda.Enabled = false; }
/// <summary> /// Selects the Single object of CuentasModel table. /// </summary> public CuentasModel GetCuentasModel(string aNroCuentasModel) { CuentasModel CuentasModel = null; try { using (var connection = Util.ConnectionFactory.conexion()) { connection.Open(); SqlCommand command = connection.CreateCommand(); command.Parameters.AddWithValue("@NroCuentasModel", aNroCuentasModel); command.CommandType = CommandType.StoredProcedure; command.CommandText = "CuentasModelSelect"; SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { string NroCuentasModel = (string)(reader["NroCuentasModel"]); bool Estado = (bool)(reader["Estado"]); decimal SaldoContable = (decimal)(reader["SaldoContable"]); decimal SaldoDisponible = (decimal)(reader["SaldoDisponible"]); decimal SobreGiro = (decimal)(reader["SobreGiro"]); string TipoCuentasModel = (string)(reader["TipoCuentasModel"]); short TipoMoneda = (short)(reader["TipoMoneda"]); int? Id_Tarjeta = reader["Id_Tarjeta"] as int?; string USUARIO_CREADOR = (string)(reader["USUARIO_CREADOR"]); int Cliente = (int)(reader["Cliente"]); DateTime FECHA_CREACION = (DateTime)(reader["FECHA_CREACION"]); DateTime?FECHA_MODIFICACION = reader["FECHA_MODIFICACION"] as DateTime?; string USUARIO_MODIFICADOR = (string)(reader["USUARIO_MODIFICADOR"]); CuentasModel = new CuentasModel { // NroCuentasModel = NroCuentasModel, Estado = Estado, Saldocontable = SaldoContable, Saldodisponible = SaldoDisponible, Sobregiro = SobreGiro, //TipoCuentasModel = TipoCuentasModel, Tipomoneda = TipoMoneda, Id_tarjeta = Id_Tarjeta, Usuario_creador = USUARIO_CREADOR, Cliente = Cliente, Fecha_creacion = FECHA_CREACION, Fecha_modificacion = FECHA_MODIFICACION, Usuario_modificador = USUARIO_MODIFICADOR, }; } } } return(CuentasModel); } catch (Exception) { return(null); } }