Example #1
0
    private void LoadPlexingPeriodPayoutData(int plexingPeriodId)
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(ConnectionString))
        {
            PlexingPeriod period = context.PlexingPeriods.FirstOrDefault(x => x.PlexingPeriodId == plexingPeriodId);

            if (period != null)
            {
                if (period.PayoutSum.HasValue)
                {
                    PayoutTextBox.Text = (period.PayoutSum.Value / 1000000).ToString();
                }
                else
                {
                    PayoutTextBox.Text = string.Empty;
                }

                if (period.CorpTax.HasValue)
                {
                    CorpTaxTextBox.Text = (period.CorpTax.Value).ToString();
                }
                else
                {
                    CorpTaxTextBox.Text = string.Empty;
                }
            }
        }

        CalculatePayout();
    }
Example #2
0
 private int GetPlexingPeriodId(int corpId)
 {
     using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
     {
         PlexingPeriod period = context.PlexingPeriods.FirstOrDefault(x => x.ToDate == null && x.CorpId == int.Parse(PlexCorpDropDownList.SelectedValue));
         return(period.PlexingPeriodId);
     }
 }
Example #3
0
    private List <PlexingPeriodInfo> LoadPlexingPeriodData(int plexingPeriodId)
    {
        PlexingPeriodInfoGridView.Columns[3].Visible = plexingPeriodId != LastPlexingPeriodId && LastPlexingPeriodId.HasValue;

        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            PlexingPeriod period = context.PlexingPeriods.FirstOrDefault(x => x.PlexingPeriodId == plexingPeriodId);
            IskPerPointAfterTax = period.IskPerPointAfterTax.HasValue ? period.IskPerPointAfterTax.Value : 0;

            var plexPointinfos = from p in context.Plexes
                                 join pi in context.PlexInfos on p.PlexInfoId equals pi.PlexId
                                 where p.PlexingPeriodId == plexingPeriodId
                                 select new { p.PlexingPeriodId, p.PlexId, p.Participants, pi.Points };

            Dictionary <string, PlexingPeriodInfo> dict = new Dictionary <string, PlexingPeriodInfo>();

            double totalPoints = 0;

            foreach (var plexPointInfo in plexPointinfos)
            {
                totalPoints += plexPointInfo.Points;

                string[] pilots = plexPointInfo.Participants.Split(',');

                double pilotPoints = ((double)plexPointInfo.Points) / pilots.Count();

                foreach (string pilot in pilots)
                {
                    if (dict.ContainsKey(pilot.Trim()))
                    {
                        dict[pilot.Trim()].Plexes += 1;
                        dict[pilot.Trim()].Points += pilotPoints;
                        dict[pilot.Trim()].Payout  = ((IskPerPointAfterTax.HasValue ? IskPerPointAfterTax.Value : 0) / 1000000) * dict[pilot.Trim()].Points;
                    }
                    else
                    {
                        dict.Add(pilot.Trim(), new PlexingPeriodInfo()
                        {
                            PlexingPeriodId = plexPointInfo.PlexingPeriodId, PlexId = plexPointInfo.PlexId, Name = pilot.Trim(), Plexes = 1, Points = pilotPoints, Payout = ((IskPerPointAfterTax.HasValue ? IskPerPointAfterTax.Value : 0) / 1000000) * pilotPoints
                        });
                    }
                }
            }

            TotalPointsLabel.Text = Math.Round(totalPoints, 2).ToString();

            return(dict.Values.ToList());
        }
    }
    private void FillPlexingPeriodDateData(int plexingPeriodId, DateTime date)
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            PlexingPeriod pp = context.PlexingPeriods.FirstOrDefault(x => x.PlexingPeriodId == plexingPeriodId);

            if (pp != null)
            {
                PlexingPeriodDateLabel.Text = GetPlexingPeriodTitle(pp.FromDate, pp.ToDate, GetCorpTag(pp.CorpId));
            }
        }

        List <MyPlexingPeriodInfo> infos = LoadPlexingPeriodData(plexingPeriodId, date);

        PlexingPeriodInfoGridView.DataSource = infos;
        PlexingPeriodInfoGridView.DataBind();
    }
Example #5
0
    protected void EndPeriodLinkButton_Click(object sender, EventArgs e)
    {
        CalculatePayout(true);

        using (PlexingFleetDataContext context = new PlexingFleetDataContext(ConnectionString))
        {
            PlexingPeriod period = context.PlexingPeriods.FirstOrDefault(x => x.PlexingPeriodId == PlexingPeriodId);

            if (period != null)
            {
                period.ToDate = DateTime.Now;
            }

            context.SubmitChanges();

            ShowEndPeriodButton(false);
        }
    }
Example #6
0
    private void CalculatePayout(bool savePayout)
    {
        double payout  = PayoutTextBox.Text.ToDouble() * 1000000;
        double percent = CorpTaxTextBox.Text.ToDouble();

        double payoutAfterTax = payout * (1 - (percent / 100));
        double tax            = (payout - payoutAfterTax);
        double points         = GetPoints(PlexingPeriodId);

        IskPerPoint         = payout / points;
        IskPerPointAfterTax = payoutAfterTax / points;

        TotalPayoutLabel.Text = FormatMillions(Math.Round((payoutAfterTax / 1000000), 2).ToString());
        TaxLabel.Text         = FormatMillions(Math.Round(tax / 1000000, 0).ToString());

        IskPerPointLabel.Text         = FormatMillions(Math.Round(IskPerPoint / 1000000, 3).ToString());
        IskPerPointAfterTaxLabel.Text = FormatMillions(Math.Round(IskPerPointAfterTax / 1000000, 3).ToString());

        TaxUpdatePanel.Update();
        TotalPayOutUpdatePanel.Update();
        IskPerPointAfterTaxUpdatePanel.Update();

        if (savePayout)
        {
            using (PlexingFleetDataContext context = new PlexingFleetDataContext(ConnectionString))
            {
                PlexingPeriod period = context.PlexingPeriods.FirstOrDefault(x => x.PlexingPeriodId == PlexingPeriodId);

                if (period != null)
                {
                    period.PayoutSum           = payout;
                    period.CorpTax             = CorpTaxTextBox.Text.ToDouble();
                    period.Points              = points;
                    period.IskPerPoint         = IskPerPoint;
                    period.IskPerPointAfterTax = IskPerPointAfterTax;

                    context.SubmitChanges();
                }
            }
        }
    }
Example #7
0
    private void FillPlexingPeriodData(int plexingPeriodId)
    {
        PlexingPeriodId = plexingPeriodId;
        CalculatePayout();
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(ConnectionString))
        {
            PlexingPeriod pp = context.PlexingPeriods.FirstOrDefault(x => x.PlexingPeriodId == plexingPeriodId);

            if (pp != null)
            {
                PlexingPeriodDateLabel.Text = GetPlexingPeriodTitle(pp.FromDate, pp.ToDate, GetCorpTag(pp.CorpId));
            }
        }

        List <PlexingPeriodInfo> infos = LoadPlexingPeriodData(plexingPeriodId);

        infos.Sort();

        PlexingPeriodInfoGridView.DataSource = infos;
        PlexingPeriodInfoGridView.DataBind();
    }
 partial void DeletePlexingPeriod(PlexingPeriod instance);
 partial void UpdatePlexingPeriod(PlexingPeriod instance);
 partial void InsertPlexingPeriod(PlexingPeriod instance);