Exemplo n.º 1
0
        public void sync_function()
        {
            getTodayRec();

            var resultDia1 = DialogResult.None;

            resultDia1 = MessageBox.Show("Do you really want to sync??", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (resultDia1 == DialogResult.Yes)
            {
                try
                {
                    string constring = "datasource=localhost; database=biometrics; port=3306; username=root; password="******"INSERT INTO sync_table(last_synced, latest_synced) SELECT latest_synced, NOW() FROM sync_table ORDER BY sync_id DESC LIMIT 1", con))
                        {
                            con.Open();
                            cmd.ExecuteNonQuery();
                            con.Close();
                        }

                        var resultDia2 = DialogResult.None;
                        resultDia2 = MessageBox.Show("Successfully synced!\nDo you want to show it ??", "Show Sync Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                        if (resultDia2 == DialogResult.Yes)
                        {
                            Log_Viewer dbviewer = new Log_Viewer();
                            dbviewer.Show();
                        }
                        //MessageBox.Show("Records inserted.");
                    }
                }

                catch (Exception ex)
                {
                    MessageBox.Show("Error " + ex.Message);
                }
            }
        }
Exemplo n.º 2
0
        private void btnSaveTodayLog_Click(object sender, EventArgs e)
        {
            getTodayRec();

            try
            {
                string constring = "datasource=localhost; database=biometrics; port=3306; username=root; password="******"TRUNCATE TABLE employee_logs_tbl", con))
                        {
                            con.Open();
                            cmd.ExecuteNonQuery();
                            con.Close();
                        }
                    }
                }

                foreach (DataGridViewRow row in dgvRecords.Rows)
                {
                    using (MySqlConnection con = new MySqlConnection(constring))
                    {
                        using (MySqlCommand cmd = new MySqlCommand("INSERT INTO employee_logs_tbl(employee_id, datetime_record, in_out) VALUES(@employeeid, @datetimerecord, @inout)", con))
                        {
                            cmd.Parameters.AddWithValue("@employeeid", row.Cells["employeeid"].Value);
                            cmd.Parameters.AddWithValue("@datetimerecord", row.Cells["datetimerecord"].Value);
                            cmd.Parameters.AddWithValue("@inout", row.Cells["inout"].Value);
                            con.Open();
                            cmd.ExecuteNonQuery();
                            con.Close();
                        }
                    }
                }

                using (MySqlConnection con = new MySqlConnection(constring))
                {
                    using (MySqlCommand cmd = new MySqlCommand("INSERT INTO temp_tbl(temp_datetime, employee_id, datetime_record, in_out) SELECT now(), employee_id, datetime_record, in_out FROM employee_logs_tbl", con))
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                var resultDia = DialogResult.None;
                resultDia = MessageBox.Show("Records successfully save!\nDo you want to show it ??", "Show Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (resultDia == DialogResult.Yes)
                {
                    Log_Viewer dbviewer = new Log_Viewer();
                    dbviewer.Show();
                }

                //MessageBox.Show("Records inserted.");
            }

            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex.Message);
            }
        }