// バッチ削除ボタン押下時の処理(ヘッダーと明細全ての削除) private void btnDeleteBatch_Click(object sender, EventArgs e) { // 念のため、本当に削除するのか、2度ユーザーに問う DialogResult result1 = MessageBox.Show("Do you really want to delete the batch data?", "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result1 == DialogResult.No) { return; } DialogResult result2 = MessageBox.Show("Again, is it OK to delete the batch?", "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result2 == DialogResult.No) { return; } string batchNo = txtBatchNo.Text; string sql = "delete from t_batch_no where batch_no='" + batchNo + "'"; string sql1 = "delete from t_parts_invoice where batch_no='" + batchNo + "'"; TfSQL tf = new TfSQL(); tf.sqlExecuteNonQuery(sql, false); System.Diagnostics.Debug.Print(sql); tf.sqlExecuteNonQuery(sql1, false); System.Diagnostics.Debug.Print(sql1); //親フォームForm1のデータグリットビューを更新するため、デレゲートイベントを発生させる this.RefreshEvent(this, new EventArgs()); // コントロールの無効化 disableControlsExceptCloseButton(this); // 登録完了フラグオン(誤って閉じることを防止する機能、オフ) b_headerComplete = true; b_partsComplete = true; // TBIテーブルのパーツ情報を削除するため、参照すべきTBIテーブル名を特定する string model = cmbModelNo.Text; DateTime month = dtpBatchDate.Value; // string tbiTable = decideReferenceTable(model, month); // TBIテーブルの同バッチ既存レコード削除 // string sql2 = "delete from " + tbiTable + " where lot = '" + batchNo + "'"; // System.Diagnostics.Debug.Print(sql2); // tf.sqlExecuteNonQueryToPqmDb(sql2, false); }
// バッチヘッダー情報更新ボタン押下時の処理 private void btnUpdateBatch_Click(object sender, EventArgs e) { string batchNo = txtBatchNo.Text; double inQty; double.TryParse(txtInputQty.Text, out inQty); double outQty; double.TryParse(txtOutputQty.Text, out outQty); DateTime inTime = dtpInputTime.Value.Date; DateTime outTime = dtpOutputTime.Value.Date; string remark = txtRemark.Text; bool[] cr = { txtInputQty.Text == string.Empty ? false : true, txtOutputQty.Text == string.Empty ? false : true, true, true, remark == string.Empty ? false : true }; string sql1 = "update t_batch_no set " + (cr[0] ? "in_qty=" + inQty + "," : "in_qty = null,") + (cr[1] ? "out_qty=" + outQty + "," : "out_qty = null,") + (cr[2] ? "in_time='" + inTime + "'," : string.Empty) + (cr[3] ? "out_time='" + outTime + "'," : string.Empty) + (cr[4] ? "remark='" + remark + "'," : "remark = null,"); string sql2 = " where batch_no='" + batchNo + "'"; string sql3 = VBStrings.Left(sql1, sql1.Length - 1) + sql2; System.Diagnostics.Debug.Print(sql3); TfSQL tf = new TfSQL(); b_headerComplete = tf.sqlExecuteNonQuery(sql3, false); if (b_headerComplete) { MessageBox.Show("Step 1: Batch general info register completed", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } //親フォームForm1のデータグリットビューを更新するため、デレゲートイベントを発生させる this.RefreshEvent(this, new EventArgs()); }
// サブプロシージャ:バッチ番号テーブル用、インサート文実行 private void insertBatchNo() { string batchNo = txtBatchNo.Text; string modelNo = cmbModelNo.Text; string modelName = txtModelName.Text; string subAssyNo = cmbSubAssyNo.Text; string subAssyName = txtSubAssyName.Text; DateTime batchDate = dtpBatchDate.Value; string shift = cmbShift.Text; string line = cmbLine.Text; string leader = txtLeaderId.Text; string leaderName = txtLeaderName.Text; double inQty; double.TryParse(txtInputQty.Text, out inQty); double outQty; double.TryParse(txtOutputQty.Text, out outQty); DateTime inTime = dtpInputTime.Value; DateTime outTime = dtpOutputTime.Value; string remark = txtRemark.Text; bool[] cr = { batchNo == string.Empty ? false : true, modelNo == string.Empty ? false : true, modelName == string.Empty ? false : true, subAssyNo == string.Empty ? false : true, subAssyName == string.Empty ? false : true, true, shift == string.Empty ? false : true, line == string.Empty ? false : true, leader == string.Empty ? false : true, leaderName == string.Empty ? false : true, txtInputQty.Text == string.Empty ? false : true, txtOutputQty.Text == string.Empty ? false : true, true, true, remark == string.Empty ? false : true, }; string sql1 = "insert into t_batch_no(" + (cr[0] ? "batch_no," : string.Empty) + (cr[1] ? "model_no," : string.Empty) + (cr[2] ? "model_name," : string.Empty) + (cr[3] ? "sub_assy_no," : string.Empty) + (cr[4] ? "sub_assy_name," : string.Empty) + (cr[5] ? "batch_date," : string.Empty) + (cr[6] ? "shift," : string.Empty) + (cr[7] ? "line," : string.Empty) + (cr[8] ? "leader_id," : string.Empty) + (cr[9] ? "leader_name," : string.Empty) + (cr[10] ? "in_qty," : string.Empty) + (cr[11] ? "out_qty," : string.Empty) + (cr[12] ? "in_time," : string.Empty) + (cr[13] ? "out_time," : string.Empty) + (cr[14] ? "remark," : string.Empty); string sql2 = ") VALUES(" + (cr[0] ? "'" + batchNo + "'," : string.Empty) + (cr[1] ? "'" + modelNo + "'," : string.Empty) + (cr[2] ? "'" + modelName + "'," : string.Empty) + (cr[3] ? "'" + subAssyNo + "'," : string.Empty) + (cr[4] ? "'" + subAssyName + "'," : string.Empty) + (cr[5] ? "'" + batchDate + "'," : string.Empty) + (cr[6] ? "'" + shift + "'," : string.Empty) + (cr[7] ? "'" + line + "'," : string.Empty) + (cr[8] ? "'" + leader + "'," : string.Empty) + (cr[9] ? "'" + leaderName + "'," : string.Empty) + (cr[10] ? " " + inQty + " ," : string.Empty) + (cr[11] ? " " + outQty + " ," : string.Empty) + (cr[12] ? "'" + inTime + "'," : string.Empty) + (cr[13] ? "'" + outTime + "'," : string.Empty) + (cr[14] ? "'" + remark + "'," : string.Empty); string sql3 = VBStrings.Left(sql1, sql1.Length - 1) + VBStrings.Left(sql2, sql2.Length - 1) + ")"; System.Diagnostics.Debug.Print(sql3); TfSQL tf = new TfSQL(); tf.sqlExecuteNonQuery(sql3, false); //親フォームForm1のデータグリットビューを更新するため、デレゲートイベントを発生させる this.RefreshEvent(this, new EventArgs()); }