示例#1
0
        public ActionResult Adms_do_sistema()
        {
            Exist_UsersDto           usuario;
            Exist_UsersDtoCollection adms = new Exist_UsersDtoCollection();
            exist_users util = new exist_users();

            adms    = util.ConsultarTodosAdms();
            usuario = getUser();
            paises();
            tratamentos();
            ViewBag.usuario = usuario;
            var SchemeList = (from scheme in adms select scheme).ToList();

            ViewBag.Adms_do_Sistema = adms;

            return(View("~/Views/Adms_do_sistema/Adms_do_Sistema.cshtml", SchemeList));
        }
示例#2
0
        public Exist_UsersDtoCollection ConsultarUsuarios()
        {
            try
            {
                string sql = "SELECT *FROM exist_users";
                Exist_UsersDtoCollection usuarios = new Exist_UsersDtoCollection();

                DataTable tabela = conexao.ExecutarConsulta(CommandType.Text, sql);

                usuarios = GetExist_UsersDtoCollection(tabela);

                return(usuarios);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#3
0
        public Exist_UsersDtoCollection Buscar(string txt)
        {
            try
            {
                string sql = "SELECT * FROM exist_users where user_name like '%" + txt + "%' ";
                Exist_UsersDtoCollection users = new Exist_UsersDtoCollection();

                conexao.LimparParametros();
                DataTable tabela = conexao.ExecutarConsulta(CommandType.Text, sql);

                users = GetExist_UsersDtoCollection(tabela);

                return(users);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#4
0
        public Exist_UsersDtoCollection PegarTodosAdms()
        {
            try
            {
                Exist_UsersDtoCollection usuarios = new Exist_UsersDtoCollection();

                string sql = "SELECT *FROM exist_users WHERE user_admin=1";

                DataTable tabela = conexao.ExecutarConsulta(CommandType.Text, sql);

                usuarios = GetExist_UsersDtoCollection(tabela);

                return(usuarios);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#5
0
        public ActionResult Atualizar_Usuarios()
        {
            Exist_UsersDto           usuario;
            Exist_UsersDtoCollection usuarios = new Exist_UsersDtoCollection();
            exist_users util = new exist_users();

            usuario = getUser();

            usuarios = util.ConsultarUsuarios();
            paises();
            tratamentos();
            ViewBag.usuario = usuario;

            var SchemeList = (from scheme in usuarios select scheme).ToList();

            ViewBag.usuarios = usuarios;

            return(View("~/Views/Atualizar_Usuarios/Atualizar_Usuarios.cshtml", SchemeList));
        }
示例#6
0
        public Exist_UsersDtoCollection ConsultarAdministradoresPorRegiao(long region_id)
        {
            try
            {
                Exist_UsersDtoCollection collection = new Exist_UsersDtoCollection();
                conexao.LimparParametros();
                string sql = "select u.* from exist_users u ";
                sql = sql + "inner join region_for_users r on u.user_id=r.user_id where r.region_id=" + region_id + "  ";

                DataTable tabela = conexao.ExecutarConsulta(CommandType.Text, sql);

                collection = GetExist_UsersDtoCollection(tabela);

                return(collection);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#7
0
        public Exist_UsersDtoCollection PegarOsMasters()
        {
            try
            {
                Exist_UsersDtoCollection usuarios = new Exist_UsersDtoCollection();
                string sql = "SELECT * FROM exist_users";

                sql = sql + " WHERE user_accesslevel = 9 ";

                conexao.LimparParametros();
                DataTable tabela = conexao.ExecutarConsulta(CommandType.Text, sql);

                usuarios = GetExist_UsersDtoCollection(tabela);

                return(usuarios);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#8
0
        public Exist_UsersDtoCollection PegarOsAdms(long region)
        {
            try
            {
                Exist_UsersDtoCollection usuarios = new Exist_UsersDtoCollection();

                string sql = "SELECT * FROM exist_users";
                if (region != 0)
                {
                    sql = sql + " inner join region_for_users on exist_users.user_id = region_for_users.user_id WHERE user_admin = 1  and region_id =" + region;
                }

                conexao.LimparParametros();
                DataTable tabela = conexao.ExecutarConsulta(CommandType.Text, sql);

                return(usuarios);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#9
0
        public Exist_UsersDtoCollection ConsultarUsuarios(long id)
        {
            try
            {
                Exist_UsersDtoCollection usuarios      = new Exist_UsersDtoCollection();
                exist_countries          countryGetter = new exist_countries();


                string sql = "SELECT * FROM exist_users";
                if (id != 0)
                {
                    sql = sql + " WHERE user_id=" + id;
                }
                DataTable tabela = conexao.ExecutarConsulta(CommandType.Text, sql);

                usuarios = GetExist_UsersDtoCollection(tabela);

                return(usuarios);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#10
0
        private Exist_UsersDtoCollection GetExist_UsersDtoCollection(DataTable tabela)
        {
            try
            {
                Exist_UsersDtoCollection usuarios = new Exist_UsersDtoCollection();

                foreach (DataRow item in tabela.Rows)
                {
                    Exist_UsersDto usuario = new Exist_UsersDto();
                    usuario.user_id      = Convert.ToInt64(item["user_id"]);
                    usuario.user_email   = item["user_email"].ToString();
                    usuario.user_company = item["user_company"].ToString();
                    usuario.user_name    = item["user_name"].ToString();
                    usuario.user_phone   = item["user_phone"].ToString();
                    usuario.dose         = Convert.ToInt64(item["dose"]);
                    usuario.user_blocked = Convert.ToBoolean(item["user_blocked"]);
                    usuario.currency_id  = Convert.ToInt64(item["currency_id"]);
                    if (item["user_accesslevel"] != DBNull.Value)
                    {
                        usuario.user_accesslevel = Convert.ToInt32(item["user_accesslevel"]);
                    }
                    if (item["user_date_expire"] != DBNull.Value)
                    {
                        usuario.user_date_expire = Convert.ToDateTime(item["user_date_expire"]);
                    }
                    if (item["user_date_register"] != DBNull.Value)
                    {
                        usuario.user_date_register = Convert.ToDateTime(item["user_date_register"]);
                    }
                    if (item["date_answer"] != DBNull.Value)
                    {
                        usuario.date_answer = Convert.ToDateTime(item["date_answer"]);
                    }
                    if (item["last_name"] != DBNull.Value)
                    {
                        usuario.last_name = item["last_name"].ToString();
                    }
                    if (item["treatment"] != DBNull.Value)
                    {
                        usuario.treatment = item["treatment"].ToString();
                    }
                    usuario.user_blocked = Convert.ToBoolean(item["user_blocked"]);
                    exist_countries paises       = new exist_countries();
                    long            user_country = Convert.ToInt64(item["user_country"]);

                    usuario.user_country = user_country;

                    var collection = paises.Consultar(user_country);
                    if (collection.Count > 0)
                    {
                        usuario.countries = collection[0];
                    }

                    if (item["comments"] != DBNull.Value)
                    {
                        usuario.comments = item["comments"].ToString();
                    }
                    if (item["user_admin"] != DBNull.Value)
                    {
                        usuario.user_admin = Convert.ToBoolean(item["user_admin"]);
                    }
                    usuario.user_password = item["user_password"].ToString();

                    if (tabela.Columns.Contains("chbx"))
                    {
                        usuario.chbx = Convert.ToBoolean(item["chbx"]);
                    }
                    usuarios.Add(usuario);
                }
                return(usuarios);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#11
0
        public Exist_UsersDto consultarUsuario(long user_id)
        {
            Exist_UsersDto usuario = new Exist_UsersDto();

            try
            {
                Exist_UsersDtoCollection usuarios = new Exist_UsersDtoCollection();

                string sql = "SELECT *FROM exist_users";
                if (user_id != 0)
                {
                    sql = sql + " WHERE user_id='" + user_id + "'";
                }
                DataTable tabela = conexao.ExecutarConsulta(CommandType.Text, sql);
                foreach (DataRow item in tabela.Rows)
                {
                    usuario.user_email   = item["user_email"].ToString();
                    usuario.user_company = item["user_company"].ToString();
                    usuario.user_name    = item["user_name"].ToString();
                    usuario.user_phone   = item["user_phone"].ToString();
                    exist_languages exist_languages  = new exist_languages();
                    long            lang_id          = Convert.ToInt64(item["lang_id"]);
                    var             lang_collections = exist_languages.Consultar(lang_id);
                    if (lang_collections.Count > 0)
                    {
                        usuario.lang_id = lang_collections[0];
                    }
                    if (item["user_date_expire"] != DBNull.Value)
                    {
                        usuario.user_date_expire = Convert.ToDateTime(item["user_date_expire"]);
                    }
                    if (item["user_date_register"] != DBNull.Value)
                    {
                        usuario.user_date_register = Convert.ToDateTime(item["user_date_register"]);
                    }
                    if (item["date_answer"] != DBNull.Value)
                    {
                        usuario.date_answer = Convert.ToDateTime(item["date_answer"]);
                    }
                    if (item["treatment"] != DBNull.Value)
                    {
                        usuario.treatment = item["treatment"].ToString();
                    }
                    usuario.currency_id = Convert.ToInt64(item["currency_id"]);
                    usuario.base_calc   = Convert.ToInt32(item["base_calc"]);
                    usuario.specie_id   = Convert.ToInt64(item["specie_id"]);
                    usuario.dose        = Convert.ToInt64(item["dose"]);

                    usuario.user_blocked  = Convert.ToBoolean(item["user_blocked"]);
                    usuario.user_id       = Convert.ToInt64(item["user_id"]);
                    usuario.user_password = item["user_password"].ToString();
                    usuario.user_country  = Convert.ToInt64(item["user_country"]);
                    CountriesDto countries = new CountriesDto()
                    {
                        country_id = Convert.ToInt64(item["user_country"])
                    };
                    usuario.user_admin = Convert.ToBoolean(item["user_admin"]);

                    if (item["comments"] != DBNull.Value)
                    {
                        usuario.comments = item["comments"].ToString();
                    }
                    if (item["user_accesslevel"] != DBNull.Value)
                    {
                        usuario.user_accesslevel = Convert.ToInt32(item["user_accesslevel"]);
                    }
                    if (item["lang_id"] != DBNull.Value)
                    {
                        usuario.lang_id.lang_id = Convert.ToInt64(item["lang_id"]);
                    }
                    if (item["table_id"] != DBNull.Value)
                    {
                        usuario.table_id = Convert.ToInt64(item["table_id"]);
                    }
                    if (item["measure_config_id"] != DBNull.Value)
                    {
                        usuario.measure_config_id = Convert.ToInt64(item["measure_config_id"]);
                    }
                    if (item["system_id"] != DBNull.Value)
                    {
                        usuario.system_id = Convert.ToInt64(item["system_id"]);
                    }
                    if (item["action"] != DBNull.Value)
                    {
                        usuario._action = Convert.ToInt32(item["action"]);
                    }
                    if (item["last_name"] != DBNull.Value)
                    {
                        usuario.last_name = item["last_name"].ToString();
                    }
                    return(usuario);
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }