Exemplo n.º 1
0
        private void SaveAdmin()
        {
            Response.Clear();
            if (Request.Form["adminId"] != null &&
                Request.Form["groupId"] != null &&
                Request.Form["adminEmail"] != null &&
                Request.Form["adminName"] != null &&
                Request.Form["adminPass"] != null &&
                Request.Form["adminPass2"] != null)
            {
                try
                {
                    int id = Convert.ToInt32(Request.Form["adminId"]);
                    int gid = Convert.ToInt32(Request.Form["groupId"]);
                    string name = Request.Form["adminName"].Trim();
                    string email = Request.Form["adminEmail"].Trim();
                    string pass = Request.Form["adminPass"].Trim();
                    string pass2 = Request.Form["adminPass2"].Trim();
                    if (pass == pass2)
                    {
                        SysAdmin admin = new SysAdmin(gid);
                        admin.Email = email;
                        admin.Name = name;
                        admin.Password = pass;
                        if (admin.Save(id))
                        {
                            Response.Write(id);
                        }
                    }
                }
                catch
                {
                    //
                }
            }

            Response.End();
        }
Exemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (Request["id"] != null)
            {
                CurrentAdmin = SysAdmin.Get(Convert.ToInt32(Request["id"]));
            }

            if (CurrentAdmin == null)
            {
                CurrentAdmin = new SysAdmin(0);
            }

            if (IsPost)
            {
                switch (AjaxAction)
                {
                    case "SysAdminPage.save":
                        SaveAdmin();
                        break;

                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// ��ȡ�û��б�
        /// </summary>
        /// <param name="grpId">ָ����ID</param>
        /// <returns></returns>
        public static ArrayList List(int grpId)
        {
            /*
             SysAdminList
            @gpId int=0
             */

            //[Id], GroupId,GroupName,[Name], Email,LastLoginInfo

            ArrayList list = new ArrayList();

            SqlParameter[] prams ={
                Database.MakeInParam("@gpId",SqlDbType.Int,grpId)
            };

            SqlDataReader reader = null;

            try
            {
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "SysAdminList", prams);
                while (reader.Read())
                {
                    SysAdmin admin = new SysAdmin();
                    admin.id = reader.GetInt32(0);
                    admin.groupId = reader.GetInt32(1);
                    admin.groupName = reader.GetString(2);
                    admin.name = reader.GetString(3);
                    admin.email = reader.GetString(4);
                    admin.lastLoginInfo = reader.GetString(5);
                    list.Add(admin);
                }
                reader.Close();
            }
            catch
            {
                //
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return list;
        }
Exemplo n.º 4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="email">�ʼ���ַ</param>
        /// <param name="pass">����</param>
        /// <param name="vcode">��֤��</param>
        /// <returns>True/False,ͬ������Session</returns>
        public static bool Login(string email, string pass)
        {
            /*
             IsSysAdmin
            @email varchar(50),
            @pass char(32),
            @info varchar(100)=''
             */
            if (String.IsNullOrEmpty(email) || String.IsNullOrEmpty(pass))
            {
                return false;
            }

            bool bln = false;
            string info=Util.GetIP()+"\\n"+DateTime.Now.ToString();
            SqlParameter[] prams ={
                    Database.MakeInParam("@email",SqlDbType.VarChar,50,email),
                    Database.MakeInParam("@pass",SqlDbType.VarChar,50,Util.MD5(pass)),
                    Database.MakeInParam("@info",SqlDbType.VarChar,100,info)
                };

            SqlDataReader reader = null;
            try
            {
                /*[Id], GroupId, [Name], LastLoginInfo,GroupName,GroupRights*/
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "IsSysAdmin", prams);
                if (reader.Read())
                {
                    SysAdmin admin = new SysAdmin();
                    admin.id = reader.GetInt32(0);
                    admin.groupId = reader.GetInt32(1);
                    admin.name = reader.GetString(2);
                    admin.email = email;
                    admin.lastLoginInfo = reader.GetString(3);
                    admin.groupName = reader.IsDBNull(4) ? "" : reader.GetString(4);
                    admin.rights = reader.IsDBNull(5) ? SysAdminRights.Default : SysAdminRights.ConvertFromString(reader.GetString(5)) as SysAdminRights;

                    Cookies.WriteCookie(_COOKIE_NAME, new string[] { "ID", "GROUPID", "NAME", "EMAIL", "LASTLOGININFO", "GROUPNAME", "RIGHTS" },
                        new string[] { admin.id.ToString(), admin.groupId.ToString(), admin.name, admin.email, admin.lastLoginInfo, admin.groupName, admin.rights.ConvertToString() });

                    bln = true;
                }
                reader.Close();
            }
            catch
            {
                //throw;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return bln;
        }
Exemplo n.º 5
0
        /// <summary>
        /// ��ȡ�û�
        /// </summary>
        /// <param name="email">�û��ʼ�</param>
        /// <returns></returns>
        public static SysAdmin Get(string email)
        {
            /*
             SysAdminGet
               @id varchar(50)
             */

            //[Id], GroupId, [Name], Email, LastLoginInfo,GroupName,GroupRights

            SysAdmin admin = null;
            SqlParameter[] prams ={
                    Database.MakeInParam("@id",SqlDbType.VarChar,50,email)
                };

            SqlDataReader reader = null;
            try
            {
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "SysAdminGet", prams);
                if (reader.Read())
                {
                    admin = new SysAdmin();
                    admin.id = reader.GetInt32(0);
                    admin.groupId = reader.GetInt32(1);
                    admin.name = reader.GetString(2);
                    admin.email = reader.GetString(3);
                    admin.lastLoginInfo = reader.GetString(4);
                    admin.groupName = reader.IsDBNull(5) ? "" : reader.GetString(5);
                    admin.rights = reader.IsDBNull(6) ? SysAdminRights.Default : SysAdminRights.ConvertFromString(reader.GetString(6)) as SysAdminRights;
                }
                reader.Close();
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return admin;
        }