Пример #1
0
        public static void ComboFill(string SSql, ComboBox aList, ref OleDbConnection ConSql)
        {
            OleDbDataReader LeRs;
            ArrayList       LaListe = new ArrayList();

            aList.DataSource = null;
            aList.Items.Clear();
            LeRs = SqlLit(SSql, ref ConSql);
            while (LeRs.Read())
            {
                LaListe.Add(new ListItem(LeRs.GetInt32(0), LeRs.GetString(1)));
            }
            LeRs.Close();
            aList.DisplayMember = "Txt";
            aList.ValueMember   = "Val";
            aList.DataSource    = LaListe;
        }
Пример #2
0
        public static void FormRempli(Control b, string sSql, ref OleDbConnection consql)
        {
            OleDbDataReader LeRs;

            LeRs = SqlLit(sSql, ref consql);
            while (LeRs.Read())
            {
                foreach (Control c in (b.Controls))
                {
                    if ((string)(Nz(c.Tag, "")) != "")
                    {
                        try
                        {
                            string LaValeur = "";
                            if (LeRs.GetFieldType(LeRs.GetOrdinal(c.Tag.ToString().Split(',')[0])).Name.Contains("Int32"))
                            {
                                LaValeur = LeRs.GetInt32(LeRs.GetOrdinal(c.Tag.ToString().Split(',')[0])).ToString();
                            }
                            if (LeRs.GetFieldType(LeRs.GetOrdinal(c.Tag.ToString().Split(',')[0])).Name.Contains("String"))
                            {
                                LaValeur = LeRs.GetString(LeRs.GetOrdinal(c.Tag.ToString().Split(',')[0]));
                            }


                            if (c.GetType().ToString().Contains("TextBox"))
                            {
                                c.Text = LaValeur;
                            }

                            if (c.GetType().ToString().Contains("Label"))
                            {
                                c.Text = LaValeur;
                            }

                            if (c.GetType().ToString().Contains("CheckBox"))
                            {
                                ((CheckBox)c).Checked = (bool)Nz(LeRs.GetBoolean(LeRs.GetOrdinal(c.Tag.ToString().Split(',')[0])), false);
                            }

                            if (c.GetType().ToString().Contains("ComboBox"))
                            {
                                //LeRs.GetFieldType(3).Name
                                ComboSetVal(LaValeur, (ComboBox)c);
                            }
                        } catch (Exception ex)
                        {
                            MessageBox.Show(c.Name + "-" + ex.Message);
                        }
                    }

                    //TODO: date
                    //                    If TypeOf(c) Is Windows.Forms.DateTimePicker Then
                    //                       If Nz(lers(c.tag), "") = "" Then
                    //                           c.value = CDate("31/12/2100")
                    //                            If c.showcheckbox Then c.checked = False
                    //                        Else
                    //                            c.value = lers(c.tag)
                    //                            c.enabled = True
                    //                            If c.showcheckbox Then c.checked = True
                    //                        End If
                    //                    End If



                    //            End If
                }
            }
            LeRs.Close();
            //    lers.Close()
        }