示例#1
0
        void AddMultiFieldToForm(TabPage TP, mfield MF, int x, int y, int count)
        {
            GroupBox G = new GroupBox();

            G.Size     = new Size(320, 50);
            G.Location = new Point(10 + x, 15 + y);

            G.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left))));
            //if (count < 10) {
            //    G.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left))));
            //}
            //else {
            //    G.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left)
            //                    | AnchorStyles.Right)));
            //}
            G.Text = MF.fieldname;
            if (!MF.allownull)
            {
                G.Text = G.Text + " (*)";
            }
            TP.Controls.Add(G);


            TextBox T = new TextBox();

            G.Controls.Add(T);
            T.Width = TextWidth; T.Height = TextHeight;
            //T.Multiline = true;
            //T.ScrollBars = ScrollBars.Vertical;
            T.Location = new Point(5, 18);
            T.Anchor   = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Left)));
            //T.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left)
            //                    | AnchorStyles.Right)));

            MF.T = T;
        }
示例#2
0
        /// <summary>
        /// Aggiunge i textbox al tab e li riempie con i valori trovati in value
        /// </summary>
        /// <param name="value">stinga codificata</param>
        /// <param name="MFKind">tabella multifieldkind</param>
        /// <param name="Fields">inventorytreemultifieldkind filtrata per idinv</param>
        void FillMultifieldTab(string value, DataTable MFKind, DataRow[] Fields)
        {
            TabControl FT = new TabControl();

            FT.Dock = DockStyle.Fill;

            Dictionary <string, List <DataRow> > HL = new Dictionary <string, List <DataRow> >();
            ArrayList TabNameList = new ArrayList();

            foreach (DataRow Fk0 in MFKind.Select(null, "ordernumber"))
            {
                DataRow F = null;
                foreach (DataRow FF in Fields)
                {
                    if (FF["idmultifieldkind"].ToString() == Fk0["idmultifieldkind"].ToString())
                    {
                        F = FF;
                        break;
                    }
                }
                if (F == null)
                {
                    continue;
                }
                string         tabname = Fk0["tabname"].ToString();
                List <DataRow> AL;
                if (HL.ContainsKey(tabname))
                {
                    AL = HL[tabname] as List <DataRow>;
                }
                else
                {
                    AL          = new List <DataRow>();
                    HL[tabname] = AL;
                    TabNameList.Add(tabname);
                }
                AL.Add(F);
            }



            tabPageInfoAgg.Controls.Clear();
            tabPageInfoAgg.Controls.Add(FT);

            Hashtable H = new Hashtable();

            string[] allmf = value.Split(new char[] { '§' });
            foreach (string coppia in allmf)
            {
                if (coppia == "")
                {
                    continue;
                }
                string[] cc   = coppia.Split(new char[] { '|' });
                string   code = cc[0].ToLower();
                string   val  = cc[1];
                H[code] = val;
            }
            //allfields= array di stringhe del tipo chiave§valore
            allfields = new mfield[Fields.Length];

            //if (value == "") allfields = new mfield[0];
            TabNameList.Sort();
            int maincount = 1;

            foreach (string tabname in TabNameList)
            {
                TabPage TP = new TabPage(tabname == "null" ? "" : tabname);
                TP.AutoScroll = true;

                int x = 0;
                int y = 0;

                int tabcount = 1;
                foreach (DataRow Field in HL[tabname])
                {
                    DataRow[] Fks = MFKind.Select(QHC.CmpEq("idmultifieldkind", Field["idmultifieldkind"]));
                    if (Fks.Length == 0)
                    {
                        continue;
                    }
                    DataRow R = Fks[0];

                    string fieldcode = R["fieldcode"].ToString();
                    object XX        = H[fieldcode.ToLower()];
                    if (XX == null)
                    {
                        XX = "";
                    }
                    mfield MF = new mfield();
                    MF.fieldname = R["fieldname"].ToString();
                    MF.allownull = (R["allownull"].ToString().ToUpper() == "S");
                    MF.systype   = R["systype"].ToString();
                    MF.tag       = R["tag"].ToString();
                    MF.fieldcode = fieldcode;
                    AddMultiFieldToForm(TP, MF, x, y, tabcount); //inizio


                    if (R["len"] != DBNull.Value)
                    {
                        MF.T.MaxLength = CfgFn.GetNoNullInt32(R["len"]);
                    }
                    MF.T.Text = XX.ToString();
                    if (MF.systype.ToLower() == "string")
                    {
                        MF.T.TextAlign = HorizontalAlignment.Left;
                    }
                    else
                    {
                        MF.T.TextAlign = HorizontalAlignment.Right;
                    }

                    allfields[maincount - 1] = MF;

                    tabcount++;
                    maincount++;
                    y += 52;
                    if (tabcount == 10)
                    {
                        x += 350;
                        y  = 0;
                    }
                }

                FT.TabPages.Add(TP);
                FT.Refresh();
            }

            ////Legenda campi obbligatori
            //if (Fields.Length > 0) {
            //    Label L = new Label();
            //    tabPageInfoAgg.Controls.Add(L);
            //    L.Text = "I campi contrassegnati da (*) sono obbligatori";
            //    L.AutoSize = true;
            //    L.Location = new Point(10 + x, 15 + y);
            //}
        }