Beispiel #1
0
        private void FillGrid()
        {
            dgvItems.Rows.Clear();

            using (var context = new DataClassesDataContext())
            {
                var period = GetPeriod(context);
                int periodID = period.ID;

                var items = context.PaymentEmployees.Where(x => x.PaymentPeriodID == periodID).Where(x => IsShowCategory1 && x.Employee.Category == 1 || IsShowCategory2 && x.Employee.Category == 2).Select(x => new { x.EmployeeID, x.Employee.FIO, Department = x.Employee.Department.Name, Category = x.Employee.CategoryName, Sum = x.Payments.TotalSum() });
                foreach (var item in items)
                {
                    var row = new DataGridViewRow();
                    row.CreateCells(dgvItems, item.FIO, item.Department, item.Category, item.Sum);
                    row.Tag = item.EmployeeID;

                    dgvItems.Rows.Add(row);
                }
            }
        }
Beispiel #2
0
        private PaymentPeriod GetPeriod(DataClassesDataContext context)
        {
            var result = context.PaymentPeriods.FirstOrDefault(x => x.Year == ShowYear && x.Month == ShowMonth);
            if (result == null)
            {
                result = new PaymentPeriod { Year = ShowYear, Month = ShowMonth };
                context.PaymentPeriods.InsertOnSubmit(result);
                context.SubmitChanges();
            }

            return result;
        }
Beispiel #3
0
        private void tsmPaymentsCreate_Click(object sender, EventArgs e)
        {
            bool isPeriodFilled = false;

            using (var context = new DataClassesDataContext())
            {
                var period = GetPeriod(context);
                isPeriodFilled = period.PaymentEmployees.Count > 0;
            }

            if (!isPeriodFilled || MessageBox.Show(this, "Начисления по периоду уже сформированны.\r\nВы хотите попробовать добавить сотрудников,\r\nотсутствующих в назначении?", "Подтверждение", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                int added = 0;
                using (var context = new DataClassesDataContext())
                {
                    added = CalcHelper.MakePayments(context, ShowYear, ShowMonth);
                }

                FillGrid();

                if (added > 0)
                {
                    MessageBox.Show(this, string.Format("Добавленно сотрудников: {0}", added), "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(this, "Сотрудников без назначений не найденно", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }