dir_add.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:3k
源码类别:
OA系统
开发平台:
ASP/ASPX
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.Data.SqlClient;
- public partial class web_regulation_dir_add : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (Session["dir_id"] != null)
- {
- ParentId.Value = Session["dir_id"].ToString();
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select name from OA_SYS_CHILD_MENU where id="+Session["dir_id"].ToString(), conn);
- LblLastDir.Text = cmd.ExecuteScalar().ToString();
- conn.Close();
- }
- }
- protected void BtnOk_Click(object sender, EventArgs e)
- {
- try
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- int sequence = 1;
- int id = 1;
- SqlCommand cmd = new SqlCommand("select max(sequence) from OA_SYS_CHILD_MENU where parent_id=" + ParentId.Value, conn);
- try
- {
- sequence = Convert.ToInt32(cmd.ExecuteScalar()) + 1;
- }
- catch { }
- cmd = new SqlCommand("select max(id) from OA_SYS_CHILD_MENU", conn);
- try
- {
- id = Convert.ToInt32(cmd.ExecuteScalar()) + 1;
- }
- catch { }
- string user = "";
- if (Session["user"] != null)
- {
- user = ((User)Session["user"]).Emp_name;
- }
- DateMgr mgr = new DateMgr();
- string time = mgr.getDateTime();
- string sql = "insert into OA_SYS_CHILD_MENU(id, name, description, menu_url, parent_id, target, sequence, " +
- "cre_user, cre_date, is_dir) values(" + id + ", '" + TxtName.Text + "','" + TxtDescription.Text +
- "','regulation/file_list_view.aspx?dir_id=" + id + "','" + ParentId.Value + "','mainFrame'," + sequence + ", '" +
- user + "', '" + time + "','Y')";
- cmd = new SqlCommand(sql, conn);
- cmd.ExecuteNonQuery();
- conn.Close();
- TxtDescription.Text = "";
- TxtName.Text = "";
- //刷新樹
- Response.Write("<script language='javascript'>window.parent.window.parent.frames.leftFrame.location.reload();location.href='dir_list.aspx'</script>");
- }
- catch (Exception ex)
- {
- Response.Write(ex.Message);
- }
- }
- }