Exemplo n.º 1
0
        private void NactiDochazku()
        {
            if (panel_Formular.Controls[0] == null)
                return;

            Int32 CisloZam = 0;
            if ((treeView_Zamestnanci.SelectedNode != null) && (!Int32.TryParse(treeView_Zamestnanci.SelectedNode.Name, out CisloZam)))
                return;
            //textBox_Vyhledavani.Text = treeView_Zamestnanci.SelectedNode.Text;
            this.Text = "Docházka - " + treeView_Zamestnanci.SelectedNode.Text;
            panel_Formular.Visible = false;
            PripravFormularMesic();
            String SQL = "SELECT CisloZam, Datum, Stredisko, Zakazka, Cinnost, SUM(Hodiny) FROM TabEGDochazkaDny WHERE CisloZam = " + CisloZam + " AND YEAR(Datum) = " + numericUpDown_Rok.Value + " AND Month(Datum) = " + numericUpDown_Mesic.Value + " GROUP BY CisloZam, Datum, Stredisko, Zakazka, Cinnost ORDER BY Datum, Stredisko, Zakazka, Cinnost";
            IHeQuery SQLDochazka = Helios.OpenSQL(SQL);
            if (DochazkaDny == null)
                DochazkaDny = new List<DochazkaStruct>();
            DochazkaDny.Clear();
            DochazkaStruct Polozka = new DochazkaStruct();
            while (!SQLDochazka.EOF())
            {
                Polozka.CisloZam = SQLDochazka.FieldValues(0);
                Polozka.Datum = SQLDochazka.FieldValues(1);
                Polozka.Stredisko = SQLDochazka.FieldValues(2);
                Polozka.Zakazka = SQLDochazka.FieldValues(3);
                Polozka.Cinnost = SQLDochazka.FieldValues(4);
                Polozka.Hodiny = SQLDochazka.FieldValues(5);
                DochazkaDny.Add(Polozka);
                SQLDochazka.Next();
            }
            String Stredisko = "";
            String Zakazka = "";
            Calendar Kalendar = new CultureInfo("cs-CZ").Calendar;
            Int32 PrvniTyden = Kalendar.GetWeekOfYear(new DateTime((int)numericUpDown_Rok.Value, (int)numericUpDown_Mesic.Value, 1), CalendarWeekRule.FirstDay, DayOfWeek.Monday);
            Int32 Tyden = 0;
            Int32 AktualniTyden;
            Int32 DenTydne;
            Int32 Radek = 0;
            TableLayoutPanel TydenTable = null;
            foreach (DochazkaStruct item in DochazkaDny)
            {
                //if (PrvniTyden == 0)
                //    PrvniTyden = Kalendar.GetWeekOfYear(item.Datum, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
                AktualniTyden = Kalendar.GetWeekOfYear(item.Datum, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
                DenTydne = (Int32)Kalendar.GetDayOfWeek(item.Datum);
                DenTydne = DenTydne == 0 ? 8 : DenTydne + 1;
                if (Tyden != AktualniTyden)
                {
                    Stredisko = item.Stredisko;
                    Zakazka = item.Zakazka;
                    Tyden = AktualniTyden;
                    Radek = 0;
                    TydenTable = (TableLayoutPanel)(((Panel)(((TableLayoutPanel)(panel_Formular.Controls[0])).GetControlFromPosition(0, AktualniTyden - PrvniTyden))).Controls[0]);
                    ((TextBox)(((TableLayoutPanel)(TydenTable.GetControlFromPosition(0, 2))).GetControlFromPosition(0, Radek))).Text = item.Stredisko;
                    ((TextBox)(((TableLayoutPanel)(TydenTable.GetControlFromPosition(0, 2))).GetControlFromPosition(1, Radek))).Text = item.Zakazka;
                }
                Stredisko = item.Stredisko;
                Zakazka = item.Zakazka;
                Radek = PridejRadek(AktualniTyden, Stredisko, Zakazka, DenTydne);
                ((TextBox)(((TableLayoutPanel)(TydenTable.GetControlFromPosition(0, 2))).GetControlFromPosition(DenTydne, Radek))).Text = item.Cinnost;
                ((TextBox)(((TableLayoutPanel)(TydenTable.GetControlFromPosition(0, 4))).GetControlFromPosition(DenTydne, Radek))).Text = item.Hodiny.ToString();
                SectiHodiny(((TextBox)(((TableLayoutPanel)(TydenTable.GetControlFromPosition(0, 4))).GetControlFromPosition(DenTydne, Radek))));
            }
            panel_Formular.Visible = true;
        }
Exemplo n.º 2
0
        private void PripravFormularMesic()
        {
            panel_Formular.Controls.Clear();

            Int16 Rok = (Int16)numericUpDown_Rok.Value;
            Int16 Mesic = (Int16)numericUpDown_Mesic.Value;
            UzamciUzavreneObdobi(Rok, Mesic);
            Calendar Kalendar = new CultureInfo("cs-CZ").Calendar;
            Int32 PrvniTyden = Kalendar.GetWeekOfYear(new DateTime(Rok, Mesic, 1), CalendarWeekRule.FirstDay, DayOfWeek.Monday);
            Int32 PosledniTyden = Kalendar.GetWeekOfYear(new DateTime(Rok, Mesic, DateTime.DaysInMonth(Rok, Mesic)), CalendarWeekRule.FirstDay, DayOfWeek.Monday);
            TableLayoutPanel Formular = new TableLayoutPanel();
            Formular.AutoSize = true;
            for (int i = PrvniTyden; i <= PosledniTyden; i++)
            {
                Formular.RowCount++;
                Formular.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            }
            Int32 Tyden;
            Int32 AktalniTyden = 0;
            Int32 DenTydne;
            Label Popisek;
            Button Tlacitko;
            TextBox Text;
            ToolTip toolTip_CtrlEnter;
            String SQL = "SELECT D.Datum_D, D.TypDne, D.Svatek FROM TabMzKalendar AS K INNER JOIN TabMzKalendarDny AS D ON D.IDKalendar = K.ID WHERE K.Rok = " + Rok + " AND K.Cislo = '001' AND D.Datum_M = " + Mesic;
            IHeQuery Svatky = Helios.OpenSQL(SQL);
            for (int Den = 1; Den <= DateTime.DaysInMonth(Rok, Mesic); Den++)
            {
                DateTime Datum = new DateTime(Rok, Mesic, Den);
                Tyden = Kalendar.GetWeekOfYear(Datum, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
                if (AktalniTyden != Tyden)
                {
                    TableLayoutPanel TydenTable = new TableLayoutPanel();
                    TydenTable.AutoSize = true;
                    TydenTable.Tag = Tyden;
                    for (int Radek = 0; Radek < 5; Radek++)
                    {
                        TydenTable.RowCount++;
                        TydenTable.RowStyles.Add(new RowStyle(SizeType.AutoSize));
                        TableLayoutPanel DenTable = new TableLayoutPanel();
                        DenTable.AutoSize = true;
                        DenTable.Margin = new Padding(0);
                        DenTable.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
                        DenTable.Tag = 1;
                        DenTable.RowCount++;
                        DenTable.RowStyles.Add(new RowStyle(SizeType.AutoSize));
                        for (int d = 0; d < 9; d++)
                        {
                            DenTable.ColumnCount++;
                            DenTable.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 70));
                        }
                        switch (Radek)
                        {
                            case 0:
                                DenTable.BackColor = System.Drawing.Color.Beige;
                                Popisek = new Label();
                                Popisek.Text = "Týden " + Tyden;
                                Popisek.Dock = DockStyle.Top;
                                Popisek.Height = 16;
                                Popisek.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                                DenTable.Controls.Add(Popisek, 0, 0);
                                DenTable.SetColumnSpan(Popisek, 2);
                                break;
                            case 1:
                                Popisek = new Label();
                                Popisek.Text = "Úsek";
                                Popisek.Dock = DockStyle.Top;
                                Popisek.Height = 16;
                                Popisek.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                                DenTable.Controls.Add(Popisek, 0, 0);
                                Popisek = new Label();
                                Popisek.Text = "Zakázka";
                                Popisek.Dock = DockStyle.Top;
                                Popisek.Height = 16;
                                Popisek.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                                DenTable.Controls.Add(Popisek, 1, 0);
                                Popisek = new Label();
                                Popisek.Text = "Činnost";
                                Popisek.Dock = DockStyle.Top;
                                Popisek.Height = 16;
                                Popisek.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                                DenTable.Controls.Add(Popisek, 2, 0);
                                DenTable.SetColumnSpan(Popisek, 7);
                                break;
                            case 2:
                                toolTip_CtrlEnter = new ToolTip();
                                Text = new TextBox();
                                Text.Dock = DockStyle.Top;
                                Text.Height = 16;
                                Text.TextAlign = HorizontalAlignment.Center;
                                Text.DoubleClick += VyberStrediska_DblClick;
                                Text.PreviewKeyDown += AllowKeys;
                                Text.KeyDown += VyberStredisko_CtrlEnter;
                                Text.KeyDown += ZpracujKlavesy;
                                Text.Validating += KontrolaStrediska_Validating;
                                Text.Enter += PodbarviFocusRadku_Enter;
                                Text.Tag = ("S" + Tyden + "_1");
                                toolTip_CtrlEnter.SetToolTip(Text, "CTRL+Enter = výběr úseku");
                                DenTable.Controls.Add(Text, 0, 0);
                                Text = new TextBox();
                                Text.Dock = DockStyle.Top;
                                Text.Height = 16;
                                Text.TextAlign = HorizontalAlignment.Center;
                                Text.DoubleClick += VyberZakazky_DblClick;
                                Text.PreviewKeyDown += AllowKeys;
                                Text.KeyDown += VyberZakazky_CtrlEnter;
                                Text.KeyDown += ZpracujKlavesy;
                                Text.Validating += KontrolaZakazky_Validating;
                                Text.Enter += PodbarviFocusRadku_Enter;
                                Text.Tag = ("Z" + Tyden + "_1");
                                toolTip_CtrlEnter.SetToolTip(Text, "CTRL+Enter = výběr zakázky");
                                DenTable.Controls.Add(Text, 1, 0);
                                break;
                            case 3:
                                Popisek = new Label();
                                Popisek.Text = "Hodiny";
                                Popisek.Dock = DockStyle.Top;
                                Popisek.Height = 16;
                                Popisek.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                                DenTable.Controls.Add(Popisek);
                                DenTable.SetColumnSpan(Popisek, 9);
                                break;
                            case 4:
                                Tlacitko = new Button();
                                Tlacitko.Text = "+";
                                Tlacitko.Width = 24;
                                Tlacitko.Height = 16;
                                Tlacitko.TabStop = false;
                                Tlacitko.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                                Tlacitko.Click += PridejRadek_Click;
                                Tlacitko.Tag = ("B" + Tyden + "_1");
                                DenTable.Controls.Add(Tlacitko, 0, 0);
                                break;
                            default:
                                break;
                        }
                        TydenTable.Controls.Add(DenTable, 0, Radek);
                    }
                    Panel TydenPanel = new Panel();
                    TydenPanel.BorderStyle = BorderStyle.Fixed3D;
                    TydenPanel.AutoSize = true;
                    TydenPanel.Controls.Add(TydenTable);
                    TydenPanel.Tag = Tyden;
                    Formular.Controls.Add(TydenPanel, 0, Tyden - PrvniTyden);
                    AktalniTyden = Tyden;
                }
                DenTydne = (Int32)Kalendar.GetDayOfWeek(Datum);
                DenTydne = DenTydne == 0 ? 8 : DenTydne + 1;
                Popisek = new Label();
                Popisek.Text = Datum.Day.ToString();
                Popisek.Dock = DockStyle.Top;
                Popisek.Height = 16;
                Popisek.Tag = Datum.Day;
                Popisek.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                if (!Svatky.EOF())
                {
                    if (Svatky.FieldValues(1) == 1)
                        Popisek.BackColor = System.Drawing.Color.Cyan;
                    if (Svatky.FieldValues(2))
                        Popisek.BackColor = System.Drawing.Color.Red;
                    Svatky.Next();
                }
                ((TableLayoutPanel)((TableLayoutPanel)((Panel)(Formular.GetControlFromPosition(0, AktalniTyden - PrvniTyden))).Controls[0]).GetControlFromPosition(0, 0)).Controls.Add(Popisek, DenTydne, 0);
                Text = new TextBox();
                Text.Dock = DockStyle.Top;
                Text.Height = 16;
                Text.TextAlign = HorizontalAlignment.Center;
                toolTip_CtrlEnter = new ToolTip();
                Text.DoubleClick += VyberCinnost_DblClick;
                Text.PreviewKeyDown += AllowKeys;
                Text.KeyDown += VyberCinnost_CtrlEnter;
                Text.KeyDown += ZpracujKlavesy;
                Text.Enter += PodbarviFocusRadku_Enter;
                Text.Validating += KontrolaCinnosti_Validating;
                toolTip_CtrlEnter.SetToolTip(Text, "CTRL+Enter = výběr činnosti");
                Text.Tag = ("C" + Den + "_1");
                ((TableLayoutPanel)((TableLayoutPanel)((Panel)(Formular.GetControlFromPosition(0, AktalniTyden - PrvniTyden))).Controls[0]).GetControlFromPosition(0, 2)).Controls.Add(Text, DenTydne, 0);
                Text = new TextBox();
                Text.Dock = DockStyle.Top;
                Text.Height = 16;
                Text.TextAlign = HorizontalAlignment.Center;
                Text.Tag = ("H" + Den + "_1");
                Text.PreviewKeyDown += AllowKeys;
                Text.KeyDown += ZpracujKlavesy;
                Text.Enter += PodbarviFocusRadku_Enter;
                Text.Validating += KontrolaHodin_Validating;
                ((TableLayoutPanel)((TableLayoutPanel)((Panel)(Formular.GetControlFromPosition(0, AktalniTyden - PrvniTyden))).Controls[0]).GetControlFromPosition(0, 4)).Controls.Add(Text, DenTydne, 0);
            }

            panel_Formular.Controls.Add(Formular);
            FocusTyden = 0;
            FocusRadek = 0;
        }