Exemple #1
0
 private void setFocusedRow()
 {
     focusedRow = gridViewUser.FocusedRowHandle;
     focusedUser = FocusedEntity;
     isRowNotFixed = true;
     fixedTimes = 3;
 }
Exemple #2
0
 /// <summary>
 /// Add new item
 /// </summary>
 public override void Add()
 {
     User usr = ClientEnvironment.UserService.CreateEntity();
     using (FormUser frm = new FormUser())
     {
         frm.Entity = usr;
         if (frm.ShowDialog(this) == DialogResult.OK)
         {
             if (usr.IsNew)
             {
                 try
                 {
                     usr = ClientEnvironment.UserService.Save(usr);
                     UserList.Add(new UserInfo(usr));
                     for (int row = 0 ; row < UserList.Count; row++)
                     {
                         if ( UserList[row].User.ID == usr.ID)
                         {
                             focusedRow = row;
                             break;
                         }
                     }
                     focusedUser = new UserInfo(usr);
                     isRowNotFixed = true;
                     fixedTimes = 3;
                     fixFocusedEntity();
                 }
                 catch (EntityException ex)
                 {
                     // 2think: what details should we show?
                     // 2think: how to localize?
                     using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex))
                     {
                         form.Text = GetLocalized("CannotSaveUser");
                         form.ShowDialog(this);
                     }
                 }
             }
             else
             {
                 try
                 {
                     usr = ClientEnvironment.UserService.SaveOrUpdate(usr);
                     UserList.ResetItemById(usr.ID);
                 }
                 catch (EntityException ex)
                 {
                     // 2think: what details should we show?
                     // 2think: how to localize?
                     using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex))
                     {
                         form.Text = GetLocalized("CannotSaveUser");
                         form.ShowDialog(this);
                     }
                 }
             }
         }
     }
  //   RefreshData(); //******************!!!!!!!!!
 }