Esempio n. 1
0
        // サブプロシージャ:DBからのDTHISTORYへの読み込み
        private void readDtHistory(ref DataTable dt)
        {
            dt.Clear();

            string   model   = txtModel.Text;
            string   process = txtProcess.Text;
            string   inspect = txtInspect.Text;
            DateTime lotFrom = dtpLotFrom.Value;
            DateTime lotTo   = dtpLotTo.Value;
            string   line    = cmbLine.Text;

            string sql = "select inspect, lot, inspectdate, line, qc_user, status, " +
                         "m1, m2, m3, m4, m5, x, r FROM tbl_measure_history " +
                         "where model = '" + model + "' AND " +
                         "process = '" + process + "' AND " +
                         "inspect = '" + inspect + "' AND " +
                         "lot >= '" + lotFrom.ToString() + "' AND " +
                         "lot <= '" + lotTo.ToString() + "' AND " +
                         "line = '" + line + "' AND " +
                         "qc_user != '1. Upper' AND qc_user != '2. Lower' " +
                         "order by lot, inspectdate";

            System.Diagnostics.Debug.Print(sql);
            TfSQL tf = new TfSQL();

            tf.sqlDataAdapterFillDatatable(sql, ref dt);
        }
Esempio n. 2
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            GetMD5(txtOldPassC.Text);
            TfSQL  tf    = new TfSQL();
            string passC = tf.sqlExecuteScalarString("select pass from qc_user where qcuser = '******'");

            if (passC == str_md5)
            {
                lblStatusC.Text      = "Available!";
                lblStatusC.ForeColor = Color.Green;
            }
            else
            {
                lblStatusC.Text      = "The old password is wrong!";
                lblStatusC.ForeColor = Color.Red;
                return;
            }
            GetMD5(txtPassC.Text);
            tf.sqlExecuteScalarString("update qc_user set pass = '******' where qcuser = '******'");
            DialogResult result = MessageBox.Show("Your password has been changed!", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information);

            if (result == DialogResult.OK)
            {
                grChangePass.Visible = false;
                grLogin.Visible      = true;
            }
        }
Esempio n. 3
0
        // サブプロシージャ:上限・下限、行セット・列セット、コマンド、の設定
        private void setLimitSetAndCommand(ref DataTable dt)
        {
            dt.Clear();
            string sql = "select upper, lower, clm_set, row_set, instrument from tbl_measure_item " +
                         "where model = '" + txtModel.Text + "' and " +
                         "inspect = '" + txtInspect.Text + "' and process = '" + txtProcess.Text + "'";

            System.Diagnostics.Debug.Print(sql);
            TfSQL tf = new TfSQL();

            tf.sqlDataAdapterFillDatatable(sql, ref dt);

            upp         = (double)dt.Rows[0]["upper"];
            txtUsl.Text = upp.ToString();
            low         = (double)dt.Rows[0]["lower"];
            txtLsl.Text = low.ToString();
            rowSet      = (int)dt.Rows[0]["row_set"];
            clmSet      = (int)dt.Rows[0]["clm_set"];
            if (dt.Rows[0]["instrument"].ToString() == "push")
            {
                command = push;
            }
            else if (dt.Rows[0]["instrument"].ToString() == "pull")
            {
                command = pull;
            }
        }
Esempio n. 4
0
        // XRグラフ作成ボタン押下時の処理
        private void btnExport_Click(object sender, EventArgs e)
        {
            TfSQL         sampl   = new TfSQL();
            string        sample  = sampl.sqlExecuteScalarString("select clm_set from tbl_measure_item where inspect = '" + txtInspect.Text + "'");
            string        descrip = sampl.sqlExecuteScalarString("select description from tbl_measure_item where inspect = '" + txtInspect.Text + "'");
            ExcelClassnew xl      = new ExcelClassnew();

            string dtpFrom = dtpLotFrom.Value.ToString("yyyy/MM/dd");
            string dtpTo   = dtpLotTo.Value.ToString("yyyy/MM/dd");

            xl.exportExcel(txtModel.Text, cmbLine.Text, txtUser.Text, txtUsl.Text, txtLsl.Text, txtProcess.Text, txtInspect.Text, sample, descrip, dgvHistory, dtpFrom, dtpTo);
        }
Esempio n. 5
0
        // 測定値の取り込みが終わったら、データベースへ登録する
        private void btnRegister_Click(object sender, EventArgs e)
        {
            if (dtBuffer.Rows.Count <= 0)
            {
                return;
            }

            string   model       = txtModel.Text;
            string   process     = txtProcess.Text;
            string   inspect     = txtInspect.Text;
            string   status      = txtStatus.Text;
            DateTime lot         = DateTime.Parse(dtBuffer.Rows[0]["lot"].ToString());;
            DateTime inspectdate = DateTime.Parse(dtBuffer.Rows[0]["inspectdate"].ToString());;
            string   line        = cmbLine.Text;

            if (txtInspect.Text == "CORE07" || txtProcess.Text == "COREASSY08")
            {
                for (int a = 5; a < 15; a++)
                {
                    if (dgvBuffer[a, 0].Value.ToString() != "" && a % 2 == 0)
                    {
                        double vm1 = double.Parse(dgvBuffer[a, 0].Value.ToString());
                        dgvBuffer[a, 0].Value = vm1 * 1000;
                    }
                }
            }

            // ブァッファーテーブル内で、平均とレンジを計算する
            calculateAverageAndRangeInDataTable(ref dtBuffer);

            // IPQCDB 測定履歴テーブルに登録する
            TfSQL tf  = new TfSQL();
            bool  res = tf.sqlMultipleInsert(model, process, inspect, lot, inspectdate, line, status, dtBuffer);

            if (res)
            {
                // バックグラウンドでPQMテーブルに登録する
                DataTable dtTemp = new DataTable();
                dtTemp = dtBuffer.Copy();
                //registerMeasurementToPqmTable(dtTemp);

                // 登録済の状態を、当フォームに表示する
                dtBuffer.Clear();
                readDtHistory(ref dtHistory);
                updateDataGripViews(dtBuffer, dtHistory, ref dgvBuffer, ref dgvHistory);

                // 編集モードフラグを立て、登録・修正ボタンを「登録」の表示に戻す
                editMode            = false;
                btnRegister.Text    = "Register";
                dtpLotInput.Enabled = true;
            }
        }
Esempio n. 6
0
        // サブプロシージャ: PQMテーブルへの登録(バックグラウンド処理)
        //private void registerMeasurementToPqmTable(DataTable dt)
        //{
        //    var task = Task.Factory.StartNew(() =>
        //    {
        //        string model = txtModel.Text;
        //        string process = txtProcess.Text;
        //        string inspect = txtInspect.Text;
        //        DateTime lot = DateTime.Parse(dt.Rows[0]["lot"].ToString());
        //        DateTime inspectdate = DateTime.Parse(dt.Rows[0]["inspectdate"].ToString());
        //        string line = cmbLine.Text;

        //        TfSqlPqm Tfc = new TfSqlPqm();
        //        Tfc.sqlMultipleInsertMeasurementToPqmTable(model, process, inspect, lot, inspectdate, line, dt, upp, low);
        //    });
        //}

        // 削除ボタン押下時の処理
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (dtBuffer.Rows.Count <= 0)
            {
                return;
            }

            DialogResult result = MessageBox.Show("Do you really want to delete the selected row?",
                                                  "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (result == DialogResult.No)
            {
                MessageBox.Show("Delete process was canceled.",
                                "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
            }
            else if (result == DialogResult.Yes)
            {
                // データの削除
                string sql = "delete from tbl_measure_history where " +
                             "model='" + txtModel.Text + "' and " +
                             "inspect='" + txtInspect.Text + "' and " +
                             "lot ='" + dtBuffer.Rows[0]["lot"] + "' and " +
                             "inspectdate ='" + dtBuffer.Rows[0]["inspectdate"] + "' and " +
                             "line ='" + cmbLine.Text + "'";

                System.Diagnostics.Debug.Print(sql);
                TfSQL tf  = new TfSQL();
                int   res = tf.sqlExecuteNonQueryInt(sql, false);

                // バックグラウンドでPQMテーブル内の削除
                DataTable dtTemp = new DataTable();
                dtTemp = dtBuffer.Copy();
                // deleteFromPqmTable(dtTemp);

                // 新規登録用バッファーテーブル、バッファーグリットビューを初期化する
                dtBuffer.Clear();

                // 削除後テーブルの再読み込み
                readDtHistory(ref dtHistory);

                // HISTORYデータグリッドビューのマーキングをクリアする
                colorViewReset(ref dgvHistory);

                // グリットビューの更新
                updateDataGripViews(dtBuffer, dtHistory, ref dgvBuffer, ref dgvHistory);

                // 編集モードフラグを下し、登録・修正ボタンを「登録」の表示にする
                editMode            = false;
                btnRegister.Text    = "Register";
                dtpLotInput.Enabled = true;
            }
        }
Esempio n. 7
0
        public void updateControls(string model, string process, string inspect, string user, string ip)
        {
            txtModel.Text   = model;
            txtProcess.Text = process;
            txtInspect.Text = inspect;
            txtUser.Text    = user;
            _ip             = ip;
            string sql_line = "select line from tbl_model_line where model = '" + txtModel.Text + "' order by line";
            TfSQL  ln       = new TfSQL();

            ln.getComboBoxData(sql_line, ref cmbLine);
            //cmbLine.SelectedIndex = 0;
        }
Esempio n. 8
0
        // サブプロシージャ:型式コンボボックスへ候補を取り込む
        public void getComboListFromDB(ref ComboBox cmb)
        {
            string sql_model = "select model from tbl_model_dbplace order by model";

            System.Diagnostics.Debug.Print(sql_model);
            TfSQL tf = new TfSQL();

            tf.getComboBoxData(sql_model, ref cmb);

            if (cmbModel.Items.Count > 0)
            {
                cmbModel.SelectedIndex = 0;
            }
        }
Esempio n. 9
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if ((txtModel.Text != "") && (txtLine.Text != ""))
     {
         TfSQL  con    = new TfSQL();
         string sqladd = "INSERT INTO tbl_model_line(model, line) VALUES('" + txtModel.Text + "', '" + txtLine.Text + "')";
         con.sqlExecuteScalarString(sqladd);
         string sqladdplace = " INSERT INTO tbl_model_dbplace (model, dbplace) VALUES('" + txtModel.Text + "', '" + txtPlace.Text + "' )";
         con.sqlExecuteScalarString(sqladdplace);
         MessageBox.Show("Add Successfully", "Notification", MessageBoxButtons.OK);
         Close();
     }
     else
     {
         MessageBox.Show("Please insert Model or Line", " Notification", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Esempio n. 10
0
        // 既存測定値の修正
        private void dgvHistory_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int curRow = int.Parse(e.RowIndex.ToString());

            if (dgvHistory.Columns[e.ColumnIndex] == Open && curRow >= 0)
            {
                // 編集モードフラグを立て、登録・修正ボタンを「修正」の表示にする
                editMode            = true;
                btnRegister.Text    = "Update";
                dtpLotInput.Enabled = false;

                // 新規登録用バッファーテーブル、バッファーグリットビューを初期化し、ボタンに対応する値を格納する
                dtBuffer.Clear();

                string sql = "select inspect, lot, inspectdate, line, qc_user, status, " +
                             "m1, m2, m3, m4, m5 FROM tbl_measure_history WHERE " +
                             "model = '" + txtModel.Text + "' AND " +
                             "inspect = '" + dgvHistory["inspect", curRow].Value.ToString() + "' AND " +
                             "lot = '" + (DateTime)dgvHistory["lot", curRow].Value + "' AND " +
                             "inspectdate = '" + (DateTime)dgvHistory["inspectdate", curRow].Value + "' AND " +
                             "line = '" + dgvHistory["line", curRow].Value.ToString() + "' " +
                             "order by qc_user";
                System.Diagnostics.Debug.Print(sql);
                TfSQL tf = new TfSQL();
                tf.sqlDataAdapterFillDatatable(sql, ref dtBuffer);

                // グリットビューの更新
                updateDataGripViews(dtBuffer, dtHistory, ref dgvBuffer, ref dgvHistory);

                // 新規登録用グリットビュー(バッファテーブル)へ、ボタンを追加する
                if (dgvBuffer.Columns.Count <= 13)
                {
                    addButtonsToDgvBuffer(dgvBuffer, edit1, edit2, edit3, edit4, edit5);
                }

                // 変更ターゲット行を表示する
                if (dgvHistory.Rows.Count >= 1)
                {
                    dgvHistory.FirstDisplayedScrollingRowIndex = curRow;
                }

                // サブプロシージャ:編集中の行をマーキングする
                colorViewForEdit(ref dgvHistory, curRow);
                colorViewForEdit(ref dgvBuffer, 0);
            }
        }
Esempio n. 11
0
        // サブサブプロシージャ:グリットビュー右端にボタンを追加
        private void addButtonsToDataGridView(DataGridView dgv)
        {
            bool  adm_flag = false;
            TfSQL flag     = new TfSQL();
            bool  fl       = flag.sqlExecuteScalarBool("select admin_flag from qc_user where qcuser = '******'");

            if (fl == true)
            {
                adm_flag = true;
            }
            Open      = new DataGridViewButtonColumn();
            Open.Text = "Open";
            Open.UseColumnTextForButtonValue = true;
            Open.Width = 45;
            dgv.Columns.Add(Open);

            if (adm_flag == true)
            {
                btnDelete.Visible = true;
            }
        }
Esempio n. 12
0
        // ロード時の処理(コンボボックスに、オートコンプリート機能の追加)
        private void Form5_Load(object sender, EventArgs e)
        {
            if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
            {
                Version deploy = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion;

                StringBuilder version = new StringBuilder();
                version.Append("VERSION: ");
                //version.Append(applicationName + "_");
                version.Append(deploy.Major);
                version.Append("_");
                //version.Append(deploy.Minor);
                //version.Append("_");
                version.Append(deploy.Build);
                version.Append("_");
                version.Append(deploy.Revision);

                Version_lbl.Text = version.ToString();
            }

            txtPwd.Visible       = false;
            btnLogIn.Enabled     = false;
            grChangePass.Visible = false;
            string sql = "select DISTINCT qcuser FROM qc_user ORDER BY qcuser";
            TfSQL  tf  = new TfSQL();

            tf.getComboBoxData(sql, ref cmbUserName);
            tf.getComboBoxData(sql, ref cmbUserC);

            string      HostName = Dns.GetHostName();
            IPHostEntry ip       = Dns.GetHostByName(HostName);

            foreach (IPAddress ipadd in ip.AddressList)
            {
                lblIP.Text = lblIP.Text + ipadd.ToString();
            }
        }
Esempio n. 13
0
        // ユーザーログイン時、パスワードとログイン状態の確認(2重ログインの防止)
        private void btnLogIn_Click(object sender, EventArgs e)
        {
            if (btnLogIn.Text == "Log In")
            {
                TfSQL  tf   = new TfSQL();
                string logt = tf.sqlExecuteScalarString("select login_times from qc_user where qcuser = '******'");
                if (logt == "0")
                {
                    grLogin.Text         = "Change Default Password";
                    lblUser.Text         = "New Password";
                    txtPwd.Size          = new Size(100, 20);
                    txtPwd.Location      = new Point(123, 47);
                    lblPass.Text         = "Confirm Password";
                    txtPassword.Size     = new Size(100, 20);
                    txtPassword.Location = new Point(123, 87);
                    btnLogIn.Text        = "Change Password";
                    btnLogIn.Enabled     = false;
                    txtPassword.ResetText();
                    txtPwd.ResetText();
                    txtPwd.Visible = true;
                    txtPwd.Focus();
                    cmbUserName.Visible   = false;
                    btnChangePass.Visible = false;
                }
                else
                {
                    string sql   = null;
                    string user  = null;
                    string pass  = null;
                    string ip    = null;
                    bool   login = false;

                    user = cmbUserName.Text;

                    if (user != null)
                    {
                        sql  = "select pass FROM qc_user WHERE qcuser='******'";
                        pass = tf.sqlExecuteScalarString(sql);

                        sql   = "select loginstatus FROM qc_user WHERE qcuser='******'";
                        login = tf.sqlExecuteScalarBool(sql);

                        sql = "select ip_address from qc_user where qcuser = '******'";
                        ip  = tf.sqlExecuteScalarString(sql);


                        GetMD5(txtPassword.Text);

                        if (pass == str_md5)
                        {
                            if (login && ip != "null" && ip != lblIP.Text)
                            {
                                DialogResult reply = MessageBox.Show("This user account is currently used by " + ip + "," + System.Environment.NewLine +
                                                                     "or the log out last time had a problem.", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                                sql = "UPDATE qc_user SET loginstatus=false, ip_address = '" + lblIP.Text + "' WHERE qcuser='******'";
                                bool res1 = tf.sqlExecuteNonQuery(sql, false);
                                return;
                            }

                            //Check IP Address
                            if (ip == "null")
                            {
                                tf.sqlExecuteScalarString("UPDATE qc_user SET ip_address = '" + lblIP.Text + "' where qcuser = '******'");
                            }

                            // ログイン状態をTRUEへ変更
                            sql = "UPDATE qc_user SET loginstatus=true WHERE qcuser='******'";
                            bool res = tf.sqlExecuteNonQuery(sql, false);

                            // 子フォームForm1を表示し、デレゲートイベントを追加:
                            frmItem f1 = new frmItem();
                            f1.RefreshEvent += delegate(object sndr, EventArgs excp)
                            {
                                // Form1を閉じる際、ログイン状態をFALSEへ変更し、当フォームForm5も閉じる
                                sql          = "UPDATE qc_user SET loginstatus=false, ip_address = 'null' WHERE qcuser='******'";
                                res          = tf.sqlExecuteNonQuery(sql, false);
                                this.Visible = true;
                                txtPassword.ResetText();
                            };
                            f1.updateControls(user, lblIP.Text);
                            f1.Show();
                            this.Visible = false;
                        }
                        else if (pass != txtPassword.Text)
                        {
                            MessageBox.Show("Password does not match", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            txtPassword.ResetText();
                        }
                    }
                }
            }
            else
            {
                if (txtPwd.Text != txtPassword.Text)
                {
                    lblStatus.Text      = "Password is not avaliable!";
                    lblStatus.ForeColor = Color.Red;
                }
                else
                {
                    string pass = txtPwd.Text;
                    GetMD5(pass);
                    TfSQL up = new TfSQL();
                    up.sqlExecuteScalarString("update qc_user set pass = '******' where qcuser = '******'");
                    up.sqlExecuteScalarString("update qc_user set login_times = '1' where qcuser = '******'");
                    btnLogIn.Text        = "Log In";
                    lblUser.Text         = "Username:"******"Password:"******"Your password has been changed!", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (result == DialogResult.OK)
                    {
                        login();
                    }
                }
            }
        }
Esempio n. 14
0
        private void login()
        {
            string sql   = null;
            string user  = null;
            string pass  = null;
            string ip    = null;
            bool   login = false;

            user = cmbUserName.Text;

            if (user != null)
            {
                TfSQL tf = new TfSQL();
                sql  = "select pass FROM qc_user WHERE qcuser='******'";
                pass = tf.sqlExecuteScalarString(sql);

                sql   = "select loginstatus FROM qc_user WHERE qcuser='******'";
                login = tf.sqlExecuteScalarBool(sql);

                sql = "select ip_address from qc_user where qcuser = '******'";
                ip  = tf.sqlExecuteScalarString(sql);

                //Check IP Address
                if (ip == "null")
                {
                    tf.sqlExecuteScalarString("UPDATE qc_user SET ip_address = '" + lblIP.Text + "'");
                }

                GetMD5(txtPassword.Text);

                if (pass == str_md5)
                {
                    if (login && ip != "null" && ip != lblIP.Text)
                    {
                        DialogResult reply = MessageBox.Show("This user account is currently used by " + ip + "," + System.Environment.NewLine +
                                                             "or the log out last time had a problem.", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                        return;
                    }

                    // ログイン状態をTRUEへ変更
                    sql = "UPDATE qc_user SET loginstatus=true WHERE qcuser='******'";
                    bool res = tf.sqlExecuteNonQuery(sql, false);

                    // 子フォームForm1を表示し、デレゲートイベントを追加:
                    frmItem f1 = new frmItem();
                    f1.RefreshEvent += delegate(object sndr, EventArgs excp)
                    {
                        // Form1を閉じる際、ログイン状態をFALSEへ変更し、当フォームForm5も閉じる
                        sql          = "UPDATE qc_user SET loginstatus=false, ip_address = 'null' WHERE qcuser='******'";
                        res          = tf.sqlExecuteNonQuery(sql, false);
                        this.Visible = true;
                        txtPassword.ResetText();
                    };
                    f1.updateControls(user, lblIP.Text);
                    f1.Show();
                    this.Visible = false;
                }
                else if (pass != txtPassword.Text)
                {
                    MessageBox.Show("Password does not match", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtPassword.ResetText();
                }
            }
        }
Esempio n. 15
0
        // ロード時の処理
        private void frmScale_Load(object sender, EventArgs e)
        {
            // 当フォームの表示場所を指定
            this.Left = 300;
            this.Top  = 15;

            if (cmbLine.Text == "")
            {
                btnMeasure.Enabled = false;
            }

            //Exit app if user has been log in by another device
            TfSQL  flag    = new TfSQL();
            string ipadd   = flag.sqlExecuteScalarString("select ip_address from qc_user where qcuser = '******'");
            bool   expmiss = flag.sqlExecuteScalarBool("select export_permission from qc_user where qcuser = '******'");

            if (ipadd == "null")
            {
                flag.sqlExecuteScalarString("UPDATE qc_user SET loginstatus=true, ip_address = '" + _ip + "' where qcuser = '******'");
            }
            if (ipadd != "null" && ipadd != _ip)
            {
                DialogResult res = MessageBox.Show("User is logged in " + _ip + "," + System.Environment.NewLine +
                                                   "Do you want to log out and log in again ?", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Question);
                if (res == DialogResult.OK)
                {
                    Application.Exit();
                }
            }
            if (txtUser.Text != "Admin")
            {
                string[] a = txtUser.Text.Split('_');

                //User permission
                if (a[1] != "CHK" && txtUser.Text != "Admin")
                {
                    btnMeasure.Enabled  = false;
                    btnRegister.Enabled = false;
                    btnDelete.Enabled   = false;
                }
                if (expmiss == false && txtUser.Text != "Admin")
                {
                    btnExport.Enabled = false;
                }
            }

            // DATETIMEPICKERを10日前の日付にする
            dtpSet10daysBefore(dtpLotFrom);

            // DATETIMEPICKERの分以下を切り上げる
            dtpRoundUpHour(dtpLotTo);

            // DATETIMEPICKERの分以下を下げる
            dtpRounddownHour(dtpLotInput);

            // 感知された1つ目のシリアルポートを選択し、オープンする
            initializePort();

            // 各種処理用のテーブルを生成してデータを読み込む
            dtBuffer = new DataTable();
            defineBufferAndHistoryTable(ref dtBuffer);
            dtHistory = new DataTable();
            defineBufferAndHistoryTable(ref dtHistory);
            readDtHistory(ref dtHistory);
            dtUpLowIns = new DataTable();
            setLimitSetAndCommand(ref dtUpLowIns);

            //addButtonsToDataGridView(dgvHistory);
            // グリットビューの更新
            updateDataGripViews(dtBuffer, dtHistory, ref dgvBuffer, ref dgvHistory);

            // グリットビュー右端にボタンを追加(初回のみ)
            addButtonsToDataGridView(dgvHistory);
        }
Esempio n. 16
0
        // ロード時の処理
        private void Form1_Load(object sender, EventArgs e)
        {
            //フォームの場所を指定
            this.Left      = 0;
            this.Top       = 0;
            dtInspectItems = new DataTable();
            dtLine         = new DataTable();
            defineItemTable(ref dtInspectItems);
            defineLineTable(ref dtLine);
            getComboListFromDB(ref cmbModel);
            updateDataGripViews(ref dgvMeasureItem, true);
            load_cmb = false;
            //  loadline();
            TfSQL flag = new TfSQL();
            bool  fl   = flag.sqlExecuteScalarBool("select admin_flag from qc_user where qcuser = '******'");

            if (fl == true)
            {
                adm_flag = true;
            }
            if (adm_flag == true)
            {
                btnEditMaster.Enabled = true;
            }

            //Exit app if user has been log in by another device and log in again
            string ipadd = flag.sqlExecuteScalarString("select ip_address from qc_user where qcuser = '******'");

            if (ipadd == "null")
            {
                flag.sqlExecuteScalarString("UPDATE qc_user SET ip_address = '" + _ip + "' where qcuser = '******'");
            }
            if (ipadd != "null" && ipadd != _ip)
            {
                DialogResult res = MessageBox.Show("User is logged in " + _ip + "," + System.Environment.NewLine +
                                                   "Do you want to log out and log in again ?", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Question);
                if (res == DialogResult.OK)
                {
                    Application.Exit();
                }
            }
            //New option
            try
            {
                if (!Directory.Exists(@"D:\Database IPQC\"))
                {
                    Directory.CreateDirectory(@"D:\Database IPQC\");
                }
                if (File.Exists(@"D:\Database IPQC\Template.xlsx"))
                {
                    File.Delete(@"D:\Database IPQC\Template.xlsx");
                }
                File.Copy(@"\\192.168.145.7\checksheet\Template.xlsx", @"D:\Database IPQC\Template.xlsx");
                if (File.Exists(@"D:\Database IPQC\Template-CheckUCL.xlsx"))
                {
                    File.Delete(@"D:\Database IPQC\Template-CheckUCL.xlsx");
                }
                File.Copy(@"\\192.168.145.7\checksheet\Template-CheckUCL.xlsx", @"D:\Database IPQC\Template-CheckUCL.xlsx");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 17
0
        // データ受信が発生したときのイベント処理(デレゲート先)
        private void RcvDataToBufferDataTable(string cmd)
        {
            // 測定値の送信要求に対する返信の場合のみ処理
            //if (cmd.Length != 17) return;

            // 因数の決定:検査項目に応じて、2つの測定値の差を、因数で割って表示・登録する(デフォルト因数は1)
            string        inspect = txtInspect.Text;
            double        factor  = 1;
            List <string> list10  = new List <string> {
                "CAFBVP2", "CAFBVP4", "CAFBVP2", "CAFBVP4", "CAFBVP2", "CAFBVP4"
            };
            List <string> list5 = new List <string> {
                "RBCAVL", "RBCAVL", "RBCAVL"
            };

            if (list10.Contains(inspect))
            {
                factor = 10;
            }
            if (list5.Contains(inspect))
            {
                factor = 5;
            }

            // 正しい文字列から始まる受信文字列のみ処理する
            if (cmd.Substring(0, 2) == command2)
            {
                // 測定値のテキストを、DOUBLEに変換してBUFFERTABLEへ格納する
                double value = 0;
                string sql   = "select dbplace from tbl_model_dbplace where model='" + txtModel.Text + "'";
                System.Diagnostics.Debug.Print(sql);
                TfSQL  tf      = new TfSQL();
                string dbplace = tf.sqlExecuteScalarString(sql);

                // HAYWARD2は10桁の精度、CARは8桁の精度
                if (dbplace == "A")
                {
                    double.TryParse(cmd.Substring(4, 8), out value);
                }
                else if (dbplace == "CAR")
                {
                    double.TryParse(cmd.Substring(4, 8), out value);
                }

                dtBuffer.Rows[vAdr][hAdr] = value;

                // 上位と下位の、2つの測定値の差を、3行目に表示する
                if (dtBuffer.Rows[0][hAdr].ToString() != String.Empty && dtBuffer.Rows[1][hAdr].ToString() != String.Empty)
                {
                    dtBuffer.Rows[2][hAdr] =
                        Math.Round((double.Parse(dtBuffer.Rows[0][hAdr].ToString()) - double.Parse(dtBuffer.Rows[1][hAdr].ToString())) / factor, 4);
                    value = double.Parse(dtBuffer.Rows[2][hAdr].ToString());
                }

                // グリットビューの更新
                updateDataGripViews(dtBuffer, dtHistory, ref dgvBuffer, ref dgvHistory);

                // スペック外のセルをマーキングする(一時テーブル)
                colorBufferViewBySpec(value, ref dgvBuffer);
            }
        }