public async void DistinguishUser(ushort fid, DateTime attendanceTime)
        {
            string pid = StorageControl.GetPerIDByFID(fid);

            if (pid == string.Empty)
            {
                ShowNoFound( );
                return;
            }

            PerInfo pi = await StorageControl.ReadPerInfo(pid);

            if (pi == null)
            {
                ShowNoFound( );
                return;
            }


            CommonRes.StorageControl.WriteAttendanceRecord(attendanceTime, fid);
            ShowAttendUser(pi.Name, pi.Department, attendanceTime);


            //var task = Dispatcher.RunAsync( CoreDispatcherPriority.High, ( ) =>
            //	{
            //		tblAttendanceMsg.Text = "用户:" + fid.ToString( ) + " 签到\r\n";
            //		tblAttendanceMsg.Text = tblAttendanceMsg.Text + attendanceTime.ToString( "HH:mm:ss" );
            //	}
            //);
        }
        /// <summary>
        /// 个人信息
        /// </summary>
        /// <returns></returns>
        public ActionResult AddPerIntroduce()
        {
            string jsonTxt = "";

            try
            {
                string datasize            = Request["perInfoJson"];
                JavaScriptSerializer jss   = new JavaScriptSerializer();
                PerInfo    perInfoSize     = jss.Deserialize <PerInfo>(datasize);
                HttpCookie loginUserCookie = Request.Cookies["loginUserInfo"];
                int        userId          = Convert.ToInt32(loginUserCookie.Values["loginUserId"]);//用户的ID
                var        userInfo        = UserService.LoadEntities(u => u.ID == userId).FirstOrDefault();
                userInfo.vcNickName = perInfoSize.nickName;
                if (UserService.EditEntity(userInfo))
                {
                    var per = PersonalinformationService.LoadEntities(p => p.iUserID == userId).FirstOrDefault();
                    //把个人信息添加到数据库中
                    per.vcName              = perInfoSize.name;
                    per.cPhone              = perInfoSize.phone;
                    per.vcGender            = perInfoSize.gender;
                    per.dBirthday           = perInfoSize.birthday;
                    per.vcWeChat            = perInfoSize.wechat;
                    per.vcEmail             = perInfoSize.Email;
                    per.vcQQ                = perInfoSize.QQ;
                    per.vcHobby             = perInfoSize.hobby;
                    per.vcPersonalIntroduce = perInfoSize.introduce;
                    per.vcAddress           = perInfoSize.address;
                    per.vcMajor             = perInfoSize.major;
                    per.vcGrade             = perInfoSize.grade;
                    per.IsDel               = false;
                    if (PersonalinformationService.EditEntity(per))
                    {
                        status  = "ok";
                        result  = "添加成功";
                        jsonTxt = "{" + "\"" + "status" + "\"" + ":" + "\"" + status + "\"" + "," + "\"" + "result" + "\"" + ":" + "\"" + result + "\"" + "}";
                    }
                    else
                    {
                        status  = "no";
                        result  = "添加失败";
                        jsonTxt = "{" + "\"" + "status" + "\"" + ":" + "\"" + status + "\"" + "," + "\"" + "result" + "\"" + ":" + "\"" + result + "\"" + "}";
                    }
                }
                else
                {
                    status  = "no";
                    result  = "请先登录";
                    jsonTxt = "{" + "\"" + "status" + "\"" + ":" + "\"" + status + "\"" + "," + "\"" + "result" + "\"" + ":" + "\"" + result + "\"" + "}";
                }
            }
            catch (Exception ex)
            {
                status  = "no";
                result  = "添加失败";
                jsonTxt = "{" + "\"" + "status" + "\"" + ":" + "\"" + status + "\"" + "," + "\"" + "result" + "\"" + ":" + "\"" + result + "\"" + "}";
            }
            return(Content(jsonTxt));
        }
Exemple #3
0
        public async Task <IActionResult> Order(OnOrdViewModel viewModel)
        {
            var meal = new Meal
            {
                CheeseBurger = viewModel.CheeseBurger,
                Lasagna      = viewModel.Lasagna,
                TiriMisu     = viewModel.TiriMisu,
                CheeseCake   = viewModel.CheeseCake,
                FrenchFries  = viewModel.FrenchFries,
                Pepsi        = viewModel.Pepsi,
                Sprite       = viewModel.Sprite,
                Water        = viewModel.Water
            };

            var creditIn = new CreditIn
            {
                BillAddress   = viewModel.BillAddress,
                BillCity      = viewModel.BillCity,
                BillState     = viewModel.BillState,
                BillZip       = viewModel.BillZip,
                CreditCardNum = viewModel.CreditCardNum,
                CCV           = viewModel.CCV,
                ExpDate       = viewModel.ExpDate
            };

            var perInfo = new PerInfo
            {
                LastName  = viewModel.LastName,
                FirstName = viewModel.FirstName,
                Email     = viewModel.Email,
                Phone     = viewModel.Phone
            };

            var req = new Req
            {
                Date     = DateTime.Now,
                Meal     = meal,
                CreditIn = creditIn,
                PerInfo  = perInfo
            };

            if (ModelState.IsValid)
            {
                _context.Add(meal);
                _context.Add(creditIn);
                _context.Add(perInfo);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Report", "Home"));
            }

            //var reqs = await _context.Req
            //    .include(x => x.Meal)
            //    .include(x => x.CreditIn)
            //    .include(x => x.PerInfo)
            //    .ToListAsync();

            //foreach (var x in reqs)
            //{
            //    if ((req.PerInfo.LastName == perInfo.LastName) && (req.PerInfo.FirstName == perInfo.FirstName))
            //    {
            //        ModelState.AddModelError("LastName", "There is already an");
            //        ModelState.AddModelError("FirstName", "This first and last name already exists");
            //    }
            //}
            //return View(viewModel);

            return(View(viewModel));
        }