Exemplo n.º 1
0
        // 登録ボタン押下時、各種確認、ボックスIDの発行、シリアルの登録、バーコードラベルのプリントを行う
        private void btnRegisterTray_Click(object sender, EventArgs e)
        {
            //閲覧モードの場合は、プリントアウト
            if (!formAddMode)
            {
                string pallet = txtPallet.Text;
                TfSato tfs    = new TfSato();

                // ビンAか、ビンBか、ユーザーに選択させる
                //DialogResult binResult = MessageBox.Show("Please click YES for Bin A, NO for Bin B.", "Print Option",
                //    MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
                //string userBin = (binResult == DialogResult.Yes) ? "A" : "B";
                string userBin = txtBatch.Text;

                // ペガトロン用か否か、ユーザーに選択させる
                DialogResult result = MessageBox.Show("Do you print Pegatoron label also?", "Print Option", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
                if (result == DialogResult.Yes)
                {
                    //tfs.printStart("packCartonInternal", pallet, dtLot, txtBatch.Text, dtpRegisterDate.Value, "Pallet", "Fox", 2, userBin);
                    tfs.printStart("packCartonPega", pallet, dtLot, txtBatch.Text, dtpRegisterDate.Value, "Pallet", "Pega", 1, userBin);
                }
                else
                {
                    tfs.printStart("packCartonInternal", pallet, dtLot, txtBatch.Text, dtpRegisterDate.Value, "Pallet", "Fox", 2, userBin);
                }
                return;
            }

            //複数のバッチが混入している場合は、警告する
            if (txtBatch.Text == "Error")
            {
                MessageBox.Show("You can not register 2 batches in a pallet.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            // 登録処理中は、閉じるボタンを除き、すべてのコントロールを無効にする
            txtCarton.Enabled          = false;
            btnRegisterPallet.Enabled  = false;
            btnDeleteSelection.Enabled = false;

            // パレットIDの新規採番
            // 2016.08.22 FUJII  パレットIDの新規採番プロシージャ「getNewPalletId」を、トランザクション処理バージョンへ変更
            // string palletNew = getNewPalletId(txtBatch.Text, txtLoginName.Text);
            TfSQL  tf        = new TfSQL();
            string palletNew = tf.sqlGetNewPalletId(maxLot, txtBatch.Text, txtLoginName.Text, dtLot, ref registerDate);

            if (palletNew == string.Empty)
            {
                MessageBox.Show("An error happened in the pallet id issuing process.", "Process Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //パックテーブルのフィールドCARTONID、その他を更新する
            bool res = tf.sqlMultipleUpdateCartonOnPallet(dtCarton, palletNew);

            if (res)
            {
                //登録済みの状態を表示
                txtPallet.Text        = palletNew;
                dtpRegisterDate.Value = registerDate;

                //親フォームfrmTrayのデータグリットビューを更新するため、デレゲートイベントを発生させる
                this.RefreshEvent(this, new EventArgs());
                this.Focus();
                MessageBox.Show("Pallet ID: " + palletNew + Environment.NewLine +
                                "and its cartons were registered.", "Process Result", MessageBoxButtons.OK, MessageBoxIcon.Information);

                //ユーザーによるメッセージボックス確認後の処理
                txtPallet.Text = String.Empty;
                txtCarton.Text = String.Empty;
                dtCarton.Clear();
                updateDataGridViews(dtCarton, ref dgvCarton, false);
            }
        }