private void Af_FormClosed(object sender, FormClosedEventArgs e) { if (oc.hasConnection()) { LoadHolidays(); } else { MetroFramework.MetroMessageBox.Show(this, "Couldn't connect to Internet !!!\nTry agan...", "ERROR !!!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_Update_Click(object sender, EventArgs e) { if (!isValid()) { return; } if (!oc.hasConnection()) { MetroFramework.MetroMessageBox.Show(this, "No Internet Connection !!!", "ERROR !!!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string sex = Male_Radio.Checked ? "Male" : Female_Radio.Checked ? "Female" : "Other"; q = "UPDATE employee SET name='" + name_text.Text + "', sex='" + sex + "', address='" + address_text.Text + "', rank='" + rank_text.Text + "', holiday='" + holis + "', shift_start='" + shiftStart.Text + "', shift_end='" + shiftEnd.Text + "' WHERE id='" + id.ToString() + "'"; sf = false; using (WaitForm wf = new WaitForm(waitAndUpadate, "Updating...")) { wf.ShowDialog(); } if (sf) { Employees.v = 1; MetroFramework.MetroMessageBox.Show(this, "Successfully Updated", "SUCCESS !!!", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } else { Employees.v = -1; MetroFramework.MetroMessageBox.Show(this, "Update Failed", "ERROR !!!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_empty_database_Click(object sender, EventArgs e) { if (!checkDevice()) { return; } if (MetroFramework.MetroMessageBox.Show(this, "You are about to clear the entire database\nAre you sure you want to proceed ?", "Warning !!!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { if (!oc.hasConnection()) { MetroFramework.MetroMessageBox.Show(this, "Error\nNo Internet Connection !!!", "STOP", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string ds = deviceBuilding.Substring(0, 3); string q1 = "DELETE FROM employee WHERE building_id='" + ds + "'"; string q2 = "DELETE FROM attendance WHERE building_id='" + ds + "'"; string q3 = "DELETE FROM leaves WHERE building_id='" + ds + "'"; if (!oc.insert(q1) || !oc.insert(q2) || !oc.insert(q3)) { MetroFramework.MetroMessageBox.Show(this, "Error\nCouldn't empty online database !!!\nMay be it's partially hampered.\nTry agan...", "STOP", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!dc.send("EMPTY\n")) { MetroFramework.MetroMessageBox.Show(this, "Error\nDevice may not be connected", "STOP", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string w = dc.wait(); if (w != "OK") { MetroFramework.MetroMessageBox.Show(this, "Error\n" + w, "STOP", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string t = dc.get(); if (t.Equals("Success")) { MetroFramework.MetroMessageBox.Show(this, "Success !!!\nDatabase Cleared", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MetroFramework.MetroMessageBox.Show(this, "Error\n" + t, "STOP", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btn_Send_server_Click(object sender, EventArgs e) { if (!isValid()) { return; } if (!oc.hasConnection()) { MetroFramework.MetroMessageBox.Show(this, "No Internet Connection :(", "STOP !!!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } sf = false; string sex = male_radio.Checked ? "Male" : female_radio.Checked ? "Female" : "Other"; string ff = fid.ToString(); if (fid < 10) { ff = "00" + ff; } else if (fid < 100) { ff = "0" + ff; } q = "INSERT INTO employee (name, sex, address, building, building_id, rank, fid, holiday, shift_start, shift_end) VALUES ('" + name_text.Text + "', '" + sex + "', '" + address_text.Text + "', '" + workingbuildingText.Text + "', '" + workingbuildingText.Text.Substring(0, 3) + "', '" + rank_box.Text + "', '" + deviceBuilding.Substring(0, 3) + ff + "', '" + holis + "', '" + shiftStart.Text + "', '" + shiftEnd.Text + "')"; using (WaitForm wf = new WaitForm(waitAndSend, "Registering...")) { wf.ShowDialog(); } if (!sf) { MetroFramework.MetroMessageBox.Show(this, "Sending Failed :(", "STOP !!!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } MetroFramework.MetroMessageBox.Show(this, "Saved successfully :)", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information); reset(); }
private void btn_Add_Click(object sender, EventArgs e) { DateTime sdt, edt; try { name_text.Text = name_text.Text.Trim(); if (name_text.Text.Length == 0) { MetroFramework.MetroMessageBox.Show(this, "Invalid Name !", "Warning !", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (sMonthBox.Text == "" || sDateBox.Text == "" || eMonthBox.Text == "" || eDateBox.Text == "") { MetroFramework.MetroMessageBox.Show(this, "Invalid Months/Dates !", "Warning !", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } sdt = new DateTime(2000, sMonthBox.SelectedIndex + 1, Convert.ToInt32(sDateBox.SelectedItem)); edt = new DateTime(2000, eMonthBox.SelectedIndex + 1, Convert.ToInt32(eDateBox.SelectedItem)); if (sdt > edt) { MetroFramework.MetroMessageBox.Show(this, "Start date can't be greater than End date !", "STOP !!!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!oc.hasConnection()) { MetroFramework.MetroMessageBox.Show(this, "Couldn't connect to internet !!!\nTry agan...", "STOP !!!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } done = false; if (sdt.Day < 10) { ss = "0" + sdt.Day.ToString(); } else { ss = sdt.Day.ToString(); } ss += "/"; if (sdt.Month < 10) { ss += ("0" + sdt.Month.ToString()); } else { ss += sdt.Month.ToString(); } if (edt.Day < 10) { ee = "0" + edt.Day.ToString(); } else { ee = edt.Day.ToString(); } ee += "/"; if (edt.Month < 10) { ee += ("0" + edt.Month.ToString()); } else { ee += edt.Month.ToString(); } //q = "INSERT INTO holidays (holiday_name, start_date, end_date) VALUES ('" + name_text.Text + "', '" + ss + "', '" + ee + "')"; q = "UPDATE holidays SET holiday_name='" + name_text.Text + "', start_date='" + ss + "', end_date='" + ee + "' WHERE id='" + id.ToString() + "'"; using (var wf = new WaitForm(performAction, "Updating...")) { wf.ShowDialog(); } if (done) { //MessageBox.Show(""); MetroFramework.MetroMessageBox.Show(this, "Holiday updated successfully :)", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } else { MetroFramework.MetroMessageBox.Show(this, "Updating Failed... !!!\nTry agan...", "ERROR !!!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }