Esempio n. 1
0
        public bool ReadRegnskaber()
        {
            string     RegnskabId;
            string     RegnskabMappe;
            string     line;
            FileStream ts;
            string     Eksportmappe;
            string     Datamappe;

            try
            {
                Eksportmappe = (string)Registry.CurrentUser.OpenSubKey(@"SOFTWARE\STONE'S SOFTWARE\SUMMAPRO\START").GetValue("Eksportmappe");
                Datamappe    = (string)Registry.CurrentUser.OpenSubKey(@"SOFTWARE\STONE'S SOFTWARE\SUMMAPRO\START").GetValue("Datamappe");
            }
            catch (System.NullReferenceException)
            {
                return(false);
            }
            DirectoryInfo dir = new DirectoryInfo(Datamappe);

            foreach (var sub_dir in dir.GetDirectories())
            {
                if (Information.IsNumeric(sub_dir.Name))
                {
                    switch (sub_dir.Name.ToUpper())
                    {
                    case "-2":
                    case "-1":
                    case "0":
                        break;

                    default:
                        //do somthing here
                        RegnskabId = sub_dir.Name;

                        try
                        {
                            m_rec_Regnskab =
                                (from d in Program.memRegnskab
                                 where d.Rid.ToString() == RegnskabId
                                 select d).First();
                        }
                        catch (System.InvalidOperationException)
                        {
                            m_rec_Regnskab = new recMemRegnskab()
                            {
                                Rid = int.Parse(RegnskabId)
                            };
                            Program.memRegnskab.Add(m_rec_Regnskab);
                        }
                        RegnskabMappe            = Datamappe + sub_dir.Name + @"\";
                        m_rec_Regnskab.Placering = RegnskabMappe;

                        m_rec_Regnskab.Eksportmappe = Eksportmappe + @"\";

                        string[] files = new string[2];
                        files[0] = RegnskabMappe + "regnskab.dat";
                        files[1] = RegnskabMappe + "status.dat";
                        m_rec_Regnskab.Afsluttet = false;
                        foreach (var file in files)
                        {
                            ts = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.None);
                            using (StreamReader sr = new StreamReader(ts, Encoding.Default))
                            {
                                while ((line = sr.ReadLine()) != null)
                                {
                                    if (line.Length > 0)
                                    {
                                        string[] X = line.Split('=');
                                        switch (X[0])
                                        {
                                        case "Navn":
                                            m_rec_Regnskab.Navn = X[1];
                                            break;

                                        case "Oprettet":
                                            m_rec_Regnskab.Oprettet = clsUtil.MSSerial2DateTime(double.Parse(X[1]));
                                            break;

                                        case "Start":
                                            m_rec_Regnskab.Start = clsUtil.MSSerial2DateTime(double.Parse(X[1]));
                                            break;

                                        case "S**t":
                                            m_rec_Regnskab.S**t = clsUtil.MSSerial2DateTime(double.Parse(X[1]));
                                            break;

                                        case "DatoLaas":
                                            m_rec_Regnskab.DatoLaas = clsUtil.MSSerial2DateTime(double.Parse(X[1]));
                                            break;

                                        case "Afsluttet":
                                            m_rec_Regnskab.Afsluttet = (X[1] == "1") ? true : false;
                                            break;

                                        case "Firmanavn":
                                            m_rec_Regnskab.Firmanavn = X[1];
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    }
                }
            }
            return(true);
        }
Esempio n. 2
0
        protected override void OnRender(DrawingContext dc)
        {
            Point textPoint = new Point(0, 32);
            Point rectPoint = new Point(0, 32);

            // Create a Pen to add to the GeometryDrawing created above.
            _Pen            = new Pen();
            _Pen.Thickness  = 1;
            _Pen.LineJoin   = PenLineJoin.Miter;
            _Pen.EndLineCap = PenLineCap.Square;

            // Create a gradient to use as a value for the Pen's Brush property.
            GradientStop firstStop = new GradientStop();

            firstStop.Color = Colors.Black;
            GradientStop secondStop = new GradientStop();

            secondStop.Offset = 1.0;
            secondStop.Color  = Colors.Black;

            LinearGradientBrush myLinearGradientBrush = new LinearGradientBrush();

            myLinearGradientBrush.GradientStops.Add(firstStop);
            myLinearGradientBrush.GradientStops.Add(secondStop);

            _Pen.Brush = myLinearGradientBrush;

            int            Regnskabid   = (int)_Bilag.regnskabid;
            recMemRegnskab rec_regnskab = (from r in Program.memRegnskab where r.Rid == Regnskabid select r).First();
            string         firma        = rec_regnskab.Firmanavn;
            DateTime       startdato    = (DateTime)rec_regnskab.Start;
            DateTime       slutdato     = (DateTime)rec_regnskab.S**t;
            DateTime       bilagsdato   = (DateTime)_Bilag.dato;

            int startMonth   = startdato.Month;
            int bilagMonth   = bilagsdato.Month;
            int regnskabsaar = slutdato.Year;
            int pnr;

            if (bilagMonth < startMonth)
            {
                pnr = bilagMonth + 12 - startMonth + 1;
            }
            else
            {
                pnr = bilagMonth - startMonth + 1;
            }
            DateTime PeriodeMonthYear = new DateTime(slutdato.Year, pnr, 1);
            string   Periode          = PeriodeMonthYear.ToString("MM-yyyy");

            dc.DrawText(MakeHeader0("Bogføringsbilag " + firma, (int)(Width - (2 * PageMargin)), TextAlignment.Left), textPoint);
            textPoint.Y += 72;

            textPoint.X = 0;
            dc.DrawText(MakeHeader1("Dato", 50, TextAlignment.Left), textPoint);
            textPoint.X += 50;
            dc.DrawText(MakeHeader1(((DateTime)_Bilag.dato).ToShortDateString(), 80, TextAlignment.Left), textPoint);

            textPoint.X = ((Width - 2 * PageMargin) / 2) - 60;
            dc.DrawText(MakeHeader1("Periode", 60, TextAlignment.Left), textPoint);
            textPoint.X += 60;
            dc.DrawText(MakeHeader1(Periode, 60, TextAlignment.Right), textPoint);

            textPoint.X = Width - (2 * PageMargin + 30 + 30);
            dc.DrawText(MakeHeader1("Bilag", 30, TextAlignment.Left), textPoint);
            textPoint.X += 30;
            dc.DrawText(MakeHeader1(((int)_Bilag.bilag).ToString(), 30, TextAlignment.Right), textPoint);

            textPoint.Y += 72;
            textPoint.X  = 5.5;

            TextinBox(dc, "Tekst", 248, TextAlignment.Left, textPoint);
            textPoint.X += 248;

            TextinBox(dc, "Kontonr", 50, TextAlignment.Right, textPoint);
            textPoint.X += 50;

            TextinBox(dc, "Kontonavn", 172, TextAlignment.Left, textPoint);
            textPoint.X += 172;

            TextinBox(dc, "Debet", 85, TextAlignment.Right, textPoint);
            textPoint.X += 85;

            TextinBox(dc, "Kredit", 85, TextAlignment.Right, textPoint);


            foreach (var t in _Bilag.tbltrans)
            {
                textPoint.Y += LineHeight;
                textPoint.X  = 5.5;

                TextinBox(dc, t.tekst, 248, TextAlignment.Left, textPoint);
                textPoint.X += 248;

                TextinBox(dc, t.kontonr.ToString(), 50, TextAlignment.Right, textPoint);
                textPoint.X += 50;

                TextinBox(dc, t.kontonavn, 172, TextAlignment.Left, textPoint);
                textPoint.X += 172;

                if (t.debet != null)
                {
                    TextinBox(dc, ((decimal)(t.debet)).ToString("#,0.00;-#,0.00"), 85, TextAlignment.Right, textPoint);
                }
                else
                {
                    TextinBox(dc, t.debet.ToString(), 85, TextAlignment.Right, textPoint);
                }
                textPoint.X += 85;

                if (t.kredit != null)
                {
                    TextinBox(dc, ((decimal)(t.kredit)).ToString("#,0.00;-#,0.00"), 85, TextAlignment.Right, textPoint);
                }
                else
                {
                    TextinBox(dc, t.kredit.ToString(), 85, TextAlignment.Right, textPoint);
                }
            }

            textPoint.Y = 956;
            textPoint.X = 0;
            dc.DrawText(MakeHeader1(".", 25, TextAlignment.Left), textPoint);
        }