Ejemplo n.º 1
0
        // フォーム3を追加モードで開く
        private void btnAddBatch_Click(object sender, EventArgs e)
        {
            //既にForm3 が開かれている場合は、閉じるように促す
            if (TfGeneral.checkOpenFormExists("Form3"))
            {
                MessageBox.Show("You need to close another already open window.", "Notice",
                                MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
                return;
            }

            string   batchNo     = string.Empty;
            string   modelNo     = cmbModelNo.Text;
            string   modelName   = txtModelName.Text;
            string   subAssyNo   = cmbSubAssyNo.Text;
            string   subAssyName = txtSubAssyName.Text;
            DateTime batchDate   = DateTime.Now;
            string   shift       = cmbShift.Text;
            string   line        = cmbLine.Text;
            string   leader      = txtLeaderId.Text;
            string   leaderName  = txtLeaderName.Text;
            string   input       = string.Empty;
            string   output      = string.Empty;
            DateTime inputTime   = dtvRounddownSeconds(DateTime.Now);
            DateTime outputTime  = inputTime;
            string   remark      = string.Empty;

            bool check = (modelNo != string.Empty && modelName != string.Empty && subAssyNo != string.Empty &&
                          subAssyName != string.Empty && shift != string.Empty && line != string.Empty);

            if (!check)
            {
                MessageBox.Show("You need to fill the following items before adding new batch no:" + System.Environment.NewLine +
                                "Model, Subassy, Shift, Line", "Notice",
                                MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
                return;
            }

            // 追加モードの場合は、ログイン時のリーダーアカウントに関係なく、管理モード(全てのレコードを編集可能)
            formAdmin = true;

            Form3 f3 = new Form3();

            //子イベントをキャッチして、データグリッドを更新する
            f3.RefreshEvent += delegate(object sndr, EventArgs excp)
            {
                updateDataGridViews(ref dtBatchNo, ref dgvBatchNo);
            };

            f3.updateControls(batchNo, modelNo, modelName,
                              subAssyNo, subAssyName, batchDate, shift, line, leader, leaderName, input, output, inputTime, outputTime, remark, true, formAdmin);
            f3.Show();
        }
Ejemplo n.º 2
0
        // フォーム3を更新モードで開く
        private void btnEditBatch_Click(object sender, EventArgs e)
        {
            // セルの選択行がない場合は、プロシージャを抜ける
            int curRow = dgvBatchNo.CurrentCell.RowIndex;

            if (curRow < 0)
            {
                return;
            }

            //既にForm3 が開かれている場合は、閉じるように促す
            if (TfGeneral.checkOpenFormExists("Form3"))
            {
                MessageBox.Show("You need to close another already open window.", "Notice",
                                MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
                return;
            }

            string   batchNo     = dtBatchNo.Rows[curRow]["batch_no"].ToString();
            string   modelNo     = dtBatchNo.Rows[curRow]["model_no"].ToString();
            string   modelName   = dtBatchNo.Rows[curRow]["model_name"].ToString();
            string   subAssyNo   = dtBatchNo.Rows[curRow]["sub_assy_no"].ToString();
            string   subAssyName = dtBatchNo.Rows[curRow]["sub_assy_name"].ToString();
            DateTime batchDate   = DateTime.Parse(dtBatchNo.Rows[curRow]["batch_date"].ToString());
            string   shift       = dtBatchNo.Rows[curRow]["shift"].ToString();
            string   line        = dtBatchNo.Rows[curRow]["line"].ToString();
            string   leader      = dtBatchNo.Rows[curRow]["leader_id"].ToString();
            string   leaderName  = dtBatchNo.Rows[curRow]["leader_name"].ToString();
            string   input       = dtBatchNo.Rows[curRow]["in_qty"].ToString();
            string   output      = dtBatchNo.Rows[curRow]["out_qty"].ToString();
            DateTime inputTime   = DateTime.Parse(dtBatchNo.Rows[curRow]["in_time"].ToString());
            DateTime outputTime  = DateTime.Parse(dtBatchNo.Rows[curRow]["out_time"].ToString());
            string   remark      = dtBatchNo.Rows[curRow]["remark"].ToString();

            // ログイン時のリーダーアカウントと、選択したレコードのリーダーが一致すれば、管理モード(全てのレコードを編集可能)
            if (txtLeaderId.Text == leader)
            {
                formAdmin = true;
            }
            else if (txtLeaderId.Text == leader)
            {
                formAdmin = false;
            }

            // 管理ユーザーの場合に限り、常に管理モード
            if (formAdminUser)
            {
                formAdmin = true;
            }

            Form3 f3 = new Form3();

            //子イベントをキャッチして、データグリッドを更新する
            f3.RefreshEvent += delegate(object sndr, EventArgs excp)
            {
                updateDataGridViews(ref dtBatchNo, ref dgvBatchNo);
            };

            f3.updateControls(batchNo, modelNo, modelName,
                              subAssyNo, subAssyName, batchDate, shift, line, leader, leaderName, input, output, inputTime, outputTime, remark, false, formAdmin);
            f3.Show();
        }