Example #1
0
        public ActionResult Enroll(ModelEnroll model)
        {
            if (ModelState.IsValid)
            {
                long userID = Utils.NewUID();
                string userImage = "";
                try
                {
                    //判断手机号是否报名
                    // string sql = string.Format("select count(1) from UserInfo where mobile ='{0}' ", model.mobile.Trim());
                    int alreadyNum = -1;
                    bll.CheckTelOrOpenID(model.mobile, SessionManager.OpenID, out alreadyNum);
                    if (alreadyNum < 0)
                    {
                        return View(model);
                    }
                    else
                    {
                        int index = 0;
                        foreach (string upload in Request.Files)
                        {
                            if (!Request.Files[upload].HasFile()) continue;
                            index++;
                            string path = AppDomain.CurrentDomain.BaseDirectory + ConfigurationManager.AppSettings["UploadImgPath"].ToString();
                            string filename = Path.GetFileName(Request.Files[upload].FileName);
                            string fileType = filename.Substring(filename.LastIndexOf('.') + 1);
                            //string fileName2 = Path.GetFileName(Request.Files[upload].ContentType);
                            string newFileName = Utils.NewUID() + "." + fileType;
                            Request.Files[upload].SaveAs(Path.Combine(path, newFileName));

                            // 插入到数据库
                            int imgResult = bll.InsertImg(Utils.NewUID(), userID, newFileName);
                            if (index == 1)
                            {
                                userImage = newFileName;
                            }
                        }
                        long longIP = IP.getIP_256(IP.GetWanIp());
                        int userResult = bll.InsertUserInfo(userID, SessionManager.OpenID, model.mobile, model.userName, model.jobName, string.IsNullOrEmpty(model.remarks) ? "" : model.remarks, userImage, 0, 1);
                        return RedirectToAction("Detail", new { userid = userID });
                    }

                }
                catch (Exception ex)
                {
                    Utils.CreateFile(@"/log/Home_Enroll.txt", ex.Message);
                    return View();
                }

            }
            else
            {
                return View(model);
            }
        }
Example #2
0
 public ActionResult Enroll()
 {
     ModelEnroll model = new ModelEnroll();
     model.MaxPhotoUploadNumber = int.Parse(ConfigurationManager.AppSettings["MaxPhotoUploadNumber"].ToString());
     return View(model);
 }