예제 #1
0
        private void txtSearchContent_KeyDown(object sender, KeyEventArgs e)
        {
            bool handled = true;

            switch (e.KeyData & Keys.KeyCode)
            {
            case Keys.Down:
                if (dgvDoctorData.Rows.Count > 0)
                {
                    dgvDoctorData.Focus();
                    int nextIndex = dgvDoctorData.CurrentRow.Index + 1;
                    if (nextIndex > -1 && dgvDoctorData.Rows.Count > nextIndex)
                    {
                        dgvDoctorData.ClearSelection();
                        this.dgvDoctorData.Rows[nextIndex].Selected = true;
                        this.dgvDoctorData.CurrentCell = this.dgvDoctorData.Rows[nextIndex].Cells[0];
                    }
                }
                break;

            case Keys.Up:
                if (dgvDoctorData.Rows.Count > 0)
                {
                    int nextIndex = dgvDoctorData.CurrentRow.Index - 1;
                    if (nextIndex > -1 && dgvDoctorData.Rows.Count > nextIndex)
                    {
                        dgvDoctorData.Focus();
                        dgvDoctorData.ClearSelection();
                        this.dgvDoctorData.Rows[nextIndex].Selected = true;
                        this.dgvDoctorData.CurrentCell = this.dgvDoctorData.Rows[nextIndex].Cells[0];
                    }
                    else
                    {
                        //this.ActiveControl = cboFirstKind;
                    }
                }
                else
                {
                    //this.ActiveControl = cboFirstKind;
                }
                break;

            case Keys.Enter:
                _selectedProduct = null;
                if (dgvDoctorData.CurrentRow != null && dgvDoctorData.CurrentRow.Index > -1)
                {
                    _selectedProduct = _currentProducts[dgvDoctorData.CurrentRow.Index];
                    e.Handled        = true;
                }
                RaiseSelectedValueChangeEvent();
                break;

            default:
                handled = false;
                break;
            }
            e.Handled = handled;
        }
예제 #2
0
 private void dgvDoctorData_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     _selectedProduct = null;
     if (e.RowIndex > -1)
     {
         _selectedProduct = _currentProducts[e.RowIndex];
     }
     RaiseSelectedValueChangeEvent();
 }
예제 #3
0
 private void FiltrateProduct()
 {
     _selectedProduct = null;
     _currentProducts = DoctorDataView.OriginalProducts.ToList();
     if (!string.IsNullOrEmpty(txtSearchContent.Text.Trim()))
     {
         string content = txtSearchContent.Text.Trim().ToLower();
         if (DoctorDataView.SearchOnlyByCode)
         {
             _currentProducts = _currentProducts.Where(x => x.Code.ToLower().Contains(content)).OrderBy(x => x.Code).ToList();
         }
         else
         {
             _currentProducts = _currentProducts.Where(x => x.Name.ToLower().Equals(content) || x.Code.ToLower().Equals(content)).Union(_currentProducts.Where(x => x.Name.ToLower().Contains(content) || x.Code.ToLower().Contains(content)).OrderBy(x => x.Name).ThenBy(x => x.Code)).ToList();
         }
     }
     else
     {
         _currentProducts = _currentProducts.OrderBy(x => x.Name).ThenBy(x => x.Code).ToList();
     }
     this.clnName.HeaderText  = "医院";//这里更改
     dgvDoctorData.DataSource = _currentProducts;
 }
예제 #4
0
        private void dgvDoctorData_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Enter:
                _selectedProduct = null;
                if (dgvDoctorData.CurrentRow != null && dgvDoctorData.CurrentRow.Index > -1)
                {
                    _selectedProduct = _currentProducts[dgvDoctorData.CurrentRow.Index];
                    e.Handled        = true;
                }
                RaiseSelectedValueChangeEvent();
                break;

            case Keys.Up:
                int nextIndex = dgvDoctorData.CurrentRow.Index;
                if (nextIndex == 0)
                {
                    txtSearchContent.Focus();
                    txtSearchContent.SelectionLength = 0;
                    txtSearchContent.SelectionStart  = txtSearchContent.Text.Length;
                    e.Handled = true;
                }
                break;

            case Keys.Back:
                txtSearchContent.Focus();
                if (txtSearchContent.Text.Length > 0)
                {
                    txtSearchContent.Text           = txtSearchContent.Text.Remove(txtSearchContent.Text.Length - 1);
                    txtSearchContent.SelectionStart = txtSearchContent.Text.Length;
                }
                e.Handled = true;
                break;
            }
        }