示例#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
        // OPEN button generate frmModule by view mode without delegate event.
        // SHIP button edit the shipping date for box id.
        private void dgvBoxId_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int currentRow = int.Parse(e.RowIndex.ToString());

            // OPEN button generate frmModule by view mode without delegate event
            if (dgvBoxId.Columns[e.ColumnIndex] == openBoxId && currentRow >= 0)
            {
                // In case frmModule is already opened, close it first
                ShGeneral.closeOpenForm("frmModule");

                string   boxId     = dgvBoxId["boxid", currentRow].Value.ToString();
                DateTime printDate = DateTime.Parse(dgvBoxId["printdate", currentRow].Value.ToString());
                string   user      = txtUser.Text == "User_9" ? txtUser.Text : dgvBoxId["suser", currentRow].Value.ToString();
                string   serialNo  = txtProductSerial.Text;

                frmModule fM = new frmModule();
                fM.updateControls(boxId, printDate, user, serialNo, false);
                fM.Show();
            }

            // SHIP button edit the shipping date for box id
            if (dgvBoxId.Columns[e.ColumnIndex] == editShipDate && currentRow >= 0)
            {
                string   boxId    = dgvBoxId["boxid", currentRow].Value.ToString();
                DateTime shipdate = dtpShipDate.Value;

                DialogResult result1 = MessageBox.Show("Do you want to update the shipping date of as follows:" + System.Environment.NewLine +
                                                       boxId + ": " + shipdate, "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                if (result1 == DialogResult.Yes)
                {
                    ShSQL tf    = new ShSQL();
                    int   count = tf.sqlExecuteScalarInt("select count(boxid) from shipment where boxid = '" + boxId + "'");
                    if (count > 0)
                    {
                        tf.sqlExecuteScalarString("delete from shipment where boxid = '" + boxId + "'");
                    }
                    else if (count == -1)
                    {
                        return;
                    }

                    string sql = "update box_id SET shipdate = '" + shipdate + "' " +
                                 "WHERE boxid = '" + boxId + "'";
                    string sql_ship = "INSERT INTO shipment SELECT boxid, serialno, model, '" + shipdate + "', '" + txtShipStatus.Text + "' FROM product_serial WHERE boxid = '" + boxId + "'";
                    if (!String.IsNullOrEmpty(txtShipStatus.Text))
                    {
                        int res = tf.sqlExecuteNonQueryInt(sql, false);
                        tf.sqlExecuteScalarString(sql_ship);
                        updateDataGripViews(ref dgvBoxId, false);
                    }
                    else
                    {
                        MessageBox.Show("Please input Shipping Status and try again.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtShipStatus.Focus();
                    }
                }
            }
        }
示例#3
0
        // OPEN button generate frmModule by view mode without delegate event.
        // SHIP button edit the shipping date for box id.
        private void dgvBoxId_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int currentRow = int.Parse(e.RowIndex.ToString());

            // OPEN button generate frmModule by view mode without delegate event
            if (dgvBoxId.Columns[e.ColumnIndex] == openBoxId && currentRow >= 0)
            {
                // In case frmModule is already opened, close it first
                ShGeneral.closeOpenForm("frmModule");

                string   boxId     = dgvBoxId["boxid", currentRow].Value.ToString();
                DateTime printDate = DateTime.Parse(dgvBoxId["printdate", currentRow].Value.ToString());
                string   user      = txtUser.Text == "User_9" ? txtUser.Text : dgvBoxId["suser", currentRow].Value.ToString();
                string   serialNo  = txtProductSerial.Text;

                frmModule fM = new frmModule();
                fM.updateControls(boxId, printDate, user, serialNo, false);
                fM.Show();
            }

            // SHIP button edit the shipping date for box id
            if (dgvBoxId.Columns[e.ColumnIndex] == editShipDate && currentRow >= 0)
            {
                string   boxId    = dgvBoxId["boxid", currentRow].Value.ToString();
                DateTime shipdate = dtpShipDate.Value;

                DialogResult result1 = MessageBox.Show("Do you want to update the shipping date of as follows:" + System.Environment.NewLine +
                                                       boxId + ": " + shipdate, "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                if (result1 == DialogResult.Yes)
                {
                    string sql = "update box_id SET shipdate ='" + shipdate + "' " +
                                 "WHERE boxid= '" + boxId + "'";
                    System.Diagnostics.Debug.Print(sql);
                    ShSQL tf  = new ShSQL();
                    int   res = tf.sqlExecuteNonQueryInt(sql, false);
                    updateDataGripViews(ref dgvBoxId, false);
                }
            }
        }