Esempio n. 1
0
 private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
 {
     if (UsersBindingSource.Current == null)
     {
         return;
     }
     GridViewUsers.CloseEditor();
     if (XtraMessageBox.Show("Are you sure you want to delete?", "CONFIRM", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         ignoreLeaveRow = true;
         RemoveRecord();
         errorProvider1.Clear();
         if (!newRec)
         {
             context.SaveChanges();
         }
         ignoreLeaveRow = false;
         modified       = false;
         newRec         = false;
         setReadOnly(true);
         panelControlStatus.Visible = true;
         LabelStatus.Text           = "Record Deleted";
         rowStatusDelete            = new Timer();
         rowStatusDelete.Interval   = 3000;
         rowStatusDelete.Start();
         rowStatusDelete.Tick += new EventHandler(TimedEventDelete);
     }
     currentVal = TextEditUser.Text;
 }
Esempio n. 2
0
        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            if (modified || newRec)
            {
                DialogResult select = DevExpress.XtraEditors.XtraMessageBox.Show("Do you want to confirm these changes?", Text, MessageBoxButtons.YesNoCancel);
                if (select == DialogResult.Cancel)
                {
                    return;
                }
                if (select == DialogResult.Yes)
                {
                    if (!SaveRecord())
                    {
                        return;
                    }
                }
                if (select == DialogResult.No)
                {
                    if (newRec)
                    {
                        RemoveRecord();
                    }
                    else
                    {
                        RefreshRecord();
                    }
                }
            }

            GridViewUsers.ClearColumnsFilter();
            if (UsersBindingSource.Current == null)
            {
                //fake query in order to create a link between the database table and the binding source
                UsersBindingSource.DataSource = from opt in context.ExtranetUser where opt.UserID == "KJM9" select opt;
            }
            CheckEditAgent.Focus();
            GridViewUsers.CloseEditor();
            newRec         = true;
            ignoreLeaveRow = true;       //so that when the grid row changes it doesn't try to save again
            UsersBindingSource.AddNew();
            if (GridViewUsers.FocusedRowHandle == GridControl.AutoFilterRowHandle)
            {
                GridViewUsers.FocusedRowHandle = GridViewUsers.RowCount - 1;
            }
            CheckEditAgent.Focus();
            setReadOnly(false);
            ignoreLeaveRow = false;
        }
Esempio n. 3
0
 private bool move()
 {
     GridViewUsers.CloseEditor();
     CheckEditAgent.Focus();
     //bindingNavigatorPositionItem.Focus();//trigger field leave event
     temp = newRec;
     if (checkForms(true))
     {
         if (!temp)
         {
             context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, (ExtranetUser)UsersBindingSource.Current);
         }
         setReadOnly(true);
         newRec   = false;
         modified = false;
         return(true);
     }
     return(false);
 }
Esempio n. 4
0
        private bool SaveRecord()
        {
            if (UsersBindingSource.Current == null)     //user is not editing a record and has never clicked Add button
            {
                return(true);
            }

            GridViewUsers.CloseEditor();
            GridViewPermissions.CloseEditor();
            if (GridViewPermissions.UpdateCurrentRow())
            {
                PermissionsBindingSource.EndEdit();
                foreach (ExtranetPermission permission in PermissionsBindingSource)
                {
                    permission.UserID      = GetUserID();
                    permission.ProductType = "HTL";
                }
            }
            CheckEditAgent.Focus();
            temp = newRec;
            //bindingNavigatorPositionItem.Focus();//trigger field leave event
            if (checkForms(false))
            {
                CheckEditAgent.Focus();
                setReadOnly(true);
                panelControlStatus.Visible = true;
                LabelStatus.Text           = "Record Saved";
                rowStatusSave          = new Timer();
                rowStatusSave.Interval = 3000;
                rowStatusSave.Start();
                rowStatusSave.Tick += TimedEventSave;
                return(true);
            }
            else
            {
                return(false);
            }
        }