public SMSPhoneNumChoose() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // DataSet TeaDept = new RolesSystem().GetRolesDuty(Convert.ToInt32(Thread.CurrentPrincipal.Identity.Name)); PhoneNum = new SMSInfoSystem().GetAllStuPhoneNum(); //学生卡 PhoneNumView = PhoneNum.Tables[0].DefaultView; string rowFilter = string.Empty; if (Thread.CurrentPrincipal.Identity.Name.ToLower() == "admin") { return; } if (!Thread.CurrentPrincipal.IsInRole("园长") && !Thread.CurrentPrincipal.IsInRole("保健")) { rowFilter = rowFilter + "stu_grade = '" + TeaDept.Tables[0].Rows[0][0].ToString() + "'"; rowFilter = rowFilter + " and stu_class = '" + TeaDept.Tables[0].Rows[0][1].ToString() + "'"; } PhoneNumView.RowFilter = rowFilter; gridControl2.DataSource = PhoneNumView; }
private void SelectPhoneInfo(string name, string id, string grade, string className) { DataSet TeaDept = new RolesSystem().GetRolesDuty(Convert.ToInt32(Thread.CurrentPrincipal.Identity.Name)); string rowFilter = string.Empty; if (!Thread.CurrentPrincipal.IsInRole("园长") && !Thread.CurrentPrincipal.IsInRole("保健")) { rowFilter = "info_stuName like '%" + name + "%'"; rowFilter = rowFilter + " and stu_grade = '" + TeaDept.Tables[0].Rows[0][0].ToString() + "'"; rowFilter = rowFilter + " and stu_class = '" + TeaDept.Tables[0].Rows[0][1].ToString() + "'"; if (id.Length == 4) { rowFilter += " and info_stuNumber=" + id; } } else { rowFilter = "info_stuName like '%" + name + "%'"; if (grade.Equals("全部")) { rowFilter = rowFilter + " and stu_grade like '%'"; } else { rowFilter = rowFilter + " and stu_grade like '%" + grade + "%'"; } if (className.Equals("全部")) { rowFilter = rowFilter + " and stu_class like '%'"; } else { rowFilter = rowFilter + " and stu_class like '%" + className + "%'"; } if (id.Length == 4) { rowFilter += " and info_stuNumber=" + id; } } PhoneNumView.RowFilter = rowFilter; gridControl2.DataSource = PhoneNumView; if (gridView2.RowCount == 0) { return; } }
public PhoneNum() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); // TODO: Add any initialization after the InitForm call getStuInfoByCondition = new GetStuInfoByCondition(); StuList = new CardInfoSystem().GetStuCardInfoList(); //学生卡 if (Thread.CurrentPrincipal.Identity.Name.ToLower() == "admin") { return; } DataSet TeaDept = new RolesSystem().GetRolesDuty(Convert.ToInt32(Thread.CurrentPrincipal.Identity.Name)); string rowFilter = string.Empty; if (!Thread.CurrentPrincipal.IsInRole("园长") && !Thread.CurrentPrincipal.IsInRole("保健")) { rowFilter = rowFilter + "info_gradeName = '" + TeaDept.Tables[0].Rows[0][0].ToString() + "'"; rowFilter = rowFilter + " and info_className = '" + TeaDept.Tables[0].Rows[0][1].ToString() + "'"; } StuView = StuList.Tables[0].DefaultView; StuView.RowFilter = rowFilter; gridControl1.DataSource = StuView; comboBoxEdit_Send_StuGrade.Properties.Items.Clear(); comboBoxEdit_Send_StuGrade.Properties.Items.AddRange(new object[] { "全部" }); comboBoxEdit_Send_StuGrade.SelectedItem = "全部"; foreach (DataRow getGradeList in getStuInfoByCondition.getGradeInfo("", "").Tables[0].Rows) { comboBoxEdit_Send_StuGrade.Properties.Items.AddRange( new object[] { getGradeList[1].ToString() }); } }
//过滤DataView private void SelectStuCardInfo(string name, string id, string grade, string className) { string rowFilter = string.Empty; DataSet TeaDept = new RolesSystem().GetRolesDuty(Convert.ToInt32(Thread.CurrentPrincipal.Identity.Name)); if (!Thread.CurrentPrincipal.IsInRole("园长") && !Thread.CurrentPrincipal.IsInRole("保健")) { rowFilter = "info_stuName like '%" + name + "%'"; rowFilter = rowFilter + " and info_gradeName = '" + TeaDept.Tables[0].Rows[0][0].ToString() + "'"; rowFilter = rowFilter + " and info_className = '" + TeaDept.Tables[0].Rows[0][1].ToString() + "'"; if (id.Length == 4) { rowFilter += " and info_stuNumber=" + id; } } else { rowFilter = "info_stuName like '%" + name + "%'"; if (grade.Equals("全部")) { rowFilter = rowFilter + " and info_gradeName like '%'"; } else { rowFilter = rowFilter + " and info_gradeName like '%" + grade + "%'"; } if (className.Equals("全部")) { rowFilter = rowFilter + " and info_className like '%'"; } else { rowFilter = rowFilter + " and info_className like '%" + className + "%'"; } if (id.Length == 4) { rowFilter += " and info_stuNumber=" + id; } } StuView.RowFilter = rowFilter; gridControl1.DataSource = StuView; if (gridView1.RowCount == 0) { return; } string selectedStuID = (gridView1.GetDataRow(gridView1.GetSelectedRows()[0])["info_stuID"]).ToString(); DisplayStuPhoneNum(selectedStuID); }