Esempio n. 1
0
        // 登録ボタン押下時、各種確認、ボックスIDの発行、シリアルの登録、バーコードラベルのプリントを行う
        private void btnRegisterTray_Click(object sender, EventArgs e)
        {
            //閲覧モードの場合は、プリントアウト
            if (!formAddMode)
            {
                string carton = txtCarton.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", carton, dtLot, txtBatch.Text, dtpRegisterDate.Value, "Carton", "Fox", 2, userBin);
                    tfs.printStart("packCartonPega", carton, dtLot, txtBatch.Text, dtpRegisterDate.Value, "Carton", "Pega", 1, userBin);
                }
                else
                {
                    tfs.printStart("packCartonInternal", carton, dtLot, txtBatch.Text, dtpRegisterDate.Value, "Carton", "Fox", 2, userBin);
                }
                return;
            }

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

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

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

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

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

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

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

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