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

📄 useredit.aspx.cs

📁 CRM管理系统 CRM管理系统
💻 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 Itsv.BLL.SystemManage;
using Itsv.Model;

public partial class SystemManage_UserEdit : PageBase
{

    /// <summary>
    /// 加载信息
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            this.CheckUserState();
            if (Request.QueryString["user_id"] != null)
            {
                UserBLL bll=new UserBLL();
                User u = bll.GetModel(int.Parse(Request.QueryString["user_id"]));
                if (u != null)
                {
                    this.txtAccount.Text = u.account;
                    this.txtName.Text = u.name;
                    this.ckbInuse.Checked = u.inuse;
                    this.lblUserID.Text = u.user_id.ToString();
                    
                    //单位信息
                    this.txtDepartment.Value = u.departmentname;
                    this.txtDepartmentCode.Value = u.departmentcode;
                }
                u = null;
                bll = null;
            }
        }
    }
    private bool CheckData()
    {
        this.msg = string.Empty;

        if (this.txtAccount.Text.Trim().Length <= 0)
            this.msg += "用户帐号不能为空\\r\\n";
        if (this.txtName.Text.Trim().Length <= 0)
            this.msg += "用户名称不能为空\\r\\n";
        if (this.txtDepartmentCode.Value.Trim().Length <= 0)
            this.msg += "所属单位部门不能为空\\r\\n";
        if (this.msg == string.Empty)
            return true;
        return false;
    }
    /// <summary>
    /// 保存修改
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (!this.CheckData())
        {
            this.ShowMessage(this.msg);
            return;
        }
        User user = new User();
        user.account = this.txtAccount.Text;
        user.name = this.txtName.Text;
        user.inuse = this.ckbInuse.Checked;
        user.user_id = int.Parse(this.lblUserID.Text);
        user.departmentcode = this.txtDepartmentCode.Value;
        user.departmentname = this.txtDepartment.Value;

        UserBLL bll = new UserBLL();
        if (bll.Update(user, ref msg))
        {
            bll = null;
            this.WriteUserAction("修改用户:"+user.account);
            Response.Redirect("usermanage.aspx");
        }
        else
        {
            bll = null;
            this.ShowMessage(this.msg);
        }
    }
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        Response.Redirect("usermanage.aspx");

    }
    /// <summary>
    /// 单位名称
    /// </summary>
    /// <returns></returns>
    public string GetCurrentName()
    {
        return this.GetEncode(this.txtDepartment.Value);
    }
    /// <summary>
    /// 单位编号
    /// </summary>
    /// <returns></returns>
    public string GetCurrentId()
    {
        return this.GetEncode(this.txtDepartmentCode.Value);
    }
    
}

⌨️ 快捷键说明

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