//加载数据 private void LoadData() { //绑定修改前数据 condition.Append("ID='").Append(Request.QueryString["ID"].ToString()).Append("'"); BLL.vw_SYS_Account bllAccount_vw = new BLL.vw_SYS_Account(); DataTable dtAccount = bllAccount_vw.GetList(condition.ToString()).Tables[0]; txbAccountName.Text = dtAccount.Rows[0]["AccountName"].ToString(); txbPassword.Text = dtAccount.Rows[0]["Password"].ToString(); tgbRoleName.Text = dtAccount.Rows[0]["RoleName"].ToString(); hdfRoleID.Text = dtAccount.Rows[0]["RoleID"].ToString(); }
//登录事件 protected void btnLogin_Click(object sender, EventArgs e) { //检测账户信息是否正确 BLL.vw_SYS_Account bllAccount_vw = new BLL.vw_SYS_Account(); string strWhere = "AccountName='" + txbUserName.Text + "' and Password='******'"; DataSet dsAccount = bllAccount_vw.GetList(strWhere); if (dsAccount.Tables[0].Rows.Count > 0) { Session["AccountName"] = txbUserName.Text; Session["AccountID"] = dsAccount.Tables[0].Rows[0]["ID"].ToString(); Session["RoleName"] = dsAccount.Tables[0].Rows[0]["RoleName"].ToString(); Alert.ShowInTop("登陆成功!", "提示信息", MessageBoxIcon.Information, "location.href='Default.aspx';"); return; } else { Alert.ShowInTop("用户名不存在 或 密码错误!", "提示信息", MessageBoxIcon.Warning); } #region 是否为系统初始账户 if (txbUserName.Text == "YJQ" && txbPassword.Text == "1111") { Model.tb_SYS_Account modelAccount = new Model.tb_SYS_Account(); modelAccount.ID = Guid.NewGuid().ToString(); modelAccount.AccountName = txbUserName.Text; modelAccount.Password = txbPassword.Text; modelAccount.AccountType = "0"; modelAccount.CreateID = modelAccount.ID; modelAccount.CreateTime = DateTime.Now; modelAccount.State = "1"; BLL.tb_SYS_Account bllAccount = new BLL.tb_SYS_Account(); bool result = bllAccount.Add(modelAccount); if (!result) { Alert.ShowInTop("初始账户添加失败!", "提示信息", MessageBoxIcon.Error); } else { Alert.ShowInTop("成功添加初始账户!", "提示信息", MessageBoxIcon.Information, "location.href='Default.aspx';"); } } #endregion }