示例#1
0
 private void EmployeeDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == DeleteEmployeeButton.Index && e.RowIndex >= 0)
     {
         if (curentRowIndex == -1)
         {
             DialogResult dialogResult = MessageBox.Show(DialogAskMesage, MesageDeleteShow, MessageBoxButtons.YesNo);
             if (dialogResult == DialogResult.Yes)
             {
                 RemoveEmployee(e.RowIndex);
             }
             else if (dialogResult == DialogResult.No)
             {
                 CustomerDataGridView.CurrentCell = null;
             }
         }
     }
     if (e.ColumnIndex == EditEmployeeButton.Index && e.RowIndex >= 0)
     {
         if (curentRowIndex == -1)
         {
             EditEmployeeButton.UseColumnTextForButtonValue    = false;
             EditEmployeeButton.DataGridView.CurrentCell.Value = ButtonTextSave;
             for (int i = 0; i < EmployeeDataGridView.RowCount; i++)
             {
                 if (i != e.RowIndex)
                 {
                     EmployeeDataGridView[EditEmployeeButton.Index, i].Value = ButtonTextEdit;
                 }
             }
             EmployeeDataGridView.Refresh();
             curentRowIndex = e.RowIndex;
             EmployeeDataGridView.SelectionMode = DataGridViewSelectionMode.CellSelect;
         }
         else
         {
             if (EmployeeDataGridView.CurrentCell.Value.ToString() == ButtonTextSave)
             {
                 SaveAllToFile();
                 EditEmployeeButton.UseColumnTextForButtonValue = true;
                 EmployeeDataGridView.SelectionMode             = DataGridViewSelectionMode.FullRowSelect;
                 employeeBindingSource.EndEdit();
                 EmployeeDataGridView.EndEdit();
                 EmployeeDataGridView.ReadOnly = true;
                 curentRowIndex = -1;
             }
         }
     }
     if (e.ColumnIndex > employeeIDDataGridViewTextBoxColumn.Index &&
         e.ColumnIndex <= SalaryEmployeeDataGridViewTextBoxColumn.Index &&
         e.RowIndex == curentRowIndex && e.ColumnIndex != dateOfEmploymentDataGridViewTextBoxColumn.Index)
     {
         EmployeeDataGridView.ReadOnly = false;
         EmployeeDataGridView.BeginEdit(false);
     }
     else
     {
         EmployeeDataGridView.ReadOnly = true;
     }
 }
示例#2
0
        /// <summary>
        /// Populates EmployeeDataViewGridView.
        /// Data is read from PunchcardDB.
        /// </summary>
        private void MainForm_Load(object sender, EventArgs e)
        {
            const string query = "SELECT * FROM Employee";

            EmployeeDataGridView.DataSource = employeeData.QueryEmployee(query);
            EmployeeDataGridView.ClearSelection();
        }
示例#3
0
 private void EmployeeDataGridView_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         var hit = EmployeeDataGridView.HitTest(e.X, e.Y);
         EmployeeDataGridView.ClearSelection();
         if (hit.RowIndex >= 0 && hit.RowIndex < EmployeeDataGridView.Rows.Count - 1)
         {
             EmployeeDataGridView.Rows[hit.RowIndex].Selected = true;
             employeeView_contextMenuStrip.Show(EmployeeDataGridView, e.X, e.Y);
         }
     }
 }
示例#4
0
 internal void RefreshTabEmployee()
 {
     employeeBindingSource.Clear();
     for (int i = 0; i < manager.Employees.Count; i++)
     {
         employeeBindingSource.Add(manager.Employees[i]);
     }
     NameTextBox.Clear();
     SurnameTextBox.Clear();
     EmployeeDateTimePicker.Value = DateTime.Now;
     SalaryTextBox.Clear();
     EmployeeDataGridView.ClearSelection();
 }
示例#5
0
        private async void EmployeeSetup()
        {
            EmployeeDataGridView.AutoGenerateColumns = false;

            var employees = await _employeesOperations.GetEmployeesAsync().ConfigureAwait(true);

            _employeeBindingSource.DataSource = employees.ToList();

            EmployeeDataGridView.InvokeIfRequired(d => { d.DataSource = _employeeBindingSource; });

            EmployeeDataGridView.Columns["idColumn"].Width = 30;
            EmployeeDataGridView.Columns["LastNameColumn"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;


            EmployeeFirstNameTextBox.DataBindings.Add("Text", _employeeBindingSource, "FirstName");
            EmployeeLastNameTextBox.DataBindings.Add("Text", _employeeBindingSource, "LastName");

            EmployeesGroupBox.EnableButton();
        }
示例#6
0
 protected override void OnActivated(EventArgs e)
 {
     EmployeeDataGridView.ClearSelection();
     CustomerDataGridView.ClearSelection();
 }
示例#7
0
 /// <summary>
 /// Clears selection from EmployeeDataGridView.
 /// </summary>
 private void MainForm_Click(object sender, EventArgs e)
 {
     EmployeeDataGridView.ClearSelection();
 }