Пример #1
0
        // 登録ボタン押下時、各種確認、ボックスIDの発行、シリアルの登録、バーコードラベルのプリントを行う
        private void btnRegisterTray_Click(object sender, EventArgs e)
        {
            if (getOkCount(dtTray) != dtTray.Rows.Count)
            {
                MessageBox.Show("Tray is not 13.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            if (txtLoginDept.Text != "MFG")
            {
                //閲覧モードの場合は、プリントアウト
                if (!formAddMode)
                {
                    string pack = txtPackId.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 = cmbBatch.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", pack, dtLot, cmbBatch.Text, dtpRegisterDate.Value, "Pack", "Fox", 1, userBin);
                        tfs.printStart("packCartonPega", pack, dtLot, cmbBatch.Text, dtpRegisterDate.Value, "Pack", "Pega", 1, userBin);
                    }
                    else
                    {
                        tfs.printStart("packCartonInternal", pack, dtLot, cmbBatch.Text, dtpRegisterDate.Value, "Pack", "Fox", 1, userBin);
                    }
                    return;
                }
            }

            //以下追加モードの場合の処理

            // 2016.08.22 FUJII  パックIDの新規採番プロシージャ「getNewPackId」を、トランザクション処理バージョンへ変更
            //if (cmbBatch.Text == string.Empty)
            //{
            //    MessageBox.Show("Please select Batch.", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
            //    return;
            //}

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

            //パックIDの新規採番
            string packNew = txtPackId.Text; // パック内容変更の処理も同ボタンで行うため、テキストボックスの既存IDを保持する

            if (formAddMode)
            {
                TfSQL tf0 = new TfSQL();
                packNew = tf0.sqlGetNewPackId(maxLot, cmbBatch.Text, txtLoginName.Text, dtLot, ref registerDate);
                if (packNew == string.Empty)
                {
                    MessageBox.Show("An error happened in the pack id issuing process.", "Process Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                txtPackId.Text = packNew;
            }

            if (txtLoginDept.Text == "MFG")
            {
                // ビンAか、ビンBか、ユーザーに選択させる
                string pack = txtPackId.Text;
                TfSato tfs  = new TfSato();
                //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 = cmbBatch.Text;
                tfs.printStart("packCartonInternal", pack, dtLot, cmbBatch.Text, dtpRegisterDate.Value, "Pack", "Non", 1, userBin);
                if (!formAddMode)
                {
                    return;
                }
            }

            //トレーテーブルのフィールドPACKID、その他を更新する
            TfSQL tf1 = new TfSQL();
            bool  res = tf1.sqlMultipleUpdateTrayInPack(dtTray, packNew);

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

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

                //ユーザーによるメッセージボックス確認後の処理
                txtPackId.Text = String.Empty;
                txtTrayId.Text = String.Empty;
                dtTray.Clear();
                capacity = 13;
                updateDataGridViews(dtTray, ref dgvTray, false);
            }
        }