private void button1_Click(object sender, EventArgs e) //借样机按钮 { string ip = Fuctions.GetIpAddress(); if (LoginForm.admin == 0) { if (ip != IPADRESS && ip != IPADDRESS1 && ip != IPADRESS2 && ip != IPADRESS3) { MessageBox.Show("请去指定电脑进行样机借阅", "提示"); return; } } //MySqlConnection conn = new MySqlConnection(GetConn.connection); //连接对象 BorrowBLL borrowbll = new BorrowBLL(); PhoneBLL phonebll = new PhoneBLL(); if (cbbStaffName.Text == "" || cbbPhoneName.Text == "" || cbbPhoneStage.Text == "" || ((cbbPhoneNum.Text == "") && (cbbPhoneNumL1.Text == "") && (cbbPhoneNumL2.Text == "") && (cbbPhoneNumL3.Text == "") && (cbbPhoneNumL4.Text == ""))) { MessageBox.Show("请输入样机信息"); return; } else { if (cbbPhoneNum.Text != "") { if (cbbPhoneNum.Text == cbbPhoneNumL1.Text || cbbPhoneNum.Text == cbbPhoneNumL2.Text || cbbPhoneNum.Text == cbbPhoneNumL3.Text || cbbPhoneNum.Text == cbbPhoneNumL4.Text) { MessageBox.Show("借阅样机编号重复,请检查编号"); return; } if (borrowbll.addBorrow(this.cbbStaffName.Text, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum.Text, LoginForm.usrName)) { //MessageBox.Show("借阅成功"); } if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum.Text)) //更新数据库 PmPhone 中的信息 { //MessageBox.Show("借阅成功"); } } if (cbbPhoneNumL1.Text != "") { if (cbbPhoneNumL1.Text == cbbPhoneNum.Text || cbbPhoneNumL1.Text == cbbPhoneNumL2.Text || cbbPhoneNumL1.Text == cbbPhoneNumL3.Text || cbbPhoneNumL1.Text == cbbPhoneNumL4.Text) { MessageBox.Show("借阅样机编号重复,请检查编号"); return; } if (borrowbll.addBorrow(this.cbbStaffName.Text, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNumL1.Text, LoginForm.usrName)) { //MessageBox.Show("借阅成功"); } if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNumL1.Text)) //更新数据库 PmPhone 中的信息 { //MessageBox.Show("借阅成功"); } } if (cbbPhoneNumL2.Text != "") { if (cbbPhoneNumL2.Text == cbbPhoneNum.Text || cbbPhoneNumL2.Text == cbbPhoneNumL1.Text || cbbPhoneNumL2.Text == cbbPhoneNumL3.Text || cbbPhoneNumL2.Text == cbbPhoneNumL4.Text) { MessageBox.Show("借阅样机编号重复,请检查编号"); return; } if (borrowbll.addBorrow(this.cbbStaffName.Text, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNumL2.Text, LoginForm.usrName)) { //MessageBox.Show("借阅成功"); } if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNumL2.Text)) //更新数据库 PmPhone 中的信息 { //MessageBox.Show("借阅成功"); } } if (cbbPhoneNumL3.Text != "") { if (cbbPhoneNumL3.Text == cbbPhoneNum.Text || cbbPhoneNumL3.Text == cbbPhoneNumL1.Text || cbbPhoneNumL3.Text == cbbPhoneNumL2.Text || cbbPhoneNumL3.Text == cbbPhoneNumL4.Text) { MessageBox.Show("借阅样机编号重复,请检查编号"); return; } if (borrowbll.addBorrow(this.cbbStaffName.Text, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNumL3.Text, LoginForm.usrName)) { //MessageBox.Show("借阅成功"); } if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNumL3.Text)) //更新数据库 PmPhone 中的信息 { //MessageBox.Show("借阅成功"); } } if (cbbPhoneNumL4.Text != "") { if (cbbPhoneNumL4.Text == cbbPhoneNum.Text || cbbPhoneNumL4.Text == cbbPhoneNumL1.Text || cbbPhoneNumL4.Text == cbbPhoneNumL2.Text || cbbPhoneNumL4.Text == cbbPhoneNumL3.Text) { MessageBox.Show("借阅样机编号重复,请检查编号"); return; } if (borrowbll.addBorrow(this.cbbStaffName.Text, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNumL4.Text, LoginForm.usrName)) { //MessageBox.Show("借阅成功"); } if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNumL4.Text)) //更新数据库 PmPhone 中的信息 { //MessageBox.Show("借阅成功"); } } MessageBox.Show("借阅成功"); } borrows = borrowbll.GetAllBorrow(); //DataGridView显示所借样机 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 PmStaff"; //还员工姓名combobox内容加载--cbbPhoneName1--cbbPhoneStage1--cbbPhoneNum1 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, "PmStaff"); conn.Close(); cbbStaffName1.DisplayMember = "StaffName"; cbbStaffName1.ValueMember = "StaffName"; cbbStaffName1.DataSource = ds.Tables["PmStaff"]; cbbStaffName1.Text = ""; }
private void button1_Click(object sender, EventArgs e) //借样机按钮 { string ip = Fuctions.GetIpAddress(); if (LoginForm.admin == 0) { if (ip != IPADRESS && ip != IPADDRESS1 && ip != IPADRESS2 && ip != IPADRESS3) { MessageBox.Show("请去指定电脑进行样机借阅", "提示"); return; } } BorrowBLL borrowbll = new BorrowBLL(); PhoneBLL phonebll = new PhoneBLL(); if (cbbPhoneName.Text == "" || cbbPhoneStage.Text == "" || ((cbbPhoneNum.Text == "") && (cbbPhoneNumL1.Text == "") && (cbbPhoneNumL2.Text == "") && (cbbPhoneNumL3.Text == "") && (cbbPhoneNumL4.Text == ""))) { MessageBox.Show("请输入样机信息"); return; } else { if (cbbPhoneNum.Text != "") { if (cbbPhoneNum.Text == cbbPhoneNumL1.Text || cbbPhoneNum.Text == cbbPhoneNumL2.Text || cbbPhoneNum.Text == cbbPhoneNumL3.Text || cbbPhoneNum.Text == cbbPhoneNumL4.Text) { MessageBox.Show("借阅样机编号重复,请检查编号"); return; } if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum.Text, LoginForm.usrName)) { //MessageBox.Show("借阅成功"); } if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum.Text)) //更新数据库 PmPhone 中的信息 { //MessageBox.Show("借阅成功"); } } if (cbbPhoneNumL1.Text != "") { if (cbbPhoneNumL1.Text == cbbPhoneNum.Text || cbbPhoneNumL1.Text == cbbPhoneNumL2.Text || cbbPhoneNumL1.Text == cbbPhoneNumL3.Text || cbbPhoneNumL1.Text == cbbPhoneNumL4.Text) { MessageBox.Show("借阅样机编号重复,请检查编号"); return; } if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNumL1.Text, LoginForm.usrName)) { //MessageBox.Show("借阅成功"); } if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNumL1.Text)) //更新数据库 PmPhone 中的信息 { //MessageBox.Show("借阅成功"); } } if (cbbPhoneNumL2.Text != "") { if (cbbPhoneNumL2.Text == cbbPhoneNum.Text || cbbPhoneNumL2.Text == cbbPhoneNumL1.Text || cbbPhoneNumL2.Text == cbbPhoneNumL3.Text || cbbPhoneNumL2.Text == cbbPhoneNumL4.Text) { MessageBox.Show("借阅样机编号重复,请检查编号"); return; } if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNumL2.Text, LoginForm.usrName)) { //MessageBox.Show("借阅成功"); } if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNumL2.Text)) //更新数据库 PmPhone 中的信息 { //MessageBox.Show("借阅成功"); } } if (cbbPhoneNumL3.Text != "") { if (cbbPhoneNumL3.Text == cbbPhoneNum.Text || cbbPhoneNumL3.Text == cbbPhoneNumL1.Text || cbbPhoneNumL3.Text == cbbPhoneNumL2.Text || cbbPhoneNumL3.Text == cbbPhoneNumL4.Text) { MessageBox.Show("借阅样机编号重复,请检查编号"); return; } if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNumL3.Text, LoginForm.usrName)) { //MessageBox.Show("借阅成功"); } if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNumL3.Text)) //更新数据库 PmPhone 中的信息 { //MessageBox.Show("借阅成功"); } } if (cbbPhoneNumL4.Text != "") { if (cbbPhoneNumL4.Text == cbbPhoneNum.Text || cbbPhoneNumL4.Text == cbbPhoneNumL1.Text || cbbPhoneNumL4.Text == cbbPhoneNumL2.Text || cbbPhoneNumL4.Text == cbbPhoneNumL3.Text) { MessageBox.Show("借阅样机编号重复,请检查编号"); return; } if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNumL4.Text, LoginForm.usrName)) { //MessageBox.Show("借阅成功"); } if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNumL4.Text)) //更新数据库 PmPhone 中的信息 { //MessageBox.Show("借阅成功"); } } 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 = ""; }