Exemple #1
0
        public int insertarcuentas(cuentas cue)
        {
            try
            {
                SqlConnection cnx = cn.conectar();

                cm = new SqlCommand("cuentas", cnx);
                cm.Parameters.AddWithValue("@b", 1);
                cm.Parameters.AddWithValue("@idcuenta", "");
                cm.Parameters.AddWithValue("@nombres", cue.nombreuser);
                cm.Parameters.AddWithValue("@clave", cue.clave);
                cm.Parameters.AddWithValue("@rol", cue.rol);
                cm.Parameters.AddWithValue("@idusuario", cue.idusuario);

                cm.CommandType = CommandType.StoredProcedure;
                cnx.Open();
                cm.ExecuteNonQuery();
                indicador = 1;
            }
            catch (Exception e)
            {
                e.Message.ToString();
                indicador = 0;
            }
            finally
            {
                cm.Connection.Close();
            }
            return(indicador);
        }
Exemple #2
0
        //capa de negocios
        public void Modificar(cuentas CuentaModificar)
        {
            //llamando a la capa de datos
            CapaDatos ModificaDato = new CapaDatos();

            ModificaDato.Modificar(CuentaModificar.usuario, CuentaModificar.Acontrasenia, CuentaModificar.Ncontrasenia, CuentaModificar.RNcontrasenia);
        }
    public bool Retirar(string numero_cuenta, decimal monto)
    {
        cuentas cuenta = banco.cuentas.Find(numero_cuenta);

        if (cuenta == null || monto <= 0 || monto > cuenta.saldo)
        {
            return(false);
        }

        cuenta.saldo -= monto;

        try
        {
            banco.SaveChanges();
            return(true);
        }
        catch (Exception) { return(false); }
    }
Exemple #4
0
        public List <cuentas> Listarcuentas()
        {
            try
            {
                cm = new SqlCommand("cuentas", cnx);
                cm.Parameters.AddWithValue("@b", 1);
                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"].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);
        }
    public bool Registrar(string numero_cuenta, string propietario, string pin, decimal saldo)
    {
        if (saldo < 100)
        {
            return(false);
        }

        cuentas cuenta = new cuentas();

        cuenta.numero_cuenta      = numero_cuenta;
        cuenta.nombre_propietario = propietario;
        cuenta.pin   = pin;
        cuenta.saldo = saldo;

        try
        {
            banco.cuentas.Add(cuenta);
            banco.SaveChanges();
            return(true);
        }
        catch (Exception) { return(false); }
    }
Exemple #6
0
        public void Crear(string tipo, string nombreProveedor, string responsableLogin,
                          string reponsableNombre, string reponsableApellido, string responsableCargo,
                          string responsableEmail, string responableTelefono, string responsablePassword,
                          bool esEspecial)
        {
            ValidarTipo(tipo);

            nombreProveedor = nombreProveedor.Trim();

            var cuenta = FindByNombre(nombreProveedor);

            // Valida si existe una cuenta con el mismo nombre
            if (cuenta != null)
            {
                throw new BusinessException(CommonMensajesResource.ERROR_Cuenta_NombreProveedorDuplicado);
            }

            var usuarioManager = new UsuarioManager();

            if (usuarioManager.FindByUsername(responsableLogin) != null)
            {
                throw new BusinessException(MensajesResource.ERROR_CuentaManager_Crear_LoginExistente);
            }

            cuenta = new cuentas
            {
                CodigoProveedor = Guid.NewGuid().ToString("D"),
                NombreCuenta    = nombreProveedor,
                Activo          = true,
                Tipo            = tipo,
                EsEspecial      = esEspecial
            };

            _db.cuentas.Add(cuenta);
            _db.SaveChanges();
            try
            {
                var usuarioMaestro = usuarioManager.CrearMaestroProveedor(
                    responsableLogin,
                    reponsableNombre,
                    reponsableApellido,
                    responsableEmail,
                    responableTelefono,
                    responsableCargo,
                    true,
                    responsablePassword,
                    cuenta.Id
                    );

                AsociarUsuarioEnCuenta(usuarioMaestro.Id, cuenta.Id);
            }
            catch (Exception)
            {
                // TODO SIMULAR
                Eliminar(cuenta.Id);

                var usuario = usuarioManager.FindByUsername(responsableLogin);
                if (usuario != null)
                {
                    usuarioManager.Eliminar(usuario.Id);
                }

                throw;
            }
        }
 public int editarcuenta(cuentas cue)
 {
     return(cu.editarcuenta(cue));
 }
 public int insertarcuentas(cuentas cue)
 {
     return(cu.insertarcuentas(cue));
 }
Exemple #9
0
        public void rellenarConsulta(Dictionary <string, object> datos)
        {
            Cursor = Cursors.WaitCursor;
            dtggrid.Rows.Clear();

            dbaseORM orm = new dbaseORM();

            string  query  = $"select * from catalogos.cuentas where proy = '{datos["secretaria"]}'";
            cuentas cuenta = orm.queryForMap <cuentas>(query);

            string descripcion = cuenta.descripcion;

            if (string.IsNullOrWhiteSpace(descripcion))
            {
                query       = $"select * from catalogos.cuentas where cuenta = '{datos["secretaria"]}'";
                cuenta      = orm.queryForMap <cuentas>(query);
                descripcion = cuenta.descripcion;
            }

            p_edocta estadoCuenta = orm.getObject <p_edocta>(datos);

            this.txtrfc.Text            = estadoCuenta.rfc;
            this.txtnombre.Text         = estadoCuenta.nombre_em;
            this.txtproyecto.Text       = estadoCuenta.proyecto;
            this.txtfolio.Text          = Convert.ToString(estadoCuenta.folio);
            this.txtdirec.Text          = estadoCuenta.direccion;
            this.txtcheque.Text         = globales.parseDateTime(estadoCuenta.f_emischeq);
            this.txtpago.Text           = estadoCuenta.tipo_pago;
            this.txtimporte.Text        = string.Format("{0:C}", estadoCuenta.imp_unit);
            this.txtubicacion.Text      = estadoCuenta.ubic_pagare;
            this.txttotal.Text          = string.Format("{0:C}", estadoCuenta.importe);
            this.txtsecretaria.Text     = estadoCuenta.secretaria + "        " + descripcion;
            this.txtpagocuenta.Text     = globales.parseDateTime(estadoCuenta.f_primdesc);
            this.txtfechasolicitud.Text = globales.parseDateTime(estadoCuenta.f_solicitud);
            this.txtplazo.Text          = Convert.ToString(estadoCuenta.plazo);
            string fecha = Convert.ToString(estadoCuenta.fallecio);

            if (!string.IsNullOrWhiteSpace(fecha))
            {
                checFallecio.Checked = true;
                checFallecio.Visible = true;
                fec_falle.Visible    = true;
                fec_falle.Text       = fecha;
            }
            else
            {
                checFallecio.Checked = false;
                fec_falle.Visible    = false;
            }
            secretaria = estadoCuenta.secretaria;

            //el código para llenar el dagrid...
            string aux = Convert.ToString(datos["folio"]);

            query = string.Format("select hum,f_descuento,numdesc,totdesc,importe,rfc,cuenta,proyecto,tipo_rel,id from datos.descuentos where  folio = {0} AND t_prestamo='Q'  order by f_descuento asc, numdesc asc", aux);
            List <descuentos> descuentos = orm.queryForList <descuentos>(query);

            descuentos.ForEach(o => {
                dtggrid.Rows.Add(globales.parseDateTime(o.f_descuento), o.numdesc, o.totdesc, string.Format("{0:C}", o.importe).Replace("$", ""), o.rfc, o.cuenta, o.proyecto, o.tipo_rel, o.id, o.fum);
            });


            string nombreAux = txtnombre.Text;

            nombreAux = (nombreAux.Contains("(")) ? nombreAux.Substring(0, nombreAux.IndexOf("(")) : nombreAux;

            this.parecidos      = orm.query($"select * from datos.p_edocta where nombre_em like '{nombreAux}%' and historial_pagado is null");
            this.contadorGlobal = 0;
            foreach (Dictionary <string, object> item in this.parecidos)
            {
                if (Convert.ToString(item["folio"]) == txtfolio.Text)
                {
                    break;
                }
                contadorGlobal++;
            }

            checarbotones();


            if (!globales.boolConsulta)
            {
                txtimporte.Cursor      = Cursors.IBeam;
                txtimporte.ReadOnly    = false;
                txtubicacion.Cursor    = Cursors.IBeam;
                txtubicacion.ReadOnly  = false;
                txtplazo.Cursor        = Cursors.IBeam;
                txtplazo.ReadOnly      = false;
                txtcheque.Cursor       = Cursors.IBeam;
                txtcheque.ReadOnly     = false;
                txttotal.Cursor        = Cursors.IBeam;
                txttotal.ReadOnly      = false;
                txtpagocuenta.Cursor   = Cursors.IBeam;
                txtpagocuenta.ReadOnly = false;
                txtnombre.Cursor       = Cursors.IBeam;
                txtnombre.ReadOnly     = false;
                checFallecio.Visible   = true;
                // fec_falle.Visible = true;
            }

            foreach (DataGridViewRow item in dtggrid.Rows)
            {
                double importe = string.IsNullOrWhiteSpace(Convert.ToString(item.Cells[3].Value)) ? 0 : Convert.ToDouble(item.Cells[3].Value);
                if (importe < 0)
                {
                    item.Cells[3].Style.BackColor = Color.FromArgb(180, 0, 0);
                    item.Cells[3].Style.ForeColor = Color.White;
                }
            }
            Cursor = Cursors.Default;
        }