Пример #1
0
        private void UpdateConsignmentPeriod(object sender, EventArgs e)
        {
            //convert selected item in combobox to consignmentPeriod
            int consignmentPeriod = ConsignmentStoreBusinessLogic.GetConsignmentPeriodFromString(
                comboBoxConsignmentPeriods.SelectedItem.ToString());

            //update consignment results and summaries data gridviews
            dataGridViewConsignmentResults.DataSource = context.ConsignmentResults.Local.Where(
                result => result.ConsignmentPeriod == consignmentPeriod).ToList();

            dataGridViewConsignmentSummaries.DataSource = context.ConsignmentSummaries.Local.Where(
                summary => summary.ConsignmentPeriod == consignmentPeriod).ToList();
        }
Пример #2
0
        private void GenerateConsignmentResults(object sender, EventArgs e)
        {
            //consignment period must
            //1. must be greater than the largest consignmentPeriod (e.g. current is 201901)
            //2. must less than current month (e.g. 201904)
            //valid consignmentPeriods are  201902, 201903

            //convert selected item in combobox to consignmentPeriod
            int consignmentPeriod = ConsignmentStoreBusinessLogic.GetConsignmentPeriodFromString(
                (int)numericUpDownMonth.Value + "/" + (int)numericUpDownYear.Value);

            int upLimitConsignmentPeriod = ConsignmentStoreBusinessLogic.GetConsignmentPeriodFromString(
                DateTime.Now.Month + "/" + DateTime.Now.Year);

            int downLimitConsignmentPeriod = context.ConsignmentSummaries.Max(summary => summary.ConsignmentPeriod);

            if (!ConsignmentStoreBusinessLogic.ValidateConsignmentPeriod(consignmentPeriod))
            {
                FormHelper.ShowErrorMessageBox("Period must greater than " +
                                               ConsignmentStoreBusinessLogic.GetConsignmentPeriodFromInt(downLimitConsignmentPeriod) + " and less than " +
                                               ConsignmentStoreBusinessLogic.GetConsignmentPeriodFromInt(upLimitConsignmentPeriod));
                return;
            }

            //Checking lost items
            GenerateConsignmentResultsForm generateConsignmentResultsForm = new GenerateConsignmentResultsForm(consignmentPeriod);

            generateConsignmentResultsForm.ShowDialog();
            generateConsignmentResultsForm.Dispose();

            //Load combobox again
            comboBoxConsignmentPeriods.Items.Clear();
            //add consignment periods to combox box (format: month/year)
            foreach (var period in context.ConsignmentSummaries.Local.ToList())
            {
                comboBoxConsignmentPeriods.Items.Add(
                    ConsignmentStoreBusinessLogic.GetConsignmentPeriodFromInt(period.ConsignmentPeriod));
            }
        }