All pastes #544438 Raw Edit

Untitled

public text v1 · immutable
·published 2007-06-06 12:58 UTC
rendered paste body
    public partial class ClientsUserControl : UserControl
    {
        internal DatabaseManager db;
        internal struct DbData
        {
            public int colSize;
            public bool disp;

            public DbData(int size, bool display)
            { this.colSize = size; this.disp = display; }
            public void setDisp(bool val)
            { this.disp = val; }
        }
        internal Dictionary<String, DbData> datas;
        
        public ClientsUserControl()
        {
            this.datas = new Dictionary<String, DbData>();
            this.db = new DatabaseManager();

            DbData toto;
            toto.colSize = 170;
            toto.disp = true;
            datas.Add("societe", toto);
            datas.Add("activite", new DbData(100, true));
            datas.Add("telephone", new DbData(80, true));
            datas.Add("fax", new DbData(80, true));
            datas.Add("email", new DbData(140, true));
            datas.Add("adresse", new DbData(140, true));
            datas.Add("code postal", new DbData(50, true));
            datas.Add("ville", new DbData(100, true));

            InitializeComponent();

            this.clientsListView.Select();
            DataTable actions = this.db.dbHardRequest(
                "SELECT libelle FROM action ORDER BY libelle;"
                );
            foreach (DataRow action in actions.Rows)
                this.actionToolStripMenuItem.DropDownItems.Add(action[0].ToString());
        }

        ...

        private void affsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.clientsListView.Columns.Clear();
            this.clientsListView.Items.Clear();
            if (this.datas.ContainsKey(((ToolStripMenuItem)sender).Name))
                this.datas[((ToolStripMenuItem)sender).Name].disp = ((ToolStripMenuItem)sender).Checked; // <-- là ca merde !
            updateListe();
        }
    }