Beispiel #1
0
        public DrugUserControl()
        {
            InitializeComponent();

            List <string> sss   = checkedComboBoxEdit1.Properties.Items.GetCheckedValues().ConvertAll(item => Convert.ToString(item));
            List <Drug>   drugs = new DrugManager().GetAll().Where(item => sss.Contains(item.cate)).ToList();;

            this.pagerNavigator1.GC = this.gridControl1;
            this.pagerNavigator1.SetData(drugs);
            this.gridView1.RowClick += (s, e) =>
            {
                if (e.Clicks == 2)
                {
                    Drug drug = gridView1.GetRow(e.RowHandle) as Drug;
                    DialogFactory.CreateDrugEditControl(drug);
                }
            };

            #region 单击查询按钮
            btnQuery.Click += (s, e) =>
            {
                Drug drug = new Drug()
                {
                    name    = buttonEdit1.Text,
                    address = textEdit2.Text,
                    form    = textEdit3.Text
                };
                List <string> checkedValue = checkedComboBoxEdit1.Properties.Items.GetCheckedValues().ConvertAll(item => Convert.ToString(item));
                List <Drug>   li           = new DrugManager().GetList(drug).Where(item => checkedValue.Contains(item.cate)).ToList();
                // gridControl1.DataSource = li;
                this.pagerNavigator1.SetData(li);
            };
            #endregion
            #region 单击查询全部按钮
            btnQueryAll.Click += (s, e) =>
            {
                checkedComboBoxEdit1.CheckAll();
                List <Drug> li = new DrugManager().GetAll();
                // gridControl1.DataSource = li;
                this.pagerNavigator1.SetData(li);
            };
            #endregion
            #region 单击重置按钮
            btnReset.Click += (s, e) =>
            {
                buttonEdit1.Text = textEdit2.Text = textEdit3.Text = string.Empty;
            };
            #endregion
        }