protected void ImportFromExcelToCreate(DataSet ds) { try { System.Data.DataTable dt = ds.Tables[0]; int nAll = dt.Rows.Count; int nCreate = 0; int nExist = 0; foreach (System.Data.DataRow dr in dt.Rows) { if (dr["SelectX"].ToString().ToLower() == "x") { string userid = Guid.NewGuid().ToString(); string usercode = dr["UserCode"].ToString().Trim(); //判断是否存在 if (KPI_UserDal.UserCodeExist(usercode, userid)) { nExist += 1; continue; } string username = dr["UserName"].ToString().Trim(); string userdesc = dr["UserDesc"].ToString().Trim(); string userpassword = KPI_UserDal.GetDESString(dr["UserPassword"].ToString().Trim()); string useremail = dr["UserEmail"].ToString().Trim(); string userphone = dr["UserPhone"].ToString().Trim(); string usertitle = dr["UserTitle"].ToString().Trim(); string usergroups = ""; int userisvalid = int.Parse(dr["UserIsValid"].ToString().Trim()); string usernote = dr["UserNote"].ToString().Trim(); string usercreatetime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); //string usermodifytime = usercreatetime; KPI_UserEntity usMenu = new KPI_UserEntity(); usMenu.UserID = userid; usMenu.UserCode = usercode; usMenu.UserName = username; usMenu.UserDesc = userdesc; usMenu.UserPassword = userpassword; usMenu.UserEMail = useremail; usMenu.UserPhone = userphone; usMenu.UserTitle = usertitle; usMenu.UserGroups = usergroups; usMenu.UserIsValid = userisvalid; usMenu.UserNote = usernote; usMenu.UserCreateTime = usercreatetime; usMenu.UserModifyTime = usercreatetime; if (KPI_UserDal.Insert(usMenu)) { nCreate += 1; } } } string strInfor = "用户总数:{0}个, 创建成功:{1}个,已存在用户: {2}个。"; strInfor = string.Format(strInfor, nAll, nCreate, nExist); MessageBox.popupClientMessage(this.Page, strInfor, "call();"); BindGrid(); return; } catch (Exception) { // //MessageBox.popupClientMessage(this.Page, ee.Message, "call();"); return; } }
protected bool UserUpdate() { string userid = ViewState["userid"].ToString(); KPI_UserEntity usEntity = new KPI_UserEntity(); usEntity.UserID = userid; usEntity.UserName = tbxUserCode.Text.Trim(); usEntity.UserEMail = tbxUserEMail.Text.Trim(); usEntity.UserPhone = tbxUserPhone.Text.Trim(); usEntity.UserTitle = tbxUserTitle.Text.Trim(); usEntity.UserGroups = lblUserGroups.Text.Trim(); usEntity.UserIsValid = int.Parse(rblUserIsValid.SelectedValue); if (KPI_UserDal.Update(usEntity)) { MessageBox.popupClientMessage(this.Page, "修改成功!", "call();"); return true; } else { MessageBox.popupClientMessage(this.Page, "修改失败!", "call();"); return false; } }
protected void btnConfirm_Click(object sender, EventArgs e) { string userid = ViewState["userid"].ToString(); string usercode = tbxUserCode.Text.Trim(); //是否特殊用户sisdemo不能修改;sisadmin可以修改 if (usercode.ToUpper() == "SISDEMO") { MessageBox.popupClientMessage(this.Page, "无权修改sisdemo用户!", "call();"); return; } //不能为空 if (tbxUserP1.Text.Trim()=="") { tbxUserPassword.Text = ""; tbxUserP1.Text = ""; tbxUserP2.Text = ""; MessageBox.popupClientMessage(this.Page, "新密码不能为空!", "call();"); return; } string username = tbxUserName.Text.Trim(); string oldpassword = KPI_UserDal.GetUserPassword(userid); string userpassword = KPI_UserDal.GetDESString(tbxUserPassword.Text.Trim()); string newpassword = KPI_UserDal.GetDESString(tbxUserP1.Text.Trim()); string userp1 = tbxUserP1.Text.Trim(); string userp2 = tbxUserP2.Text.Trim(); string useremail = tbxUserEMail.Text.Trim(); string userphone = tbxUserPhone.Text.Trim(); string usertitle = tbxUserTitle.Text.Trim(); //判断用户是否为空 if (username == "") { tbxUserPassword.Text = ""; tbxUserP1.Text = ""; tbxUserP2.Text = ""; MessageBox.popupClientMessage(this.Page, "用户姓名都不能空!", "call();"); return; } //判断旧密码是否正确 if (oldpassword != userpassword) { tbxUserPassword.Text = ""; tbxUserP1.Text = ""; tbxUserP2.Text = ""; MessageBox.popupClientMessage(this.Page, "旧密码不正确!", "call();"); return; } //判断新密码是否一致 if (userp1 != userp2) { tbxUserPassword.Text = ""; tbxUserP1.Text = ""; tbxUserP2.Text = ""; MessageBox.popupClientMessage(this.Page, "新密码不一致!", "call();"); return; } //判断新旧密码是否一致 if (oldpassword == newpassword) { tbxUserPassword.Text = ""; tbxUserP1.Text = ""; tbxUserP2.Text = ""; MessageBox.popupClientMessage(this.Page, "新密码不一致!", "call();"); return; } KPI_UserEntity usEntity = new KPI_UserEntity(); usEntity.UserID = userid; usEntity.UserName = username; usEntity.UserPassword = newpassword; usEntity.UserEMail = useremail; usEntity.UserPhone = userphone; usEntity.UserTitle = usertitle; if (KPI_UserDal.Update(usEntity)) { MessageBox.popupClientMessage(this.Page, "修改成功!", "call();"); } else { MessageBox.popupClientMessage(this.Page, "修改错误!", "call();"); } return; }
protected bool UserInsert() { KPI_UserEntity usEntity = new KPI_UserEntity(); usEntity.UserID = Guid.NewGuid().ToString(); usEntity.UserCode = tbxUserCode.Text.Trim(); usEntity.UserName = tbxUserName.Text.Trim(); usEntity.UserPassword = KPI_UserDal.GetDESString("123456"); usEntity.UserEMail = tbxUserEMail.Text.Trim(); usEntity.UserPhone = tbxUserPhone.Text.Trim(); usEntity.UserTitle = tbxUserTitle.Text.Trim(); usEntity.UserGroups = lblUserGroups.Text.Trim(); usEntity.UserIsValid = int.Parse(rblUserIsValid.SelectedValue); if (KPI_UserDal.Insert(usEntity)) { MessageBox.popupClientMessage(this.Page, "添加成功!新用户的初始密码为:123456", "call();"); return true; } else { MessageBox.popupClientMessage(this.Page, "添加失败!", "call();"); return false; } }