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

📄 useroption.ascx.cs

📁 某个公司需要维持良好的客户关系
💻 CS
字号:
namespace CRM.Web.Controls
{
	using System;
	using System.Data;
	using System.Drawing;
	using System.Web;
	using CRM.Model;
	using System.Web.UI.WebControls;
	using System.Web.UI.HtmlControls;

	/// <summary>
	///		UserOption 的摘要说明。
	/// </summary>
	public class UserOption : CRM.Web.Utility.UserControlBase
	{
		protected System.Web.UI.WebControls.Label Msg;
		protected System.Web.UI.WebControls.TextBox LoginName;
		protected System.Web.UI.WebControls.Button CheckUserLoginName;
		protected System.Web.UI.WebControls.TextBox LoinPwd;
		protected System.Web.UI.WebControls.RequiredFieldValidator Requiredfieldvalidator1;
		protected System.Web.UI.WebControls.TextBox LoginCheckPwd;
		protected System.Web.UI.WebControls.RequiredFieldValidator Requiredfieldvalidator2;
		protected System.Web.UI.WebControls.TextBox UserNickName;
		protected System.Web.UI.WebControls.RequiredFieldValidator Requiredfieldvalidator3;
		protected System.Web.UI.WebControls.DropDownList Sex;
		protected System.Web.UI.WebControls.TextBox Birthday;
		protected System.Web.UI.WebControls.DropDownList Month;
		protected System.Web.UI.WebControls.DropDownList Day;
		protected System.Web.UI.WebControls.TextBox MobilePhone;
		protected System.Web.UI.WebControls.RegularExpressionValidator Regularexpressionvalidator7;
		protected System.Web.UI.WebControls.TextBox Phone;
		protected System.Web.UI.WebControls.RegularExpressionValidator Regularexpressionvalidator1;
		protected System.Web.UI.WebControls.TextBox Email;
		protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator4;
		protected System.Web.UI.WebControls.TextBox PostCode;
		protected System.Web.UI.WebControls.RegularExpressionValidator Regularexpressionvalidator2;
		protected System.Web.UI.WebControls.TextBox Address;
		protected System.Web.UI.WebControls.Button UserInfo_Submit;
		protected System.Web.UI.WebControls.Button UserInfo_Reset;
		protected System.Web.UI.HtmlControls.HtmlTextArea BZ;

		protected CRM.Model.UserPower power;
		protected CRM.Model.Parameter parms;
		protected CRM.Model.SysRoleInfo role = new CRM.Model.SysRoleInfo();
		protected System.Web.UI.WebControls.DropDownList UserRole;
		protected CRM.Model.SysUserInfo user = new CRM.Model.SysUserInfo();

		private void Page_Load(object sender, System.EventArgs e)
		{
			this.parms = base.GetRequestParm();
			this.power = base.GetUserPower(this.parms);
			this.CheckUserLoginName.Enabled=false;
			this.LoginName.Enabled=false;
			this.LoinPwd.Visible = false;
			this.LoginCheckPwd.Visible = false;
			this.Requiredfieldvalidator1.Enabled = false;
			this.Requiredfieldvalidator2.Enabled = false;
	
			if (parms.Action == "Read")
			{
				this.PageDateBind("Read");
				
				this.LoginCheckPwd.Visible = false;
				this.PageControlsVisible(false);
			}
			else if (parms.Action == "Update")
			{
				this.PageDateBind("Update");
				this.PageControlsVisible(true);
			}
			else if (parms.Action == "Add")
			{
				this.CheckUserLoginName.Enabled = true;
				this.LoginName.Enabled=true;
				this.LoinPwd.Visible = true;
				this.LoginCheckPwd.Visible = true;
				this.Requiredfieldvalidator1.Enabled = true;
				this.Requiredfieldvalidator2.Enabled = true;
				this.PageControlsVisible(true);
			}	
			this.UserRole.DataSource=BLL.SysRole.GetAllSysRole();
			this.UserRole.DataTextField="RoleName";
			this.UserRole.DataValueField="RoleId";
			this.UserRole.DataBind();
		}

		#region 页面导航
		protected void GetWebNavigate()
		{
			this.Response.Write(base.InitWebNavigate(this.parms));
		}
		#endregion

		#region 页面控件数据绑定
		protected void PageDateBind(string option)
		{
			this.user = BLL.SysUser.GetSysUserById(this.parms.ItemId);
			if (!Page.IsPostBack)
			{
				this.LoginName.Text = this.user.LoginName;
				this.UserNickName.Text = this.user.TrueName;
				this.UserRole.SelectedValue = BLL.SysUser.GetUserRoleById(this.parms.ItemId).RoleId;
				this.Sex.SelectedValue = this.user.Sex.Trim();
				if (this.user.Birthday.Length ==10)
				{
					this.Birthday.Text = this.user.Birthday.Substring(0,4);
					this.Month.SelectedValue = this.user.Birthday.Substring(5,2);
					this.Day.SelectedValue = this.user.Birthday.Substring(8,2);
				}
				this.MobilePhone.Text = this.user.MobilePhone.Trim();
				this.Phone.Text = this.user.Phone.Trim();
				this.Email.Text = this.user.Email.Trim();
				this.PostCode.Text = this.user.PostCode.Trim();
				this.Address.Text = this.user.Address;
				this.BZ.Value = this.user.BZ;
			}
		}
		#endregion

		#region 页面数据收集
		protected void PagePageCollectData()
		{
			this.user.LoginName = this.LoginName.Text;
			this.user.LoginPwd = this.LoinPwd.Text;
			this.user.TrueName = this.UserNickName.Text;
			this.role.RoleId = this.UserRole.SelectedValue;
			this.user.Sex = this.Sex.SelectedValue;
			if (this.Birthday.Text != "")
			{
				this.user.Birthday = this.Birthday.Text +"-"+ this.Month.SelectedValue +"-"+ this.Day.SelectedValue;
			}
			this.user.MobilePhone = this.MobilePhone.Text;
			this.user.Phone = this.Phone.Text;
			this.user.Email = this.Email.Text;
			this.user.PostCode = this.PostCode.Text;
			this.user.Address = this.Address.Text;
			this.user.BZ = this.BZ.Value;
		}
		#endregion

		#region 输入数据验证
		protected bool PageInputCheck()
		{
			if (Page.IsValid == true)
			{return true;}
			else
			{return false;}
		}
		#endregion

		#region 页面控件可编辑性设置
		protected void PageControlsVisible(bool visible)
		{
			if (visible == false)
			{
				this.UserInfo_Submit.Enabled = false;
				this.UserInfo_Reset.Enabled = false;
			}

		}
		#endregion

		#region 页面提示信息设置
		protected void PageMsgDisplay(string msg)
		{
			this.Msg.Text = msg;
		}
		#endregion

		#region 用户帐号检测
		private void CheckUserLoginName_Click(object sender, System.EventArgs e)
		{
			try
			{
				if (this.LoginName.Text.Trim() != "")
				{
					if ((BLL.SysUser.GetAllSysUser().Select("LoginName ='"+this.LoginName.Text.Trim()+"'")).Length==0)
						this.Msg.Text ="恭喜您,此帐号可以使用!";
					else
						this.Msg.Text ="对不起,该帐号已经被使用!";
				}
				else
				{this.Msg.Text="对不起,被检测帐号不能为空!";}
			}
			catch
			{}
		}
		#endregion

		#region 添加修改用户信息
		private void UserInfo_Submit_Click(object sender, System.EventArgs e)
		{
			if (this.PageInputCheck() == true)
			{
				this.PagePageCollectData();
				if (parms.Action == "Add")
				{
					if (base.SysUserOption("Add",this.user,this.role.RoleId,this.parms)==base.AddSucceed)
					{this.Msg.Text =base.AddSucceed;}
					else
					{this.Msg.Text=base.AddFailed;}
				
				}
				else if (parms.Action == "Update")
				{
					if (base.SysUserOption("Update",this.user,this.role.RoleId,this.parms)==base.UpdateSucceed)
					{this.Msg.Text=base.UpdateSucceed;}
					else
					{this.Msg.Text=base.UpdateFailed;}
				}
			}
		}
		#endregion

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		///		设计器支持所需的方法 - 不要使用代码编辑器
		///		修改此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.CheckUserLoginName.Click += new System.EventHandler(this.CheckUserLoginName_Click);
			this.UserRole.SelectedIndexChanged += new System.EventHandler(this.UserRole_SelectedIndexChanged);
			this.UserInfo_Submit.Click += new System.EventHandler(this.UserInfo_Submit_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void UserRole_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}
	}
}

⌨️ 快捷键说明

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