Пример #1
0
        private void Button_Click(object sender, EventArgs e)
        {
            ToolStripButton button  = (ToolStripButton)sender;
            var             btnenum = button.Text.ToEnum <ToolScriptButton>();

            switch (btnenum)
            {
            case ToolScriptButton.Insert:
                WindowExtension <T> windowinsert = new WindowExtension <T>(new T(), true);
                DialogResult        dialoginsert = windowinsert.ShowDialog();
                break;

            case ToolScriptButton.Update:
                var rows = Panel._gridView.SelectedRows;
                if (rows.Count == 0)
                {
                    return;
                }
                var result = FreeSqlFactory._Freesql.Select <T>().Skip(Panel._gridView.SelectedRows[0].Index).Take(1).First();    //ExtenstionClass.GetList<T>(new DefaultSqlite()).Skip(Panel.gridView.SelectedRows[0].Index).Take(1).FirstOrDefault();
                WindowExtension <T> windowupdate = new WindowExtension <T>(result, false);
                DialogResult        dialogupdate = windowupdate.ShowDialog();
                break;

            case ToolScriptButton.Delete:
                var resultDelete = FreeSqlFactory._Freesql.Select <T>().Skip(Panel._gridView.SelectedRows[0].Index).Take(1).First();
                FreeSqlFactory._Freesql.Delete <T>(resultDelete).ExecuteAffrows();
                break;

            case ToolScriptButton.Refresh:
                break;
            }
            Panel._gridView.DataSource = FreeSqlFactory._Freesql.Select <T>().ToList();
        }
Пример #2
0
        private void GridViewExtension_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            var objects = (T)this.CurrentRow.DataBoundItem;//visit  相当于一个实体

            WindowExtension <T> window = new WindowExtension <T>(objects, false);

            DialogResult dialog = window.ShowDialog();

            this.DataSource = FreeSqlFactory._Freesql.Select <T>().ToList();
        }