/// <summary> /// 保存记录 /// </summary> private void SaveLog_Click(object sender, EventArgs e) { try { List <string> errorList = new List <string>();//创建一个错误列表 //获取根据当前页面内容生成的读者信息(若有错误会被添加到错误列表中) //string readerLevel = cbb_readerLevel.Text;//获取修改后的值 UserManagementReaderLevel level = GetReaderLevel(ref errorList); //判断是否修改读者信息成功 if (userManagementBll.UpdateReaderLevel(level, ref errorList)) { MessageBox.Show("修改成功"); } else { MessageBox.Show("修改失败"); foreach (var i in errorList) { MessageBox.Show(i);//逐条显示错误信息 } } } catch (Exception ex) { MessageBox.Show(ex.Message); } DataBind(); //数据绑定 ChangeControlEnableState(); //改变菜单按钮启用状态 }
/// <summary> /// 修改读者权限级别为 5 /// </summary> /// <param name="info">读者信息</param> /// <returns>修改是否成功</returns> public bool ChangeReaderLevelToFive(UserManagementReaderLevel level) { string sqlStr = "UPDATE tb_ReaderInformation, " + "tb_BasicInformation " + "SET " + "ReaderLevelId = 5 " + "WHERE " + "tb_ReaderInformation.UserId = tb_BasicInformation.UserId " + "AND " + "tb_BasicInformation.UserNumber = @_userNumber"; MySqlParameter[] para = new MySqlParameter[] { new MySqlParameter("@_userNumber", level.UserNumber) }; int countUpdate = helper.ExecuteNonQuery(sqlStr, para, CommandType.Text); if (countUpdate > 0) { return(true); } else { return(false); } }
public bool UpdateReaderLevel(UserManagementReaderLevel level, ref List <string> errorMsg) { bool result = false; try { if (level.UserNumber == "") { errorMsg.Add("UserNumber Error"); return(false); } if (!UserManagementReaderLevel.isNull(level)) //是否有空项 { if (UserManagementReaderLevel.isNormative(level, ref errorMsg)) //是否符合规范 { switch (level.ReaderLevelName) { case "1": result = userManagementDal.ChangeReaderLevelToOne(level); break; case "2": result = userManagementDal.ChangeReaderLevelToTwo(level); break; case "3": result = userManagementDal.ChangeReaderLevelToThree(level); break; case "4": result = userManagementDal.ChangeReaderLevelToFour(level); break; case "5": result = userManagementDal.ChangeReaderLevelToFive(level); break; default: result = false; break; } } } } catch (Exception e) { Console.WriteLine(e.Message); throw e; } return(result); }
private UserManagementReaderLevel GetReaderLevel(ref List <string> error) { List <string> errorList = new List <string>(); UserManagementReaderLevel level = new UserManagementReaderLevel() { UserName = txb_userName.Text, UserNumber = txb_userNum.Text, Contact = txb_contact.Text, ReaderLevelName = cbb_readerLevel.Text, BorrowBookNumber = txb_borrowBookNum.Text, ReserveBookNumber = txb_reserveBookNum.Text, BorrowBookDays = txb_borrowDays.Text, RenewBookDays = txb_renewDays.Text, ForfeitMultiples = txb_forfeitMul.Text, RenewBookNumber = txb_renewNum.Text }; error = errorList; //返回错误列表 return(level); //返回读者信息 }