private void btnOk_Click(object sender, EventArgs e) { string strSql = "select * from PmBorrow where 1=1"; string strSqlNum = "select * from PmPhone where 1 = 1"; string strSqlNumOut = "select * from PmPhone where 1 = 1 and PhoneStatus = '借出'"; string num = ""; string numOut = ""; txtNum.Text = ""; txtNumOut.Text = ""; if (cbbStaffName.Text == "" && cbbPhoneName.Text == "" && cbbPhoneStage.Text == "" && cbbPhoneNum.Text == "" && cbbHGroupTest.Text == "" && cbbIsNormal.Text == "" && cbbIsReturn.Text == "") { MessageBox.Show("请选择查询条件", "提示"); return; } if (cbbStaffName.Text != "") { strSql = strSql + " and StaffName ='" + cbbStaffName.Text + "'"; } if (cbbPhoneName.Text != "") { strSql = strSql + " and PhoneName ='" + cbbPhoneName.Text + "'"; } if (cbbPhoneStage.Text != "") { strSql = strSql + " and PhoneStage ='" + cbbPhoneStage.Text + "'"; } if (cbbPhoneNum.Text != "") { strSql = strSql + " and PhoneNum ='" + cbbPhoneNum.Text + "'"; } if (cbbHGroupTest.Text != "") { strSql = strSql + " and Test ='" + cbbHGroupTest.Text + "'"; } if (cbbIsNormal.Text != "") { strSql = strSql + " and IsNormal ='" + cbbIsNormal.Text + "'"; } if (cbbIsReturn.Text != "") { strSql = strSql + " and IsReturn ='" + cbbIsReturn.Text + "'"; } strSql = strSql + " order by BorrowID desc"; BorrowBLL borrowbll = new BorrowBLL(); borrows = borrowbll.selByCondition(strSql); borrowQDataGrid.DataSource = borrows; PhoneBLL phonebll = new PhoneBLL(); if (cbbPhoneName.Text != "") { strSqlNum = strSqlNum + " and PhoneName ='" + cbbPhoneName.Text + "'"; strSqlNumOut = strSqlNumOut + " and PhoneName ='" + cbbPhoneName.Text + "'"; if (cbbPhoneStage.Text != "") { strSqlNum = strSqlNum + " and PhoneStage ='" + cbbPhoneStage.Text + "'"; strSqlNumOut = strSqlNumOut + " and PhoneStage ='" + cbbPhoneStage.Text + "'"; } num = phonebll.selByConditionNum(strSqlNum); numOut = phonebll.selByConditionNum(strSqlNumOut); txtNum.Text = num; txtNumOut.Text = numOut; } }