using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QMFrameWork.Common.Serialization;
using QMFrameWork.Data;
using QMFrameWork.WebUI.Attribute;
using QMFrameWork.WebUI.DataSource;
using QMAPP.Entity.Sys;
using QMAPP.Common.Web.Controllers;
using QMAPP.Web.Models.Sys;

namespace QMAPP.Web.Controllers
{
    /// <summary>
    /// 个性设置
    /// </summary>
    public class PersnalController : QController
    {
        #region 初始化

        /// <summary>
        /// 初始化
        /// </summary>
        /// <returns></returns>
        [HandleException]
        public ActionResult PersnalInfoSet()
        {
            PersnalSetModel model = new PersnalSetModel();
            PersnalSet info = null;

            //获取个性设置信息
            QMAPP.ServicesAgent.ServiceAgent agent = new QController().GetServiceAgent();
            info=agent.InvokeServiceFunction<PersnalSet>("PersnalSetBLL_Get");

            if (info != null)
            {
                model.CKISCOLUMNHELP = info.ISCOLUMNHELP=="1"?true:false;
                model.DEFAULTSKIN = info.DEFAULTSKIN;
                model.DEFAULTSYSTEM = info.DEFAULTSYSTEM;
            }
            else
            {
                model.CKISCOLUMNHELP = true;
                model.DEFAULTSKIN = "skin1";
                model.DEFAULTSYSTEM = "";
            }

            return View("PersnalInfoSet",model);
        }

        #endregion

        #region 保存

        [HandleException]
        public ActionResult Save(PersnalSetModel model)
        {
            PersnalSet info = new PersnalSet();
            info.DEFAULTSKIN = model.DEFAULTSKIN;
            info.DEFAULTSYSTEM = model.DEFAULTSYSTEM;
            info.ISCOLUMNHELP = model.CKISCOLUMNHELP == true ? "1" : "0";

            QMAPP.ServicesAgent.ServiceAgent agent = new QController().GetServiceAgent();
            agent.InvokeServiceFunction("PersnalSetBLL_Save",info);

            SetMessage(AppResource.SaveMessge);

            return View("PersnalInfoSet", model);
        }

        #endregion

    }
}