protected void GetUser(int id) { //UserGroup ugbll = new UserGroup(); //ddlUserGroup.DataSource = ugbll.GetUserGroupList("").Tables[0]; //ddlUserGroup.DataTextField = "USERGROUPNAME"; //ddlUserGroup.DataValueField = "USERGROUPID"; //ddlUserGroup.DataBind(); User bll = new User(); SF_User model = new SF_User(); model = bll.GetUserModel(id); uid.Text = id.ToString(); txtUserName.Text = model.UserName; ddlUserGroup.SelectedValue = model.UserGroupID.ToString(); txtPsnNumber.Text = model.PersonNumber; ddlState.SelectedValue = model.UserStatus.ToString(); lblRegTime.Text = model.CreateTime.ToString(); List <string> rid = model.Role; for (int i = 0; i < rid.Count; i++) { string[] r = rid[i].ToString().Split(','); lstRole.Items.Add(new ListItem(r[1], r[0])); } }
protected void btnAddPerson_Click(object sender, EventArgs e) { User usersCrud = new User(); SF_User user = new SF_User(); if (txtPwd.Text != "" && ddlUserGroup.SelectedValue != "-1") { int usercount = 0; string userName = ""; user.PassWord = SecurityEncryption.MD5(txtPwd.Text.Trim(), 32); int roleID = 0; roleID = Convert.ToInt32(ddlRole.SelectedValue); user.UserGroupID = Convert.ToInt32(ddlUserGroup.SelectedValue); user.UserStatus = ddlState.SelectedValue; for (int i = 0; i < xlstSelected.Items.Count; i++) { user.UserName = xlstSelected.Items[i].Value.ToString(); user.PersonNumber = xlstSelected.Items[i].Value.ToString(); if (!usersCrud.UserExists(user.UserName)) { int n = (int)usersCrud.CreateUser(user); if (n >= 1) { if (roleID != 0) { usersCrud.AddUserRole(n, roleID); } } usercount++; } else { userName += user.UserName + ","; } } JSHelper.Alert(string.Format("共添加{0}个用户!", usercount), this); } else { JSHelper.Alert("初始化信息请填写完整!", this); } }
protected void btnOK_Click(object sender, EventArgs e) { User bll = new User(); SF_User model = new SF_User(); model.UserID = int.Parse(uid.Text); model.UserName = txtUserName.Text; model.UserGroupID = int.Parse(ddlUserGroup.SelectedItem.Value); model.UserStatus = ddlState.SelectedItem.Value; if (bll.UpdateUser(model) >= 1) { strinfo.InnerHtml = JSHelper.ErrInfo("用户信息更新成功!"); strinfo.Visible = true; } else { strinfo.InnerHtml = JSHelper.ErrInfo("用户信息更新失败!"); strinfo.Visible = true; } }
protected void btnSure_Click(object sender, EventArgs e) { if (upctrlPsn.UploadedFiles[0].IsValid && upctrlPsn.HasFile) { commonFunc.SaveFile(upctrlPsn, this); string savePath = commonFunc.GetSavePath(upctrlPsn, this); Aspose.Cells.Workbook xlsPsn = new Aspose.Cells.Workbook(savePath); //xlsPsn.Open(savePath); Aspose.Cells.Cells cellsPsn = xlsPsn.Worksheets[0].Cells; var dtTemp = cellsPsn.ExportDataTable(0, 0, cellsPsn.MaxDataRow + 1, cellsPsn.MaxDataColumn + 1); User usersCrud = new User(); SF_User user = new SF_User(); if (ddlUserGroup.SelectedValue != "-1" && ddlRole.SelectedValue != "-1") { int usercount = 0; int usercount2 = 0; string userName = ""; user.PassWord = SecurityEncryption.MD5("123456", 32); int roleID = 0; roleID = Convert.ToInt32(ddlRole.SelectedValue); user.UserGroupID = Convert.ToInt32(ddlUserGroup.SelectedValue); for (int i = 1; i < dtTemp.Rows.Count; i++) { user.UserName = dtTemp.Rows[i][0].ToString().Trim(); user.PersonNumber = dtTemp.Rows[i][0].ToString().Trim(); if (!usersCrud.UserExists(user.UserName)) { int n = (int)usersCrud.CreateUser(user); if (n >= 1) { if (roleID != 0) { usersCrud.AddUserRole(n, roleID); } } usercount++; } else { if (cellsPsn.Columns.Count >= 3 && dtTemp.Rows[i][3].ToString().Trim() != "") { SF_User user2 = usersCrud.GetUserModel(user.UserName); user2.UserName = dtTemp.Rows[i][3].ToString().Trim(); int n2 = (int)usersCrud.UpdateUser(user2); if (n2 >= 1) { usercount2++; } } userName += user.UserName + ","; } } commonFunc.DeleteFile(savePath); JSHelper.Alert(string.Format("共添加{0}个用户!共更新{1}个用户!", usercount, usercount2), this); } else { JSHelper.Alert("初始化信息请填写完整!", this); } } }
private void LoginVerify(string username, string pwd) { User userCrud = new User(); SF_User user = new SF_User(); if (userCrud.CheckLogin(username, pwd)) { user = userCrud.GetUserModel(username); var ds = userCrud.GetUserList2(string.Format("USERNAME='******'", username), "").Tables[0].Select(); if (ds[0]["USERSTATUS"].ToString() == "1") { //验证许可证 //LicHelper.LicHelper lic = new LicHelper.LicHelper(); //if (lic.CheckLicStatus()) //{ //string macid = lic.GetMachineCode(); //if (lic.IsMachine(macid)) //{ // if (lic.ContainDept(ds[0]["LEVELID"].ToString(), ds[0]["DEPTNAME"].ToString())) // { List <string> lst = new List <string>(); try { userCrud.UpdateLoginTime(Convert.ToDecimal(ds[0]["USERID"])); } catch { } SessionBox.CreateUserSession(new UserSession(Convert.ToDecimal(ds[0]["USERID"]), ds[0]["USERNAME"].ToString(), user.Role, null, ds[0]["LEVELID"].ToString(), user.UserGroupID, user.PersonNumber, ds[0]["NAME"].ToString(), ds[0]["DEPTNUMBER"].ToString(), ds[0]["DEPTNAME"].ToString(), user.UserStatus)); try { GhtnTech.SecurityFramework.BLL.LogManager.WriteLog(SessionBox.GetUserSession().PersonNumber, SessionBox.GetUserSession().LoginName, GetUserIP(), DateTime.Now, GhtnTech.SecurityFramework.BLL.ActiveType.登录, "", ""); } catch { } if (Request.Params["txtUrl"] != null) { Response.Redirect("~/MainFrame.aspx?txtUrl=" + Request.Params["txtUrl"].ToString().Trim()); } else { Response.Redirect("~/MainFrame.aspx"); } // } // else // { // JSHelper.AlertAndClose(UpdatePanel1, this, "您矿未获得授权。请联系管理员取得授权后再使用!"); // } //} //else //{ // JSHelper.AlertAndClose(UpdatePanel1, this, "您目前使用的服务器未获得授权。请联系管理员取得授权后再使用!"); //} //} //else //{ // if (ds[0]["LEVELID"].ToString().Contains('1') || ds[0]["LEVELID"].ToString().Contains('0')) // { // //Response.Redirect("UpdateLic.aspx", true); // //JSHelper.AlertAndRedirect(UpdatePanel1, "许可证已经过期!", "UpdateLic.aspx", this); // JSHelper.ShowModalDialogWindow(UpdatePanel1,this,"UpdateLic.aspx",800,500,100,200); // } // else // { // JSHelper.AlertAndClose(UpdatePanel1, this, "许可证已经过期!请联系管理员取得更新授权后再使用!"); // } //} // //Response.Redirect("~/Default.aspx"); } else { JSHelper.Alert(UpdatePanel1, this, "用户被锁定,请与管理员联系!"); } } else { JSHelper.Alert(UpdatePanel1, this, "用户名或密码错误!"); } }