⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 deptallinfo.aspx.cs

📁 本系统有两种操作用户
💻 CS
字号:
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 Module_ProRes_DeptAllInfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserName"] != null)
        {
            if (Session["Popedom"].ToString() == "0")
            {
                this.Panel1.Visible = true;
            }
        }
        else
        {
            Response.Write("<script language=javascript>top.location.href='../../Index.aspx'</script>");
        }
        if (!IsPostBack)
        {
            SqlData da = new SqlData();
            string str = Request["ID"].ToString();
            string cmdtxt1 = "select * from tb_Department where ID='" + str + "'";
            SqlCommand Com1 = new SqlCommand(cmdtxt1, da.ExceCon());
            SqlDataReader dr1 = Com1.ExecuteReader();
            dr1.Read();
            if (dr1.HasRows)
            {
                this.txtDeptName.Text = dr1["DepName"].ToString();
                this.txtDeptManager.Text = dr1["DepManager"].ToString();
                this.txtDeptAddress.Text = dr1["DepAddress"].ToString();
                this.txtDeptPhone.Text = dr1["DepPhone"].ToString();
                this.txtDescript.Text = dr1["DepDescription"].ToString();
                this.txtPostCard.Text = dr1["DepPost"].ToString();
                this.txtBaseTime.Text = Convert.ToDateTime(dr1["DepBaseTime"]).ToString("yyyy-MM-dd");
            }
            dr1.Close();

            string cmdtxt2 = "select * from tb_User";
            SqlCommand Com2 = new SqlCommand(cmdtxt2,da.ExceCon());
            SqlDataReader dr2 = Com2.ExecuteReader();
            while (dr2.Read())
            {
                this.DropDownList1.Items.Add(dr2["Name"].ToString());
            }
            dr2.Close();
        }
    }
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        this.Panel2.Visible = false;
        this.Panel3.Visible = true;

        this.btnSave.Enabled = true ;
        this.btnDelete.Enabled = true;
        this.txtBaseTime.ReadOnly = false;
        this.txtDeptAddress.ReadOnly = false;
        this.txtDeptPhone.ReadOnly = false;
        this.txtDescript.ReadOnly = false;
        this.txtPostCard.ReadOnly = false;
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string cmdtxt = "Update tb_Department set DepName='" + this.txtDeptName.Text + "',DepManager='" + this.DropDownList1.SelectedValue + "'";
        cmdtxt += ",DepPhone='" + this.txtDeptPhone.Text + "',DepBaseTime='" + this.txtBaseTime.Text + "',DepPost='" + this.txtPostCard.Text + "'";
        cmdtxt += ",DepAddress='" + this.txtDeptAddress.Text + "',DepDescription='" + this.txtDescript.Text + "' where ID='"+Request["ID"].ToString()+"'";
        SqlData da = new SqlData();
        if (da.ExceSQL(cmdtxt))
        {
            Response.Write("<script language=javascript>alert('操作成功!');location='DeptInfo.aspx'</script>");
        }
        else
        {
            Response.Write("<script language=javascript>alert('操作失败!');location='javascript:history.go(-1)'</script>");
        }

    }
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        string cmdtxt = "DELETE FROM tb_Department where ID='"+Request["ID"].ToString()+"'";
        SqlData da = new SqlData();
        if (da.ExceSQL(cmdtxt))
        {
            Response.Write("<script language=javascript>alert('操作成功!');this.parent.rightFrame.location='DeptInfo.aspx'</script>");
        }
        else
        {
            Response.Write("<script language=javascript>alert('操作失败!');location='javascript:history.go(-1)'</script>");
        }      
    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        Response.Write("<script>this.parent.rightFrame.location='DeptInfo.aspx'</script>");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -