使用DotNetTextBox 为不同的用户组创建不同的文件夹
问题一、每次都不能自动进入对应的文件夹,必须自己转到相应的文件夹!代码如下:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SQLite;public partial class M_Edit_Content : System.Web.UI.Page
{
private int Id = -1;
private string Sname = ""; protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
BindUserData(Id);
ChangedUser(); }
///获取参数nId的值
if (Request.Params["Id"] != null)
{
///获取参数nId的值
if (Int32.TryParse(Request.Params["Id"], out Id) == false)
{ return;
}
}
}
public void ChangedUser()
{
if (Session["Officeid"] != null)
{
this.Label1.Text = Session["Sex"].ToString();//登陆专业名
if (this.Label1.Text == "会计专业")
{
Sname = "kuaiji";
Body.UploadFolder = "upload/" + Sname + "/"; }
if (this.Label1.Text == "市场营销")
{
Sname = "yx";//市场营销
Body.UploadFolder = "upload/" + Sname + "/"; }
if (this.Label1.Text == "电子商务")
{
Sname = "sw";//电子商务
Body.UploadFolder = "upload/" + Sname + "/"; }
if (this.Label1.Text == "工商企业管理")
{
Sname = "gs";//工商企业管理
Body.UploadFolder = "upload/" + Sname + "/"; }
if (this.Label1.Text == "数控技术")
{
Sname = "sk";//数控技术
Body.UploadFolder = "upload/" + Sname + "/"; }
if (this.Label1.Text == "电气自动化技术")
{
Sname = "dq";//电气自动化技术
Body.UploadFolder = "upload/" + Sname + "/"; }
if (this.Label1.Text == "模具设计与制造")
{
Sname = "mj";//模具设计与制造
Body.UploadFolder = "upload/" + Sname + "/"; }
}
else
{
Response.Redirect("~/Office/Office_Login.aspx");
}
} private void BindUserData(int Id)
{
DB getsing = new DB();
SQLiteDataReader dr = getsing.Getsing_Content(Id);
if (dr.Read())
{//读取数据 this.Body.Text = dr["Body"].ToString();
//this.title.Text = dr["title"].ToString();
//this.DropDownList1.Text = dr["Class_name"].ToString();
//this.DropDownList1.SelectedValue = dr["Class_Id"].ToString(); }
dr.Close();
}
protected void Save_News_Click(object sender, EventArgs e)
{
//string tilte = this.title.Text.Trim().Replace("'", "''");
string Body = this.Body.Text.Trim().Replace("'", "''");
//string Class_name = this.DropDownList1.SelectedItem.Text.ToString();//类别名称
//string Class_Id = this.DropDownList1.SelectedValue.ToString();//类别ID
string sql = "UPDATE cn_Content SET body ='" + Body + "' WHERE Id = " + Id.ToString() + " "; DB.execnonsql(sql);
Page.ClientScript.RegisterStartupScript(this.GetType(), "Startup", "<script>alert('您已成功保存数据,系统将返回首页!');window.location.href='Management_Content.aspx'</script>");//无刷新弹出对话框
return;
}
}
问题一、每次都不能自动进入对应的文件夹,必须自己转到相应的文件夹!代码如下:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SQLite;public partial class M_Edit_Content : System.Web.UI.Page
{
private int Id = -1;
private string Sname = ""; protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
BindUserData(Id);
ChangedUser(); }
///获取参数nId的值
if (Request.Params["Id"] != null)
{
///获取参数nId的值
if (Int32.TryParse(Request.Params["Id"], out Id) == false)
{ return;
}
}
}
public void ChangedUser()
{
if (Session["Officeid"] != null)
{
this.Label1.Text = Session["Sex"].ToString();//登陆专业名
if (this.Label1.Text == "会计专业")
{
Sname = "kuaiji";
Body.UploadFolder = "upload/" + Sname + "/"; }
if (this.Label1.Text == "市场营销")
{
Sname = "yx";//市场营销
Body.UploadFolder = "upload/" + Sname + "/"; }
if (this.Label1.Text == "电子商务")
{
Sname = "sw";//电子商务
Body.UploadFolder = "upload/" + Sname + "/"; }
if (this.Label1.Text == "工商企业管理")
{
Sname = "gs";//工商企业管理
Body.UploadFolder = "upload/" + Sname + "/"; }
if (this.Label1.Text == "数控技术")
{
Sname = "sk";//数控技术
Body.UploadFolder = "upload/" + Sname + "/"; }
if (this.Label1.Text == "电气自动化技术")
{
Sname = "dq";//电气自动化技术
Body.UploadFolder = "upload/" + Sname + "/"; }
if (this.Label1.Text == "模具设计与制造")
{
Sname = "mj";//模具设计与制造
Body.UploadFolder = "upload/" + Sname + "/"; }
}
else
{
Response.Redirect("~/Office/Office_Login.aspx");
}
} private void BindUserData(int Id)
{
DB getsing = new DB();
SQLiteDataReader dr = getsing.Getsing_Content(Id);
if (dr.Read())
{//读取数据 this.Body.Text = dr["Body"].ToString();
//this.title.Text = dr["title"].ToString();
//this.DropDownList1.Text = dr["Class_name"].ToString();
//this.DropDownList1.SelectedValue = dr["Class_Id"].ToString(); }
dr.Close();
}
protected void Save_News_Click(object sender, EventArgs e)
{
//string tilte = this.title.Text.Trim().Replace("'", "''");
string Body = this.Body.Text.Trim().Replace("'", "''");
//string Class_name = this.DropDownList1.SelectedItem.Text.ToString();//类别名称
//string Class_Id = this.DropDownList1.SelectedValue.ToString();//类别ID
string sql = "UPDATE cn_Content SET body ='" + Body + "' WHERE Id = " + Id.ToString() + " "; DB.execnonsql(sql);
Page.ClientScript.RegisterStartupScript(this.GetType(), "Startup", "<script>alert('您已成功保存数据,系统将返回首页!');window.location.href='Management_Content.aspx'</script>");//无刷新弹出对话框
return;
}
}
Body.UploadFolder = "upload//" + Sname + "//";
WebEditor1.UploadConfig =Sname + ".config";
WebEditor1.UploadFolder = "upload/" + Sname + "/
看看参考