Exemplo n.º 1
0
        public ActionResult feedback(managerModel mm, FormCollection form)
        {
            headdisplay();
            IRecaptcha <RecaptchaV2Result> recaptcha = new RecaptchaV2(new RecaptchaV2Data()
            {
                Secret = "6LfBriQTAAAAANGF9w6CrSl_8yksdNy9dNi7Xp9R"
            });

            // Verify the captcha
            var result = recaptcha.Verify();

            if (mm.FBName_p != "" && mm.FBcontent_p != "" && mm.FBmail_p != null &&
                mm.FBName_p != null && mm.FBcontent_p != null && result.Success == true)
            {
                int count = 0;
                try
                {
                    string sqlstr       = @"INSERT INTO localsql.feedback(
                                    idfeedback,Name,content,phone,mail
                                )VALUES(
                                   @idfeedback,@Name,@content,@phone,@mail)",
                           sqlstrselect = @"SELECT idfeedback FROM localsql.feedback";
                    count = selectCount(count, sqlstrselect);
                    MySqlConnection con = new MySqlConnection(sqlconStr);
                    MySqlCommand    link;
                    con.Open();
                    link             = con.CreateCommand();
                    link.CommandText = sqlstr;

                    link.Parameters.Clear();
                    link.Parameters.AddWithValue("idfeedback", count + 1);
                    link.Parameters.AddWithValue("Name", mm.FBName_p);
                    link.Parameters.AddWithValue("content", mm.FBcontent_p);
                    link.Parameters.AddWithValue("phone", mm.FBphone_p);
                    link.Parameters.AddWithValue("mail", mm.FBmail_p);
                    link.ExecuteNonQuery();
                    con.Close();
                }
                catch (Exception ex) { }
                TempData["message"] = "送出成功";
                return(RedirectToAction("index"));
            }
            else
            {
                ViewBag.msg = "0";
                return(View());
            }
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            string[] imgpath = { "" };
            headdisplay();
            managerModel mm = new managerModel();

            ViewBag.noticeTitle = selectsql("SELECT * FROM localsql.notice order by date desc", new[] { "type", "title" }, 0, 5);
            ViewBag.link        = selectsql("SELECT * FROM localsql.link ", new[] { "Img", "linkweb" }, 0, 5);

            int             count = 0, rows = 0;
            MySqlConnection con = new MySqlConnection(sqlconStr);
            MySqlCommand    link;

            con.Open();
            link             = con.CreateCommand();
            link.CommandText = "SELECT * FROM localsql.album_address";
            MySqlDataReader read = link.ExecuteReader();

            count = 0;
            Array.Resize(ref imgpath, imgpath.Length);
            while (read.Read())
            {
                if (count != int.Parse(read["album_AlbumCount"].ToString()))
                {
                    imgpath[count] = (read["album_AlbumCount"]).ToString() + "/" + read["ImgAddress"].ToString();
                    count++;
                    Array.Resize(ref imgpath, imgpath.Length + 1);
                }
                if (count > 4)
                {
                    break;
                }
            }
            Array.Resize(ref imgpath, imgpath.Length - 1);
            con.Close();
            ViewBag.albumImg = imgpath;

            ViewBag.headTurnImg = selectTurnImg();
            return(View());
        }