Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        tMember mb = Session[CDKey.LOGINUSER] as tMember;



        //  string s = Session[CDKey.LOGINUSER].ToString();
        if (Session[CDKey.LOGINUSER] == null)
        {
            Response.Write("<script>alert('沒抓到SESSION');</script>");
            Response.Redirect("Login.aspx");
        }
        else
        {
            id = mb.fIdMember;
            Response.Write("<script>alert(" + id + ");</script>");
            if (mb.fIdentity == 0)
            {
                HyperLink Hyper1 = (HyperLink)Master.FindControl("HyperLink1");
                Hyper1.Text        = mb.fAccount;
                Hyper1.NavigateUrl = "~/memberCenter_New.aspx";
            }
            else
            {
                HyperLink Hyper1 = (HyperLink)Master.FindControl("HyperLink1");
                Hyper1.Text        = mb.fAccount;
                Hyper1.NavigateUrl = "~/memberCenter_Store.aspx";
            }

            HyperLink Hyper2 = (HyperLink)Master.FindControl("HyperLink2");
            Hyper2.Text        = "登出";
            Hyper2.NavigateUrl = "~/Logout.aspx";
        }

        id = mb.fIdMember;

        var likeStores = from c in db.tCollection
                         join m in db.tMember on c.fIdStores equals m.fIdMember
                         where c.fIdMember == id
                         select new
        {
            fName  = m.fName,
            fPhoto = m.fPhoto
        };

        DLLikeStores.DataSource = likeStores;
        DLLikeStores.DataBind();



        // string i = DLLikeStores.Items[0].ToString();
        // Label2.Text = i;
        // Label RegionIDLabel = DLLikeStores.Items[].FindControl("lblLikeStores") as Label;
        //RegionIDLabel.Text = "AAA";



        //try foreach 裡面哪一層有你的物件 才可以find


        /*  var likeStore = from a in db.tCollection
         *                join m in db.tMember on a.fIdMember equals m.fIdMember
         *                where a.fIdMember == id
         *                select m;
         */
    }
Beispiel #2
0
    public void inPageLoad()
    {
        lblSession.Visible = false;
        this.ImageButton1.Attributes["onmouseover"] = "this.src='/img/update2.png';";
        this.ImageButton1.Attributes["onmouseout"]  = "this.src='/img/update.png';";

        tMember mb = Session[CDKey.LOGINUSER] as tMember;


        //      string s = Session[CDKey.LOGINUSER].ToString();
        if (Session[CDKey.LOGINUSER] == null)
        {
            Response.Write("<script>alert('沒抓到SESSION');</script>");
            Response.Redirect("Login.aspx");
        }
        else
        {
            tMember member = (tMember)Session[CDKey.LOGINUSER];
            p.ProcessLetterMsg(member, lblLetter);

            id = mb.fIdMember;
            lblSession.Text = id.ToString();
            if (mb.fIdentity == 0)
            {
                HyperLink Hyper1 = (HyperLink)Master.FindControl("HyperLink1");
                Hyper1.Text        = mb.fAccount;
                Hyper1.NavigateUrl = "~/memberCenter_New.aspx";
            }
            else
            {
                HyperLink Hyper1 = (HyperLink)Master.FindControl("HyperLink1");
                Hyper1.Text        = mb.fAccount;
                Hyper1.NavigateUrl = "~/memberCenter_Store.aspx";
            }

            HyperLink Hyper2 = (HyperLink)Master.FindControl("HyperLink2");
            Hyper2.Text        = "登出";
            Hyper2.NavigateUrl = "~/Logout.aspx";
        }


        if (Page.IsPostBack == false)
        {
            var likeStores = from c in db.tCollection
                             join m in db.tMember on c.fIdStores equals m.fIdMember
                             where c.fIdMember == id
                             select new
            {
                fName  = m.fName,
                fPhoto = m.fPhoto
            };

            DLLikeStores.DataSource = likeStores;
            DLLikeStores.DataBind();

            var linqlikeServices = from l in db.tLIkeServices
                                   join m in db.tMember on l.fidStores equals m.fIdMember
                                   join se in db.tServices on l.fidServices equals se.fIdServices
                                   join s in db.tServicesPic on l.fidServices equals s.fIdServices
                                   join g in db.tGalleryPhoto on s.fIdPhoto equals g.fIdPhoto
                                   where l.fidMember == id
                                   select new
            {
                fName  = se.fName,
                fPhoto = g.fPhoto
            };
            DLLikeServices.DataSource = linqlikeServices;
            DLLikeServices.DataBind();

            var likeStoreCount = from c in db.tCollection
                                 where c.fIdMember == id
                                 select c.fIdCollectionStores;
            int countstore = likeStoreCount.Count();
            if (countstore == 0)
            {
                lblLikestore.Text = "尚未加入喜歡的店家";
            }
            else
            {
                lblLikestore.Text = "您有" + countstore + "個喜歡的店家";
            }
            var likeServicesCount = from l in db.tLIkeServices
                                    where l.fidMember == id
                                    select l.fidLIkeServices;
            int countLikeServices = likeServicesCount.Count();
            if (countLikeServices == 0)
            {
                lblLikeServices.Text = "尚未有收藏的服務";
            }
            else
            {
                lblLikeServices.Text = "您有" + countLikeServices + "個收藏的服務";
            }
            var table = from m in db.tMember
                        where m.fIdMember == id
                        select m;
            foreach (tMember o in table)
            {
                txtName.Text     = o.fName;
                txtPhone.Text    = o.fPhone;
                txtAddress.Text  = o.fAddress;
                txtEmail.Text    = o.fEmail;
                lblUserName.Text = o.fName;

                imgPic2.ImageUrl = imgURL + o.fPhoto;
                imgPic.ImageUrl  = imgURL + o.fPhoto;
            }
        }
    }
    public void inPageLoad()
    {
        tMember mb = Session[CDKey.LOGINUSER] as tMember;

        if (Session[CDKey.LOGINUSER] == null)
        {
            Response.Redirect("Login.aspx");
        }
        else
        {
            tMember member = (tMember)Session[CDKey.LOGINUSER];
            //p.ProcessLetterMsg(member, lblLetter);

            id = mb.fIdMember;
        }


        if (Page.IsPostBack == false)
        {
            //抓取服務進度
            var inServices = from c in db.tCalendar
                             join s in db.tServices on c.fIdServices equals s.fIdServices
                             where c.fIdMember == id && c.fDate > DateTime.Now.Date && c.fAccepted.Equals("True")
                             select new
            {
                finName = s.fName,
                finDate = c.fDate.Value.Month.ToString() + "月" + c.fDate.Value.Day.ToString() + "日"
            };
            DLNotYetTime.DataSource = inServices;
            DLNotYetTime.DataBind();

            var in2Services = from c in db.tCalendar
                              join s in db.tServices on c.fIdServices equals s.fIdServices
                              where c.fIdMember == id && c.fDate == DateTime.Now.Date && c.fAccepted.Equals("True")
                              select new
            {
                finName = s.fName,
                finDate = c.fDate.Value.Month.ToString() + "月" + c.fDate.Value.Day.ToString() + "日"
            };
            DllSameTime.DataSource = in2Services;
            DllSameTime.DataBind();

            var in3Services = from c in db.tCalendar
                              join s in db.tServices on c.fIdServices equals s.fIdServices
                              where c.fIdMember == id && c.fDate < DateTime.Now.Date && c.fAccepted.Equals("True") && c.fOK == null
                              select new
            {
                finName = s.fName,
                finDate = c.fDate.Value.Month.ToString() + "月" + c.fDate.Value.Day.ToString() + "日",
                fidSer  = s.fIdServices
            };
            DllOverTime.DataSource = in3Services;
            DllOverTime.DataBind();

            var in4Services = from c in db.tCalendar
                              join s in db.tServices on c.fIdServices equals s.fIdServices
                              join e in db.tEvaluation on s.fIdServices equals e.fidServices
                              where c.fIdMember == id && e.fidMember == id && c.fDate < DateTime.Now.Date && e.fStar != null && c.fAccepted.Equals("True")
                              select new
            {
                finName = s.fName,
                finDate = c.fDate.Value.Month.ToString() + "月" + c.fDate.Value.Day.ToString() + "日",
                fidStar = e.fStar
            };
            DataList1.DataSource = in4Services;
            DataList1.DataBind();

            var in5Services = from c in db.tCalendar
                              join s in db.tServices on c.fIdServices equals s.fIdServices
                              where c.fIdMember == id && c.fAccepted.Equals("False")
                              select new
            {
                finName = s.fName,
                finDate = c.fDate.Value.Month.ToString() + "月" + c.fDate.Value.Day.ToString() + "日"
            };
            DLLnotAccepted.DataSource = in5Services;
            DLLnotAccepted.DataBind();

            //抓取喜歡的店家
            var likeStores = from c in db.tCollection
                             join m in db.tMember on c.fIdStores equals m.fIdMember
                             where c.fIdMember == id
                             select new
            {
                flikeStoreName  = m.fName,
                flikeStorePhoto = m.fPhoto,
                fStore          = c.fIdStores
            };

            DLLikeStores.DataSource = likeStores;
            DLLikeStores.DataBind();
            //抓取收藏的服務

            /*  var linqlikeServices = from l in db.tLIkeServices
             *                       join m in db.tMember on l.fidStores equals m.fIdMember
             *                       join se in db.tServices on l.fidServices equals se.fIdServices
             *                       join s in db.tServicesPic on l.fidServices equals s.fIdServices
             *                       join g in db.tGalleryPhoto on s.fIdPhoto equals g.fIdPhoto
             *                       where l.fidMember == id
             *                       select new
             *                       {
             *                           fStore=l.fidStores,
             *                           fServices=l.fidServices,
             *                           fLikeServiceName = se.fName,
             *                           fLikeServicePhoto = g.fPhoto
             *                       };*/


            var qqq = from l in db.tLIkeServices
                      join se in db.tServices on l.fidServices equals se.fIdServices
                      join s in db.tServicesPic on l.fidServices equals s.fIdServices
                      join g in db.tGalleryPhoto on s.fIdPhoto equals g.fIdPhoto
                      join st in db.tMember on se.fIdStores equals st.fIdMember
                      where l.fidMember == id
                      select new
            {
                fStore            = st.fIdMember,
                fServices         = l.fidServices,
                fLikeServiceName  = se.fName,
                fLikeServicePhoto = g.fPhoto
            };



            DLLikeServices.DataSource = qqq;
            DLLikeServices.DataBind();
            //喜歡店家數量
            var likeStoreCount = from c in db.tCollection
                                 where c.fIdMember == id
                                 select c.fIdCollectionStores;
            int countstore = likeStoreCount.Count();
            if (countstore == 0)
            {
                lblLikestore.Text = "尚未加入喜歡的店家";
            }
            else
            {
                lblLikestore.Text = "您有 " + countstore + " 個喜歡的店家";
            }
            //收藏服務數量
            var likeServicesCount = from l in db.tLIkeServices
                                    where l.fidMember == id
                                    select l.fidLIkeServices;
            int countLikeServices = likeServicesCount.Count();
            if (countLikeServices == 0)
            {
                lblLikeServices.Text = "尚未有收藏的服務";
            }
            else
            {
                lblLikeServices.Text = "您有 " + countLikeServices + " 個收藏的服務";
            }
            //顯示行程數量
            var cale = from c in db.tCalendar
                       where c.fIdMember == id && c.fDate > DateTime.Now.Date && c.fAccepted.Equals("True")
                       select new
            {
                fcount = c.fIdCalendar
            };
            int caleCount = cale.Count();
            if (caleCount == 0)
            {
                lblNew.Text = "尚無未開始行程";
            }
            else
            {
                lblNew.Text = "您有 " + caleCount + " 個未開始行程";
            }

            //顯示基本資料
            var table = from m in db.tMember
                        where m.fIdMember == id
                        select m;
            foreach (tMember o in table)
            {
                txtName.Text    = o.fName;
                txtPhone.Text   = o.fPhone;
                txtAddress.Text = o.fAddress;
                txtEmail.Text   = o.fEmail;

                imgPic2.ImageUrl = o.fPhoto;
                imgPic.ImageUrl  = o.fPhoto;
                lblUserName.Text = "準新人:" + o.fName;
            }
            //前3筆發文討論
            var disc = (from d in db.tDiscussion
                        where d.fIdMember == id
                        orderby d.fSendTime descending
                        select  new
            {
                fidtit = d.fIdTitle,
                ftitle = d.fTitle,
                ftime = d.fSendTime
            }).Take(20);
            DLDis.DataSource = disc;
            DLDis.DataBind();
            //前3筆回文
            var discR = (from r in db.tDiscussionReply
                         join d in db.tDiscussion on r.fIdTitle equals d.fIdTitle
                         where r.fIdMember == id
                         orderby r.fSendTime descending
                         select new {
                fcon = r.fContent,
                fidtit = d.fIdTitle,
                ftitle = d.fTitle,
                ftime = r.fSendTime
            }).Take(20);
            DLDisR.DataSource = discR;
            DLDisR.DataBind();
            //我的詢價
            var Askp = (from a in db.tAskPrice
                        where a.fIdMember == id
                        orderby a.fSendTime descending
                        select new
            {
                fidtit = a.fIdTitle,
                ftitle = a.fTitle,
                ftime = a.fSendTime
            }).Take(20);
            DLAskP.DataSource = Askp;
            DLAskP.DataBind();
        }
    }