예제 #1
0
        public ActionResult Indexx()  //我的人力服務瀏覽
        {
            Session["CaseIDD"] = null;
            if (Session["MEMBERID"] == null)
            {
                Session["MEMBERID"] = 3;//先寫死
            }
            int memberid = (int)Session["MEMBERID"];

            List <CaseManPower> cms = new List <CaseManPower>();
            var q = (from o in db.Cases
                     join m in db.ManPower on o.CaseID equals m.CaseID
                     where o.MemberID == memberid
                     orderby o.StartDateTime
                     select o).ToList();
            List <OrderCount> oco = new List <OrderCount>();

            foreach (var a in q)
            {
                OrderCount ocou = new OrderCount();
                ocou.CaseID    = a.CaseID;
                ocou.CaseTitle = a.CaseTitle;
                ocou.Cou       = db.Orders.Where(o => o.CaseID == a.CaseID).Count();
                oco.Add(ocou);

                CaseManPower cm = new CaseManPower();
                cm.CaseID        = a.CaseID;
                cm.CaseTitle     = a.CaseTitle;
                cm.StartDateTime = a.StartDateTime;
                int caseid = a.CaseID;
                int stasid = a.StatusID;
                cm.StatusName = db.CaseStatus.Find(stasid).StatusName;
                var q2 = db.ManPower.Where(m => m.CaseID == caseid).Select(m => m);
                foreach (var x in q2)
                {
                    cm.MPName         = x.MPName;
                    cm.MPPoint        = x.MPPoint;
                    cm.MPNeedCount    = x.MPNeedCount;    //需要的人數
                    cm.MPActuralCount = x.MPActuralCount; //實際徵求到的人數
                    cm.MPTime         = x.MPTime;         //徵求時間
                    cm.MPDate         = x.MPDate;         //徵求日期
                }
                cms.Add(cm);
            }

            //MemberCaseCount mcc = new MemberCaseCount();
            //var t = mcc.casecount(memberid);
            int ccount = db.Cases.Where(o => o.MemberID == memberid).Count();

            ViewBag.allcase = ccount;
            ViewBag.MPcase  = q.Count();

            ViewBag.Count = oco;

            return(View(cms));
        }
예제 #2
0
        public ActionResult EditMan(int id) //CaseID 修改的頁面 先讀取單筆
        {
            CaseManPower cg = new CaseManPower();
            var          q  = db.Cases.Find(id);

            cg.CaseID         = q.CaseID;
            Session["CaseID"] = q.CaseID;
            cg.CaseTitle      = q.CaseTitle;
            cg.CaseContent    = q.CaseContent;
            cg.StartDateTime  = q.StartDateTime;
            cg.Location       = q.Location; //地址還不完整!!!!!!!
            cg.Contact        = q.Contact;
            cg.StatusID       = q.StatusID;
            cg.StatusName     = db.CaseStatus.Find(q.StatusID).StatusName; //狀態
            var g = db.ManPower.Where(m => m.CaseID == q.CaseID).First();

            cg.MPID           = g.MPID;
            cg.MPName         = g.MPName;
            cg.MPNeedCount    = g.MPNeedCount;
            cg.MPActuralCount = g.MPActuralCount;
            cg.MPTime         = g.MPTime;
            cg.MPDate         = g.MPDate;
            var sub = db.MPSubClass.Find(g.MPSubClassID);

            cg.MPSubClass1 = sub.MPSubClass1;                         //小分類
            cg.MPClass1    = db.MPClass.Find(sub.MPClassID).MPClass1; //大分類
            var re = db.Region.Find(q.RegionID);

            cg.RegionName = re.RegionName;                    //區
            cg.CityName   = db.City.Find(re.CityID).CityName; //縣市
            int count = db.Picture.Where(o => o.CaseID == id).Count();

            if (count > 0)
            {
                var pimg = db.Picture.Where(m => m.CaseID == id).FirstOrDefault();
                cg.ImageID = pimg.ImageID;
            }

            Cases  _case  = db.Cases.Find(id);
            Region region = db.Region.Find(q.RegionID);

            ViewBag.RegionID = new SelectList(db.Region.Where(o => o.CityID == region.CityID), "RegionID", "RegionName", _case.RegionID);
            ViewBag.CityID   = new SelectList(db.City, "CityID", "CityName", region.CityID);
            ManPower   mans     = db.ManPower.Find(g.MPID);
            MPSubClass subclass = db.MPSubClass.Find(g.MPSubClassID);

            ViewBag.MPSubClassID = new SelectList(db.MPSubClass.Where(o => o.MPClassID == subclass.MPClassID), "MPSubClassID", "MPSubClass1", mans.MPSubClassID);
            ViewBag.MPClassID    = new SelectList(db.MPClass, "MPClassID", "MPClass1", subclass.MPClassID);

            return(View(cg));
        }
예제 #3
0
        public ActionResult EditMan(CaseManPower goodv, HttpPostedFileBase strPhoto)
        {
            if (strPhoto != null)
            {
                //string strPath = Request.PhysicalApplicationPath + "Areas\\Members\\MemberImages";
                //strPhoto.SaveAs(strPath + strPhoto.FileName);
                var    imagesSize = strPhoto.ContentLength;
                byte[] imageByte  = new byte[imagesSize];
                strPhoto.InputStream.Read(imageByte, 0, imagesSize);

                db.Picture.Add(new Picture {
                    CaseID = goodv.CaseID, Images = imageByte
                });
                db.SaveChanges();
                TempData["message"] = "上傳成功";
            }
            else
            {
                TempData["message"] = "請先選檔案";
            }
            var c = db.Cases.Find(goodv.CaseID);

            c.CaseTitle   = goodv.CaseTitle;
            c.CaseContent = goodv.CaseContent;
            c.Contact     = goodv.Contact;
            c.Location    = goodv.Location;
            c.RegionID    = goodv.RegionID;
            var g = db.ManPower.Find(goodv.MPID);

            //g.MPName = goodv.MPName;
            g.MPNeedCount    = goodv.MPNeedCount;
            g.MPActuralCount = goodv.MPActuralCount;
            g.MPSubClassID   = goodv.MPSubClassID;
            g.MPDate         = goodv.MPDate;
            g.MPTime         = goodv.MPTime;
            db.SaveChanges();
            return(RedirectToAction("LoadMan"));
        }
예제 #4
0
        public ActionResult LoadMan(int id = 0)//CaseID  完整資訊  單筆 單圖
        {
            CaseManPower cm = new CaseManPower();

            if (id == 0)
            {
                id = (int)Session["CaseIDD"];
            }
            var q = db.Cases.Find(id);

            cm.CaseID          = q.CaseID;
            Session["CaseIDD"] = q.CaseID;
            cm.CaseTitle       = q.CaseTitle;
            cm.CaseContent     = q.CaseContent;
            cm.StartDateTime   = q.StartDateTime;
            cm.Location        = q.Location; //地址還不完整!!!!!!!
            cm.Contact         = q.Contact;
            cm.StatusID        = q.StatusID;
            cm.StatusName      = db.CaseStatus.Find(q.StatusID).StatusName; //狀態
            var g = db.ManPower.Where(m => m.CaseID == q.CaseID).First();

            cm.MPName         = g.MPName;
            cm.MPTime         = g.MPTime;
            cm.MPDate         = g.MPDate;
            cm.MPNeedCount    = g.MPNeedCount;    //需要的人數
            cm.MPActuralCount = g.MPActuralCount; //實際徵求到的人數
            var sub = db.MPSubClass.Find(g.MPSubClassID);

            cm.MPSubClass1 = sub.MPSubClass1;                         //小分類
            cm.MPClass1    = db.MPClass.Find(sub.MPClassID).MPClass1; //大分類
            var re = db.Region.Find(q.RegionID);

            cm.RegionName = re.RegionName;                    //區
            cm.CityName   = db.City.Find(re.CityID).CityName; //縣市
            int count = db.Picture.Where(o => o.CaseID == id).Count();

            if (count > 0)
            {
                var pimg = db.Picture.Where(m => m.CaseID == id).First();
                cm.ImageID = pimg.ImageID;
            }

            List <ContentViewModel> che = new List <ContentViewModel>();
            var q3 = db.Content.Where(o => o.CaseID == id).OrderByDescending(o => o.MessageDateTime).ToList();

            foreach (var a in q3)
            {
                ContentViewModel _order = new ContentViewModel();
                int mem = a.MemberID;
                var mb  = db.Member.Find(mem);
                _order.MessageContent  = a.MessageContent;
                _order.ContentID       = a.ContentID;
                _order.MessageDateTime = a.MessageDateTime;
                _order.AuthorRepeat    = a.AuthorRepeat;
                _order.NickName        = mb.NickName;
                _order.MemberID        = mem;
                _order.Birthday        = mb.Birthday;
                _order.Phone           = mb.Phone;
                _order.Address         = mb.Address;
                var reg = db.Region.Find(mb.RegionID);
                _order.RegionName = reg.RegionName;
                _order.CityName   = db.City.Where(o => o.CityID == reg.CityID).First().CityName;

                string mpclassname = "";
                var    mpl         = db.MPSCList.Where(o => o.MemberID == mem).ToList(); //每個會員的多個小專長ID
                foreach (var b in mpl)
                {
                    string MPSub = db.MPSubClass.Find(b.MPSubClassID).MPSubClass1;
                    mpclassname = mpclassname + MPSub + " ";
                }
                _order.MPSubClass1 = mpclassname;

                che.Add(_order);
            }
            ViewBag.ContentMember = che;

            return(View(cm));
        }