//DatosCuentas public ActionResult DatosCuentas() { BancoHabana.Models.Procesos p = new BancoHabana.Models.Procesos(); List <BancoHabana.Models.Cuentas> cuen = new List <BancoHabana.Models.Cuentas>(); string cuenta = Request.Form["opcionesCuenta"].ToString(); Session["cuentap"] = cuenta; Cuentas pr = new Cuentas(); pr = p.getDatosCuentas(cuenta); Session["cuentasdatos"] = pr; return(View()); }
protected void EliminarLinkButton_Click(object sender, EventArgs e) { RepositorioCuenta rep = new RepositorioCuenta(); Cuentas c = rep.Buscar(ToInt(IdTextBox.Text)); if (c != null) { if (rep.Eliminar(ToInt(IdTextBox.Text))) { CallModal("Se elimino la cuenta"); Limpiar(); } else { CallModal("No se elimino la cuenta"); } } }
public bool devolvertipo_cuenta(string alias) { DaoCuenta dao = new DaoCuenta(); Cuentas Cue = new Cuentas(); Cue.set_Alias(alias); if (dao.Devolver_Tipo_Cuenta(Cue) == "1") { return(true); } else { return(false); } }
public void Actualizar(Cuentas cuenta) { string consulta = "update Cuentas set FechaApertura=@FechaApertura,Numero=@Numero,Banco=@Banco,Tipo=@Tipo,MontoInicial=@MontoInicial,MontoDisponible=@MontoDisponible where IdCuenta=@Id"; DynamicParameters parametros = new DynamicParameters(); parametros.Add("@Id", cuenta.IdCuenta, DbType.Int32); parametros.Add("@FechaApertura", cuenta.FechaApertura, DbType.Date); parametros.Add("@Numero", cuenta.Numero, DbType.String); parametros.Add("@Banco", cuenta.Banco, DbType.String); parametros.Add("@Tipo", cuenta.Tipo, DbType.Int32); parametros.Add("@MontoInicial", cuenta.MontoInicial, DbType.Decimal); parametros.Add("@MontoDisponible", cuenta.MontoDisponible, DbType.Decimal); cn.Open(); cn.Execute(consulta, parametros, commandType: CommandType.Text); cn.Close(); }
protected void BuscarButton_Click(object sender, EventArgs e) { Cuentas Cuenta = new Cuentas(); DataTable dt = new DataTable(); string filtro = "1=1"; if (FiltroDropDown.SelectedIndex == 0) //CuentaId { if (FiltroTextBox.Text.Trim().Length == 0) { filtro = "1=1"; } else { filtro = "CuentaId = " + FiltroTextBox.Text; } } else if (FiltroDropDown.SelectedIndex == 1) //Descripcion { if (FiltroTextBox.Text.Trim().Length == 0) { filtro = "1=1"; } else { filtro = "Descripcion like '%" + FiltroTextBox.Text + "%'"; } } else if (FiltroDropDown.SelectedIndex == 2) //Balance { if (FiltroTextBox.Text.Trim().Length == 0) { filtro = "1=1"; } else { filtro = "Balance = " + FiltroTextBox.Text; } } dt = Cuenta.Listar("CuentaId, Descripcion, Balance", filtro); BuscarGridView.DataSource = dt; BuscarGridView.DataBind(); }
protected void GuardarButton_Click(object sender, EventArgs e) { RepositorioBase <Cuentas> repositorio = new RepositorioBase <Cuentas>(); Cuentas cuenta = LlenaClase(); bool paso = false; if (Page.IsValid) { if (cuenta.CuentaID == 0) { paso = repositorio.Guardar(cuenta); } else { var verificar = repositorio.Buscar(Utilities.Utils.ToInt(CuentaIDTextbox.Text)); if (verificar != null) { paso = repositorio.Modificar(cuenta); } else { Utilities.Utils.ShowToastr(this, "Cuenta No Existe", "Fallido", "error"); return; } } if (paso) { Utilities.Utils.ShowToastr(this, "Cuenta Registrada", "Exito", "Exito"); } else { Utilities.Utils.ShowToastr(this, "No pudo Guardarse la cuenta", "ERROR", "error"); } Limpiar(); return; } }
protected void BuscarButton_Click(object sender, EventArgs e) { if (TbCuentaId.Text == "") { Utilitarios.ShowToastr(this.Page, "El ID no puede estar en Blanco.", "Advertencia", "Warning"); return; } Cuentas cuenta = new Cuentas(); if (!(cuenta.Buscar(Convert.ToInt16(TbCuentaId.Text)))) { Utilitarios.ShowToastr(this.Page, "Registro no encontrado.", "Error", "Error"); Limpiar(); return; } LlenarCampos(cuenta); }
public IEnumerable <Cuentas> GetAllCuentas() { //Obtiene todas las Cuentas string consulta = "SELECT id, activo, cta, descripcion, id_companiaf, sub_cta, sub_sub_cta FROM cuenta "; try { List <Cuentas> lstCuentas = new List <Cuentas>(); { con.Open(); NpgsqlCommand cmd = new NpgsqlCommand(consulta, con); NpgsqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Cuentas cuentas = new Cuentas(); cuentas.id = Convert.ToInt32(rdr["id"]); cuentas.activo = Convert.ToBoolean(rdr["activo"].ToString().Trim()); cuentas.cta = rdr["cta"].ToString().Trim(); cuentas.descripcion = rdr["descripcion"].ToString().Trim(); cuentas.id_companiaf = Convert.ToInt32(rdr["id_companiaf"].ToString().Trim()); cuentas.sub_cta = rdr["sub_cta"].ToString(); cuentas.sub_sub_cta = rdr["sub_sub_cta"].ToString(); lstCuentas.Add(cuentas); } con.Close(); } return(lstCuentas); } catch (Exception ex) { con.Close(); throw; } finally { con.Close(); } }
public static Cuentas Buscar(int id) { Contexto db = new Contexto(); Cuentas cuentas = new Cuentas(); try { cuentas = db.Cuentas.Find(id); } catch (Exception) { throw; } finally { db.Dispose(); } return(cuentas); }
private void Guardarbutton_Click(object sender, EventArgs e) { if (Validar(2)) { MessageBox.Show("Llenar Campos vacios"); errorProvider.Clear(); return; } else { cuentas = LlenaClase(); if (IdnumericUpDown.Value == 0) { if (BLL.CuentasBLL.Guardar(cuentas)) { MessageBox.Show("Guardado!", "Exitoso", MessageBoxButtons.OK, MessageBoxIcon.Information); Limpiar(); } else { MessageBox.Show("No se pudo Guardar!!"); } } else { var result = MessageBox.Show("Seguro de Modificar?", "+Cuentas", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (BLL.CuentasBLL.Modificar(LlenaClase())) { MessageBox.Show("Modificado!!"); Limpiar(); } else { MessageBox.Show("No se pudo Guardar!!"); } } } } }
private Cuentas LlenaClase() { Cuentas cuentas = new Cuentas(); if (IdnumericUpDown.Value == 0) { cuentas.CuentaId = 0; } else { cuentas.CuentaId = Convert.ToInt32(IdnumericUpDown.Value); } cuentas.Monto = Convert.ToInt32(MontotextBox.Text); cuentas.TipoId = Convert.ToInt32(TipocomboBox.Text); cuentas.Descripcion = DescripciontextBox.Text; return(cuentas); }
public static bool Modificar(Cuentas cuentas) { bool paso = false; Contexto db = new Contexto(); try { db.Entry(cuentas).State = EntityState.Modified; paso = db.SaveChanges() > 0; } catch (Exception) { throw; } finally { db.Dispose(); } return(paso); }
public static bool Modificar(Cuentas cuenta) { bool paso = false; Contexto contexto = new Contexto(); try { contexto.Entry(cuenta).State = EntityState.Modified; if (contexto.SaveChanges() > 0) { paso = true; } contexto.Dispose(); } catch (Exception) { throw; } return(paso); }
public bool validarCuenta(string cuenta, string contrasenia) { DaoCuenta dao = new DaoCuenta(); Cuentas Cue = new Cuentas(); Cue.set_Alias(cuenta); Cue.set_contrasenia(contrasenia); if (dao.existeCuenta(Cue) == false) { return(false); } else if (Cue.get_contrasenia() != contrasenia) { return(false); } else { return(true); } }
private void trvCuentas_MouseDoubleClick(object sender, MouseButtonEventArgs e) { cuentaSeleccionada = (Cuentas)trvCuentas.SelectedItem; switch (TipoCuenta) { case 0: cuentaSeleccionada.Children = FuncionesGenericas <Cuentas> .Select(consSql.selectCuentasID_Balance(cuentaSeleccionada.IdCuenta, cuentaSeleccionada.NivelCuenta), funGlb.conexion()); break; case 1: cuentaSeleccionada.Children = FuncionesGenericas <Cuentas> .Select(consSql.selectCuentasID_EdoRes_Trad(cuentaSeleccionada.IdCuenta, cuentaSeleccionada.NivelCuenta), funGlb.conexion()); break; case 2: cuentaSeleccionada.Children = FuncionesGenericas <Cuentas> .Select(consSql.selectCuentasID_BO(cuentaSeleccionada.IdCuenta, cuentaSeleccionada.NivelCuenta), funGlb.conexion()); break; } //cuentaSeleccionada.Children = FuncionesGenericas<Cuentas>.Select(consSql.selectCuentasID_Balance(cuentaSeleccionada.IdCuenta, cuentaSeleccionada.NivelCuenta), funGlb.conexion()); trvCuentas.Items.Refresh(); }
private void Buscar_Click(object sender, EventArgs e) { int id; repositorio = new RepositorioBase <Cuentas>(); Cuentas cuentas = new Cuentas(); int.TryParse(IDnumericUpDown1.Text, out id); cuentas = repositorio.Buscar(id); if (cuentas != null) { MessageBox.Show("Cuenta Encotrada", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); LlenarCampo(cuentas); } else { MessageBox.Show("No encontrado"); } }
private void BuscarButton_Click(object sender, EventArgs e) { int id; repositorio = new RepositorioBase <Cuentas>(); Cuentas cuenta = new Cuentas(); int.TryParse(CuentaIDnumericUpDown.Text, out id); cuenta = repositorio.Buscar(id); if (cuenta != null) { MessageBox.Show("Cuenta Encontrada.!!", "Exito!!!", MessageBoxButtons.OK); LlenaCampo(cuenta); } else { MessageBox.Show("Cuenta no Encontrada", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static bool Guardar(Cuentas cuenta) { bool paso = false; Contexto contexto = new Contexto(); try { if (contexto.Cuentas.Add(cuenta) != null) { contexto.SaveChanges(); paso = true; } contexto.Dispose(); } catch (Exception) { throw; } return(paso); }
public List <Cuentas> listarCuentas() { try { SqlConnection cnx = cn.conectar(); cm = new SqlCommand("pro_cuentas", cnx); cm.Parameters.AddWithValue("@b", 2); cm.Parameters.AddWithValue("@idcuenta", ""); cm.Parameters.AddWithValue("@nombreuser", ""); cm.Parameters.AddWithValue("@clave", ""); cm.Parameters.AddWithValue("@rol", ""); cm.Parameters.AddWithValue("@idusuario", ""); cm.CommandType = CommandType.StoredProcedure; cnx.Open(); dr = cm.ExecuteReader(); listaCuentas = new List <Cuentas>(); while (dr.Read()) { Cuentas cue = new Cuentas(); cue.idcuenta = Convert.ToInt32(dr["idcuenta"].ToString()); cue.nombreuser = dr["nombre user"].ToString(); cue.clave = dr["clave"].ToString(); cue.rol = dr["rol"].ToString(); cue.idusuario = Convert.ToInt32(dr["idusuario"].ToString()); listaCuentas.Add(cue); } } catch (Exception e) { e.Message.ToString(); listaCuentas = null; } finally { cm.Connection.Close(); } return(listaCuentas); }
///<summary> ///permite guardar una entidad en la base de datos /// </summary> ///<para name ="cuenta"> una instancia de articulo</para> ///<returns>Retorna true si guardo o fals si no lo hizo</returns> public static bool Guardar(Cuentas Cuenta) { bool paso = false; // creamos una instancia del contexto para poder con la base de datos Contexto contexto = new Contexto(); try { if (contexto.Cuenta.Add(Cuenta) != null) { contexto.SaveChanges(); // gurdar los cambien la base de datos paso = true; } contexto.Dispose(); //// para serrar la conexion } catch (Exception) { throw; } return(paso); }
private static bool Insertar(Cuentas cuentas) { bool paso = false; Contexto db = new Contexto(); try { db.Cuentas.Add(cuentas); paso = db.SaveChanges() > 0; } catch (Exception) { throw; } finally { db.Dispose(); } return(paso); }
/* Efectúa: Se encarga de ejecutar la inserción en la tabla cuentas de la base de datos. * Requiere: Que la entidad Cuentas no esté vacía. * Modifica: La tabla Cuentas en la base de datos cuando inserta la cuenta. */ public String insertarCuenta(Cuentas cuenta) { String returnValue = ""; int r; try { adapterCuentas.Insert(cuenta.NombreUsuario, cuenta.Contrasenna, cuenta.UltimoAcceso, cuenta.CedulaUsuario); } catch (SqlException e) { r = e.Number; if (r == 2627) { returnValue = "Ya existe una cuenta con el nombre de usuario digitado"; } else { returnValue = "Se ha producido un error al insertar la cuenta"; } } return(returnValue); }
private void Buscarbutton_Click_1(object sender, EventArgs e) { int id; //= Convert.ToInt32(CuentaIdnumericUpDown.Value); repositorio = new RepositorioBase <Cuentas>(new Contexto()); Cuentas cuentas = new Cuentas(); int.TryParse(CuentaIdnumericUpDown.Text, out id); if (cuentas != null) { MessageBox.Show("Cuenta Encontrada.!!", "Exito!!!", MessageBoxButtons.OK); LlenarCampo(cuentas); // DescripciontextBox.Text = cuentas.Descripcion; //MontoNumericUpDown.Text = cuentas.Monto.ToString(); } else { MessageBox.Show("Cuenta no Encontrada", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void LlenarDropDownList() { Cuentas cuenta = new Cuentas(); TiposEgresos tipoEgreso = new TiposEgresos(); Miembros miembro = new Miembros(); CuentaIdDropDownList.DataSource = cuenta.Listado(" * ", "1=1", ""); CuentaIdDropDownList.DataTextField = "Descripcion"; CuentaIdDropDownList.DataValueField = "CuentaId"; CuentaIdDropDownList.DataBind(); TipoEgresoIdDropDownList.DataSource = tipoEgreso.Listado(" * ", "1=1", ""); TipoEgresoIdDropDownList.DataTextField = "Descripcion"; TipoEgresoIdDropDownList.DataValueField = "TipoEgresoId"; TipoEgresoIdDropDownList.DataBind(); MiembroIdDropDownList.DataSource = miembro.Listado(" * ", "1=1", ""); MiembroIdDropDownList.DataTextField = "Nombre"; MiembroIdDropDownList.DataValueField = "MiembroId"; MiembroIdDropDownList.DataBind(); }
public ActionResult Create(RegistroModel registro) { try { Cuentas cuentaDB = new Cuentas(); if (ModelState.IsValid) { db.Cuentas.Add(cuentaDB); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (RetryLimitExceededException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View()); }
protected void GuadarButton_Click(object sender, EventArgs e) { BLL.RepositorioBase <Cuentas> repositorio = new BLL.RepositorioBase <Cuentas>(); Cuentas cuentas = new Cuentas(); bool paso = false; LlenaClase(cuentas); if (IsValid) { if (cuentas.CuentaId == 0) { if (paso = repositorio.Guardar(cuentas)) { Util.ShowToastr(this, "saved successfully", "Success", "success"); } else { Util.ShowToastr(this, "Error al Guardar", "Error", "error"); } Limpiar(); } else { if (paso = repositorio.Modificar(cuentas)) { Util.ShowToastr(this, "Modificado successfully", "Success", "success"); Limpiar(); } else { Util.ShowToastr(this, "Error al Modificar", "Error", "error"); } } } }
protected void guadarButton_Click1(object sender, EventArgs e) { BLL.RepositorioBase <Cuentas> repositorio = new BLL.RepositorioBase <Cuentas>(); Cuentas cuenta = new Cuentas(); bool paso = false; cuenta = LlenaClase(); if (cuenta.CuentaId == 0) { paso = repositorio.Guardar(cuenta); Utils.ShowToastr(this, "Guardado", "Exito", "success"); Limpiar(); } else { int id = Utils.ToInt(cuentaIdTextBox.Text); BLL.RepositorioBase <Cuentas> repository = new BLL.RepositorioBase <Cuentas>(); cuenta = repository.Buscar(id); if (cuenta != null) { paso = repositorio.Modificar(LlenaClase()); Utils.ShowToastr(this, "Modificado Correctamente", "Exito", "success"); } else { Utils.ShowToastr(this, "Id no existe", "Error", "error"); } } if (paso) { Limpiar(); } else { Utils.ShowToastr(this, "No se pudo guardar", "Error", "error"); } }
/// <summary> /// Permite modificar una entidad en la base de datos /// </summary> /// <param name="cuenta"></param> /// <returns> retuna true si modifico y false si no </returns> public static bool Modificar(Cuentas cuenta) { bool paso = false; // creamos una instancia del contexto para poder con la base de datos Contexto contexto = new Contexto(); try { contexto.Entry(cuenta).State = System.Data.Entity.EntityState.Modified; if (contexto.SaveChanges() > 0) { paso = true; } contexto.Dispose();// serrar la conexion. } catch (Exception) { throw; } return(paso); }
//Obtiene las cuentas de cada compañia public List <Cuentas> GetCuentasData(string intIdCompania) { string consulta = "SELECT id, activo, cta, descripcion, id_companiaf, sub_cta, sub_sub_cta FROM cuenta WHERE id_companiaf = " + intIdCompania; try { List <Cuentas> listCuentas = new List <Cuentas>(); { con.Open(); NpgsqlCommand cmd = new NpgsqlCommand(consulta, con); NpgsqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Cuentas cuentas = new Cuentas(); cuentas.id = Convert.ToInt32(rdr["id"]); cuentas.activo = Convert.ToBoolean(rdr["activo"].ToString().Trim()); cuentas.cta = rdr["cta"].ToString().Trim(); cuentas.descripcion = rdr["descripcion"].ToString().Trim(); cuentas.id_companiaf = Convert.ToInt32(rdr["id_companiaf"].ToString().Trim()); cuentas.sub_cta = rdr["sub_cta"].ToString().Trim(); cuentas.sub_sub_cta = rdr["sub_sub_cta"].ToString().Trim(); listCuentas.Add(cuentas); } con.Close(); } return(listCuentas); } catch { con.Close(); throw; } finally { con.Close(); } }
protected void GuardarButton_Click(object sender, EventArgs e) { bool Paso = false; Cuentas cuenta = new Cuentas(); LlenarClase(cuenta); if (TbCuentaId.Text == "") { Paso = cuenta.Insertar(); } else { Paso = cuenta.Editar(); } if (Paso) { Utilitarios.ShowToastr(this.Page, "Transaccion Exitosa.", "Felicidades", "Success"); LlenarCampos(cuenta); } }
public List<Cuentas> ConsultaCuentas(string IdCoop, int Id_Tipo_Cta) { List<Cuentas> consultacuentas = new List<Cuentas>(); int idcoop = Convert.ToInt32(IdCoop); int idtipocta = Convert.ToInt32(Id_Tipo_Cta); sqlDataAdapter.SelectCommand = new SqlCommand(); sqlDataAdapter.SelectCommand.Connection = sqlConnection; sqlDataAdapter.SelectCommand.CommandText = "ConsultaCuentas"; sqlDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure; SqlParameter Param1 = new SqlParameter("@Id_Reclamo", SqlDbType.Int); Param1.Direction = ParameterDirection.Input; Param1.Value = idcoop; sqlDataAdapter.SelectCommand.Parameters.Add(Param1); SqlParameter Param2 = new SqlParameter("@Id_Tipo_Cta", SqlDbType.Int); Param2.Direction = ParameterDirection.Input; Param2.Value = idtipocta; sqlDataAdapter.SelectCommand.Parameters.Add(Param2); sqlDataAdapter.Fill(ds, "ConsultaCuentas"); foreach (DataRow dr in ds.Tables["ConsultaCuentas"].Rows) { Cuentas tmp = new Cuentas(); tmp.Cuenta = Convert.ToString(dr["Cuenta"]); tmp.IdCoop = Convert.ToString(dr["Id_Coop"]); tmp.IdCuenta = Convert.ToString(dr["Id_Cuenta"]); consultacuentas.Add(tmp); } return consultacuentas; }