예제 #1
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;
            }
        }
예제 #2
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);
        }
예제 #3
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);
     }
 }
예제 #4
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);
            }
        }
예제 #5
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();
                    }
                }
            }
        }
예제 #6
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();
                }
            }
        }
예제 #7
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);
            }
        }
예제 #8
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);
        }