// サブプロシージャ:新規バッチの発行 private string getNewBatch() { string subAssyNo = cmbSubAssyNo.Text; string sql; TfSQL tf = new TfSQL(); sql = "select batch_prefix from t_model_sub_assy where sub_assy_no = '" + subAssyNo + "'"; string batchPrefix = tf.sqlExecuteScalarString(sql); sql = "select max(batch_no) from t_batch_no where batch_no like '" + batchPrefix + "%'"; string batchOld = tf.sqlExecuteScalarString(sql); DateTime dateOld = new DateTime(0); long numberOld = 0; string batchNew; if (batchOld != string.Empty) { dateOld = DateTime.ParseExact(VBStrings.Mid(batchOld, 10, 6), "yyMMdd", CultureInfo.InvariantCulture); numberOld = long.Parse(VBStrings.Right(batchOld, 4)); } if (dateOld != DateTime.Today) { batchNew = batchPrefix + "#" + DateTime.Today.ToString("yyMMdd") + "#" + "0001"; } else { batchNew = batchPrefix + "#" + DateTime.Today.ToString("yyMMdd") + "#" + (numberOld + 1).ToString("0000"); } return(batchNew); }
// コンボボックス項目選択時の処理(サブ組NO) private void cmbSubAssyNo_SelectedIndexChanged(object sender, EventArgs e) { string subAssy = cmbSubAssyNo.Text; string sql = "select sub_assy_name FROM t_model_sub_assy where sub_assy_no ='" + subAssy + "'"; TfSQL tf = new TfSQL(); txtSubAssyName.Text = tf.sqlExecuteScalarString(sql); }
// コンボボックス選択時、リーダー名を表示する private void cmbLeaderId_SelectedIndexChanged(object sender, EventArgs e) { string sql = "select leader_name FROM t_leader_id where leader_id ='" + cmbLeaderId.Text + "'"; System.Diagnostics.Debug.Print(sql); TfSQL tf = new TfSQL(); string name = tf.sqlExecuteScalarString(sql); txtLeaderName.Text = name; }
// ユーザーログイン private void btnLogIn_Click(object sender, EventArgs e) { string leaderId = cmbLeaderId.Text; string leaderName = txtLeaderName.Text; leaderId = cmbLeaderId.Text; if (leaderId != null) { TfSQL tf = new TfSQL(); string sql1 = "select pass FROM t_leader_id WHERE leader_id='" + leaderId + "'"; string pass = tf.sqlExecuteScalarString(sql1); if (pass == txtPassword.Text) { // 子フォームForm1を表示し、デレゲートイベントを追加: Form1 f1 = new Form1(); f1.RefreshEvent += delegate(object sndr, EventArgs excp) { // 子フォームForm1を閉じる際、当フォームを表示する txtPassword.Text = string.Empty; this.Visible = true; }; string sql2 = "select adminflag FROM t_leader_id WHERE leader_id='" + leaderId + "'"; bool adminUser = tf.sqlExecuteScalarBool(sql2); f1.updateControls(leaderId, leaderName, adminUser); f1.Show(); this.Visible = false; } else if (pass != txtPassword.Text) { MessageBox.Show("Password does not match", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
// コンボボックス項目選択時の処理(モデルNO) private void cmbModelNo_SelectedIndexChanged(object sender, EventArgs e) { string sql; TfSQL tf = new TfSQL(); string model = cmbModelNo.Text; sql = "select model_name FROM t_model_sub_assy where model_no ='" + model + "'"; System.Diagnostics.Debug.Print(sql); txtModelName.Text = tf.sqlExecuteScalarString(sql); // コンボボックスへ候補をセットする(サブ組NO) sql = "select sub_assy_no FROM t_model_sub_assy where model_no ='" + model + "'"; System.Diagnostics.Debug.Print(sql); tf.getComboBoxData(sql, ref cmbSubAssyNo); cmbSubAssyNo.Enabled = true; // コンボボックスへ候補をセットする(ライン) sql = "select line FROM t_model_line where model_no ='" + model + "'"; System.Diagnostics.Debug.Print(sql); tf.getComboBoxData(sql, ref cmbLine); cmbLine.Enabled = true; }