Exemplo n.º 1
0
        protected void btnSave_Click(object sender, ImageClickEventArgs e)
        {
            string msgs = string.Empty;
            List <YDT.Model.Sys_Setting> list = setBll.FindALL();

            foreach (YDT.Model.Sys_Setting item in list)
            {
                if (item.Setting_Key == "SendWarn")//预警格式
                {
                    item.Setting_Value = ddlSetting_Value.Text;
                    string users = txtSetting_Remarks.Text;
                    if (!users.Contains("[user]"))
                    {
                        MessageBox.Show(this, "未包含编码:[user],此编码将会被系统替换成短信接收对象的人名,所以必须包含。");
                    }
                    else if (!users.Contains("[warn]"))
                    {
                        MessageBox.Show(this, "未包含编码:[warn],此编码将会被系统替换成短信接收对象的预警事由,所以必须包含。");
                    }
                    else
                    {
                        item.Setting_Remarks = txtSetting_Remarks.Text;
                    }
                }
                else if (item.Setting_Key == "MsgFormat")//执法短信回访格式
                {
                    string users = txtSetting_Remarks2.Text;
                    if (!users.Contains("{0}"))
                    {
                        MessageBox.Show(this, "未包含编码:{0},此编码将会被系统替换为服务对象的姓名,所以必须包含。");
                    }
                    else if (!users.Contains("{1}"))
                    {
                        MessageBox.Show(this, "未包含编码:{1},此编码将会被系统替换为服务事项的名称,所以必须包含。");
                    }
                    else
                    {
                        item.Setting_Remarks = txtSetting_Remarks2.Text;
                    }
                    bool bol = setBll.Update(item, out msgs);
                    if (bol == true && users.Contains("{0}") && users.Contains("{1}") && txtSetting_Remarks.Text.Contains("[user]") && txtSetting_Remarks.Text.Contains("[warn]"))
                    {
                        MessageBox.ShowAndRedirect(this, "保存成功", "Sys_Setting.aspx");
                    }
                }
            }
        }
        /// <summary>
        /// 保存设定项目
        /// </summary>
        public void SaveConfigItemList()
        {
            string msg  = string.Empty;
            string json = string.Empty;

            if (!string.IsNullOrEmpty(Request["JSON"]))
            {
                json = Request["JSON"].ToString().Trim();
                List <Sys_Setting> listConfig = new JavaScriptSerializer().Deserialize <List <Sys_Setting> >(json);
                Sys_SettingBLL     bllSetting = new Sys_SettingBLL();
                bool flag = bllSetting.Update(listConfig);
                if (flag)
                {
                    msg = "保存成功!";

                    //#region 设置系统全局变量值

                    ////系统是否自动发送短信
                    //Sys_Setting config = listConfig.Find(p => p.Setting_Key == "AutoSendMsg");
                    //SMSHelper.Instance.IsAutoSendSMS = config.Setting_Value == "0" ? false : true;
                    ////发送短信时间起
                    //config = listConfig.Find(p => p.Setting_Key == "SendMsgFromHour");
                    //SMSHelper.Instance.SendMsgFromHour = Convert.ToInt32(config.Setting_Value);
                    ////发送短信时间止
                    //config = listConfig.Find(p => p.Setting_Key == "SendMsgToHour");
                    //SMSHelper.Instance.SendMsgToHour = Convert.ToInt32(config.Setting_Value);
                    ////短信平台账户
                    //config = listConfig.Find(p => p.Setting_Key == "SMSUSERID");
                    //SMSHelper.Instance.SMSUserID = config.Setting_Value;
                    ////短信平台密码
                    //config = listConfig.Find(p => p.Setting_Key == "SMSUSERPWD");
                    //SMSHelper.Instance.SMSUserPwd = config.Setting_Value;

                    //#endregion
                }
                else
                {
                    msg = "保存失败!原因:" + msg;
                }
            }
            Response.Write(msg);
        }