예제 #1
0
        public Form1()
        {
            InitializeComponent();

            Logg.toLog("Start");

            // Eventhandlers - designer only accepts one/type it seems or stuff f***s up
            // Milproduktionsbaserat
            myNumboxMilprodAntalMil.TextChanged += myNumboxKostnBransleOljaPerMil_TextChanged;
            myNumboxMilprodAntalMil.TextChanged += myNumboxDackskostnadMil_TextChanged;
            myNumboxMilprodAntalMil.TextChanged += myNumboxRantaRorelseKapitalKrMil_TextChanged;
            myNumboxMilprodAntalMil.TextChanged += myNumboxKostnadRepUnderhPerMil_TextChanged;
            myNumboxMilprodAntalMil.TextChanged += beraknaMilkostnad;

            // Beräkning av summa:
            myNumboxSummaPersKostn.TextChanged           += beraknaSumma;
            myNumboxAvskrivningarSummaBelopp.TextChanged += beraknaSumma;
            myNumboxBerKalkylrantaAvskr.TextChanged      += beraknaSumma;
            myNumboxBerKalkylrantaAvskr.TextChanged      += beraknaSumma;
            myNumboxDrivmedelOlja.TextChanged            += beraknaSumma;
            myNumboxDackskostnad.TextChanged             += beraknaSumma;
            myNumboxOvrKostRantaRorligtKap.TextChanged   += beraknaSumma;
            myNumboxReparationochUnderhall.TextChanged   += beraknaSumma;
            myNumboxSummaOvrigaKostk.TextChanged         += beraknaSumma;

            // när summan ändras
            myNumboxSumma.TextChanged += beraknaMilkostnad;


            // totalsumman
            myNumboxSumma.TextChanged        += beraknaTotalt;
            myNumboxVinstRisk.TextChanged    += beraknaTotalt;
            myNumboxAvgSidointkt.TextChanged += beraknaTotalt;

            // Beräkna vinst/risk
            myNumboxSumma.TextChanged         += beraknaVinstRisk;
            myNumboxVinstRiskProc.TextChanged += beraknaVinstRisk;

            // Milkostn ink vinst/risk
            myNumboxSumma.TextChanged           += beraknaMilkostnInkVinstRisk;
            myNumboxVinstRisk.TextChanged       += beraknaMilkostnInkVinstRisk;
            myNumboxMilprodAntalMil.TextChanged += beraknaMilkostnInkVinstRisk;

            // Milkostnad efter sidointäkt
            myNumboxTotalt.TextChanged          += beraknaMilkostnESidointakt;
            myNumboxMilprodAntalMil.TextChanged += beraknaMilkostnESidointakt;

            // Reducerad total pga samlastning
            myNumboxTotalt.TextChanged += myNumboxFyllnadsgradProc_TextChanged;

            // Print
            printDocCaptureScreen.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDocumentCaptureScreen_PrintPage);
            printDocTextOnly.PrintPage      += new System.Drawing.Printing.PrintPageEventHandler(printTextOnly_PrintPage);
        }
예제 #2
0
        /// <summary>
        /// Beräknar kostnad/avskrivningsår för lastbil
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void myNumboxLastbAnskVarde_Ar_TextChanged(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(myNumboxLastbAnskVarde.Text))
            {
                myNumboxLastbArligAvskrivning.Text = string.Empty;
                return;
            }

            if (String.IsNullOrWhiteSpace(myNumboxLastbAvskrtidAr.Text))
            {
                myNumboxLastbArligAvskrivning.Text = string.Empty;
                return;
            }

            double value    = Convert.ToDouble(myNumboxLastbAnskVarde.Text);
            double years    = Convert.ToDouble(myNumboxLastbAvskrtidAr.Text);
            double quotient = value / years;

            Logg.toLog("A change Value: " + value + " years " + years + " quotient: " + value / years);

            myNumboxLastbArligAvskrivning.Text = quotient.ToString("F2");
        }
예제 #3
0
        // xyz - column 1,2 or 3
        // biulcrt - bold, italics, underline, left, center, right adjust, title (larger size text + extra space before)

        private int recursiveControlListMaker(Control.ControlCollection CC)
        {
            GroupBox groupbox;
            TextBox  textbox;
            Label    label;
            string   formatting;
            int      column, index;
            int      numRowsTotal    = 0;
            int      numRowsGroupBox = 0;

            System.Text.RegularExpressions.Match formattingMatch;

            foreach (Control C in CC)
            {
                try
                {
                    if (reasonableFormat.IsMatch((string)C.Tag))
                    {
                        formattingMatch = reasonableFormat.Match((string)C.Tag);

                        index = Convert.ToInt32(formattingMatch.Groups[1].Value);

                        try
                        {
                            column = Convert.ToInt32((formattingMatch.Groups[2].Value.ToCharArray())[0] - 'w');
                        }
                        catch
                        {
                            column = 0;
                        }
                        try
                        {
                            formatting = formattingMatch.Groups[3].ToString();
                        }
                        catch
                        {
                            formatting = "";
                        }
                    }
                    else
                    {
                        index      = -1;
                        formatting = "";
                        column     = 0;
                    }
                }
                catch
                {
                    index      = -1;
                    formatting = "";
                    column     = 0;
                }

                try
                {
                    groupbox = (GroupBox)C;

                    try
                    {
                        numRowsGroupBox = recursiveControlListMaker(groupbox.Controls);
                        numRowsTotal   += numRowsGroupBox;
                        numRowsTotal++;

                        try
                        {
                            globallistOfLabelandValue[index, 0] = groupbox.Text;
                            globallistOfLabelandValue[index, 4] = formatting + 't';
                            globallistOfLabelandValue[index, 5] = Convert.ToString(numRowsGroupBox);
                        }
                        catch { }
                    }
                    catch (Exception ex)
                    {
                        Logg.toLog("Exception " + ex.Message);
                    }
                    continue;
                }
                catch { } // do nothing

                try
                {
                    textbox = (TextBox)C;

                    if (column == 0)
                    {
                        globallistOfLabelandValue[index, 1] = textbox.Text;
                    }
                    else
                    {
                        globallistOfLabelandValue[index, column] = textbox.Text;
                    }

                    globallistOfLabelandValue[index, 4] = formatting;

                    if (column == 0 || column == 1)
                    {
                        numRowsTotal++;
                    }

                    continue;
                }
                catch { } // do nothing

                try
                {
                    label = (Label)C;

                    globallistOfLabelandValue[index, column] = label.Text;
                    globallistOfLabelandValue[index, 4]      = formatting;

                    continue;
                }
                catch (Exception ex)
                {
                    Logg.toLog("Exception: " + ex.Message);
                } // do nothing
            }
            return(numRowsTotal);
        }