Ejemplo n.º 1
0
        public List<string> GetTableHtmlPrimary()
        {
            var gc = new GraphClass(main, dtTil, dtTil); // Brukes til selger aktivitet
            var doc = new List<string>();
            if (StopRankingPending())
                return doc;
            var hashId = random.Next(999, 99999);
            int hashIddRow = 0;
            string urlID = "linkm"; // Marker linker for måned-periode
            if (dtDetaljer.Rows.Count > 8)
                dt = dtDetaljer;
            else
            {
                if (main.salesCodes.Count() < 4)
                    doc.Add("<br><span class='Subtitle' style='color:red !important;'>Ikke nok selgerkoder valgt for å lage en meningsfull tabell.</span><br>");
                else
                    doc.Add("<span class='Subtitle' style='color:red !important;'>Fant ingen transaksjoner.</span><br>");
                return doc;
            }

            main.openXml.SaveDocument(dt, "Oversikt", "Del 1", dtTil, "OVERSIKT DEL 1 - " + dtTil.ToString("dddd d. MMMM yyyy", norway));

            doc.Add("<div class='toolbox hidePdf'>");
            doc.Add("<a class='GuiButton hidePdf' onclick='toggleTable(" + hashId + ");' href='#'>Vis / Skjul</a><br>");
            doc.Add("<a class='GuiButton hidePdf' onclick='toggleAll();' href='#'>Alle</a><br>");
            doc.Add("</div>");

            doc.Add("<table class='" + outerclass + " toggleAll' id='" + hashId + "'><tr><td>");
            doc.Add("<table class='tablesorter'>");
            doc.AddRange(MakeTableHeaderPrimary());
            doc.Add("<tbody>");
            string kategori = "";

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                bool kat = ErKat(dt.Rows[i]["Kat"].ToString());

                string onclickStr = "";
                string classStr = " class='Kategori' ";
                if (ErKatSpecial(dt.Rows[i]["Kat"].ToString()))
                    classStr = " class='KategoriSpecial' ";
                if (kat)
                {
                    kategori = dt.Rows[i]["Kat"].ToString();
                    hashIddRow = random.Next(9999, 99999);
                    onclickStr = " onclick='toggleRow(" + hashIddRow + ");' ";
                }
                if (!kat)
                {
                    onclickStr = "";
                    if (main.salesCodes.GetKategori(dt.Rows[i]["Kat"].ToString()) == "Cross")
                        classStr = " class='" + hashIddRow + " CrossSelger' ";
                    else
                        classStr = " class='" + hashIddRow + " Selger' ";
                }

                if (dt.Rows.Count == i + 1) // Vi er på siste row
                    doc.Add("</tbody><tfoot><tr><td class='text-cat'><a href='#" + urlID + "t" + "'>" + dt.Rows[i]["Kat"] + "</a></td>");
                else
                {
                    if (kat)
                        doc.Add("<tr" + onclickStr + classStr + "><td class='text-cat'><a href='#" + urlID + "b" + dt.Rows[i]["Kat"] + "'>" + dt.Rows[i]["Kat"] + "</a></td>");
                    else
                        doc.Add("<tr" + onclickStr + classStr + "><td class='text-cat'><a href='#" + urlID + "s" + dt.Rows[i]["Kat"] + "'>" + main.salesCodes.GetNavn(dt.Rows[i]["Kat"].ToString()) + "</a></td>");
                }

                if (main.appConfig.importSetting.StartsWith("Full"))
                {
                    doc.Add("<td class='numbers-gen'>" + PlusMinus(dt.Rows[i]["Omset"].ToString()) + "</td>");
                    doc.Add("<td class='numbers-gen'>" + PlusMinus(dt.Rows[i]["Inntjen"].ToString()) + "</td>");
                    doc.Add("<td class='numbers-percent'>" + PercentShare(dt.Rows[i]["Prosent"].ToString(), "Inntjen", kat) + "</td>");

                    doc.Add("<td class='numbers-finans'>" + PlusMinus(dt.Rows[i]["FinansAntall"].ToString()) + "</td>");
                    if (main.appConfig.oversiktKravVis && main.appConfig.oversiktKravFinansAntall && main.appConfig.oversiktKravFinans)
                    {
                        doc.Add("<td class='numbers-small" + ObjectToClassStr(dt.Rows[i]["FinansKravOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["FinansKrav"].ToString()) + "</td>");
                        if (main.appConfig.oversiktKravMtdShowTarget)
                            doc.Add("<td class='numbers-small" + ObjectToClassStr(dt.Rows[i]["FinansKravUmodOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["FinansKravUmod"].ToString()) + "</td>");
                    }
                    doc.Add("<td class='numbers-gen'>" + PlusMinus(dt.Rows[i]["FinansInntjen"].ToString()) + "</td>");
                    if (main.appConfig.oversiktKravVis && !main.appConfig.oversiktKravFinansAntall && main.appConfig.oversiktKravFinans)
                    {
                        doc.Add("<td class='numbers-gen" + ObjectToClassStr(dt.Rows[i]["FinansKravOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["FinansKrav"].ToString()) + "</td>");
                        if (main.appConfig.oversiktKravMtdShowTarget)
                            doc.Add("<td class='numbers-gen" + ObjectToClassStr(dt.Rows[i]["FinansKravUmodOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["FinansKravUmod"].ToString()) + "</td>");
                    }
                    doc.Add("<td class='numbers-percent'>" + PercentShare(dt.Rows[i]["FinansMargin"].ToString(), "Finans", kat) + "</td>");

                    doc.Add("<td class='numbers-moderna'>" + PlusMinus(dt.Rows[i]["ModAntall"].ToString()) + "</td>");
                    if (main.appConfig.oversiktKravVis && main.appConfig.oversiktKravModAntall && main.appConfig.oversiktKravMod)
                    {
                        doc.Add("<td class='numbers-small" + ObjectToClassStr(dt.Rows[i]["ModKravOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["ModKrav"].ToString()) + "</td>");
                        if (main.appConfig.oversiktKravMtdShowTarget)
                            doc.Add("<td class='numbers-small" + ObjectToClassStr(dt.Rows[i]["ModKravUmodOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["ModKravUmod"].ToString()) + "</td>");
                    }
                    doc.Add("<td class='numbers-gen'>" + PlusMinus(dt.Rows[i]["ModOmset"].ToString()) + "</td>");
                    if (main.appConfig.oversiktKravVis && !main.appConfig.oversiktKravModAntall && main.appConfig.oversiktKravMod)
                    {
                        doc.Add("<td class='numbers-gen" + ObjectToClassStr(dt.Rows[i]["ModKravOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["ModKrav"].ToString()) + "</td>");
                        if (main.appConfig.oversiktKravMtdShowTarget)
                            doc.Add("<td class='numbers-gen" + ObjectToClassStr(dt.Rows[i]["ModKravUmodOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["ModKravUmod"].ToString()) + "</td>");
                    }
                    doc.Add("<td class='numbers-percent'>" + PercentShare(dt.Rows[i]["ModMargin"].ToString(), "TA", kat) + "</td>");

                    doc.Add("<td class='numbers-strom'>" + PlusMinus(dt.Rows[i]["StromAntall"].ToString()) + "</td>");
                    if (main.appConfig.oversiktKravVis && main.appConfig.oversiktKravStromAntall && main.appConfig.oversiktKravStrom)
                    {
                        doc.Add("<td class='numbers-small" + ObjectToClassStr(dt.Rows[i]["StromKravOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["StromKrav"].ToString()) + "</td>");
                        if (main.appConfig.oversiktKravMtdShowTarget)
                            doc.Add("<td class='numbers-small" + ObjectToClassStr(dt.Rows[i]["StromKravUmodOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["StromKravUmod"].ToString()) + "</td>");
                    }
                    doc.Add("<td class='numbers-gen'>" + PlusMinus(dt.Rows[i]["StromInntjen"].ToString()) + "</td>");
                    if (main.appConfig.oversiktKravVis && !main.appConfig.oversiktKravStromAntall && main.appConfig.oversiktKravStrom)
                    {
                        doc.Add("<td class='numbers-gen" + ObjectToClassStr(dt.Rows[i]["StromKravOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["StromKrav"].ToString()) + "</td>");
                        if (main.appConfig.oversiktKravMtdShowTarget)
                            doc.Add("<td class='numbers-gen" + ObjectToClassStr(dt.Rows[i]["StromKravUmodOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["StromKravUmod"].ToString()) + "</td>");
                    }
                    doc.Add("<td class='numbers-percent'>" + PercentShare(dt.Rows[i]["StromMargin"].ToString(), "Strom", kat) + "</td>");

                    doc.Add("<td class='numbers-service'>" + PlusMinus(dt.Rows[i]["AntallTjen"].ToString()) + "</td>");
                    if (main.appConfig.oversiktKravVis && main.appConfig.oversiktKravRtgsaAntall && main.appConfig.oversiktKravRtgsa)
                    {
                        doc.Add("<td class='numbers-small" + ObjectToClassStr(dt.Rows[i]["RtgsaKravOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["RtgsaKrav"].ToString()) + "</td>");
                        if (main.appConfig.oversiktKravMtdShowTarget)
                            doc.Add("<td class='numbers-small" + ObjectToClassStr(dt.Rows[i]["RtgsaKravUmodOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["RtgsaKravUmod"].ToString()) + "</td>");
                    }
                    doc.Add("<td class='numbers-gen'>" + PlusMinus(dt.Rows[i]["TjenInntjen"].ToString()) + "</td>");
                    if (main.appConfig.oversiktKravVis && !main.appConfig.oversiktKravRtgsaAntall && main.appConfig.oversiktKravRtgsa)
                    {
                        doc.Add("<td class='numbers-gen" + ObjectToClassStr(dt.Rows[i]["RtgsaKravOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["RtgsaKrav"].ToString()) + "</td>");
                        if (main.appConfig.oversiktKravMtdShowTarget)
                            doc.Add("<td class='numbers-gen" + ObjectToClassStr(dt.Rows[i]["RtgsaKravUmodOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["RtgsaKravUmod"].ToString()) + "</td>");
                    }
                    doc.Add("<td class='numbers-percent'>" + PercentShare(dt.Rows[i]["TjenMargin"].ToString(), "RTG", kat) + "</td>");
                }
                if (!main.appConfig.importSetting.StartsWith("Full"))
                {
                    doc.Add("<td class='numbers-service'>" + PlusMinus(dt.Rows[i]["AntallTjen"].ToString()) + "</td>");
                    if (main.appConfig.oversiktKravVis && main.appConfig.oversiktKravRtgsaAntall && main.appConfig.oversiktKravRtgsa)
                    {
                        doc.Add("<td class='numbers-small" + ObjectToClassStr(dt.Rows[i]["RtgsaKravOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["RtgsaKrav"].ToString()) + "</td>");
                        if (main.appConfig.oversiktKravMtdShowTarget)
                            doc.Add("<td class='numbers-small" + ObjectToClassStr(dt.Rows[i]["RtgsaKravUmodOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["RtgsaKravUmod"].ToString()) + "</td>");
                    }
                    doc.Add("<td class='numbers-gen'>" + PlusMinus(dt.Rows[i]["TjenOmset"].ToString()) + "</td>");
                    if (main.appConfig.oversiktKravVis && !main.appConfig.oversiktKravRtgsaAntall && main.appConfig.oversiktKravRtgsa)
                    {
                        doc.Add("<td class='numbers-gen" + ObjectToClassStr(dt.Rows[i]["RtgsaKravOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["RtgsaKrav"].ToString()) + "</td>");
                        if (main.appConfig.oversiktKravMtdShowTarget)
                            doc.Add("<td class='numbers-gen" + ObjectToClassStr(dt.Rows[i]["RtgsaKravUmodOppfylt"]) + "'>" + PlusMinus(dt.Rows[i]["RtgsaKravUmod"].ToString()) + "</td>");
                    }
                    doc.Add("<td class='numbers-gen'>" + PlusMinus(dt.Rows[i]["TjenInntjen"].ToString()) + "</td>");
                }
                doc.Add("</tr>");
            }
            doc.Add("</tfoot></table></td></tr></table>");

            return doc;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sjekk av databasens siste og første dato.
        /// </summary>
        /// <param name="forced">Sjekk fra til dato i databasen for transaksjoner</param>
        public void RetrieveDb(bool forced = false)
        {
            try
            {
                string dateFormat = "dd/MM/yyyy HH:mm:ss";
                appConfig.dbFrom = DateTime.Now;
                //dbTilDT = rangeMin;

                if (appConfig.dbFrom == null || appConfig.dbTo == null
                    || appConfig.dbFrom == DateTime.MinValue || appConfig.dbTo == DateTime.MinValue
                    || forced || newInstall
                    || appConfig.dbFrom > appConfig.dbTo)
                {
                    Log.n("Oppdaterer databasen..", null, true);

                    SqlCeCommand cmd = new SqlCeCommand("SELECT MIN(Dato) AS Expr1 FROM tblSalg WHERE (Avdeling = '" + appConfig.Avdeling + "')", connection);
                    string temp = cmd.ExecuteScalar().ToString();
                    if (!String.IsNullOrEmpty(temp))
                        appConfig.dbFrom = DateTime.ParseExact(temp, dateFormat, FormMain.norway);

                    cmd = new SqlCeCommand("SELECT MAX(Dato) AS Expr1 FROM tblSalg WHERE (Avdeling = '" + appConfig.Avdeling + "')", connection);
                    temp = cmd.ExecuteScalar().ToString();
                    if (!String.IsNullOrEmpty(temp))
                        appConfig.dbTo = DateTime.ParseExact(temp, dateFormat, FormMain.norway);

                    openXml.ClearDatabase();
                    database.ClearCacheTables(); // slett month cache tables

                    if (newInstall)
                    {
                        ClearHash("", true);
                        ClearBudgetHash(BudgetCategory.None, true);
                        newInstall = false;
                    }
                }

                if (!autoMode)
                {
                    // Oppdaterer avdelinger..
                    Log.n("Oppdaterer avdelinger..", null, true);
                    bwHentAvdelinger.RunWorkerAsync();
                }

                if (appConfig.dbFrom.Date != DateTime.Now.Date && appConfig.dbTo.Date != DateTime.Now.Date && appConfig.dbFrom.Date > rangeMin.Date && appConfig.dbTo.Date > rangeMin.Date)
                {
                    try
                    {
                        if (appConfig.dbFrom.Date != DateTime.Now.Date && appConfig.dbTo.Date != DateTime.Now.Date)
                        {
                            if (appConfig.dbTo.DayOfWeek == DayOfWeek.Sunday && appConfig.ignoreSunday && appConfig.dbFrom.Date != appConfig.dbTo.Date) { appConfig.dbTo = appConfig.dbTo.AddDays(-1); }

                            ChangeRankDateTimePicker(appConfig.dbTo, appConfig.dbFrom, appConfig.dbTo);
                            ChangeBudgetDateTimePicker(appConfig.dbTo, appConfig.dbFrom, appConfig.dbTo);
                            StatusInformation.Text = "Database:  " + appConfig.dbFrom.ToString("d. MMMM yyyy", norway) + "  -  " + appConfig.dbTo.ToString("d. MMMM yyyy", norway) + "  ";
                            Log.n("Databasen har transaksjoner mellom " + appConfig.dbFrom.ToString("d. MMMM yyyy", norway) + " og " + appConfig.dbTo.ToString("d. MMMM yyyy", norway) + " for din avdeling.", Color.Black, true);
                        }
                    }
                    catch
                    {
                        ChangeRankDateTimePicker(DateTime.Now, rangeMin, rangeMax);
                        ChangeBudgetDateTimePicker(DateTime.Now, rangeMin, rangeMax);
                        StatusInformation.Text = "Database: N/A  ";
                    }
                }
                else
                {
                    ChangeRankDateTimePicker(DateTime.Now, DateTime.Now, DateTime.Now);
                    ChangeBudgetDateTimePicker(DateTime.Now, DateTime.Now, DateTime.Now);
                    StatusInformation.Text = "Database: (tom)  ";
                }
                gc = new GraphClass(this);
            }
            catch
            {
                Log.n("Feil ved lasting av databasen, eller databasen er tom.", Color.Red);
                appConfig.dbFrom = DateTime.Now;
                appConfig.dbTo = DateTime.Now;
                ChangeRankDateTimePicker(DateTime.Now, rangeMin, rangeMax);
                ChangeBudgetDateTimePicker(DateTime.Now, rangeMin, rangeMax);
                StatusInformation.Text = "Database: N/A  ";
            }
        }