123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using LeaRun.Application.Web.Common;
- namespace LeaRun.Application.Web.Areas.WeChatManage.Controllers
- {
- public class SetParamsController : MvcControllerBase
- {
- //
- // GET: /WeChatManage/SetParams/
- /// <summary>
- /// 设置系统参数
- /// </summary>
- /// <returns></returns>
- #region 视图功能
- public ActionResult Index()
- {
- //定义变量
- String AppId = "";
- String Secret = "";
- String Token = "";
- String sql = "SELECT AppId,[Secret],Token FROM BCS_WxAccessToken";
- //从数据库中获取数据
- DataTable dt = SqlHelper.ExecuteDataTable(sql, CommandType.Text, null);
- if (dt.Rows.Count > 0)
- {
- AppId = dt.Rows[0]["AppId"].ToString();
- Secret = dt.Rows[0]["Secret"].ToString();
- Token = dt.Rows[0]["Token"].ToString();
- }
- ViewBag.AppId = AppId;
- ViewBag.Secret = Secret;
- ViewBag.Token = Token;
- return View();
- }
- #endregion
- #region 提交数据
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="CorpId">AppID</param>
- /// <param name="CorpSecret">Secret</param>
- /// <param name="Token">Token</param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveForm(string CorpId, string CorpSecret, String Token)
- {
- //定义变量
- String Sql = "UPDATE BCS_WxAccessToken SET AppId = '" + CorpId + "',[Secret] = '" + CorpSecret + "',Token = '" + Token +"'";
- int num = SqlHelper.ExecuteNonQuery(Sql, CommandType.Text, null);
- if (num > 0)
- {
- return Success("操作成功。");
- }
- else
- {
- return Error("保存失败.");
- }
- }
- #endregion
- }
- }
|