Ejemplo n.º 1
0
        // サブプロシージャ:新規バッチの発行
        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);
        }
Ejemplo n.º 2
0
        // フォームクローズボタン押下時の処理
        private void btnClose_Click(object sender, EventArgs e)
        {
            // 更新モードの場合は、処理なし。
            if (!formAddMode)
            {
                this.Close();
            }

            // ヘッダー・オペレーター・部品・副資材、4ステップが完了しているか否か、確認
            if (!(b_headerComplete && b_operatorComplete && b_partsComplete && b_subMatComplete))
            {
                string imcompleteList =
                    (b_headerComplete ? string.Empty : "header, ") +
                    (b_operatorComplete ? string.Empty : "operator, ") +
                    (b_partsComplete ? string.Empty : "parts, ") +
                    (b_subMatComplete ? string.Empty : "sub material, ");

                string message = "Is it ok to close this form?" + System.Environment.NewLine + System.Environment.NewLine +
                                 "Please check the followings:" + System.Environment.NewLine +
                                 VBStrings.Left(imcompleteList, imcompleteList.Length - 2) + System.Environment.NewLine + System.Environment.NewLine +
                                 "Click Yes to close." + System.Environment.NewLine +
                                 "Click No to check.";

                DialogResult reply = MessageBox.Show(message, "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                if (reply == DialogResult.Yes)
                {
                    this.Close();
                }
            }
            else
            {
                this.Close();
            }
        }
Ejemplo n.º 3
0
        // バッチヘッダー情報更新ボタン押下時の処理
        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());
        }
Ejemplo n.º 4
0
        // サブプロシージャ:データグリットビューの更新
        public void updateDataGridViews(ref DataTable dt, ref DataGridView dgv)
        {
            string   batchNo       = txtBatchNo.Text;
            string   modelNo       = cmbModelNo.Text;
            string   modelName     = txtModelName.Text;
            string   subAssyNo     = cmbSubAssyNo.Text;
            string   subAssyName   = txtSubAssyName.Text;
            DateTime batchDate     = dtpBatchDate.Value.Date;
            DateTime batchNextDate = dtpBatchDate.Value.Date.AddDays(1);
            string   shift         = cmbShift.Text;
            string   line          = cmbLine.Text;
            string   leader        = txtLeaderId.Text;
            string   leaderName    = txtLeaderName.Text;
            bool     b_batch       = chkBatch.Checked;
            bool     b_model       = chkModel.Checked;
            bool     b_subAssy     = chkSubAssy.Checked;
            bool     b_batchDate   = chkBatchDate.Checked;
            bool     b_shift       = chkShift.Checked;
            bool     b_line        = chkLine.Checked;
            bool     b_leader      = chkLeader.Checked;

            string sql1 = "select batch_no, model_no, model_name, sub_assy_no, sub_assy_name, batch_date, " +
                          "shift, line, leader_id, leader_name, in_qty, out_qty, in_time, out_time, remark from t_batch_no where ";

            bool[] cr = { batchNo == String.Empty ? false : true,
                          modelNo == String.Empty ? false : true,
                          subAssyNo == String.Empty ? false : true,
                          true,
                          shift == String.Empty ? false : true,
                          line == String.Empty ? false : true,
                          leader == String.Empty ? false : true };

            bool[] ck = { b_batch,
                          b_model,
                          b_subAssy,
                          b_batchDate,
                          b_shift,
                          b_line,
                          b_leader };

            string sql2 = (!(cr[0] && ck[0]) ? String.Empty : "batch_no like '" + batchNo + "%' AND ") +
                          (!(cr[1] && ck[1]) ? String.Empty : "model_no = '" + modelNo + "' AND ") +
                          (!(cr[2] && ck[2]) ? String.Empty : "sub_assy_no = '" + subAssyNo + "' AND ") +
                          (!(cr[3] && ck[3]) ? String.Empty : "batch_date >= '" + batchDate + "' AND batch_date < '" + batchNextDate + "' AND ") +
                          (!(cr[4] && ck[4]) ? String.Empty : "shift = '" + shift + "' AND ") +
                          (!(cr[5] && ck[5]) ? String.Empty : "line = '" + line + "' AND ") +
                          (!(cr[6] && ck[6]) ? String.Empty : "leader_id = '" + leader + "' AND ");

            bool b_all = (cr[0] && ck[0]) || (cr[1] && ck[1]) || (cr[2] && ck[2]) || (cr[3] && ck[3]) || (cr[4] && ck[4]) ||
                         (cr[5] && ck[5]) || (cr[6] && ck[6]);

            System.Diagnostics.Debug.Print(b_all.ToString());
            System.Diagnostics.Debug.Print(cr[0].ToString() + " " + ck[0].ToString() + " " + cr[1].ToString() + " " + ck[1].ToString() + " " +
                                           cr[2].ToString() + " " + ck[2].ToString() + " " + cr[3].ToString() + " " + ck[3].ToString() + " " +
                                           cr[4].ToString() + " " + ck[4].ToString() + cr[5].ToString() + " " + ck[5].ToString() + " " + cr[6].ToString() + " " + ck[6].ToString());

            if (!b_all)
            {
                MessageBox.Show("Please select at least one check box and fill the criteria.", "Notice",
                                MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
                return;
            }

            string sql3 = sql1 + VBStrings.Left(sql2, sql2.Length - 5);

            System.Diagnostics.Debug.Print(sql3);

            dt.Clear();
            TfSQL tf = new TfSQL();

            tf.sqlDataAdapterFillDatatable(sql3, ref dt);

            // データグリットビューへDTAATABLEを格納
            dgv.DataSource          = dt;
            dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;

            //行ヘッダーに行番号を表示する
            for (int i = 0; i < dgv.Rows.Count; i++)
            {
                dgv.Rows[i].HeaderCell.Value = (i + 1).ToString();
            }
            //行ヘッダーの幅を自動調節する
            dgv.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);

            // 一番下の行を表示する
            if (dgv.Rows.Count != 0)
            {
                dgv.FirstDisplayedScrollingRowIndex = dgv.Rows.Count - 1;
            }
        }
Ejemplo n.º 5
0
        // サブプロシージャ:バッチ番号テーブル用、インサート文実行
        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());
        }