当前位置:文档之家› 大数据库原理与设计大作业源代码

大数据库原理与设计大作业源代码

数据库原理与设计大作业源代码(1) 用户登录界面运行超市管理信息系统后,首先进入用户登录界面,用户输入用户名和密码后,系统进行验证,验证通过进入程序的主界面。

在进行系统登录过程中,登录模块将调用数据库里的用户信息表,并对用户名和密码进行验证,只有输入了正确的账号和密码后,系统登录才会成功。

在登录模块中,对系统的尝试登录次数进行了限制,禁止用户无终止的进行系统登录尝试,在本系统中,当用户对系统的三次登录失败后,系统将自动机制登录,突出登录模块。

并在输入了错误的或者是不存在的账户和密码时,系统会给出出错信息提示,指明登录过程中的错误输入或者错误操作,以便用户进行正确的登录。

登录界面如图5-2所示。

图5-2 登录界面主要实现代码如下://登录private void radBtnOk_Click(object sender, EventArgs e){try{if (radTxtBoxUser.Text.Trim() == ""){this.radLbInfo.Text = "请输入您的用户名!";}else if (radTxtBoxPsw.Text.Trim() == ""){this.radLbInfo.Text = "请输入您的密码!";}else{commandUnit com = new commandUnit();string str = @"select * from UserInfo where loginNo = '" + radTxtBoxUser.Text.ToString() + "'";DataTable table = com.GetDataSet(str);if (table.Rows.Count <= 0){this.radLbInfo.Text = "用户名不存在!";radTxtBoxUser.Text = "";radTxtBoxPsw.Text = "";return;}str = @"select * from UserInfo where loginNo = '" + radTxtBoxUser.Text.ToString() + "' and passWord = '" + radTxtBoxPsw.Text.ToString() + "'";DataTable tableUser = com.GetDataSet(str);if (tableUser.Rows.Count > 0){_currentUser = radTxtBoxUser.Text;_currentPsw = radTxtBoxPsw.Text;IsLogin = true;this.Close();}else{this.radLbInfo.Text = "密码错误!";radTxtBoxPsw.Text = "";}}}catch (System.Exception ex){throw ex;}}(2) 主界面系统登录成功后,进入主界面菜单。

主界面如图5-3所示。

图5-3 主界面(3) 修改密码界面成功登录系统后,单击“用户信息管理”菜单的“修改密码”,可以进入“修改密码”界面,进行密码的修改。

修改密码界面如图5-4所示。

图5-4 修改密码界面主要实现代码如下://修改密码protected virtual void radBtnOk_Click(object sender, EventArgs e){if (radTxtBoxOldPsw.Text == null ||radTxtBoxOldPsw.Text.Trim() == ""){MessageBox.Show("请输入旧密码!。

", "提醒", MessageBoxButtons.OK, rmation);return;}if (radTxtBoxNewPsw.Text == null ||radTxtBoxNewPsw.Text.Trim() == ""|| radTxtBoxEnterPsw.Text == null || radTxtBoxEnterPsw.Text.Trim() == ""){MessageBox.Show("请输入新密码!。

", "提醒", MessageBoxButtons.OK, rmation);return;}string currPwd = RFrmLogin.CurrentPsw;if (currPwd == radTxtBoxOldPsw.Text.Trim()){if (isSame()){commandUnit com = new commandUnit();string str = @"update UserInfo set passWord = '" +radTxtBoxEnterPsw.Text.ToString() + "' where loginNo = '" + RFrmLogin.CurrentUser + "'";if (com.ExecuteCommand(str) > 0){MessageBox.Show("密码修改成功!。

", "提醒", MessageBoxButtons.OK, rmation);}else{MessageBox.Show("密码修改失败,请联系管理员!。

", "提醒", MessageBoxButtons.OK, rmation);}}else{MessageBox.Show("两次密码输入不一致!", "提醒", MessageBoxButtons.OK, rmation);}}else{MessageBox.Show("输入密码错误!", "提醒", MessageBoxButtons.OK, rmation);}}(4) 修改密码界面管理员成功登录系统后,单击“用户信息管理”菜单的“修改权限”,可以进入“修改权限”界面,进行员工权限的修改。

修改权限界面如图5-5所示。

图5-5 修改权限界面主要实现代码如下://修改权限protected override void radBtnOk_Click(object sender, EventArgs e) {if (radTxtBoxOldPsw.Text == null || radTxtBoxOldPsw.Text.Trim() == ""){MessageBox.Show("请输入用户名!。

", "提醒", MessageBoxButtons.OK, rmation);return;}if (radComBoxPower.Text == null || radComBoxPower.Text.Trim() == ""){MessageBox.Show("请为用户设置权限!。

", "提醒", MessageBoxButtons.OK, rmation);return;}commandUnit com = new commandUnit();string str = @"update UserInfo set power = '" + radComBoxPower.SelectedValue.ToString() + "' where loginNo = '" + radTxtBoxOldPsw.Text.ToString() + "'";if (com.ExecuteCommand(str) > 0){MessageBox.Show("权限修改成功!。

", "提醒", MessageBoxButtons.OK, rmation);}else{MessageBox.Show("权限修改失败,请联系管理员!。

", "提醒", MessageBoxButtons.OK, rmation);}}(5) 编辑员工信息界面管理员成功登录系统后,单击“基本信息管理”菜单的“员工信息”,可以进入“查看员工信息”界面和“编辑员工信息”界面,“查看员工信息”界面只能查看员工信息,“编辑员工信息”界面进行员工信息的修改、添加、删除等功能。

编辑员工信息界面如图5-6所示。

图5-6 编辑员工信息界面主要实现代码如下://保存protected virtual void tSBtnSave_Click(object sender, EventArgs e){try{if (IsVilude()){bool isSuccess = false;commandUnit com = new commandUnit();EmployeeModel emp;for (int j = 0; j < radWithGV.RowCount; j++){emp = new EmployeeModel();#region同步数据if (radWithGV.Rows[j].Tag != null){emp = radWithGV.Rows[j].Tag as EmployeeModel;}else{emp.EmployeeNo =radWithGV.Rows[j].Cells["employeeNo"].Value.ToString(); =radWithGV.Rows[j].Cells["name"].Value.ToString();emp.Sex =radWithGV.Rows[j].Cells["sex"].Value.ToString();emp.IdCard =radWithGV.Rows[j].Cells["idCard"].Value.ToString();emp.Duty =radWithGV.Rows[j].Cells["duty"].Value.ToString();emp.Note =radWithGV.Rows[j].Cells["note"].Value.ToString();emp.IsNew = true;}#endregionif (emp.IsNew){string str = "select * from EmployeeInfo where employeeNo = '" + emp.EmployeeNo + "'";DataTable dtable = com.GetDataSet(str);if (dtable.Rows.Count <= 0){str = @"insert into EmployeeInfo values('" + emp.EmployeeNo + "','" + + "','" + emp.Sex + "','" + emp.IdCard + "','" + emp.Duty + "','" + emp.Note + "')";if (com.ExecuteCommand(str) > 0){_isSaved = true;isSuccess = true;emp.IsNew = false;radWithGV.Rows[j].Tag = emp;}}else{MessageBox.Show("该员工已存在,请审核信息!");}}else if (emp.IsModified){string strSql = @"update EmployeeInfo set name = '"+ + "',sex = '"+ emp.Sex+ "',idCard = '"+ emp.IdCard + "',duty = '"+ emp.Duty + "',note = '" + emp.Note + "' where employeeNo = '" + emp.EmployeeNo + "'";if (com.ExecuteCommand(strSql) > 0){_isSaved = true;isSuccess = true;emp.IsModified = false;radWithGV.Rows[j].Tag = emp;}}elsecontinue;}if (isSuccess){MessageBox.Show("保存成功!");}}else{MessageBox.Show("数据非法!");}}catch (System.Exception ex){throw ex;}}(6) 职务信息界面管理员成功登录系统后,单击“基本信息管理”菜单的“职务信息”,可以进入“职务信息”界面,“职务信息”界面进行职务信息的修改、添加、删除等功能。

相关主题