Пример #1
0
        public async Task <ActionResult> Register(TB_LoginOn model)
        {
            if (ModelState.IsValid)
            {
                using (SubBugEntities db = new SubBugEntities())
                {
                    if (await db.TB_LoginOn.FirstOrDefaultAsync(l => l.LoginNo == model.LoginNo) != null)
                    {
                        ModelState.AddModelError("", "用户名已经存在!");
                        return(View());
                    }
                    else
                    {
                        model = new TB_LoginOn()
                        {
                            LoginNo    = Request.Params["LoginNo"].ToUpper(),
                            LoginPwd   = md5.MD5Encrypt(Request.Params["LoginPwd"]),
                            LoginName  = Request.Params["LoginName"].ToUpper(),
                            LPhone     = Request.Params["LPhone"],
                            ComputerNo = Request.Params["ComputerNo"].ToUpper(),
                            AId        = 1
                        };
                        db.TB_LoginOn.Add(model);
                        await db.SaveChangesAsync();

                        return(RedirectToAction("Login", "Account"));
                    }
                }
            }
            return(View(model));
        }
Пример #2
0
        public async Task <ActionResult> Create(TB_BugSubmit model)
        {
            if (Session["LoginName"] != null)
            {
                model.LId        = ((TB_LoginOn)Session["LoginName"]).LId;
                model.Claimant   = ((TB_LoginOn)Session["LoginName"]).LoginName;
                model.LPhone     = ((TB_LoginOn)Session["LoginName"]).LPhone;
                model.ComputerNo = ((TB_LoginOn)Session["LoginName"]).ComputerNo;
            }
            else
            {
                if (ModelState.IsValid)
                {
                    model.LId        = 1;
                    model.AppName    = Request.Params["AppName"].ToUpper();
                    model.Describe   = Request.Params["Describe"];
                    model.Claimant   = Request.Params["Claimant"].ToUpper();
                    model.LPhone     = Request.Params["LPhone"].ToUpper();
                    model.ComputerNo = Request.Params["ComputerNo"].ToUpper();
                }
            }

            model.LIP     = System.Web.HttpContext.Current.Request.UserHostAddress;
            model.SubDate = DateTime.Now;
            model.YN      = "N";

            using (SubBugEntities db = new SubBugEntities())
            {
                try
                {
                    db.TB_BugSubmit.Add(model);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index", "Home"));
                }
                catch
                {
                    return(View());
                }
            }
        }