예제 #1
0
        public void Set_TablePanel_TextBox_ForData(TableLayoutPanel tablePanel, string feildnames, string si_id, OdbcConnection conn)
        {
            string sql = string.Format("select rc_id,{0} from sport_rc where si_id={1} order by group_id,road;", feildnames, si_id);
            int    r_i = 1;
            Font   fnt = new Font("╝либ┼ж", 10);

            using (OdbcDataReader dr = new OdbcCommand(sql, conn).ExecuteReader())
            {
                while (dr.Read())
                {
                    string rc_id   = dr[0].ToString();
                    int    min_int = tablePanel.ColumnCount;

                    if (dr.FieldCount - 3 < min_int)
                    {
                        min_int = dr.FieldCount - 3;
                    }
                    for (int i = 0; i < min_int; i++)
                    {
                        if (dr.GetName(i + 3) == "rank" || dr.GetName(i + 3) == "rc" || dr.GetName(i + 3) == "grk" || dr.GetName(i + 3) == "note")
                        {
                            TextBox tb = new TextBox();
                            tb.TextAlign = HorizontalAlignment.Right;
                            tb.Font      = fnt;
                            tb.Name      = String.Format("{0}_{1}", dr.GetName(i + 3), rc_id);
                            tb.Text      = dr[i + 3].ToString();
                            tablePanel.Controls.Add(tb, i, r_i);
                        }
                        else
                        {
                            TextBox lb = new TextBox(); lb.ReadOnly = true; lb.Text = dr[i + 3].ToString(); tablePanel.Controls.Add(lb, i, r_i);
                        }
                    }
                    r_i++;
                }
            }
        }