Exemplo n.º 1
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here
                Admin.Models.member.Member mem = new Admin.Models.member.Member();
                var memberList = new List<Admin.Models.member.Member>() ;
                var encPassword = Encryptor.MD5Hash(collection.Get("Password"));
                //int roleid = Int32.Parse(collection.Get("RoleID").ToString());
                int roleid = 1;
                model.Createmember(collection.Get("FirstName"), collection.Get("LastName"), collection.Get("Email"), collection.Get("Username"), encPassword,roleid);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Exemplo n.º 2
0
        public Member GetRoleIDByMemberID(int memid)
        {
            Member mem = new Member();
            SQLManager.SQLManager sqlConn = new SQLManager.SQLManager();
            try
            {
                sqlConn.Connection = new SqlConnection(sqlConn.ConnectionString);

                sqlConn.Query = "select RoleID,MemberID from tbl_member where MemberID=@MemberID";
                sqlConn.Command = new SqlCommand(sqlConn.Query, sqlConn.Connection);
                sqlConn.Command.Parameters.AddWithValue("@MemberID", memid);
                sqlConn.Connection.Open();

                using (sqlConn.Reader = sqlConn.Command.ExecuteReader())
                {
                    while (sqlConn.Reader.Read())
                    {
                        mem.RoleID = Int32.Parse(sqlConn.Reader["RoleID"].ToString());

                    }
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                if (sqlConn.Reader != null)
                    sqlConn.Reader.Close();
                sqlConn.Connection.Close();
                sqlConn.Connection.Dispose();

            }

            return mem;
        }
Exemplo n.º 3
0
        /// <summary>
        ///   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// 
        public List<Member> getonlymembers()
        {
            SQLManager.SQLManager sqlConn = new SQLManager.SQLManager();
            Member mem = new Member();
            var onlymemberlist = new List<Member>();
            try
            {
                sqlConn.Connection = new SqlConnection(sqlConn.ConnectionString);
                sqlConn.Query = " select MemberID,FirstName,LastName from tbl_memberinfo";
                sqlConn.Command = new SqlCommand(sqlConn.Query, sqlConn.Connection);
                sqlConn.Connection.Open();

                using (sqlConn.Reader = sqlConn.Command.ExecuteReader())
                {
                    while (sqlConn.Reader.Read())
                    {
                        onlymemberlist.Add(new Admin.Models.member.Member
                        {
                            MemberID = Int32.Parse(sqlConn.Reader["MemberID"].ToString()),

                            FirstName = sqlConn.Reader["FirstName"].ToString(),
                            LastName = sqlConn.Reader["LastName"].ToString()
                        });
                    }
                }

            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                if (sqlConn.Reader != null)
                    sqlConn.Reader.Close();
                sqlConn.Connection.Close();
                sqlConn.Connection.Dispose();

            }

            return onlymemberlist;
        }
Exemplo n.º 4
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public List<Member> getNameByroleid()
        {
            SQLManager.SQLManager sqlConn = new SQLManager.SQLManager();
            Member mem = new Member();
            var onlyRoleName = new List<Member>();
              try
            {
                sqlConn.Connection = new SqlConnection(sqlConn.ConnectionString);
                sqlConn.Query = " select RoleID,Name from tbl_role";
                sqlConn.Command = new SqlCommand(sqlConn.Query, sqlConn.Connection);
                sqlConn.Connection.Open();

                using (sqlConn.Reader = sqlConn.Command.ExecuteReader())
                {
                    while (sqlConn.Reader.Read())
                    {
                        onlyRoleName.Add(new Admin.Models.member.Member
                        {
                            RoleID = Int32.Parse(sqlConn.Reader["RoleID"].ToString()),

                            Name = sqlConn.Reader["Name"].ToString(),
                            //.RoleILastName = sqlConn.Reader["LastName"].ToString()
                        });
                    }
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                if (sqlConn.Reader != null)
                    sqlConn.Reader.Close();
                sqlConn.Connection.Close();
                sqlConn.Connection.Dispose();

            }

            return onlyRoleName;
        }
Exemplo n.º 5
0
        public Member GetMemberNameFromMemberId(int mid)
        {
            Member mem = new Member();
            // string encPassword = "";

            SQLManager.SQLManager sqlConn = new SQLManager.SQLManager();
            try
            {
                sqlConn.Connection = new SqlConnection(sqlConn.ConnectionString);
                sqlConn.Query = "select MemberID, FirstName,Lastname from tbl_memberinfo where MemberID=@mid";
                sqlConn.Command = new SqlCommand(sqlConn.Query, sqlConn.Connection);
                sqlConn.Command.Parameters.AddWithValue("@mid", mid);

                sqlConn.Connection.Open();

                using (sqlConn.Reader = sqlConn.Command.ExecuteReader())
                {
                    if (sqlConn.Reader.Read())
                    {

                        mem.FirstName = sqlConn.Reader["FirstName"].ToString();
                        mem.LastName = sqlConn.Reader["LastName"].ToString();
                    }
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                if (sqlConn.Reader != null)
                    sqlConn.Reader.Close();
                sqlConn.Connection.Close();
                sqlConn.Connection.Dispose();

            }
            return mem;
        }
Exemplo n.º 6
0
        public Member GetMemberIDFromUsername(string username)
        {
            Member mem = new Member();
            // string encPassword = "";

            SQLManager.SQLManager sqlConn = new SQLManager.SQLManager();
            try
            {
                sqlConn.Connection = new SqlConnection(sqlConn.ConnectionString);
                sqlConn.Query = "select MemberID from tbl_member as tbm where tbm.username=@username";
                sqlConn.Command = new SqlCommand(sqlConn.Query, sqlConn.Connection);
                sqlConn.Command.Parameters.AddWithValue("@username", username);

                sqlConn.Connection.Open();

                using (sqlConn.Reader = sqlConn.Command.ExecuteReader())
                {
                    if (sqlConn.Reader.Read())
                    {

                        mem.MemberID = Int32.Parse(sqlConn.Reader["MemberID"].ToString());
                    }
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                if (sqlConn.Reader != null)
                    sqlConn.Reader.Close();
                sqlConn.Connection.Close();
                sqlConn.Connection.Dispose();

            }
            return mem;
        }
Exemplo n.º 7
0
        public Member GetMemberByMemberID(int memID)
        {
            Member mem = new Member();
            SQLManager.SQLManager sqlConn = new SQLManager.SQLManager();
            try
            {
                sqlConn.Connection = new SqlConnection(sqlConn.ConnectionString);
                // sqlConn.Query = "select Email,UserName,Password,FirstName,LastName from tbl_member,tbl_memberinfo where tbl_member.MemberID=tbl_memberinfo.MemberID";
                sqlConn.Query = "select m.MemberID,m.Email,m.UserName,m.Password,mi.FirstName,mi.LastName from tbl_member as m join tbl_memberinfo as mi on m.MemberID = mi.MemberID where m.MemberID=@MemberID";
                sqlConn.Command = new SqlCommand(sqlConn.Query, sqlConn.Connection);
                sqlConn.Command.Parameters.AddWithValue("@MemberID", memID);
                sqlConn.Connection.Open();

                using (sqlConn.Reader = sqlConn.Command.ExecuteReader())
                {
                    while (sqlConn.Reader.Read())
                    {
                        mem.MemberID = Int32.Parse(sqlConn.Reader["MemberID"].ToString());
                        mem.Email = sqlConn.Reader["Email"].ToString();
                        mem.Username = sqlConn.Reader["UserName"].ToString();
                        mem.Password = sqlConn.Reader["Password"].ToString();
                        mem.FirstName = sqlConn.Reader["FirstName"].ToString();
                        mem.LastName = sqlConn.Reader["LastName"].ToString();
                    }
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                if (sqlConn.Reader != null)
                    sqlConn.Reader.Close();
                sqlConn.Connection.Close();
                sqlConn.Connection.Dispose();

            }

            return mem;
        }
Exemplo n.º 8
0
        /// /////////////////////////////////////////////////////////////////
        /// </summary>
        /// 
        /// 
        //   public class ImageResult : FileStreamResult
        //         {
        //             public ImageResult(Image input):this(input,input.Width,input.Height) { }
        //             public ImageResult(Image input, int width,int height) :
        //             base(GetMemoryStream(input,width,height,ImageFormat.Png), "image/png")
        //{ }
        // static MemoryStream GetMemoryStream(Image input,int width,
        //                     int height,ImageFormat fmt)
        // {
        //    // maintain aspect ratio
        //    if (input.Width > input.Height)
        //       height = input.Height * width / input.Width;
        //    else
        //       width = input.Width * height / input.Height;
        //    var bmp = new Bitmap(input, width, height);
        //    var ms = new MemoryStream();
        //    bmp.Save(ms, ImageFormat.Png);
        //    ms.Position = 0;
        //    return ms;
        //  }
        //}
        //     ///
        //     ///
        /// 
        /// 
        /// /////////////////
        /// <returns></returns>
        public List<Member> GetAllmembers()
        {
            SQLManager.SQLManager sqlConn = new SQLManager.SQLManager();
            Member mem = new Member();
            var memberList = new List<Member>();
            try
            {
                sqlConn.Connection = new SqlConnection(sqlConn.ConnectionString);
                sqlConn.Query = " select m.MemberID,m.Email,m.UserName,mi.FirstName,mi.LastName from tbl_member as m join tbl_memberinfo as mi on m.MemberID = mi.MemberID ";
                sqlConn.Command = new SqlCommand(sqlConn.Query, sqlConn.Connection);
                sqlConn.Connection.Open();
                //var id = Convert.ToInt32(sqlConn.Command.ExecuteScalar());
                using (sqlConn.Reader = sqlConn.Command.ExecuteReader())
                {
                    while (sqlConn.Reader.Read())
                    {
                        memberList.Add(new Admin.Models.member.Member
                        {
                            MemberID = Int32.Parse(sqlConn.Reader["MemberID"].ToString()),
                            Email = sqlConn.Reader["Email"].ToString(),
                            Username = sqlConn.Reader["Username"].ToString(),
                            //   Password=sqlConn.Reader["Password"].ToString(),
                            // string Password = GenerateRandomString(Password).ToString();
                            FirstName = sqlConn.Reader["FirstName"].ToString(),
                            LastName = sqlConn.Reader["LastName"].ToString()
                        });
                    }
                }

            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                if (sqlConn.Reader != null)
                    sqlConn.Reader.Close();
                sqlConn.Connection.Close();
                sqlConn.Connection.Dispose();

            }

            return memberList;
        }