private void button3_Click(object sender, EventArgs e) { //判空 if (txtStudentNo.Text == "") { txtStudentNo.Focus(); MessageBox.Show("请输入查询的内容~", "提示"); return; } if (txtCardNo.Text == "") { txtCardNo.Focus(); MessageBox.Show("请输入查询的内容~", "提示"); return; } if (txtMoney.Text == "") { txtMoney.Focus(); MessageBox.Show("请输入查询的内容~", "提示"); return; } if (comboBox1.Text == "") { comboBox1.Focus(); MessageBox.Show("请输入查询的内容~", "提示"); return; } //注册金额,不得小于最小的上机金额---------- //的金额是否满足要求 Entity.BasicData basicdate = new Entity.BasicData(); Facade.QueryBasicDateFacade queryBasicDate = new Facade.QueryBasicDateFacade(); IList <Entity.BasicData> LbasicDate = queryBasicDate.QueryBasicDate(basicdate); if (Convert.ToInt16(txtMoney.Text) < LbasicDate[0].LeastMoney) { MessageBox.Show("您的注册余额不满足上使用条件,请修改!", "提示"); txtMoney.Focus(); return; } //显示学生的信息,确保有学生 //txtStudent 给到实体 Entity.Student student = new Entity.Student(); student.StudentNo = Convert.ToInt32(txtStudentNo.Text); Facade.StudentFacade studentfacade = new Facade.StudentFacade(); IList <Entity.Student> Student = new List <Entity.Student>(); Student = studentfacade.studentfacade(student); if (Student.Count == 0) { MessageBox.Show("没有该生的信息哦,可以选择添加该生的信息~"); return; } else { txtInfo.Text = "姓名:" + Student[0].Name + "\r\n" + "性别:" + Student[0].Sex + "\r\n" + "年级:" + Student[0].Grade + "\r\n" + "班级:" + Student[0].Class + "\r\n" + "专业:" + Student[0].Department + "\r\n"; } //将卡号的信息传给实体card,然后和数据库绑定 Entity.Card card = new Entity.Card(); card.StudentNo = Convert.ToInt32(txtStudentNo.Text); card.CardNo = Convert.ToInt32(txtCardNo.Text); card.Money = Convert.ToInt32(txtMoney.Text); //card.Type = listbox.Text .ToString(); card.Type = comboBox1.Text.Trim(); card.Notes = "使用"; card.Status = "未结账"; card.UserID = frmLogin.UserName; //card.UserID = "YY"; //实体带给外观,返回该学号是否注册 Facade.QuerIesitCardno Queryisexit = new Facade.QuerIesitCardno(); IList <Entity.Card> QueryCardExit = new List <Entity.Card>(); QueryCardExit = Queryisexit.QuerIsexitcardno(card); if (QueryCardExit.Count != 0) { MessageBox.Show("该学生已注册,无需注册", "提示"); //获取学生已注册的信息 card.CardNo = QueryCardExit[0].CardNo; Facade.StudentMoneyFacade QueryCardno = new Facade.StudentMoneyFacade(); IList <Entity.Card> card_info = new List <Entity.Card>(); card_info = QueryCardno.StudentMoney(card); txtInfo.Clear(); // txtInfo.Text = "姓名:" + card_info [0].StudentNo + "\r\n" + "性别:" + Student[0].Sex + "\r\n" + "年级:" + Student[0].Grade + "\r\n" + "班级:" + Student[0].Class + "\r\n" + "专业:" + Student[0].Department + "\r\n"; txtInfo.Text = "姓名:" + Student[0].Name + "\r\n" + "性别:" + Student[0].Sex + "\r\n" + "年级:" + Student[0].Grade + "\r\n" + "班级:" + Student[0].Class + "\r\n" + "专业:" + Student[0].Department + "\r\n" + "卡号:" + card_info[0].CardNo.ToString() + "\r\n"; txtCardNo.Text = ""; txtMoney.Text = ""; comboBox1.Text = ""; return; } else { //实体带给外观,返回是否有学号 Facade.StudentMoneyFacade QueryCardno = new Facade.StudentMoneyFacade(); IList <Entity.Card> card_info = new List <Entity.Card>(); card_info = QueryCardno.StudentMoney(card); if (card_info.Count != 0) { MessageBox.Show("该卡号已被使用,请重新输入!"); return; } else { //实体带参给facade,完成添加 Facade.addCardFacade addCard = new Facade.addCardFacade(); bool falg; falg = addCard.addCard(card); if (falg == true) { MessageBox.Show("注册成功,您可以正常使用", "温馨提示"); } //将注册的金额放到充值卡中 Entity.Charge charge = new Entity.Charge(); charge.CardNo = txtCardNo.Text; charge.UserID = frmLogin.UserName; charge.StudentNo = student.StudentNo; charge.AddMoney = Convert.ToInt16(txtMoney.Text); Facade.AddChargeAndReturn addMoney = new Facade.AddChargeAndReturn(); addMoney.addCharge(charge); } } }
/// <summary> /// 上机 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { Entity.Card card = new Entity.Card(); //卡号 card.CardNo = Convert.ToInt16(txtCardno.Text.Trim()); // Facade.QuerIesitCardno queryExitCardno = new Facade.QuerIesitCardno(); Facade.QueyExitCardno queryExitCardno = new Facade.QueyExitCardno(); IList <Entity.Card> lCard = new List <Entity.Card>(); lCard = queryExitCardno.queryExitCardno(card); if (lCard.Count == 0) { MessageBox.Show("请确定该卡号是否可用!"); txtCardno.Text = ""; } else { //判断上机的金额是否满足要求 Entity.BasicData basicdate = new Entity.BasicData(); Facade.QueryBasicDateFacade queryBasicDate = new Facade.QueryBasicDateFacade(); IList <Entity.BasicData> LbasicDate = queryBasicDate.QueryBasicDate(basicdate); if (lCard[0].Money < LbasicDate[0].LeastMoney) { MessageBox.Show("您的余额不满足上机条件,请充值!"); } else { //正在上机不符合条件--2017.01.20 Entity.online online = new Entity.online(); online.CardNo = Convert.ToInt16(txtCardno.Text.Trim()); Facade.IsOnlineFacade IsOnline = new Facade.IsOnlineFacade(); IList <Entity.online> lonline = new List <Entity.online>(); lonline = IsOnline.IsOnline(online); if (lonline.Count != 0) { MessageBox.Show("该卡号正在上机,请重新选择卡号!"); } else { Entity.Student student = new Entity.Student(); student.StudentNo = lCard[0].StudentNo; Facade.StudentFacade studentinfo = new Facade.StudentFacade(); IList <Entity.Student> lstudent = new List <Entity.Student>(); lstudent = studentinfo.studentfacade(student); txtStudentNo.Text = lstudent[0].StudentNo.ToString(); txtName.Text = lstudent[0].Name; txtSex.Text = lstudent[0].Sex.ToString(); txtType.Text = lstudent[0].Notes.ToString(); //将正在上机的信息读入onlie表 // Entity.online online = new Entity.online(); online.CardNo = lCard[0].CardNo; online.StudentNo = lCard[0].StudentNo; online.studentname = txtName.Text; online.studentsex = txtSex.Text; online.cardType = lCard[0].Type; online.Computer = Environment.MachineName; Facade.addOnlineFacade addOnline = new Facade.addOnlineFacade(); addOnline.addOnline(online); //获得数据库的当前时间 Facade.IsOnlineFacade Online = new Facade.IsOnlineFacade(); IList <Entity.online> Lonline = new List <Entity.online>(); Lonline = IsOnline.IsOnline(online); txtONdate.Text = Lonline[0].ondate.ToString(); txtOntime.Text = Lonline[0].ontime.ToString(); //将正在上机的信息读入line表 Entity.line line = new Entity.line(); line.CardNo = lCard[0].CardNo; //line.UserID = frmLogin.UserName; line.LoginDate = Convert.ToDateTime(txtONdate.Text); line.LoginTime = TimeSpan.Parse(txtOntime.Text); line.Status = "正常上机"; line.StudentNo = lCard[0].StudentNo; line.StudentName = txtName.Text; line.Computer = Environment.MachineName; line.sex = txtSex.Text; Facade.AddLineFacade addLine = new Facade.AddLineFacade(); addLine.addLine(line); MessageBox.Show("上机成功,感谢使用!"); } } } }
private void btAdd_Click(object sender, EventArgs e) { //判空 foreach (Control con in this.Controls) { if (con.Text == "") { MessageBox.Show("请将内容补充完整", "提示"); con.Focus(); return; } } foreach (Control contxt in this.groupBox1.Controls) { if (contxt.Text == "") { MessageBox.Show("请将内容补充完整", "提示"); contxt.Focus(); return; } } //查找学号,如果没有该学号,则将信息添加到学生库中 Entity.Student student = new Entity.Student(); student.StudentNo = Convert.ToInt16(txtStudentID.Text); student.Name = txtStudentName.Text; student.Grade = txtGrade.Text; student.Class = txtClass.Text; student.Sex = cbSex.Text; student.Department = txtDepartment.Text; student.Notes = txtNotice.Text; //调用外观层,得到已经赋值的学生 Facade.StudentFacade studentfacade = new Facade.StudentFacade(); IList <Entity.Student> Student = new List <Entity.Student>(); Student = studentfacade.studentfacade(student); if (Student.Count == 0) //该学号没有使用可以使用 { Facade.AddStudentFacade addStudentFacade = new Facade.AddStudentFacade(); bool flag; flag = addStudentFacade.addStudent(student); if (flag == true) { MessageBox.Show("添加成功", "提示"); txtStudentID.Text = ""; txtStudentName.Text = ""; txtGrade.Text = ""; cbSex.Text = ""; txtDepartment.Text = ""; txtNotice.Text = ""; txtClass.Text = ""; return; } } else { MessageBox.Show("该学号已占用,请重新输入学号!", "提示"); txtStudentID.Text = ""; txtStudentID.Focus(); return; } }