Ejemplo n.º 1
0
        private void Start()
        {
            switch (WindowMode)
            {
            case 1:
            {
                if (cbProjectName.SelectedIndex > 0)
                {
                    //DateTime StartDate = Convert.ToDateTime(cStartDate.SelectedDate);
                    //DateTime FinishDate = Convert.ToDateTime(cFinishDate.SelectedDate);
                    //string name = cbProjectName.SelectedItem.ToString().Remove(0, 38);
                    List <DistributionPerson> lst_dp;
                    List <InfoUser2>          lst_2 = DataWork.GetInfoReportShortWithSearch(Convert.ToDateTime(cStartDate.SelectedDate), Convert.ToDateTime(cFinishDate.SelectedDate), true, cbProjectName.SelectedItem.ToString().Remove(0, 38), cbCurrency_Report.SelectedValue.ToString().Remove(0, 38), cbMarks_Report.SelectedValue.ToString().Remove(0, 38), ActiveUser.UserID);
                    dgPlus.ItemsSource = lst_2;
                    List <InfoUser2> lst_1 = DataWork.GetInfoReportShortWithSearch(Convert.ToDateTime(cStartDate.SelectedDate), Convert.ToDateTime(cFinishDate.SelectedDate), false, cbProjectName.SelectedItem.ToString().Remove(0, 38), cbCurrency_Report.SelectedValue.ToString().Remove(0, 38), cbMarks_Report.SelectedValue.ToString().Remove(0, 38), ActiveUser.UserID);
                    dgMinus.ItemsSource = lst_1;
                    Single sum   = 0;
                    Single sum_p = 0;
                    Single sum_m = 0;

                    foreach (InfoUser2 iu2 in lst_1)
                    {
                        sum_m += iu2.sum;
                        sum   += iu2.sum;
                    }

                    foreach (InfoUser2 iu2 in lst_2)
                    {
                        sum_p += iu2.sum;
                        sum   += iu2.sum;
                    }
                    sum_report        = sum;
                    tbTotalPlus.Text  = String.Format("{0:#,##0.00 $;-#,##0.00 $;0}", sum_p);
                    tbTotalMinus.Text = String.Format("{0:#,##0.00 $;-#,##0.00 $;0}", sum_m);

                    lst_dp            = DataWork.GetDistributionList(cbProjectName.SelectedItem.ToString().Remove(0, 38));
                    tbTotalShort.Text = String.Format("{0:#,##0.00 $;-#,##0.00 $;0}", sum);
                    foreach (DistributionPerson dp in lst_dp)
                    {
                        if (dp.Percent != "")
                        {
                            dp.sum = sum * Convert.ToInt32(dp.Percent) / 100;
                        }
                    }

                    if (cbProjectName.SelectedIndex == 0)
                    {
                        lst.Clear();
                    }
                    dgDistributionPercents.ItemsSource = lst_dp;
                }
            }
            break;

            case 2:
            {
                if (cbProjectName.SelectedIndex > 0)
                {
                    //DateTime StartDate = Convert.ToDateTime(cStartDate.SelectedDate);
                    //DateTime FinishDate = Convert.ToDateTime(cFinishDate.SelectedDate);
                    List <ReportDistributionData> lst = DataWork.GetReportDistribution(cbProjectName.SelectedItem.ToString(), Convert.ToDateTime(cStartDate.SelectedDate), Convert.ToDateTime(cFinishDate.SelectedDate));
                    dgReportDistribution.ItemsSource = lst;
                    Single sum_d = 0;
                    foreach (ReportDistributionData rdd in lst)
                    {
                        sum_d += Convert.ToSingle(rdd.Sum);
                    }

                    tbTotalSum.Text = String.Format("{0:#,##0.00 $; -#,##0.00 $;0}", sum_d);
                    //if (cbProjectName.SelectedIndex == 0)
                    // lst.Clear();
                }
            }
            break;
            }
        }