/// <summary> /// 查询数据 /// </summary> private void ReadData() { string condition = ""; if (Te_departmentname.Text.Length > 0) { condition = "departmentname like '%" + this.Te_departmentname.Text + "%'"; } DEPARTMENT_INFO departmentbll = new DEPARTMENT_INFO(); this.gridControl1.DataSource = departmentbll.GetList(condition).Tables[0]; this.gridView1.BestFitColumns(); DBUtility.ToolHelper.DrawRowIndicator(gridView1, 40); DBUtility.ToolHelper.SetLineColorofGridView(this.gridView1); }
/// <summary> /// 初始化窗体,取得学院名称到列表 /// </summary> private void init_department() { Student.BLL.DEPARTMENT_INFO departmentBll = new DEPARTMENT_INFO(); DataSet ds = departmentBll.GetAllList(); cbb_department.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; cbb_department.Properties.Items.Clear(); cbb_department.EditValue = null; cbb_department.Properties.NullText = "--请选择--"; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string departmentName = ds.Tables[0].Rows[i]["departmentname"].ToString(); this.cbb_department.Properties.Items.Add(departmentName); } }
/// <summary> /// 删除数据 /// </summary> /// <param name="id"></param> /// <returns></returns> private bool deleteData(int id) { try { BLL.MAJOR_INFO majorinfobll = new MAJOR_INFO(); int recordCount = majorinfobll.GetRecordCount("departmentno = " + id.ToString()); if (recordCount > 0) { MessageBox.Show("该学院信息已经被使用,不能被删除!", "提示信息"); return(false); } else { BLL.DEPARTMENT_INFO departmentbll = new DEPARTMENT_INFO(); departmentbll.Delete(id); return(true); } } catch (Exception exception) { MessageBox.Show("删除失败!", exception.Message); return(false); } }