Beispiel #1
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        int id = Convert.ToInt32(Session["ticketid"]);
        int id1;
        id1 = Convert.ToInt32(Session["clientid"]);

        Hashtable dataforvalue = new Hashtable();
        bll compview = new bll();
        if (id != 0)
        {
            dataforvalue = compview.selcomp(id);

            commaDelimited = dataforvalue["fullstring"].ToString();

            string[] year = commaDelimited.Split(new char[] { ',' });
            foreach (string month in year)
            {
                d[k] = month;
                k++;
            }

            int a = id1;
            bll noof = new bll();
            int w, z, tn, cn, tc = 0, cc = 0;
            Hashtable datano = new Hashtable();
            datano = noof.noofrows(a);
            w = Convert.ToInt32(datano["noofrows"]);
            tn = Convert.ToInt32(datano["nooftxt"]);
            cn = Convert.ToInt32(datano["noofcb"]);
            dynamicTextBoxes = new TextBox[tn];
            dynamiccombobox = new AjaxControlToolkit.ComboBox[cn];
            Table tbl = new Table();
            for (z = 0; z < w; z++)
            {
                bll cuscontrol = new bll();
                Hashtable data = new Hashtable();
                data = cuscontrol.ccomp(a, z);

                TableRow tr = new TableRow();
                TableCell td0 = new TableCell();
                tr.CssClass = "table_tr";
                TableCell td1 = new TableCell();
                int field = Convert.ToInt32(data["id"]);

                if (data["control"].ToString() == "Combobox")
                {
                    Response.Write(System.Environment.NewLine);
                    lbl = new System.Web.UI.WebControls.Label();
                    lbl.ID = (2 * z).ToString();

                    lbl.Text = data["label"].ToString();
                    lbl.CssClass = "ajxtxt";

                    td0.Controls.Add(lbl);
                    cb = new AjaxControlToolkit.ComboBox();
                    cb.ID = (2 * z + 1).ToString();
                    cb.Enabled = false;
                    cb.CssClass = "ajxtxt";
                    cb.ForeColor = Color.Black;
                    dynamiccombobox[cc] = cb;
                    cc++;
                    td1.Controls.Add(cb);

                    if (data["value"].ToString() == "get")
                    {
                        string q = data["dbname"].ToString();
                        bll reff = new bll();

                        Type t = reff.GetType();

                        Type[] paramTypes = new Type[1];
                        paramTypes[0] = Type.GetType("System.Int32");

                        MethodInfo CosineInfo = t.GetMethod(q, paramTypes);

                        Object[] parameters = new Object[1];
                        parameters[0] = a;
                        Object returnVal = CosineInfo.Invoke(reff, parameters);

                        string commaDelimited1 = returnVal.ToString();
                        string[] year1 = commaDelimited1.Split(new char[] { ',' });
                        foreach (string month1 in year1)
                        {
                            cb.Items.Add(month1);
                        }
                        cb.SelectedItem.Text = d[2 * z + 1];

                    }
                    else
                    {
                        string returnVal = data["value"].ToString();

                        string commaDelimited2 = returnVal.ToString();
                        string[] year2 = commaDelimited2.Split(new char[] { ',' });
                        foreach (string month2 in year2)
                        {
                            cb.Items.Add(month2);

                        }
                        cb.SelectedItem.Text = d[2 * z + 1];
                    }
                    tr.Cells.Add(td0);
                    tr.Cells.Add(td1);
                    tbl.Rows.Add(tr);
                }

                else
                {
                    int y = 10;
                    lbl = new System.Web.UI.WebControls.Label();
                    lbl.ID = (2 * z).ToString();
                    lbl.Text = data["label"].ToString();

                    lbl.CssClass = "ajxtxt";

                    td0.Controls.Add(lbl);
                    TextBox txt = new TextBox();
                    txt.ID = (2 * z + 1).ToString();
                    // txt.Text = data["value"].ToString();
                    txt.Enabled = false;
                    txt.CssClass = "ajxtxt";
                    txt.Text = d[2 * z + 1];
                    td1.Controls.Add(txt);
                    dynamicTextBoxes[tc] = txt;
                    tc++;
                }
                tr.Cells.Add(td0);
                tr.Cells.Add(td1);
                tbl.Rows.Add(tr);
            }
            PlaceHolder1.Controls.Add(tbl);

        }
    }