Example #1
0
        // When SHIP button is clicked, register the shipping date to multiple box ids
        private void btnEditShipping_Click(object sender, EventArgs e)
        {
            string   idFrom   = txtBoxIdFrom.Text;
            DateTime shipdate = dtpShipDate.Value;

            if (idFrom == String.Empty)
            {
                MessageBox.Show("Both box-id-from and box-id-to, plus ship date have to be selected.", "Notice",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
            }
            else
            {
                DialogResult result1 = MessageBox.Show("Have you slected box-id-from, box-id-to, and shipdate correctly?", "Notice",
                                                       MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                if (result1 == DialogResult.Yes)
                {
                    DialogResult result2 = MessageBox.Show("Are you really sure to update the ship date?", "Notice",
                                                           MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                    if (result2 == DialogResult.Yes)
                    {
                        string sql = "update box_id SET shipdate = '" + shipdate + "' WHERE boxid = '" + idFrom + "'";
                        ShSQL  tf  = new ShSQL();
                        int    res = tf.sqlExecuteNonQueryInt(sql, false);
                        tf.sqlExecuteScalarString("update shipment SET ship_date = '" + shipdate + "' WHERE boxid = '" + idFrom + "'");
                        MessageBox.Show(res + " records were updated", "Notice",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);

                        rdbShipDate.Checked = true;
                        updateDataGripViews(ref dgvBoxId, false);
                    }
                }
            }
        }
Example #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();
                    }
                }
            }
        }
Example #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);
                }
            }
        }