Esempio n. 1
0
 private void btnView_Click(object sender, EventArgs e)
 {
     if (currDataGrid.Rows.Count == 0)
     {
         return;
     }
     using (FrmEditor frm = new FrmEditor())
     {
         var mName  = this.lastSelectItem.Tag.ToString();
         var editor = Activator.CreateInstance(dicEditor[mName]) as UserControl;
         editor.Dock = DockStyle.Fill;
         frm.Content = editor;
         frm.BLL     = dicBLL[mName];
         object model    = null;
         var    dataGrid = dicDataGridView[mName];
         var    ext      = dataGrid as IExtension;
         if (ext == null)
         {
             var viewModel = currDataGrid.SelectedRows[0].DataBoundItem;
             model = viewModel.GetType().GetProperty("Model").GetValue(viewModel, null);
         }
         else
         {
             if (ext.Model == null)
             {
                 return;
             }
             model = ext.Model;
         }
         frm.Model   = model;
         frm.Operate = OperateType.View;
         frm.Icon    = System.Drawing.Icon.FromHandle(Resources.查找.GetHicon());
         frm.ShowDialog();
     }
 }
Esempio n. 2
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     using (FrmEditor frm = new FrmEditor())
     {
         var mName  = this.lastSelectItem.Tag.ToString();
         var editor = Activator.CreateInstance(dicEditor[mName]) as UserControl;
         editor.Dock = DockStyle.Fill;
         frm.Content = editor;
         frm.BLL     = dicBLL[mName];
         var dataGrid = dicDataGridView[mName];
         var ext      = dataGrid as IExtension;
         if (ext == null)
         {
             frm.Model   = Activator.CreateInstance(typeof(Model.TUserModel).Assembly.GetType("Model." + mName + "Model"));
             frm.Operate = OperateType.New;
         }
         else
         {
             frm.Model   = ext.GetCreateModel();
             frm.Operate = OperateType.Save;
         }
         frm.Icon = System.Drawing.Icon.FromHandle(Resources.增加.GetHicon());
         if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             listView1_SelectedIndexChanged(sender, e);
         }
     }
 }