Exemplo n.º 1
0
        private bool Check_path(string db, string attribute)
        {
            using (OleDbCommand cmd = new OleDbCommand())
            {
                string          path = "";
                OleDbDataReader dr;
                cmd.Connection  = Access_DataBase.DB_Conn_Open(db);
                cmd.CommandText = "SELECT * FROM path WHERE DB_name = '" + attribute + "'";
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    path = dr[1].ToString();
                }
                if (path.Length != 0)//實體位子檢測
                {
                    if (!File.Exists(path))
                    {
                        Scan_result_richTextBox.SelectionColor = Color.Red;
                        Scan_result_richTextBox.AppendText("[" + DT_Now + "] [檔案不存在]" + attribute + " 實體路徑初始化載入失敗" + path + Environment.NewLine);
                        return(false);
                    }
                    else
                    {
                        Scan_result_richTextBox.SelectionColor = Color.Green;
                        Scan_result_richTextBox.AppendText("[" + DT_Now + "] [資料庫]" + attribute + " 初始化路徑載入成功" + Environment.NewLine);
                        switch (attribute)
                        {
                        case "QRcode_Scan":
                            connectionString_QRcode_Scan = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";";
                            break;

                        case "StaffDB":
                            connectionString_StaffDB = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";";
                            break;
                            //case "Photo":
                            //    connectionString_Photo = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";";
                            //    break;
                        }
                        return(true);
                    }
                }
                else
                {
                    Scan_result_richTextBox.SelectionColor = Color.Red;
                    Scan_result_richTextBox.AppendText("[" + DT_Now + "] " + attribute + " 初始化路徑載入失敗" + path + Environment.NewLine);
                    return(false);
                }
            }
        }
Exemplo n.º 2
0
        private void Generate_QR_Click(object sender, EventArgs e)
        {
            string Message = Check_TextBox();

            if (Message.Length > 0)
            {
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                MessageBox.Show(Message, "請檢察欄位", buttons);
            }
            else
            {
                //確認資料庫是否重複姓名
                using (OleDbCommand cmd = new OleDbCommand())
                {
                    Pic_pro = new Picture_Process();
                    OleDbDataReader dr;
                    cmd.Connection  = Access_DataBase.DB_Conn_Open(connectionStaffDB);
                    cmd.CommandText = "SELECT * FROM staff_info WHERE Name = @name OR(ID = @id)";//" Name_Textbox.Text =Name " " + IDnumber_Textbox.Text + " = ID
                    cmd.Parameters.AddWithValue("@name", Name_Textbox.Text);
                    cmd.Parameters.AddWithValue("@id", IDnumber_Textbox.Text);
                    dr = cmd.ExecuteReader();
                    if (!dr.HasRows)
                    {
                        //Convert.ToBase64String(//AES加密後);
                        //Encoding.UTF8.GetString(//AES解密後)
                        string Encode_str = Encode(IDnumber_Textbox.Text);                                      //加密
                        byte[] Zxing_QR   = ZXing_QR(Encode_str);
                        Insert(Encode_str, IDnumber_Textbox.Text, SavePhoto(photopath_TextBox.Text), Zxing_QR); //存入D
                        QR QRForm = new QR(Zxing_QR, Name_Textbox.Text, Encode_str);
                        QRForm.ShowDialog(this);
                        Refush_GirdView();
                        Initial_New_StaffTB();
                    }
                    else//repeat
                    {
                        //TODO MessageBox Warning
                        MessageBoxButtons buttons = MessageBoxButtons.OK;
                        MessageBox.Show("員工重複申請", "重複", buttons);
                    }
                }
            }


            //先確認資料欄位有沒有資料

            //存檔資料庫 連同照片轉成binaray
        }
Exemplo n.º 3
0
        private void button_correct_Click(object sender, EventArgs e)
        {
            Main_Form.Scan_result_richTextBox.AppendText("[" + System_Time + "] " + "按壓正確按鈕" + Environment.NewLine);
            Management_interface MI  = new Management_interface(connectionQRcode_DB, connectionStaffDB, Main_Form);
            Access_DataBase      Adb = new Access_DataBase();

            if (Adb.Check_Admin(textBox_psw.Text))
            {
                Main_Form.Scan_result_richTextBox.SelectionColor = Color.Green;
                Main_Form.Scan_result_richTextBox.AppendText("[" + System_Time + "] " + "管理者嘗試登入:成功" + Environment.NewLine);
                MI.ShowDialog(this);
                this.Dispose();
            }
            else
            {
                Main_Form.Scan_result_richTextBox.SelectionColor = Color.Red;
                Main_Form.Scan_result_richTextBox.AppendText("[" + System_Time + "] " + "管理者嘗試登入:失敗!" + Environment.NewLine);
                label_error.Text = "密碼錯誤";
            }
        }
Exemplo n.º 4
0
 private void Main_System_FormClosing(object sender, FormClosingEventArgs e)
 {
     Access_DataBase.DB_Conn_Open(connectionString_QRcode_Scan).Close();
     Access_DataBase.DB_Conn_Open(connectionString_StaffDB).Close();
 }
Exemplo n.º 5
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            DT_Now = DateTime.Now;

            if (VideoViewer.GetCurrentVideoFrame() != null)
            {
                BarcodeReader Reader = new BarcodeReader();
                Bitmap        img    = new Bitmap(VideoViewer.GetCurrentVideoFrame());

                //----------------加入CV---------------------
                //Image<Gray, byte> I = new Image<Gray, byte>(img);
                //Image<Bgr, byte> DrawI = I.Convert<Bgr, byte>();
                //Image<Gray, byte> CannyImage = I.Clone(); //灰階處理
                //CvInvoke.GaussianBlur(I, CannyImage, new Size(5, 5), 0);
                //CvInvoke.Canny(I, CannyImage, 100, 200);
                //MyCV.BoundingBox(CannyImage, DrawI);
                //pictureBox1.Image = DrawI.Bitmap;
                //pictureBox2.Image = CannyImage.Bitmap;
                //Result result = Reader.Decode(DrawI.Bitmap);
                //----------------CV end----------------------
                Result result = Reader.Decode(img); //原本
                img.Dispose();                      //釋放資源


                if (result != null)
                {
                    Scan_result_richTextBox.SelectionColor = Color.Green;
                    Scan_result_richTextBox.AppendText("[" + DT_Now + "] 掃描條碼顯示: " + result + Environment.NewLine);

                    //Scan_result.Items.Add("DBconnection = " + connectionString);
                    //資料庫(自動Dispose寫法)
                    String check_psd = "SELECT * FROM staff_info WHERE Encode_ID = '" + result + "'";
                    using (OleDbCommand cmd = new OleDbCommand())
                    {
                        DataSet          ds        = new DataSet();
                        Table_Row        TBR       = new Table_Row();
                        List <Table_Row> table_row = new List <Table_Row>();

                        //OleDbDataReader dr;
                        cmd.Connection  = Access_DataBase.DB_Conn_Open(connectionString_StaffDB);
                        cmd.CommandText = check_psd;
                        //dr = cmd.ExecuteReader();
                        OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);

                        try
                        {
                            adapter.Fill(ds, "Encode_ID");
                            adapter.Fill(ds, "Name");
                            adapter.Fill(ds, "Sex");
                            adapter.Fill(ds, "Job");
                            adapter.Fill(ds, "Phone");
                            adapter.Fill(ds, "CarNumP");
                            adapter.Fill(ds, "Photo");

                            try
                            {
                                TBR.Id      = ds.Tables["Encode_ID"].Rows[0]["Encode_ID"].ToString();
                                TBR.Name    = ds.Tables["Name"].Rows[0]["Name"].ToString();
                                TBR.Sex     = ds.Tables["Sex"].Rows[0]["Sex"].ToString();
                                TBR.Job     = ds.Tables["Job"].Rows[0]["Job"].ToString();
                                TBR.CarNumP = ds.Tables["CarNumP"].Rows[0]["CarNumP"].ToString();
                                TBR.CarNumP = ds.Tables["Phone"].Rows[0]["Phone"].ToString();
                                TBR.Photo   = (byte[])ds.Tables["Photo"].Rows[0]["Photo"];
                                table_row.Add(TBR);
                                ds.Tables.Clear();

                                string Table_name = DT_Now.ToString("yyyy_MM");
                                Check_Table_Exsits(Access_DataBase.DB_Conn_Open(connectionString_QRcode_Scan), cmd, Table_name);//檢查有無當月Table沒有建立
                                ShowInfo SI_form = new ShowInfo(table_row, this, Table_name, connectionString_QRcode_Scan);
                            }
                            catch
                            {
                                TimerThread.Stop();
                                string            message   = "此條碼可能被註銷,或者不是岡山榮家發行";
                                string            caption   = "查無此資料";
                                MessageBoxButtons buttons   = MessageBoxButtons.OK;
                                DialogResult      DiaResult = MessageBox.Show(message, caption, buttons);
                                //MessageBox.Show(message, caption, buttons);
                                if (DiaResult == DialogResult.OK)
                                {
                                    TimerThread.Start();
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                    }
                }
            }
        }