예제 #1
0
        public static void PrintSituatieRulajIncasariClient(PrintPageEventArgs e, Firma firma, DateTime inceput, DateTime sfarsit)
        {
            List <decimal> rulajLuni    = firma.RulajClientLuniDinPerioada(inceput, sfarsit);
            List <decimal> incasariLuni = firma.IncasariClientLuniDinPerioada(inceput, sfarsit);

            List <int> nrFacturiLuni  = firma.NumarFacturiClientLuniDinPerioada(inceput, sfarsit);
            List <int> nrIncasariLuni = firma.NumarIncasariLuniDinPerioada(inceput, sfarsit);

            int leftMargin = 50;

            int inaltimeRand = 18;

            int maxRanduriPePagina = 33;

            int inceputTabel = 430;

            int yTabelCurent = 0; //inaltimea din tabel la care ma aflu - cand se face o pagina noua incepe din nou de la 0

            int totalPagini = 1 + rulajLuni.Count / maxRanduriPePagina;

            Pen solid  = new Pen(Brushes.Black);
            Pen dashed = new Pen(Brushes.Black);


            dashed.DashStyle   = System.Drawing.Drawing2D.DashStyle.Dash;
            dashed.DashPattern = new float[] { 2, 3 };

            #region toatePaginile

            e.Graphics.DrawString("Societatea: " + firma.Nume, new Font("Calibri", 13, FontStyle.Bold), Brushes.Black, new Point(leftMargin, 40));
            e.Graphics.DrawString("Situatie client rulaj - incasari lunare pentru " + inceput.ToShortDateString() + " - " + sfarsit.ToShortDateString(), new Font("Calibri", 11, FontStyle.Italic), Brushes.Black, new Point(380, 42));

            e.Graphics.DrawString("Data tiparirii: " + DateTime.Now, new Font("Calibri", 10, FontStyle.Italic), Brushes.Black, new Point(leftMargin, e.MarginBounds.Bottom + 20));
            e.Graphics.DrawString("pag. " + p + @"/" + totalPagini, new Font("Calibri", 10, FontStyle.Italic), Brushes.Black, new Point(e.MarginBounds.Right, e.MarginBounds.Bottom + 20));

            #endregion

            #region grafic

            Point startA = new Point(e.MarginBounds.Right - 40, 120);
            Point stopA  = new Point(e.MarginBounds.Right - 20, 120);

            Point startB = new Point(e.MarginBounds.Right - 40, 140);
            Point stopB  = new Point(e.MarginBounds.Right - 20, 140);

            e.Graphics.DrawLine(solid, startA, stopA);
            e.Graphics.DrawLine(dashed, startB, stopB);

            e.Graphics.DrawString("Rulaj", new Font("Calibri", 10, FontStyle.Italic), Brushes.Black, new Point(e.MarginBounds.Right - 10, 110));
            e.Graphics.DrawString("Incasari", new Font("Calibri", 10, FontStyle.Italic), Brushes.Black, new Point(e.MarginBounds.Right - 10, 130));

            GraphicLibrary.GraficLinie(e.Graphics, leftMargin + 10, 130, e.MarginBounds.Right, 200, rulajLuni, GraphicLibrary.LuniPrescurtatePerioada(inceput, sfarsit), Color.Black, false, "Incasari", "Luni", true);
            GraphicLibrary.GraficLinie(e.Graphics, leftMargin + 10, 130, e.MarginBounds.Right, 200, incasariLuni, GraphicLibrary.LuniPrescurtatePerioada(inceput, sfarsit), Color.Black, true, "Incasari", "Luni", false);

            #endregion

            #region statistici

            e.Graphics.DrawString("Luna", new Font("Calibri", 10, FontStyle.Bold), Brushes.Black, new Point(leftMargin, inceputTabel - 20));
            e.Graphics.DrawString("Rulaj", new Font("Calibri", 10, FontStyle.Bold), Brushes.Black, new Point(leftMargin + 100, inceputTabel - 20));
            e.Graphics.DrawString("Incasari", new Font("Calibri", 10, FontStyle.Bold), Brushes.Black, new Point(leftMargin + 200, inceputTabel - 20));
            e.Graphics.DrawString("Numar facturi", new Font("Calibri", 10, FontStyle.Bold), Brushes.Black, new Point(leftMargin + 300, inceputTabel - 20));
            e.Graphics.DrawString("Numar incasari", new Font("Calibri", 10, FontStyle.Bold), Brushes.Black, new Point(leftMargin + 400, inceputTabel - 20));


            if (rulajLuni.Count > 0)
            {
                while (i < rulajLuni.Count)
                {
                    if (i % 2 == 0)
                    {
                        e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(242, 242, 242)), 50, inceputTabel - 1 + yTabelCurent, e.MarginBounds.Right, inaltimeRand);
                    }

                    e.Graphics.DrawString(GraphicLibrary.LuniSiAnPrescurtatePerioada(inceput, sfarsit)[i].ToString(), new Font("Calibri", 10, FontStyle.Regular), Brushes.Black, new Point(leftMargin, inceputTabel + yTabelCurent));
                    e.Graphics.DrawString(rulajLuni[i].ToString("0.00"), new Font("Calibri", 10, FontStyle.Regular), Brushes.Black, new Point(leftMargin + 100, inceputTabel + yTabelCurent));
                    e.Graphics.DrawString(incasariLuni[i].ToString("0.00"), new Font("Calibri", 10, FontStyle.Regular), Brushes.Black, new Point(leftMargin + 200, inceputTabel + yTabelCurent));
                    e.Graphics.DrawString(nrFacturiLuni[i].ToString(), new Font("Calibri", 10, FontStyle.Regular), Brushes.Black, new Point(leftMargin + 300, inceputTabel + yTabelCurent));
                    e.Graphics.DrawString(nrIncasariLuni[i].ToString(), new Font("Calibri", 10, FontStyle.Regular), Brushes.Black, new Point(leftMargin + 400, inceputTabel + yTabelCurent));


                    // e.Graphics.DrawString(facPer[i].Valoare_Cu_TVA.ToString(), new Font("Calibri", 10, FontStyle.Regular), Brushes.Black, new Point(leftMargin + 520, inceputTabel + yTabelCurent));


                    i++;                          //incrementez contorul general in orice caz, cu asta se trece peste toate, neavand importanta cate intrari vreau in pagina
                    yTabelCurent += inaltimeRand; //trec pe urmatorul rand

                    if (j < maxRanduriPePagina)   // verific daca am trecut cu contorul care merge pana la maximul de randuri din pagina
                    {
                        j++;                      //daca nu, il incrementez
                        e.HasMorePages = false;   // si ii spun ca nu va fi o alta pagina
                    }
                    else // daca da
                    {
                        j = 0;                 //resetez contorul
                        e.HasMorePages = true; //si ii spun sa creeaze o pagina noua
                        p++;
                        return;                //returnand aici, functia se va mai executa o data, cu variabilele globale in starea adecvata
                    }
                }
            }


            #endregion
        }