Exemple #1
0
        public ActionResult Edit(string id)
        {
            var bll   = new MemberBll();
            var model = bll.GetMember(id);

            List <SelectListItem> Sexy     = bll.GetDict(1);
            List <SelectListItem> CardType = bll.GetDict(2);
            List <SelectListItem> Status   = bll.GetDict(3);

            foreach (SelectListItem r in Sexy)
            {
                if (model.sexy == r.Value)
                {
                    ViewBag.Sexy += "<option value='" + r.Value.ToString() + "'selected>" + r.Text.ToString() + "</option>";
                }
                else
                {
                    ViewBag.Sexy += "<option value='" + r.Value.ToString() + "'>" + r.Text.ToString() + "</option>";
                }
            }

            foreach (SelectListItem r in CardType)
            {
                if (model.cardtype == r.Value)
                {
                    ViewBag.CardType += "<option value='" + r.Value.ToString() + "'selected>" + r.Text.ToString() + "</option>";
                }
                else
                {
                    ViewBag.CardType += "<option value='" + r.Value.ToString() + "'>" + r.Text.ToString() + "</option>";
                }
            }

            foreach (SelectListItem r in Status)
            {
                if (model.Status.ToString() == r.Value)
                {
                    ViewBag.Status += "<option value='" + r.Value.ToString() + "'selected>" + r.Text.ToString() + "</option>";
                }
                else
                {
                    ViewBag.Status += "<option value='" + r.Value.ToString() + "'>" + r.Text.ToString() + "</option>";
                }
            }


            return(View(model));
        }
Exemple #2
0
        public ActionResult Create()
        {
            var bll = new MemberBll();
            List <SelectListItem> Sexy     = bll.GetDict(1);
            List <SelectListItem> CardType = bll.GetDict(2);
            List <SelectListItem> Status   = bll.GetDict(3);

            foreach (SelectListItem r in Sexy)
            {
                ViewBag.Sexy += "<option value='" + r.Value.ToString() + "'>" + r.Text.ToString() + "</option>";
            }

            foreach (SelectListItem r in CardType)
            {
                ViewBag.CardType += "<option value='" + r.Value.ToString() + "'>" + r.Text.ToString() + "</option>";
            }

            foreach (SelectListItem r in Status)
            {
                ViewBag.Status += "<option value='" + r.Value.ToString() + "'>" + r.Text.ToString() + "</option>";
            }

            return(View());
        }
Exemple #3
0
        public ActionResult Edit(string id, FormCollection fc)
        {
            var    bll   = new MemberBll();
            var    model = bll.GetMember(id);
            string pas   = fc["Passwd"].ToString().Trim();

            if (pas != "******")
            {
                model.Passwd = MD5Encrypt(pas);
            }
            model.sexy     = fc["optSexy"].ToString();
            model.cardtype = fc["optCardType"].ToString();
            model.cardno   = fc["cardno"].ToString();
            if (fc["birthday"] != null)
            {
                model.birthday = DateTime.Parse(fc["birthday"].ToString());
            }
            model.Status = Int32.Parse(fc["optStatus"].ToString());

            try
            {
                bll.EditMember(model);
            }
            catch (ValidException ex)
            {
                this.ModelState.AddModelError(ex.Name, ex.Message);
                List <SelectListItem> Sexy     = bll.GetDict(1);
                List <SelectListItem> CardType = bll.GetDict(2);
                List <SelectListItem> Status   = bll.GetDict(3);

                foreach (SelectListItem r in Sexy)
                {
                    if (model.sexy == r.Value)
                    {
                        ViewBag.Sexy += "<option value='" + r.Value.ToString() + "'selected>" + r.Text.ToString() + "</option>";
                    }
                    else
                    {
                        ViewBag.Sexy += "<option value='" + r.Value.ToString() + "'>" + r.Text.ToString() + "</option>";
                    }
                }

                foreach (SelectListItem r in CardType)
                {
                    if (model.cardtype == r.Value)
                    {
                        ViewBag.CardType += "<option value='" + r.Value.ToString() + "'selected>" + r.Text.ToString() + "</option>";
                    }
                    else
                    {
                        ViewBag.CardType += "<option value='" + r.Value.ToString() + "'>" + r.Text.ToString() + "</option>";
                    }
                }

                foreach (SelectListItem r in Status)
                {
                    if (model.Status.ToString() == r.Value)
                    {
                        ViewBag.Status += "<option value='" + r.Value.ToString() + "'selected>" + r.Text.ToString() + "</option>";
                    }
                    else
                    {
                        ViewBag.Status += "<option value='" + r.Value.ToString() + "'>" + r.Text.ToString() + "</option>";
                    }
                }
                return(View(model));
            }

            return(this.RefreshParent());
        }