Пример #1
0
        public static void PrintWorkersReport(List<UslugaRepCls> uslugi, WorkerRep.TYPE typ,
            string Data_Od, string Data_Do)
        {
            document.Dispose();

            document = new ReportDocument();

            DataTable printTbl = new DataTable("tblRaport");

            for (int i = 0; i < 8; i++)
                printTbl.Columns.Add(i.ToString());

            float SumaBrutto = 0;
            int SumaCzas = 0;

            for (int j = 0; j < uslugi.Count; j++)
            {
                printTbl.Rows.Add((j + 1).ToString(), uslugi[j].IMIE, uslugi[j].NAZWISKO,
                    uslugi[j].ADRES, uslugi[j].NUMER, uslugi[j].NAZWA, uslugi[j].Brutto,
                    uslugi[j].CZAS);

                SumaBrutto += uslugi[j].Brutto;
                SumaCzas += uslugi[j].CZAS;
            }

            printTbl.Rows.Add("", "", "", "", "", "", "", "");

            printTbl.Rows.Add("", "", "", "", "", "RAZEM:", SumaBrutto, SumaCzas);

            string TytulRaportu = "";
            string TypRaportu = "";

            switch (typ)
            {
                case WorkerRep.TYPE.VIEWBYMONTH:
                    TytulRaportu = "Raport czasu pracy za msc. " + GetMonthName(DateTime.Today.Month);
                    TypRaportu = "Data: " + DateTime.Today.ToShortDateString();
                    break;

                case WorkerRep.TYPE.VIEWBYDAY:
                    TytulRaportu = "Dzienny raport czasu pracy";
                    TypRaportu = "Data: " + DateTime.Today.ToShortDateString();
                    break;

                case WorkerRep.TYPE.VIEWBYDATE:
                    TytulRaportu = "Raport czasu pracy za okres od " + Data_Od + " do " + Data_Do;
                    TypRaportu = "Data: " + DateTime.Today.ToShortDateString();
                    break;
            }

            document.AddText("Tytul", TytulRaportu);

            document.AddText("rodzaj", TypRaportu);

            document.AddData(printTbl);

            PrintPreviewDialog printDLG = new PrintPreviewDialog();

            document.setXML(Settings.AppDirectory + "\\Workers.xml");

            printDLG.Document = document;

            printDLG.Width = Screen.PrimaryScreen.Bounds.Width;
            printDLG.Height = Screen.PrimaryScreen.Bounds.Height;

            printDLG.ShowDialog();
        }
Пример #2
0
        private void cmdRapDet_Click(object sender, EventArgs e)
        {
            WorkerRep findWorker = new WorkerRep();

            findWorker.ShowDialog();

            TYP = findWorker.RESULT;

            DATA_OD = findWorker.DATA_OD;
            DATA_DO = findWorker.DATA_DO;

            List<UslugaRepCls> uslugiRep = null;

            switch (findWorker.RESULT)
            {
                case WorkerRep.TYPE.CANCEL:
                    return;

                case WorkerRep.TYPE.VIEWBYMONTH:
                    string startDate = DateTime.Today.Year + "-" + DateTime.Today.Month + "-01";

                    string endDate = DateTime.Today.Year + "-" + DateTime.Today.Month + "-" +
                        DateTime.DaysInMonth(DateTime.Today.Year, DateTime.Today.Month);

                    uslugiRep = CustomerDatabase.GetWorkersReport(findWorker.WID,
                        startDate, endDate);
                    break;

                case WorkerRep.TYPE.VIEWBYDAY:
                    uslugiRep = CustomerDatabase.GetWorkersReport(findWorker.WID, DateTime.Today.ToShortDateString(),
                        DateTime.Today.ToShortDateString());
                    break;

                case WorkerRep.TYPE.VIEWBYDATE:
                    uslugiRep = CustomerDatabase.GetWorkersReport(findWorker.WID,
                        findWorker.DATA_OD, findWorker.DATA_DO);
                    break;
            }

            if (uslugiRep == null) Message.NotFound();

            dgwWorkers.DataSource = uslugiRep;

            SetDataGridView.SetWorkerReportView(ref dgwWorkers);
        }