Ejemplo n.º 1
0
        private void aButtonEdit_Click(object sender, EventArgs e)
        {
            try
            {
                // SAVE POSITION AND SORTATION
                Class_Library.DataGridView.DGVPositionInfo DGVPOS      = DGVUtilities.GetPosition(aDataGridViewMachines);
                Class_Library.DataGridView.DGVSortInfo     DGVSortInfo = DGVUtilities.GetSortation(aDataGridViewMachines);

                EditLicensedMachineForm Eform = new EditLicensedMachineForm();
                // GET MACHINE BY ID COLUMN OF SELECTED ROW
                Eform.InputMachine = DataAccess_LicensedMachinesTable.GetByID(Convert.ToInt32(aDataGridViewMachines[0, aDataGridViewMachines.CurrentCell.RowIndex].FormattedValue), Config.DBDir_Name);
                // LAUNCH EDIT FORM
                DialogResult _eform = Eform.ShowDialog();
                if (_eform == DialogResult.OK)
                {
                    RefreshDataGridViewTable();

                    // SET POSITION AND SORTATION
                    DGVUtilities.SetPosition(DGVPOS, aDataGridViewMachines);
                    // Check if user has sorted columns yet. If not, leave it at default (do nothing).
                    if (DGVSortInfo.SortByColumn != 0 && DGVSortInfo.Sortation != SortOrder.None)
                    {
                        DGVUtilities.SetSortation(DGVSortInfo, aDataGridViewMachines);
                    }
                }
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("No machines are selected.", "Edit Failed");
            }
        }
        private void aButtonEdit_Click(object sender, EventArgs e)
        {
            // INSTANTIATE
            DataAccess_LicensedMachinesTable db    = new DataAccess_LicensedMachinesTable();
            EditLicensedMachineForm          Eform = new EditLicensedMachineForm();

            // GET MACHINE BY ID COLUMN OF SELECTED ROW
            Eform.InputMachine = db.GetByID(Convert.ToInt32(aDataGridViewMachines[0, aDataGridViewMachines.CurrentCell.RowIndex].FormattedValue), Config.DBDir_Name);
            // LAUNCH EDIT FORM
            DialogResult _eform = Eform.ShowDialog();

            if (_eform == DialogResult.OK)
            {
                RefreshDataGridViewTable();
            }
        }
        private void AButtonMove_Click(object sender, EventArgs e)
        {
            DataAccess_LicensedMachinesTable dblm = new DataAccess_LicensedMachinesTable();

            try
            {
                // GET ROW INDEX OF SELECTED CELL(S)
                List <int> rowIndexes = (from sc in aDataGridViewMachines.SelectedCells.Cast <DataGridViewCell>()
                                         select sc.RowIndex).Distinct().ToList();

                // GET ID OF EACH MACHINE SELECTED
                List <int> SelectedMachines_ID = new List <int>();
                foreach (int SelectedRow in rowIndexes)
                {
                    SelectedMachines_ID.Add(Convert.ToInt32(aDataGridViewMachines[0, SelectedRow].FormattedValue));
                }

                // GET LICENSED MACHINES SELECTED
                List <LicensedMachines> MachinesSelectedToMove = new List <LicensedMachines>();
                foreach (int MachineID in SelectedMachines_ID)
                {
                    MachinesSelectedToMove.Add(dblm.GetByID(MachineID, Config.DBDir_Name));
                }

                // LAUNCH MOVE FORM
                MoveForm moveForm = new MoveForm();
                moveForm.SelectedMachines_Input = MachinesSelectedToMove;
                DialogResult _moveForm = moveForm.ShowDialog();
                if (_moveForm == DialogResult.OK)
                {
                    RefreshDataGridViewTable();
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.ToString());
            }
        }