Exemplo n.º 1
0
        private void SetDatasourceCombobox()
        {
            DateTime startDate = dtpStartWorkDate.Value.Date;
            DateTime endDate   = DateTime.Now.Date;
            decimal  rate      = ProvidentFundCalculator.GetProvidentFundNotOverRatePercent(startDate, endDate);

            List <ComboBoxHelper.ComboBoxSource <decimal> > comboBoxSource = new List <ComboBoxHelper.ComboBoxSource <decimal> >();

            for (int loop = 1; loop <= rate; loop++)
            {
                comboBoxSource.Add(new ComboBoxHelper.ComboBoxSource <decimal>
                {
                    Display = loop.ToString(),
                    Value   = loop,
                });
            }

            if (rate == 0)
            {
                comboBoxSource.Add(new ComboBoxHelper.ComboBoxSource <decimal>
                {
                    Display = rate.ToString(),
                    Value   = rate,
                });
            }

            ComboBoxHelper.SetSourceToComboBox(cboProvidentFundRate, nameof(ComboBoxHelper.ComboBoxSource <decimal> .Display), nameof(ComboBoxHelper.ComboBoxSource <decimal> .Value), comboBoxSource);
        }
Exemplo n.º 2
0
        private void SetDatasourceGridView()
        {
            DateTime startDate = dtpStartWorkDate.Value.Date;
            DateTime endDate   = DateTime.Now.Date;

            //Dictionary<Int32, decimal> monthAndYear = ProvidentFundCalculator.GetMonthAndYearPVDPaid(startDate, endDate);

            decimal month    = ProvidentFundCalculator.GetMonthPVDPaid(startDate, endDate);
            decimal monthCal = ProvidentFundCalculator.GetMonthPVDPaid(startDate, endDate);

            monthCal -= 3;
            decimal yearWork = ProvidentFundCalculator.GetWorkYear(startDate, endDate);

            if (yearWork == 0)
            {
                return;
            }

            List <EmployeeLogDetail> providentFunds = new List <EmployeeLogDetail>();

            for (int row = 0; row <= yearWork; row++)
            {
                EmployeeLogDetail providentFund = new EmployeeLogDetail();

                if (row == 0)
                {
                    providentFund.Month = month - 11 >= 0 ? 11 : month;
                }
                else if (month - 12 >= 0)
                {
                    providentFund.Month = 12;
                }
                else
                {
                    providentFund.Month = month;
                }

                month -= providentFund.Month;

                providentFund.WorkYear             = row == 0 ? "1-11 M" : row + "+";
                providentFund.ProvidentFundCollect = 0;
                providentFund.Salary = Convert.ToDecimal(txtSalary.Text);

                DateTime newEndDate = endDate.AddMonths(-Convert.ToInt32(monthCal));
                providentFund.CompanyPaidPercent = ProvidentFundCalculator.GetCompanyPaidPercent(startDate, newEndDate);
                monthCal -= providentFund.Month;

                ConditionsDatetime conditionsDatetime = new ConditionsDatetime(startDate);

                providentFunds.Add(providentFund);
            }

            gridViewDisplay.DataSource = providentFunds;

            SetComBoboxOnGird(startDate, endDate, providentFunds);
        }
Exemplo n.º 3
0
        private void Calulate()
        {
            DateTime startDate = dtpStartWorkDate.Value.Date;
            DateTime endDate   = DateTime.Now.Date;
            decimal  salary    = Convert.ToDecimal(txtSalary.Text);
            decimal  rate      = ComboBoxHelper.GetSelectedValueFromComboBox <decimal>(cboProvidentFundRate);

            decimal providentFundCalculator = ProvidentFundCalculator.GetCalulateProvidentFund(startDate, endDate, salary, rate);

            lbTatalPVD.Text = providentFundCalculator.ToString("N2");
        }
Exemplo n.º 4
0
        private void CalulateOnGird()
        {
            if (gridViewDisplay.DataSource == null)
            {
                return;
            }

            List <EmployeeLogDetail> providentFunds = gridViewDisplay.DataSource as List <EmployeeLogDetail>;

            foreach (EmployeeLogDetail provident in providentFunds)
            {
                decimal providentFundCalculator = ProvidentFundCalculator.GetCalulateProvidentFund(provident.Month, provident.CompanyPaidPercent, provident.Salary, provident.PVDRate);
                provident.ProvidentFundCollect = providentFundCalculator;
            }

            lbTatalPVD.Text = providentFunds.Sum(a => a.ProvidentFundCollect).ToString("N2");
        }
Exemplo n.º 5
0
        private void GridViewDisplay_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            decimal rate = Convert.ToDecimal(gridViewDisplay["cboPVDRate", e.RowIndex].Value);

            gridViewDisplay.Rows[e.RowIndex].Cells[nameof(EmployeeLogDetail.PVDRate)].Value = rate;

            decimal month                = Convert.ToDecimal(gridViewDisplay[nameof(EmployeeLogDetail.Month), e.RowIndex].Value);
            decimal salary               = Convert.ToDecimal(gridViewDisplay[nameof(EmployeeLogDetail.Salary), e.RowIndex].Value);
            decimal companyPaidPercent   = Convert.ToDecimal(gridViewDisplay[nameof(EmployeeLogDetail.CompanyPaidPercent), e.RowIndex].Value);
            decimal providentFundCollect = ProvidentFundCalculator.GetCalulateProvidentFund(month, companyPaidPercent, salary, rate);

            gridViewDisplay.Rows[e.RowIndex].Cells[nameof(EmployeeLogDetail.ProvidentFundCollect)].Value = providentFundCollect;
        }
Exemplo n.º 6
0
        private void SetComBoboxOnGird(DateTime startDate, DateTime endDate, List <EmployeeLogDetail> providentFunds)
        {
            int     index = 0;
            decimal month = ProvidentFundCalculator.GetMonthPVDPaid(startDate, endDate);

            month -= 3;
            foreach (EmployeeLogDetail data in providentFunds)
            {
                DateTime newEndDate = endDate.AddMonths(-Convert.ToInt32(month));
                month -= data.Month;
                decimal rate = ProvidentFundCalculator.GetProvidentFundNotOverRatePercent(startDate, newEndDate);
                List <ComboBoxHelper.ComboBoxSource <decimal> > comboBoxSource = new List <ComboBoxHelper.ComboBoxSource <decimal> >();
                for (int loop = 1; loop <= rate; loop++)
                {
                    comboBoxSource.Add(new ComboBoxHelper.ComboBoxSource <decimal>
                    {
                        Display = loop.ToString(),
                        Value   = loop,
                    });
                }

                if (rate == 0)
                {
                    comboBoxSource.Add(new ComboBoxHelper.ComboBoxSource <decimal>
                    {
                        Display = rate.ToString(),
                        Value   = rate,
                    });
                }

                DataGridViewComboBoxCell cellCombobox = new DataGridViewComboBoxCell();
                cellCombobox.DisplayMember = nameof(ComboBoxHelper.ComboBoxSource <decimal> .Display);
                cellCombobox.ValueMember   = nameof(ComboBoxHelper.ComboBoxSource <decimal> .Value);
                cellCombobox.DataSource    = comboBoxSource;

                gridViewDisplay.Rows[index].Cells["cboPVDRate"] = cellCombobox;

                ++index;
            }

            gridViewDisplay.Refresh();
        }