CeramicProject/newyt/Module_data/msg_set.aspx.cs

132 lines
4.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.IO;
using Ajax;
public partial class MContent_msg_set : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) {
Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(Session["user"]);
pdquanxianbj(user.juese);
DataTable dt = DBHlper.Execute("select top 1 * from nr_z_msgset").Tables[0];
string formstate=dt.Rows[0]["formstate"].ToString();
string videostate = dt.Rows[0]["videostate"].ToString();
if (formstate == "0")
{
rdoform_yes.Checked = false;
rdoform_no.Checked = true;
}
else if (formstate == "1")
{
rdoform_yes.Checked = true;
rdoform_no.Checked = false;
}
if (videostate == "0")
{
rdosound_yes.Checked = false;
rdosound_no.Checked = true;
}
else if (videostate == "1")
{
rdosound_yes.Checked = true;
rdosound_no.Checked = false;
}
DataTable videodt = DBHlper.Execute("select * from nr_z_video").Tables[0];
rep_date.DataSource = videodt;
rep_date.DataBind();
}
Utility.RegisterTypeForAjax(typeof(MContent_msg_set));
}
protected void btn_saveclick(object o, EventArgs e)
{
try
{
string formstate = "";
string videostate = "";
if (rdoform_yes.Checked)
{
formstate = "1";
}
if (rdoform_no.Checked)
{
formstate = "0";
}
if (rdosound_yes.Checked)
{
videostate = "1";
}
if (rdosound_no.Checked)
{
videostate = "0";
}
string filelength = string.Empty;
string contenttype = string.Empty;
if (file_video.PostedFile.FileName != "")
{
string[] fname = file_video.PostedFile.FileName.Split('.');
string filename = file_video.FileName;
string aUrl = Server.MapPath("~\\fujian\\video");
if (!Directory.Exists(aUrl))
Directory.CreateDirectory(aUrl);
string ionam = aUrl + "\\" + filename;
if (!File.Exists(ionam))
{
file_video.SaveAs(aUrl + "\\" + filename);//存储文件到磁盘
}
DBHlper.excutecmd("insert into nr_z_video values ('" + filename + "','" + DateTime.Now + "',0)");
}
DBHlper.excutecmd("update nr_z_msgset set formstate='" + formstate + "',videostate='" + videostate + "'");
Response.Redirect("msg_set.aspx");
}
catch (Exception ex)
{
Response.Redirect("msg_set.aspx");
}
}
public string ckeckqy(string qyval)
{
string ck = "";
if (qyval == "1")
{
ck = "checked";
}
return ck;
}
//修改提示音状态
[Ajax.AjaxMethod]
public void setvideo(int id)
{
DBHlper.excutecmd("update nr_z_video set isqiyong=0");
DBHlper.excutecmd("update nr_z_video set isqiyong=1 where id="+id);
}
//删除提示音
[Ajax.AjaxMethod]
public void delvideo(int id)
{
DBHlper.excutecmd("delete from nr_z_video where id=" + id);
}
#region
void pdquanxianbj(int juese)
{
Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(Session["user"]);
if (DBHlper.getzt(user.id) != 1)
{
Response.Redirect("../index.aspx");
}
if (DBHlper.GetPermission(juese, "系统提醒", "nr_z_msgset", "查看全部") == false)
{
Response.Redirect("../Common/nopower.htm");
}
}
#endregion
}