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/
///
/// 设置系统参数
///
///
#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 提交数据
///
/// 保存
///
/// AppID
/// Secret
/// Token
///
[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
}
}