public bool DeviceInfoUpdate(string rootPath) { string deviceOldImagePath = this.GetDeviceImagePath(this.deviceId); if (deviceOldImagePath != "") { if (String.Compare(deviceOldImagePath, this.deviceImagePath, true) != 0) { System.IO.File.Delete(rootPath + "\\" + deviceOldImagePath); } } string updateString = "update deviceInfo set deviceName=" + SqlString.GetQuotedString(this.deviceName); updateString += ",deviceTypeId=" + this.deviceTypeId; updateString += ",deviceSign=" + SqlString.GetQuotedString(this.deviceSign); updateString += ",deviceModel=" + SqlString.GetQuotedString(this.deviceModel); updateString += ",deviceSerialNumber=" + SqlString.GetQuotedString(this.deviceSerialNumber); updateString += ",deviceImagePath=" + SqlString.GetQuotedString(this.deviceImagePath); updateString += ",deviceMadePlace=" + SqlString.GetQuotedString(this.deviceMadePlace); updateString += ",deviceOutDate='" + this.deviceOutDate; updateString += "',devicePurchaseTime='" + this.devicePurchaseTime; updateString += "',deviceNotes=" + SqlString.GetQuotedString(this.deviceNotes); updateString += " where deviceId=" + this.deviceId; DataBase db = new DataBase(); if (db.InsertOrUpdate(updateString) < 0) { this.errMessage = "修改设备信息失败!"; return(false); } return(true); }
protected void Btn_Add_Click(object sender, EventArgs e) { string collegeName = this.CollegeName.SelectedValue; string specialFieldName = this.specialFieldName.Text; if (specialFieldName == "") { Response.Write("<script>alert('专业输入不能为空!');</script>"); return; } string queryString = "select * from collegespecInfo where specialFieldName=" + SqlString.GetQuotedString(specialFieldName); DataBase db = new DataBase(); if (db.GetRecord(queryString)) { Response.Write("<script>alert('该专业已经存在!');</script>"); return; } string insertString = "insert into collegespecInfo(specialFieldName,collegeName) values ("; insertString += SqlString.GetQuotedString(specialFieldName) + ","; insertString += SqlString.GetQuotedString(collegeName) + ")"; if (db.InsertOrUpdate(insertString) < 0) { Response.Write("<script>alert('添加专业失败!');</script>"); } Response.Write("<script>alert('添加专业成功!');location.href='fieldSet.aspx';</script>"); }
//向数据库中加入新的学生信息,成功返回true public bool InsertStudent() { if (IsExist()) { return(false); //如果该学号的学生已经存在则返回添加失败 } string insertString = "insert into studentInfo(studentNumber,studentName,studentSex,"; insertString += "studentState,collegeName,studentSpec,studentBirthday,"; insertString += "studentTelephone,studentAddress,studentMemo) values ("; insertString += SqlString.GetQuotedString(this.studentNumber) + ","; insertString += SqlString.GetQuotedString(this.studentName) + ","; insertString += SqlString.GetQuotedString(this.studentSex) + ","; insertString += SqlString.GetQuotedString(this.studentState) + ","; insertString += SqlString.GetQuotedString(this.collegeName) + ","; insertString += SqlString.GetQuotedString(this.studentSpec) + ","; insertString += SqlString.GetQuotedString(this.studentBirthday.ToString("yyyy-MM-dd")) + ","; insertString += SqlString.GetQuotedString(this.studentTelephone) + ","; insertString += SqlString.GetQuotedString(this.studentAddress) + ","; insertString += SqlString.GetQuotedString(this.studentMemo) + ")"; DataBase db = new DataBase(); if (db.InsertOrUpdate(insertString) > 0) { this.ErrMessage = "<font color=red>学生信息添加成功!</font>"; return(true); } else { this.ErrMessage = "<font color=red>添加学生信息时发生了错误!</font>"; return(false); } }
//根据交费编号对交费信息进行更新操作 public bool Update() { string updateString = "update moneyInfo set studentNumber=" + SqlString.GetQuotedString(this.studentNumber); updateString += ",giveMoneyType=" + SqlString.GetQuotedString(this.giveMoneyType); updateString += ",giveMoneyYear=" + this.giveMoneyYear; updateString += ",giveMoneyMonth=" + this.giveMoneyMonth; updateString += ",giveMoneyDay=" + this.giveMoneyDay; updateString += ",giveMoney=" + this.giveMoney; updateString += " where moneyId=" + this.moneyId; Student student = new Student(); if (!this.IsExistStudent()) { this.errMessage = "该学号的学生不存在!"; return(false); } DataBase db = new DataBase(); if (db.InsertOrUpdate(updateString) < 0) { this.errMessage = "数据更新时发生了错误!"; return(false); } return(true); }
public bool checkAdmin(AdminModel admin) { string queryString; bool hasUser, isPasswordRight; queryString = "select * from [admin] where username = "******"对不起,用户名不存在!"; return(false); } queryString = "select * from [admin] where username = "******" and password = "******"对不起,用户密码错误!"; return(false); } return(true); }
//用新的住宿信息更新该学生的住宿信息 public bool UpdateLiveInfo() { //首先查询目标房间是否还有剩余床位 Room room = new Room(); int leftNumberOfBed = room.GetLeftNumberOfBed(this.roomNo); if (leftNumberOfBed <= 0) { this.errMessage = "对不起,目标房间没有剩余床位了!"; return(false); } //将老房间的剩余床位数加一,将新房间的剩余床位数减1 string oldRoomNo = this.GetOldRoomNo(); //得到原来的住宿房间编号 string updateOldRoomString, updateNewRoomString, updateLiveString; updateOldRoomString = "update roomInfo set leftNumberOfBed = leftNumberOfBed + 1 where roomNo=" + SqlString.GetQuotedString(oldRoomNo); updateNewRoomString = "update roomInfo set leftNumberOfBed = leftNumberOfBed - 1 where roomNo=" + SqlString.GetQuotedString(this.roomNo); updateLiveString = "update liveInfo set apartmentNo=" + SqlString.GetQuotedString(this.apartmentNo); updateLiveString += ",roomNo=" + SqlString.GetQuotedString(this.roomNo); updateLiveString += ",liveinYear=" + this.liveinYear; updateLiveString += ",liveinMonth=" + this.liveinMonth; updateLiveString += ",liveinDay=" + this.LiveinDay; updateLiveString += ",liveMemo=" + SqlString.GetQuotedString(this.liveMemo); updateLiveString += " where studentNumber=" + SqlString.GetQuotedString(this.studentNumber); string[] updateSqls = new string[] { updateOldRoomString, updateNewRoomString, updateLiveString }; DataBase db = new DataBase(); if (!db.ExecuteSQL(updateSqls)) { this.errMessage = "更换房间操作时发生了错误!"; return(false); } return(true); }
public bool AddGuaHaoInfo(GuaHaoModel guaHaoModel) { if (guaHaoModel.getName().Equals("")) { this.errMessage = "病人姓名输入不能为空!"; return(false); } string sqlString = "insert into [t_guahao] (name,sex,age,subjectId,operateTime,operator) values ("; sqlString += SqlString.GetQuotedString(guaHaoModel.getName()) + ","; sqlString += SqlString.GetQuotedString(guaHaoModel.getSex()) + ","; sqlString += guaHaoModel.getAge() + ","; sqlString += guaHaoModel.getSubjectId() + ",'"; sqlString += guaHaoModel.getOperateTime() + "',"; sqlString += SqlString.GetQuotedString(guaHaoModel.getOperator()) + ")"; DataBase db = new DataBase(); if (db.InsertOrUpdate(sqlString) <= 0) { this.errMessage = "向数据库中加入挂号信息发生了错误!"; return(false); } return(true); }
public bool InsertVisitInfo() { //首先检查操作员输入的被访人信息是否存在 string queryString = "select * from studentInfo where studentName=" + SqlString.GetQuotedString(interviewee); DataBase db = new DataBase(); if (false == db.GetRecord(queryString)) { this.ErrMessage = "你输入被访人信息不存在!"; return(false); } //通过了验证后进行来访登记 string insertString = "insert into visitInfo(interviewee,interviewer,relation,apartmentNo,roomNo,managerName,beginTime,endTime,interviewMemo) values ("; insertString += SqlString.GetQuotedString(interviewee) + ","; insertString += SqlString.GetQuotedString(interviewer) + ","; insertString += SqlString.GetQuotedString(relation) + ","; insertString += SqlString.GetQuotedString(apartmentNo) + ","; insertString += SqlString.GetQuotedString(roomNo) + ","; insertString += SqlString.GetQuotedString(managerName) + ","; insertString += SqlString.GetQuotedString(this.beginTime.ToString("yyyy-MM-dd HH:mm:ss")) + ","; insertString += SqlString.GetQuotedString(this.endTime.ToString("yyyy-MM-dd HH:mm:ss")) + ","; insertString += SqlString.GetQuotedString(interviewMemo) + ")"; if (db.InsertOrUpdate(insertString) > 0) { this.ErrMessage = "<font color=red>来访信息登记成功!</font>"; return(true); } else { this.ErrMessage = "<font color=red>登记来访信息时发生了错误!</font>"; return(false); } }
//将房间信息加入到数据库中 public bool InsertRoomInfo() { if (this.IsExistRoomNo()) { return(false); //该房间已经存在时 } if (this.leftNumberOfBed > this.numberOfBed) { this.errMessage = "你输入的剩余床位数不能大于总的床位数!"; return(false); } string insertString = "insert into roomInfo(roomNo,apartmentNo,roomType,roomPrice,numberOfBed,leftNumberOfBed,roomTelephone,roomMemo) values ("; insertString = insertString + SqlString.GetQuotedString(this.roomNo) + ","; insertString = insertString + SqlString.GetQuotedString(this.apartmentNo) + ","; insertString = insertString + SqlString.GetQuotedString(this.roomType) + ","; insertString = insertString + roomPrice + ","; insertString = insertString + this.numberOfBed + ","; insertString = insertString + this.leftNumberOfBed + ","; insertString = insertString + SqlString.GetQuotedString(this.roomTelephone) + ","; insertString = insertString + SqlString.GetQuotedString(this.roomMemo) + ")"; DataBase db = new DataBase(); if (db.InsertOrUpdate(insertString) < 0) { this.ErrMessage = "添加房间信息时发生了错误!"; return(false); } return(true); }
public bool InsertHealthInfo() { //首先检查操作员输入的房间信息是否存在 string queryString = "select * from roomInfo where apartmentNo=" + SqlString.GetQuotedString(apartmentNo); queryString += "and roomNo=" + SqlString.GetQuotedString(roomNo); DataBase db = new DataBase(); if (false == db.GetRecord(queryString)) { this.ErrMessage = "你输入被访人信息不存在!"; return(false); } //通过了验证后进行来访登记 string insertString = "insert into healthInfo(apartmentNo,roomNo,healthTime,healthCheck,healthScore) values ("; insertString += SqlString.GetQuotedString(this.apartmentNo) + ","; insertString += SqlString.GetQuotedString(this.roomNo) + ","; insertString += SqlString.GetQuotedString(this.healthTime.ToString("yyyy-MM-dd HH:mm:ss")) + ","; insertString += SqlString.GetQuotedString(this.healthCheck) + ","; insertString += SqlString.GetQuotedString(this.healthScore) + ")"; if (db.InsertOrUpdate(insertString) > 0) { this.ErrMessage = "<font color=red>卫生检查信息登记成功!</font>"; return(true); } else { this.ErrMessage = "<font color=red>登记卫生检查信息时发生了错误!</font>"; return(false); } }
public bool NewDeviceAdd() { if (IsExist(this.deviceName)) { this.errMessage = "该设备名称信息在系统中已经存在!"; return(false); } string insertString = "insert into deviceInfo(deviceName,deviceTypeId,deviceSign,deviceModel,deviceSerialNumber,deviceImagePath,deviceState,deviceMadePlace,deviceOutDate,devicePurchaseTime,deviceNotes) values ("; insertString += SqlString.GetQuotedString(deviceName) + ","; insertString += deviceTypeId + ","; insertString += SqlString.GetQuotedString(deviceSign) + ","; insertString += SqlString.GetQuotedString(deviceModel) + ","; insertString += SqlString.GetQuotedString(deviceSerialNumber) + ","; insertString += SqlString.GetQuotedString(deviceImagePath) + ","; insertString += deviceState + ","; insertString += SqlString.GetQuotedString(deviceMadePlace) + ",'"; insertString += deviceOutDate + "','"; insertString += devicePurchaseTime + "',"; insertString += SqlString.GetQuotedString(deviceNotes) + ")"; DataBase db = new DataBase(); if (db.InsertOrUpdate(insertString) < 0) { this.errMessage = "添加新设备失败!"; return(false); } return(true); }
public bool AddDeviceRejectInfo() { if (this.deviceId == 0) { this.errMessage = "请选择报废设备"; return(false); } if (!(new DeviceInfo()).IsExist(deviceId)) { this.errMessage = "该设备信息不存在"; return(false); } if ((new DeviceInfo()).GetDeviceState(deviceId) != 1) { this.errMessage = "该设备未在空闲状态,不得报废!"; return(false); } string insertString = "insert into rejectInfo(deviceId,deviceRejectTime,deviceRejectReason,depreciationMoney) values ("; insertString += deviceId + ",'"; insertString += deviceRejectTime + "',"; insertString += SqlString.GetQuotedString(deviceRejectReason) + ","; insertString += depreciationMoney + ")"; string updateString = "update deviceInfo set deviceState=4 where deviceId=" + deviceId; string[] sqlStrings = new string[] { insertString, updateString }; DataBase db = new DataBase(); if (db.ExecuteSQL(sqlStrings) == false) { this.errMessage = "设备报废失败!"; return(false); } return(true); }
public bool checkAdmin() { string str; bool hasUser, isPasswordRight; //下载于51aspx.com str = "select * from admin where adminUserName = "******"抱歉,用户名不存在!"; return(false); } //下载于51aspx.com str = "select * from admin where adminUserName = "******" and adminPassword = "******"抱歉,用户密码不正确!"; return(false); } return(true); }
//根据计算公式计算评分 public bool CalcAppraisalScore() { string calcString = "update appraisalView set appraisalScore=((basicScoreH+" + SqlString.GetQuotedString(this.totalScoreH); calcString += ")*healthScale)+((basicScoreI-" + SqlString.GetQuotedString(this.totalScoreI); calcString += ")*illegalScale)"; DataBase db = new DataBase(); if (db.InsertOrUpdate(calcString) < 0) { this.errMessage = "更新计算时发生了错误!"; return(false); } string queryString = "select * from appraisalView where appraisalYear=" + SqlString.GetQuotedString(appraisalYear); queryString += " and appraisalTerm=" + SqlString.GetQuotedString(appraisalTerm); DataSet ds = db.GetDataSet(queryString); DataRow dr = ds.Tables[0].Rows[0]; if (dr["appraisalScore"] == null) { string calcString1 = "update appraisalView set appraisalScore=basicScoreH*healthScale+basicScoreI*illegalScale"; if (db.InsertOrUpdate(calcString1) < 0) { this.errMessage = "更新计算时发生了错误!"; return(false); } } return(true); }
//判断用户的登录管理权限 public bool checkAdmin() { string queryString; bool hasUser, isPasswordRight; //首先在数据库中查询该管理帐号是否存在 queryString = "select * from admin where adminUsername = "******" and adminUserrole = " + SqlString.GetQuotedString(this.adminUserRole); DataBase db = new DataBase(); hasUser = db.GetRecord(queryString); if (false == hasUser) { errMessage = "对不起,用户名不存在!"; return(false); } //再查询数据库该管理帐号的密码是否正确 queryString = "select * from admin where adminUsername = "******" and adminPassword = "******"对不起,用户密码错误!"; return(false); } return(true); }
//根据查询条件搜索评比设置信息 public DataSet QueryAppraisalSet(string appraisalYear, string appraisalTerm) { string queryString = "select * from appraisalSet where appraisalYear=" + SqlString.GetQuotedString(appraisalYear); queryString += " and appraisalTerm=" + SqlString.GetQuotedString(appraisalTerm); return((new DataBase()).GetDataSet(queryString)); }
public AdminModel getAdminInfo(string username) { string sqlString = "select * from [admin] where username=" + SqlString.GetQuotedString(username); DataBase db = new DataBase(); DataSet ds = db.GetDataSet(sqlString); AdminModel adminModel = null; return(adminModel); }
//根据查询条件执行入住信息的查询 public DataSet GetQueryLiveInfo(string studentNumber, string studentName, string apartmentNo, string roomNo) { string queryString = "select * from liveInfoView where studentNumber like '%" + studentNumber + "%'"; queryString += " and studentName like '%" + studentName + "%'"; queryString += " and apartmentNo = " + SqlString.GetQuotedString(apartmentNo); queryString += " and roomNo = " + SqlString.GetQuotedString(roomNo); DataSet ds = (new DataBase()).GetDataSet(queryString); return(ds); }
//传递登出信息到登录日志 public bool Tologout() { string updateString = "update log set logoutTime=" + SqlString.GetQuotedString(this.logoutTime.ToString("yyyy-MM-dd HH:mm:ss")); updateString += " where loginTime=" + SqlString.GetQuotedString(this.loginTime.ToString("yyyy-MM-dd HH:mm:ss")); DataBase db = new DataBase(); if (db.InsertOrUpdate(updateString) < 0) { return(false); } return(true); }
//修改登录密码 public bool ChangePassword() { string updateString = "update admin set adminPassword="******" where adminUserName=" + SqlString.GetQuotedString(adminUserName); DataBase db = new DataBase(); if (db.InsertOrUpdate(updateString) < 0) { return(false); } return(true); }
//根据房间编号得到该房间的剩余床位 public int GetLeftNumberOfBed(string roomNo) { string queryString = "select leftNumberOfBed from roomInfo where roomNo=" + SqlString.GetQuotedString(roomNo); DataBase db = new DataBase(); DataSet ds = db.GetDataSet(queryString); if (ds.Tables[0].Rows.Count > 0) { return(Convert.ToInt16(ds.Tables[0].Rows[0]["leftNumberOfBed"])); } return(0); }
//根据查询条件搜索违规总扣分 public string QueryTotalScoreI(string appraisalYear) { DataBase db = new DataBase(); string sumstring = "select sum(illegalScore) from illegalInfo,appraisalInfo"; sumstring += " where illegalInfo.apartmentNo=appraisalInfo.apartmentNo and illegalInfo.roomNo=appraisalInfo.roomNo"; sumstring += " and ((Year(illegalInfo.illegalTime) = " + SqlString.GetQuotedString(appraisalYear); sumstring += " and Month(illegalInfo.illegalTime) between 9 and 12)"; sumstring += " or (Year(illegalInfo.illegalTime) = " + SqlString.GetQuotedString(appraisalYear); sumstring += "+1 and Month(illegalInfo.illegalTime) between 3 and 6))"; this.totalScoreI = db.GetRecordCount(sumstring).ToString(); return(totalScoreI); }
public bool ChangePassword() {//下载于51aspx.com string str = "update admin set adminPassword="******" where adminUserName=" + SqlString.GetQuotedString(adminUserName); DataBase db = new DataBase(); if (db.InsertOrUpdate(str) < 0) { return(false); } return(true); }
public bool ChangePassword(AdminModel admin) { string updateString = "update [admin] set password="******" where username=" + SqlString.GetQuotedString(admin.getUsername()); DataBase db = new DataBase(); if (db.InsertOrUpdate(updateString) < 0) { return(false); } return(true); }
//学生入住房间业务功能函数 public bool AddLiveInfo() { //首先检查操作员输入的学号信息是否存在 string queryString = "select * from studentInfo where studentNumber=" + SqlString.GetQuotedString(studentNumber); DataBase db = new DataBase(); if (false == db.GetRecord(queryString)) { this.ErrMessage = "你输入学号的学生信息不存在!"; return(false); } //然后检查该学号的学生是否已经登记了入住信息 queryString = "select * from liveInfo where studentNumber=" + SqlString.GetQuotedString(studentNumber); if (db.GetRecord(queryString)) { this.ErrMessage = "对不起,该学生已经入住公寓了!"; return(false); } //然后检查要入住的房间人员是否已经满了,通过剩余床位判断 Room room = new Room(); int leftNumberBed = room.GetLeftNumberOfBed(roomNo); if (leftNumberBed <= 0) { this.ErrMessage = "对不起,目标房间没有剩余床位容纳学生了!"; return(false); } //通过了上面的几个验证后说明数据都是输入合法的进行入住的登记了 string insertString = "insert into liveInfo(studentNumber,apartmentNo,roomNo,liveinYear,liveinMonth,liveinDay,liveMemo) values ("; insertString += SqlString.GetQuotedString(studentNumber) + ","; insertString += SqlString.GetQuotedString(apartmentNo) + ","; insertString += SqlString.GetQuotedString(roomNo) + ","; insertString += this.liveinYear + ","; insertString += this.liveinMonth + ","; insertString += this.liveinDay + ","; insertString += SqlString.GetQuotedString(liveMemo) + ")"; string updateString = "update roomInfo set leftNumberOfBed = leftNumberOfBed - 1 where roomNo=" + SqlString.GetQuotedString(roomNo); string[] sqlstring = new string[] { insertString, updateString }; if (!db.ExecuteSQL(sqlstring)) { this.ErrMessage = "对不起,执行数据库操作时发生了错误!"; return(false); } return(true); }
//传递登录信息到登录日志 public bool Tologin() { string insertString = "insert into log(adminUserName,adminUserrole,loginTime) values ("; insertString += SqlString.GetQuotedString(this.adminUserName) + ","; insertString += SqlString.GetQuotedString(this.adminUserRole) + ","; insertString += SqlString.GetQuotedString(this.loginTime.ToString("yyyy-MM-dd HH:mm:ss")) + ")"; DataBase db = new DataBase(); if (db.InsertOrUpdate(insertString) < 0) { return(false); } return(true); }
//根据房间编号从数据库中取得房间信息并填充到对应字段中 public void GetRoomInfo(string roomNo) { DataBase db = new DataBase(); string queryString = "select * from roomInfo where roomNo=" + SqlString.GetQuotedString(roomNo); DataSet ds = db.GetDataSet(queryString); this.roomNo = roomNo; this.apartmentNo = ds.Tables[0].Rows[0]["apartmentNo"].ToString(); this.roomType = ds.Tables[0].Rows[0]["roomType"].ToString(); this.roomPrice = Convert.ToSingle(ds.Tables[0].Rows[0]["roomPrice"].ToString()); this.numberOfBed = Convert.ToInt16(ds.Tables[0].Rows[0]["numberOfBed"].ToString()); this.leftNumberOfBed = Convert.ToInt16(ds.Tables[0].Rows[0]["leftNumberOfBed"].ToString()); this.roomTelephone = ds.Tables[0].Rows[0]["roomTelephone"].ToString(); this.roomMemo = ds.Tables[0].Rows[0]["roomMemo"].ToString(); }
//根据报修流水号对报修信息进行审核操作 public bool UpdateRepairInfo() { string updateString = "update repairInfo set repairAduit=" + SqlString.GetQuotedString(this.repairAduit); updateString += ",repairResult=" + SqlString.GetQuotedString(this.repairResult); updateString += " where repairId=" + this.repairId; DataBase db = new DataBase(); if (db.InsertOrUpdate(updateString) < 0) { this.errMessage = "数据更新时发生了错误!"; return(false); } return(true); }
//根据违规流水号对违规信息进行处理操作 public bool UpdateSolvingIllegal() { string updateString = "update illegalInfo set illegalSolve=" + SqlString.GetQuotedString(this.illegalSolve); updateString += ",illegalScore=" + SqlString.GetQuotedString(this.illegalScore); updateString += " where illegalId=" + this.illegalId; DataBase db = new DataBase(); if (db.InsertOrUpdate(updateString) < 0) { this.errMessage = "数据更新时发生了错误!"; return(false); } return(true); }
//判断数据库中是否存在该房间编号的房间信息 public bool IsExistRoomNo() { bool isExist = true; string queryString = "select * from roomInfo where roomNo=" + SqlString.GetQuotedString(this.roomNo); DataBase db = new DataBase(); if (false == db.GetRecord(queryString)) { isExist = false; } else { this.ErrMessage = "该房间编号已经存在!"; } return(isExist); }