/* *需求:通过按键实现样机 借还一起,主要是为了记录做过的实验,及实验后的状态 *思路:先借 后还 */ private void button1_Click(object sender, EventArgs e) { string ip = Fuctions.GetIpAddress(); if (LoginForm.admin == 0) { if (ip != IPADRESS && ip != IPADDRESS1 && ip != IPADRESS2) { MessageBox.Show("请去指定电脑进行样机借阅", "提示"); return; } } BorrowBLL borrowbll = new BorrowBLL(); PhoneBLL phonebll = new PhoneBLL(); //若是五行中的 样机编号没有选,给出提示 if (cbbPhoneNum1.Text == "" && cbbPhoneNum2.Text == "" && cbbPhoneNum3.Text == "" && cbbPhoneNum4.Text == "" && cbbPhoneNum.Text == "" & cbbPhoneNum5.Text == "" && cbbPhoneNum6.Text == "" && cbbPhoneNum7.Text == "" && cbbPhoneNum8.Text == "" && cbbPhoneNum9.Text == "") { MessageBox.Show("请输入样机编号"); return; } if (cbbPhoneName.Text == "" || cbbPhoneStage.Text == "") { MessageBox.Show("请输入样机信息"); return; } else { //判断样机状态是否选择 if (cbbPhoneNum.Text != "") { if (cbbIsNormal.Text == "") { MessageBox.Show("请输入样机状态"); return; } //样机状态是否正常,若是故障时需要输入备注 if (cbbIsNormal.Text == "故障" && txtRemark.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } } if (cbbPhoneNum1.Text != "") { if (cbbIsNormal1.Text == "") { MessageBox.Show("请输入样机状态"); return; } //样机状态是否正常,若是故障时需要输入备注 if (cbbIsNormal1.Text == "故障" && txtRemark1.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } } if (cbbPhoneNum2.Text != "") { //样机状态是否正常,若是故障时需要输入备注 if (cbbIsNormal2.Text == "故障" && txtRemark2.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } if (cbbIsNormal2.Text == "") { MessageBox.Show("请输入样机状态"); return; } } if (cbbPhoneNum3.Text != "") { if (cbbIsNormal3.Text == "") { MessageBox.Show("请输入样机状态"); return; } //样机状态是否正常,若是故障时需要输入备注 if (cbbIsNormal3.Text == "故障" && txtRemark3.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } } if (cbbPhoneNum4.Text != "") { if (cbbIsNormal4.Text == "") { MessageBox.Show("请输入样机状态"); return; } //样机状态是否正常,若是故障时需要输入备注 if (cbbIsNormal4.Text == "故障" && txtRemark4.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } } if (cbbPhoneNum5.Text != "") { if (cbbIsNormal5.Text == "") { MessageBox.Show("请输入样机状态"); return; } //样机状态是否正常,若是故障时需要输入备注 if (cbbIsNormal5.Text == "故障" && txtRemark5.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } } if (cbbPhoneNum6.Text != "") { if (cbbIsNormal6.Text == "") { MessageBox.Show("请输入样机状态"); return; } //样机状态是否正常,若是故障时需要输入备注 if (cbbIsNormal6.Text == "故障" && txtRemark6.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } } if (cbbPhoneNum7.Text != "") { if (cbbIsNormal7.Text == "") { MessageBox.Show("请输入样机状态"); return; } //样机状态是否正常,若是故障时需要输入备注 if (cbbIsNormal7.Text == "故障" && txtRemark7.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } } if (cbbPhoneNum8.Text != "") { if (cbbIsNormal8.Text == "") { MessageBox.Show("请输入样机状态"); return; } //样机状态是否正常,若是故障时需要输入备注 if (cbbIsNormal8.Text == "故障" && txtRemark8.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } } if (cbbPhoneNum9.Text != "") { if (cbbIsNormal9.Text == "") { MessageBox.Show("请输入样机状态"); return; } //样机状态是否正常,若是故障时需要输入备注 if (cbbIsNormal9.Text == "故障" && txtRemark9.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } } //借机操作 if (cbbPhoneNum.Text != "") { //借与还操作 if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum.Text, LoginForm.usrName)) { } else { MessageBox.Show(this.cbbPhoneNum.Text + "借", "提示"); } if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum.Text, cbbHGroupTest.Text, cbbIsNormal.Text, txtRemark.Text)) { //MessageBox.Show("操作成功", "提示"); } else { MessageBox.Show(this.cbbPhoneNum.Text + "还", "提示"); } } //借机操作2 if (cbbPhoneNum1.Text != "") { //借与还操作 if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum1.Text, LoginForm.usrName)) { } else { MessageBox.Show(this.cbbPhoneNum1.Text + "借错误", "提示"); } if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum1.Text, cbbHGroupTest.Text, cbbIsNormal1.Text, txtRemark1.Text)) { //MessageBox.Show("操作成功", "提示"); } else { MessageBox.Show(this.cbbPhoneNum1.Text + "还错误", "提示"); } } //操作3 if (cbbPhoneNum2.Text != "") { //借与还操作 if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum2.Text, LoginForm.usrName)) { } else { MessageBox.Show(this.cbbPhoneNum2.Text + "借错误", "提示"); } if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum2.Text, cbbHGroupTest.Text, cbbIsNormal2.Text, txtRemark2.Text)) { //MessageBox.Show("操作成功", "提示"); } else { MessageBox.Show(this.cbbPhoneNum2.Text + "还错误", "提示"); } } //操作4 if (cbbPhoneNum3.Text != "") { //借与还操作 if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum3.Text, LoginForm.usrName)) { } else { MessageBox.Show(this.cbbPhoneNum3.Text + "借错误", "提示"); } if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum3.Text, cbbHGroupTest.Text, cbbIsNormal3.Text, txtRemark3.Text)) { //MessageBox.Show("操作成功", "提示"); } else { MessageBox.Show(this.cbbPhoneNum3.Text + "还错误", "提示"); } } //操作5 if (cbbPhoneNum4.Text != "") { //样机状态是否正常,若是故障时需要输入备注 if (cbbIsNormal4.Text == "故障" && txtRemark4.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } //借与还操作 if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum4.Text, LoginForm.usrName)) { } else { MessageBox.Show(this.cbbPhoneNum4.Text + "借错误", "提示"); } if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum4.Text, cbbHGroupTest.Text, cbbIsNormal4.Text, txtRemark4.Text)) { //MessageBox.Show("操作成功", "提示"); } else { MessageBox.Show(this.cbbPhoneNum4.Text + "还错误", "提示"); } } //操作6 if (cbbPhoneNum5.Text != "") { //样机状态是否正常,若是故障时需要输入备注 if (cbbIsNormal5.Text == "故障" && txtRemark5.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } //借与还操作 if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum5.Text, LoginForm.usrName)) { } else { MessageBox.Show(this.cbbPhoneNum5.Text + "借错误", "提示"); } if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum5.Text, cbbHGroupTest.Text, cbbIsNormal5.Text, txtRemark5.Text)) { //MessageBox.Show("操作成功", "提示"); } else { MessageBox.Show(this.cbbPhoneNum5.Text + "还错误", "提示"); } } //操作7 if (cbbPhoneNum6.Text != "") { //样机状态是否正常,若是故障时需要输入备注 if (cbbIsNormal6.Text == "故障" && txtRemark6.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } //借与还操作 if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum6.Text, LoginForm.usrName)) { } else { MessageBox.Show(this.cbbPhoneNum6.Text + "借错误", "提示"); } if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum6.Text, cbbHGroupTest.Text, cbbIsNormal6.Text, txtRemark6.Text)) { //MessageBox.Show("操作成功", "提示"); } else { MessageBox.Show(this.cbbPhoneNum6.Text + "还错误", "提示"); } } //操作8 if (cbbPhoneNum7.Text != "") { //样机状态是否正常,若是故障时需要输入备注 if (cbbIsNormal7.Text == "故障" && txtRemark7.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } //借与还操作 if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum7.Text, LoginForm.usrName)) { } else { MessageBox.Show(this.cbbPhoneNum7.Text + "借错误", "提示"); } if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum7.Text, cbbHGroupTest.Text, cbbIsNormal7.Text, txtRemark7.Text)) { //MessageBox.Show("操作成功", "提示"); } else { MessageBox.Show(this.cbbPhoneNum7.Text + "还错误", "提示"); } } //操作9 if (cbbPhoneNum8.Text != "") { //样机状态是否正常,若是故障时需要输入备注 if (cbbIsNormal8.Text == "故障" && txtRemark8.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } //借与还操作 if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum8.Text, LoginForm.usrName)) { } else { MessageBox.Show(this.cbbPhoneNum8.Text + "借错误", "提示"); } if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum8.Text, cbbHGroupTest.Text, cbbIsNormal8.Text, txtRemark8.Text)) { //MessageBox.Show("操作成功", "提示"); } else { MessageBox.Show(this.cbbPhoneNum8.Text + "还错误", "提示"); } } //操作10 if (cbbPhoneNum9.Text != "") { //样机状态是否正常,若是故障时需要输入备注 if (cbbIsNormal9.Text == "故障" && txtRemark9.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } //借与还操作 if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum9.Text, LoginForm.usrName)) { } else { MessageBox.Show(this.cbbPhoneNum9.Text + "借错误", "提示"); } if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum9.Text, cbbHGroupTest.Text, cbbIsNormal9.Text, txtRemark9.Text)) { //MessageBox.Show("操作成功", "提示"); } else { MessageBox.Show(this.cbbPhoneNum9.Text + "还错误", "提示"); } } MessageBox.Show("操作成功"); } string strSql = "select * from PmBorrow where StaffName = '" + LoginForm.usrName + "' order by BorrowID DESC"; //样机名称combobox内容加载 borrows = borrowbll.selByCondition(strSql); //DataGrid 内容加载 borrowDataGrid.DataSource = borrows; //借机相关内容更新********************************************************** strSql = "select distinct PhoneName from PmPhone where PhoneStatus = '在库'and PhoneDisplay = 'TRUE'"; //更新借样机cbb中样机信息 MySqlCommand cmd = new MySqlCommand(strSql, conn); MySqlDataAdapter da = new MySqlDataAdapter(cmd); DataSet ds = new DataSet(); conn.Open(); da.Fill(ds, "PmPhone"); conn.Close(); cbbPhoneName.DisplayMember = "PhoneName"; cbbPhoneName.ValueMember = "PhoneName"; cbbPhoneName.DataSource = ds.Tables["PmPhone"]; cbbPhoneName.Text = ""; //收尾工作:清空无关信息 txtRemark.Text = ""; txtRemark1.Text = ""; txtRemark2.Text = ""; txtRemark3.Text = ""; txtRemark4.Text = ""; txtRemark5.Text = ""; txtRemark6.Text = ""; txtRemark7.Text = ""; txtRemark8.Text = ""; txtRemark9.Text = ""; //默认正常 cbbIsNormal.Text = "正常"; cbbIsNormal1.Text = "正常"; cbbIsNormal2.Text = "正常"; cbbIsNormal3.Text = "正常"; cbbIsNormal4.Text = "正常"; cbbIsNormal5.Text = "正常"; cbbIsNormal6.Text = "正常"; cbbIsNormal7.Text = "正常"; cbbIsNormal8.Text = "正常"; cbbIsNormal9.Text = "正常"; }
private void btnReturn_Click(object sender, EventArgs e) //还样机按钮 { string ip = Fuctions.GetIpAddress(); //if (LoginForm.admin == 0) //{ // if (ip != IPADRESS && ip != IPADDRESS1 && ip != IPADRESS2) // { // MessageBox.Show("请去指定电脑进行样机借阅"); // return; // } //} BorrowBLL borrowbll = new BorrowBLL(); PhoneBLL phonebll = new PhoneBLL(); // 若是第一行的四个中有一个为空,则给出提示 if (cbbPhoneName1.Text == "" || cbbPhoneStage1.Text == "" || cbbHGroupName1.Text == "" || cbbHGroupTest1.Text == "") { MessageBox.Show("请输入除备注以外的所有信息", "提示"); return; } //若是五行中的 样机编号没有选,给出提示 if (cbbPhoneNum1.Text == "" && cbbPhoneNum2.Text == "" && cbbPhoneNum3.Text == "" && cbbPhoneNum4.Text == "" && cbbPhoneNum5.Text == "") { MessageBox.Show("请输入归还的样机编号"); } //样机归还时第一行的信息是否完整 if (cbbPhoneNum1.Text != "") { if (cbbPhoneNum1.Text == cbbPhoneNum2.Text || cbbPhoneNum1.Text == cbbPhoneNum3.Text || cbbPhoneNum1.Text == cbbPhoneNum4.Text || cbbPhoneNum1.Text == cbbPhoneNum5.Text) { MessageBox.Show("归还样机编号重复,请检查编号"); return; } if (cbbIsNormal1.Text == "") { MessageBox.Show("请输入样机状态"); return; } if (cbbIsNormal1.Text == "故障" && txtRemark1.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } else { if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum1.Text, cbbHGroupTest1.Text + "|" + cbbHGroupTest2.Text + "|" + cbbHGroupTest3.Text, cbbIsNormal1.Text, txtRemark1.Text) && phonebll.updatePhoneStatusIn(cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum1.Text)) { MessageBox.Show("样机归还成功", "提示"); } else { MessageBox.Show("样机状态未成功更新,请检查信息是否输入正确", "提示"); } } } //样机归还时第二行的信息是否完整 if (cbbPhoneNum2.Text != "") { if (cbbPhoneNum2.Text == cbbPhoneNum1.Text || cbbPhoneNum2.Text == cbbPhoneNum3.Text || cbbPhoneNum2.Text == cbbPhoneNum4.Text || cbbPhoneNum2.Text == cbbPhoneNum5.Text) { MessageBox.Show("归还样机编号重复,请检查编号"); return; } if (cbbIsNormal2.Text == "") { MessageBox.Show("请输入样机状态"); return; } if (cbbIsNormal2.Text == "故障" && txtRemark2.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } else { if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum2.Text, cbbHGroupTest1.Text + "|" + cbbHGroupTest2.Text + "|" + cbbHGroupTest3.Text, cbbIsNormal2.Text, txtRemark2.Text) && phonebll.updatePhoneStatusIn(cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum2.Text)) { // MessageBox.Show("样机归还成功", "提示"); } else { MessageBox.Show("样机状态未成功更新,请检查信息是否输入正确", "提示"); } } } //样机归还时第三行的信息是否完整 if (cbbPhoneNum3.Text != "") { if (cbbPhoneNum3.Text == cbbPhoneNum1.Text || cbbPhoneNum3.Text == cbbPhoneNum2.Text || cbbPhoneNum3.Text == cbbPhoneNum4.Text || cbbPhoneNum3.Text == cbbPhoneNum5.Text) { MessageBox.Show("归还样机编号重复,请检查编号"); return; } if (cbbIsNormal3.Text == "") { MessageBox.Show("请输入样机状态"); return; } if (cbbIsNormal3.Text == "故障" && txtRemark3.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } else { if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum3.Text, cbbHGroupTest1.Text + "|" + cbbHGroupTest2.Text + "|" + cbbHGroupTest3.Text, cbbIsNormal3.Text, txtRemark3.Text) && phonebll.updatePhoneStatusIn(cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum3.Text)) { //MessageBox.Show("样机归还成功", "提示"); } else { MessageBox.Show("样机状态未成功更新,请检查信息是否输入正确", "提示"); } } } //样机归还时第四行的信息是否完整 if (cbbPhoneNum4.Text != "") { if (cbbPhoneNum4.Text == cbbPhoneNum1.Text || cbbPhoneNum4.Text == cbbPhoneNum2.Text || cbbPhoneNum4.Text == cbbPhoneNum3.Text || cbbPhoneNum4.Text == cbbPhoneNum5.Text) { MessageBox.Show("归还样机编号重复,请检查编号"); return; } if (cbbIsNormal4.Text == "") { MessageBox.Show("请输入样机状态"); return; } if (cbbIsNormal4.Text == "故障" && txtRemark4.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } else { if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum4.Text, cbbHGroupTest1.Text + "|" + cbbHGroupTest2.Text + "|" + cbbHGroupTest3.Text, cbbIsNormal4.Text, txtRemark4.Text) && phonebll.updatePhoneStatusIn(cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum4.Text)) { //MessageBox.Show("样机归还成功", "提示"); } else { MessageBox.Show("样机状态未成功更新,请检查信息是否输入正确", "提示"); } } } //样机归还时第五行的信息是否完整 if (cbbPhoneNum5.Text != "") { if (cbbPhoneNum5.Text == cbbPhoneNum1.Text || cbbPhoneNum5.Text == cbbPhoneNum2.Text || cbbPhoneNum5.Text == cbbPhoneNum3.Text || cbbPhoneNum5.Text == cbbPhoneNum4.Text) { MessageBox.Show("归还样机编号重复,请检查编号"); return; } if (cbbIsNormal5.Text == "") { MessageBox.Show("请输入样机状态"); return; } if (cbbIsNormal5.Text == "故障" && txtRemark5.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } else { if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum5.Text, cbbHGroupTest1.Text + "|" + cbbHGroupTest2.Text + "|" + cbbHGroupTest3.Text, cbbIsNormal5.Text, txtRemark5.Text) && phonebll.updatePhoneStatusIn(cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum5.Text)) { //MessageBox.Show("样机归还成功", "提示"); } else { MessageBox.Show("样机状态未成功更新,请检查信息是否输入正确", "提示"); } } } string strSql = "select * from PmBorrow where StaffName = '" + LoginForm.usrName + "' and IsReturn = 'false' order by BorrowID DESC"; //样机名称combobox内容加载 borrows = borrowbll.selByCondition(strSql); //DataGrid 内容加载 borrowDataGrid.DataSource = borrows; //借机相关内容更新********************************************************** strSql = "select distinct PhoneName from PmPhone where PhoneStatus = '在库' and PhoneDisplay = 'TRUE'"; //更新样机cbb信息 MySqlCommand cmd = new MySqlCommand(strSql, conn); MySqlDataAdapter da = new MySqlDataAdapter(cmd); DataSet ds = new DataSet(); conn.Open(); da.Fill(ds, "PmPhone"); conn.Close(); cbbPhoneName.DisplayMember = "PhoneName"; cbbPhoneName.ValueMember = "PhoneName"; cbbPhoneName.DataSource = ds.Tables["PmPhone"]; cbbPhoneName.Text = ""; //**********************************************************还机相关内容更新 strSql = "select distinct PhoneName from PmBorrow where IsReturn = 'false' and StaffName = '" + LoginForm.usrName + "'"; //还样机名称combobox内容加载 cmd = new MySqlCommand(strSql, conn); da = new MySqlDataAdapter(cmd); ds = new DataSet(); conn.Open(); da.Fill(ds, "PmBorrow"); conn.Close(); cbbPhoneName1.DisplayMember = "PhoneName"; cbbPhoneName1.ValueMember = "PhoneName"; cbbPhoneName1.DataSource = ds.Tables["PmBorrow"]; cbbPhoneName1.Text = ""; //--其余的清空 cbbHGroupName1.Text = ""; cbbHGroupTest1.Text = ""; cbbHGroupName2.Text = ""; cbbHGroupTest2.Text = ""; cbbHGroupName3.Text = ""; cbbHGroupTest3.Text = ""; cbbIsNormal1.Text = ""; txtRemark1.Text = ""; cbbIsNormal2.Text = ""; txtRemark2.Text = ""; cbbIsNormal3.Text = ""; txtRemark3.Text = ""; cbbIsNormal4.Text = ""; txtRemark4.Text = ""; cbbIsNormal5.Text = ""; txtRemark5.Text = ""; }
private void btnReturn_Click(object sender, EventArgs e) //还样机按钮 { string ip = Fuctions.GetIpAddress(); if (LoginForm.admin == 0) { if (ip != IPADRESS && ip != IPADDRESS1 && ip != IPADRESS2) { MessageBox.Show("请去指定电脑进行样机借阅"); return; } } //MySqlConnection conn = new MySqlConnection(GetConn.connection); //连接对象 BorrowBLL borrowbll = new BorrowBLL(); PhoneBLL phonebll = new PhoneBLL(); // 若是第一行的五个中有一个为空,则给出提示 if (cbbStaffName1.Text == "" || cbbPhoneName1.Text == "" || cbbPhoneStage1.Text == "" || cbbHGroupName1.Text == "" || cbbHGroupTest1.Text == "") { MessageBox.Show("请输入除备注以外的所有信息", "提示"); return; } //若是五行中的 样机编号没有选,给出提示 if (cbbPhoneNum1.Text == "" && cbbPhoneNum2.Text == "" && cbbPhoneNum3.Text == "" && cbbPhoneNum4.Text == "" && cbbPhoneNum5.Text == "") { MessageBox.Show("请输入归还的样机编号"); } //样机归还时第一行的信息是否完整 if (cbbPhoneNum1.Text != "") { if (cbbPhoneNum1.Text == cbbPhoneNum2.Text || cbbPhoneNum1.Text == cbbPhoneNum3.Text || cbbPhoneNum1.Text == cbbPhoneNum4.Text || cbbPhoneNum1.Text == cbbPhoneNum5.Text) { MessageBox.Show("归还样机编号重复,请检查编号"); return; } if (cbbIsNormal1.Text == "") { MessageBox.Show("请输入样机状态"); return; } if (cbbIsNormal1.Text == "故障" && txtRemark1.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } else { if (borrowbll.returnPhone(cbbStaffName1.Text, cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum1.Text, cbbHGroupTest1.Text, cbbIsNormal1.Text, txtRemark1.Text) && phonebll.updatePhoneStatusIn(cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum1.Text)) { // MessageBox.Show("样机归还成功", "提示"); } else { MessageBox.Show("样机状态未成功更新,请检查信息是否输入正确", "提示"); } } } //样机归还时第二行的信息是否完整 if (cbbPhoneNum2.Text != "") { if (cbbPhoneNum2.Text == cbbPhoneNum1.Text || cbbPhoneNum2.Text == cbbPhoneNum3.Text || cbbPhoneNum2.Text == cbbPhoneNum4.Text || cbbPhoneNum2.Text == cbbPhoneNum5.Text) { MessageBox.Show("归还样机编号重复,请检查编号"); return; } if (cbbIsNormal2.Text == "") { MessageBox.Show("请输入样机状态"); return; } if (cbbIsNormal2.Text == "故障" && txtRemark2.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } else { if (borrowbll.returnPhone(cbbStaffName1.Text, cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum2.Text, cbbHGroupTest1.Text, cbbIsNormal2.Text, txtRemark2.Text) && phonebll.updatePhoneStatusIn(cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum2.Text)) { // MessageBox.Show("样机归还成功", "提示"); } else { MessageBox.Show("样机状态未成功更新,请检查信息是否输入正确", "提示"); } } } //样机归还时第三行的信息是否完整 if (cbbPhoneNum3.Text != "") { if (cbbPhoneNum3.Text == cbbPhoneNum1.Text || cbbPhoneNum3.Text == cbbPhoneNum2.Text || cbbPhoneNum3.Text == cbbPhoneNum4.Text || cbbPhoneNum3.Text == cbbPhoneNum5.Text) { MessageBox.Show("归还样机编号重复,请检查编号"); return; } if (cbbIsNormal3.Text == "") { MessageBox.Show("请输入样机状态"); return; } if (cbbIsNormal3.Text == "故障" && txtRemark3.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } else { if (borrowbll.returnPhone(cbbStaffName1.Text, cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum3.Text, cbbHGroupTest1.Text, cbbIsNormal3.Text, txtRemark3.Text) && phonebll.updatePhoneStatusIn(cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum3.Text)) { //MessageBox.Show("样机归还成功", "提示"); } else { MessageBox.Show("样机状态未成功更新,请检查信息是否输入正确", "提示"); } } } //样机归还时第四行的信息是否完整 if (cbbPhoneNum4.Text != "") { if (cbbPhoneNum4.Text == cbbPhoneNum1.Text || cbbPhoneNum4.Text == cbbPhoneNum2.Text || cbbPhoneNum4.Text == cbbPhoneNum3.Text || cbbPhoneNum4.Text == cbbPhoneNum5.Text) { MessageBox.Show("归还样机编号重复,请检查编号"); return; } if (cbbIsNormal4.Text == "") { MessageBox.Show("请输入样机状态"); return; } if (cbbIsNormal4.Text == "故障" && txtRemark4.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } else { if (borrowbll.returnPhone(cbbStaffName1.Text, cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum4.Text, cbbHGroupTest1.Text, cbbIsNormal4.Text, txtRemark4.Text) && phonebll.updatePhoneStatusIn(cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum4.Text)) { //MessageBox.Show("样机归还成功", "提示"); } else { MessageBox.Show("样机状态未成功更新,请检查信息是否输入正确", "提示"); } } } //样机归还时第五行的信息是否完整 if (cbbPhoneNum5.Text != "") { if (cbbPhoneNum5.Text == cbbPhoneNum1.Text || cbbPhoneNum5.Text == cbbPhoneNum2.Text || cbbPhoneNum5.Text == cbbPhoneNum3.Text || cbbPhoneNum5.Text == cbbPhoneNum4.Text) { MessageBox.Show("归还样机编号重复,请检查编号"); return; } if (cbbIsNormal5.Text == "") { MessageBox.Show("请输入样机状态"); return; } if (cbbIsNormal5.Text == "故障" && txtRemark5.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } else { if (borrowbll.returnPhone(cbbStaffName1.Text, cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum5.Text, cbbHGroupTest1.Text, cbbIsNormal5.Text, txtRemark5.Text) && phonebll.updatePhoneStatusIn(cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum5.Text)) { //MessageBox.Show("样机归还成功", "提示"); } else { MessageBox.Show("样机状态未成功更新,请检查信息是否输入正确", "提示"); } } } borrows = borrowbll.GetAllBorrow(); borrowDataGrid.DataSource = borrows; //**********************************************************借机相关内容更新 string strSql = "select distinct PhoneName from PmPhone where PhoneStatus = '在库' and PhoneDisplay = 'TRUE'"; //更新cbb中样机信息 MySqlCommand cmd = new MySqlCommand(strSql, conn); MySqlDataAdapter da = new MySqlDataAdapter(cmd); DataSet ds = new DataSet(); conn.Open(); da.Fill(ds, "PmPhone"); conn.Close(); cbbPhoneName.DisplayMember = "PhoneName"; cbbPhoneName.ValueMember = "PhoneName"; cbbPhoneName.DataSource = ds.Tables["PmPhone"]; cbbPhoneName.Text = ""; //**********************************************************还机相关内容更新 //strSql = "select distinct StaffName from PmBorrow"; //--还员工姓名combobox内容更新 strSql = "select distinct StaffName from PmBorrow where IsReturn='false' order by convert(StaffName USING gbk) asc"; cmd = new MySqlCommand(strSql, conn); da = new MySqlDataAdapter(cmd); ds = new DataSet(); conn.Open(); da.Fill(ds, "PmBorrow"); conn.Close(); cbbStaffName1.DisplayMember = "StaffName"; cbbStaffName1.ValueMember = "StaffName"; cbbStaffName1.DataSource = ds.Tables["PmBorrow"]; cbbStaffName1.Text = ""; //cbbHGroupName1.Text = ""; //--其余的清空 //cbbHGroupTest1.Text = ""; cbbIsNormal1.Text = ""; txtRemark1.Text = ""; cbbIsNormal2.Text = ""; txtRemark2.Text = ""; cbbIsNormal3.Text = ""; txtRemark3.Text = ""; cbbIsNormal4.Text = ""; txtRemark4.Text = ""; cbbIsNormal5.Text = ""; txtRemark5.Text = ""; }
private void btnReturn_Click(object sender, EventArgs e) //还样机按钮 { string ip = Fuctions.GetIpAddress(); if (LoginForm.admin == 0) { if (ip != IPADRESS) { MessageBox.Show("请去指定电脑进行样机借阅"); return; } } BorrowBLL borrowbll = new BorrowBLL(); PhoneBLL phonebll = new PhoneBLL(); if (cbbPhoneName1.Text == "" || cbbPhoneStage1.Text == "" || cbbPhoneNum1.Text == "" || cbbHGroupName1.Text == "" || cbbHGroupTest1.Text == "" || cbbIsNormal1.Text == "") { MessageBox.Show("请输入除备注以外的所有信息", "提示"); return; } else if (cbbIsNormal1.Text == "故障" && txtRemark.Text == "") { MessageBox.Show("样机故障,请输入故障信息", "提示"); return; } else { if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum1.Text, cbbHGroupTest1.Text, cbbIsNormal1.Text, txtRemark.Text)) { MessageBox.Show("样机归还成功", "提示"); } if (phonebll.updatePhoneStatusIn(cbbPhoneName1.Text, cbbPhoneStage1.Text, cbbPhoneNum1.Text)) { MessageBox.Show("样机状态更新成功", "提示"); } else { MessageBox.Show("样机状态未成功更新,请检查信息是否输入正确", "提示"); } } borrows = borrowbll.GetAllBorrow(); borrowDataGrid.DataSource = borrows; //借机相关内容更新********************************************************** string strSql = "select distinct PhoneName from PmPhone where PhoneStatus = '在库' and PhoneDisplay = 'TRUE'"; //更新样机cbb信息 MySqlCommand cmd = new MySqlCommand(strSql, conn); MySqlDataAdapter da = new MySqlDataAdapter(cmd); DataSet ds = new DataSet(); conn.Open(); da.Fill(ds, "PmPhone"); conn.Close(); cbbPhoneName.DisplayMember = "PhoneName"; cbbPhoneName.ValueMember = "PhoneName"; cbbPhoneName.DataSource = ds.Tables["PmPhone"]; cbbPhoneName.Text = ""; //**********************************************************还机相关内容更新 strSql = "select distinct PhoneName from PmBorrow where IsReturn = 'false' and StaffName = '" + LoginForm.usrName + "'"; //还样机名称combobox内容加载 cmd = new MySqlCommand(strSql, conn); da = new MySqlDataAdapter(cmd); ds = new DataSet(); conn.Open(); da.Fill(ds, "PmBorrow"); conn.Close(); cbbPhoneName1.DisplayMember = "PhoneName"; cbbPhoneName1.ValueMember = "PhoneName"; cbbPhoneName1.DataSource = ds.Tables["PmBorrow"]; cbbPhoneName1.Text = ""; cbbHGroupName1.Text = ""; //--其余的清空 cbbHGroupTest1.Text = ""; cbbIsNormal1.Text = ""; txtRemark.Text = ""; }