Esempio n. 1
0
        private void btAdd_Click(object sender, EventArgs e)
        {
            var addData = new AddPartialDayDetalizationDataForm(new PartialDayDetalization {
                WorkDate = null
            },
                                                                "Добавить детализацию неполного дня");

            if (addData.ShowDialog() == DialogResult.OK)
            {
                var d = addData.Detalization;
                if (employeeRepository.TryAddPartialDayDetalization(id, d))
                {
                    dgvPartialDayDetalization.Rows.Add($"{d.WorkDate?.Date:dd/MM/yyyy}", d.WorkHours,
                                                       d.Used.GetDisplayName(), d.Comment);
                }
            }
        }
Esempio n. 2
0
        private void btEdit_Click(object sender, EventArgs e)
        {
            var selectedRow = dgvPartialDayDetalization.Rows[dgvPartialDayDetalization.SelectedCells[0].RowIndex];

            if (!DateTime.TryParse(dgvPartialDayDetalization.Rows[dgvPartialDayDetalization.SelectedCells[0].RowIndex]
                                   .Cells[0]?.Value?.ToString(), out var wDate))
            {
                return;
            }
            var editData = new AddPartialDayDetalizationDataForm(GetPDetalization(selectedRow), "Редактировать детализацию неполного дня");

            if (editData.ShowDialog() == DialogResult.OK)
            {
                if (employeeRepository.TryEditPartialDayDetalization(wDate, id, editData.Detalization))
                {
                    EditRowOnGrid(selectedRow, editData);
                }
            }
        }