コード例 #1
0
 private void btLoadService_Click_1(object sender, EventArgs e)
 {
     if (txtSearchService1.Text == "")
     {
         this.loadData();
     }
     else
     {
         string Key = txtSearchService1.Text.Trim();
         if (Key == null || Key == string.Empty || Key.Length == 0)
         {
             List <ServiceDTO> listTimKiem = srvBUS.select();
             this.loadData(listTimKiem);
         }
         else
         {
             List <ServiceDTO> listTimKiem = srvBUS.search(Key);
             this.loadData(listTimKiem);
         }
     }
 }
コード例 #2
0
        //
        //---- LOAD DATA
        //
        #region Load Data

        private void loadData()
        {
            srvBUS = new ServiceBUS();

            List <ServiceDTO> list = srvBUS.select();

            if (list == null)
            {
                MessageBox.Show("Fail");
                return;
            }
            dtgvService.Columns.Clear();
            dtgvService.DataSource = null;

            dtgvService.AutoGenerateColumns = false;
            dtgvService.AllowUserToAddRows  = false;
            dtgvService.DataSource          = list;

            DataGridViewTextBoxColumn NAME = new DataGridViewTextBoxColumn();

            NAME.Name             = "name";
            NAME.HeaderText       = "Name:";
            NAME.DataPropertyName = "name";
            NAME.AutoSizeMode     = DataGridViewAutoSizeColumnMode.Fill;
            dtgvService.Columns.Add(NAME);

            DataGridViewTextBoxColumn KIND = new DataGridViewTextBoxColumn();

            KIND.Name             = "kind";
            KIND.HeaderText       = "Kind";
            KIND.DataPropertyName = "kind";
            KIND.AutoSizeMode     = DataGridViewAutoSizeColumnMode.Fill;
            dtgvService.Columns.Add(KIND);

            DataGridViewTextBoxColumn COST = new DataGridViewTextBoxColumn();

            COST.Name             = "cost";
            COST.HeaderText       = "Cost";
            COST.DataPropertyName = "cost";
            COST.AutoSizeMode     = DataGridViewAutoSizeColumnMode.Fill;
            dtgvService.Columns.Add(COST);


            CurrencyManager myCurrencyManager = (CurrencyManager)this.BindingContext[dtgvService.DataSource];

            myCurrencyManager.Refresh();
        }