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

📄 useradd.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_UserAdd : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            this.CheckUserState();
            this.txtDepartment.Value = this.CurrentUser.departmentname;
            this.txtDepartmentCode.Value = this.CurrentUser.departmentcode;
        }

    }
    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.txtPassword.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.password = this.txtPassword.Text;
        user.add_date = DateTime.Now;
        user.add_user = CurrentUser.name;
        user.add_account = CurrentUser.account;
        user.inuse = this.ckbInuse.Checked;
        user.last_access_date = DateTime.Now;

        user.departmentcode = this.txtDepartmentCode.Value;
        user.departmentname = this.txtDepartment.Value;

        UserBLL bll = new UserBLL();
        if (bll.Add(user, ref msg))
        {
            this.WriteUserAction("添加用户:"+user.account);
            Response.Redirect("usermanage.aspx");
        }
        else
        {
            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 + -