示例#1
0
        // When ADDBOXID button is clicked, open frmModule by edit mode with delegate function
        private void btnAddBoxId_Click(object sender, EventArgs e)
        {
            string user = txtUser.Text;

            bool bl = ShGeneral.checkOpenFormExists("frmModule");

            if (bl)
            {
                MessageBox.Show("Please close brows-mode form or finish the current edit form.", "BoxId DB",
                                MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
            }
            else
            {
                frmModule fM = new frmModule();
                // Catch the child (frmModule) event, then update this form's datagridview
                fM.RefreshEvent += delegate(object sndr, EventArgs excp)
                {
                    updateDataGripViews(ref dgvBoxId, false);
                    this.Focus();
                };

                fM.updateControls(String.Empty, DateTime.Now, user, String.Empty, true);
                fM.Show();
            }
        }
示例#2
0
        // Change the capacity of the box (only for the super user)
        private void btnChangeLimit_Click(object sender, EventArgs e)
        {
            // Open frmCapacity with delegate event
            bool bl = ShGeneral.checkOpenFormExists("frmCapacity");

            if (bl)
            {
                MessageBox.Show("Please close or complete another form.", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
            }
            else
            {
                frmCapacity f4 = new frmCapacity();
                // When the delegate event is triggered by child, update this form's datagridview
                f4.RefreshEvent += delegate(object sndr, EventArgs excp)
                {
                    limit         = f4.getLimit();
                    txtLimit.Text = limit.ToString();
                    updateDataGripViews(dtOverall, ref dgvProductSerial);
                    this.Focus();
                };

                f4.updateControls(limit.ToString());
                f4.Show();
            }
        }
示例#3
0
        // Replace a product serial in already registered box id (only for super user)
        private void btnReplace_Click(object sender, EventArgs e)
        {
            // If more than 2 columns or more than 2 records are selected, leave the procedure
            if (dgvProductSerial.Columns.GetColumnCount(DataGridViewElementStates.Selected) >= 2 ||
                dgvProductSerial.Rows.GetRowCount(DataGridViewElementStates.Selected) >= 2 ||
                dgvProductSerial.CurrentCell.ColumnIndex != 0)
            {
                MessageBox.Show("Please select only one serial number.", "Notice",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
                return;
            }

            // Open form frmModuleReplace with delegate function
            bool bl = ShGeneral.checkOpenFormExists("frmModuleReplace");

            if (bl)
            {
                MessageBox.Show("Please close or complete another form.", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
                return;
            }

            updateRowIndex = dgvProductSerial.CurrentCell.RowIndex;
            frmModuleReplace f2 = new frmModuleReplace();

            // Update this form's datagridview when child's delegate event is triggered
            f2.RefreshEvent += delegate(object sndr, EventArgs excp)
            {
                dtOverall.Clear();
                readDatatable(ref dtOverall);
                updateDataGripViews(dtOverall, ref dgvProductSerial);
                dgvProductSerial.CurrentCell = dgvProductSerial[0, updateRowIndex];
                dgvProductSerial.FirstDisplayedScrollingRowIndex = updateRowIndex;
                this.Focus();
            };

            string curSerial   = dgvProductSerial.CurrentCell.Value.ToString();
            int    curRowIndex = dgvProductSerial.CurrentRow.Index;

            f2.updateControls(curSerial, curRowIndex + 1);
            f2.Show();
        }