예제 #1
0
        private void LoadData()
        {
            try
            {
                Label_Wait.Visible = true;
                dataGrid.Visible   = false;

                using (WaitForm wf = new WaitForm(waitAndLoad))
                {
                    wf.ShowDialog();
                }
                dataGrid.DataSource = dt;
                extractHolidays();
                dataGrid.AutoResizeColumns();
                dataGrid.AutoResizeColumn(4);
                Label_Wait.Visible             = false;
                dataGrid.Visible               = true;
                dataGrid.Columns["id"].Visible = false;
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, ex.Message, "ERROR !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        private void btn_Grant_Click(object sender, EventArgs e)
        {
            string   s  = sDateTime.Value.ToString("dd-MM-yyyy");
            string   t  = eDateTime.Value.ToString("dd-MM-yyyy");
            DateTime sd = new DateTime(Convert.ToInt32(s.Substring(6, 4)), Convert.ToInt32(s.Substring(3, 2)), Convert.ToInt32(s.Substring(0, 2)));
            DateTime ed = new DateTime(Convert.ToInt32(t.Substring(6, 4)), Convert.ToInt32(t.Substring(3, 2)), Convert.ToInt32(t.Substring(0, 2)));

            if (sd > ed)
            {
                MetroFramework.MetroMessageBox.Show(this, "Start date can't be later than end date !", "STOP !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            done = false;
            //performAction();
            using (var wf = new WaitForm(performAction, "Performing..."))
            {
                wf.ShowDialog();
            }
            if (done)
            {
                MetroFramework.MetroMessageBox.Show(this, "Leave Granted :)", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Close();
            }
            else
            {
                MetroFramework.MetroMessageBox.Show(this, "Couldn't connect\nPlease try again...", "STOP !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
 private void btn_Delete_Click(object sender, EventArgs e)
 {
     if (deviceBuilding == "")
     {
         //MessageBox.Show("No supported device found");
         MetroFramework.MetroMessageBox.Show(this, "No supported device found", "ERROR !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (dataGrid.RowCount < 1)
     {
         return;
     }
     if (MetroFramework.MetroMessageBox.Show(this, "Are you sure you want to delete this employee?", "WARNING !!!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes)
     {
         return;
     }
     df = 0;
     using (WaitForm wf = new WaitForm(performDelete, "Deleting..."))
     {
         wf.ShowDialog();
     }
     if (df == 2)
     {
         MetroFramework.MetroMessageBox.Show(this, "Deleted", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         LoadData();
     }
     else if (df == 1)
     {
         MetroFramework.MetroMessageBox.Show(this, "Couldn't delete from device", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         MetroFramework.MetroMessageBox.Show(this, "Couldn't delete !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #4
0
 private void btn_Delete_Click(object sender, EventArgs e)
 {
     if (dataGrid.RowCount < 1)
     {
         return;
     }
     if (MetroFramework.MetroMessageBox.Show(this, "Are you sure you want to delete this holiday ?", "Warning !!!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes)
     {
         return;
     }
     //if (MessageBox.Show("Are you sure you want to delete this holiday ?", "Warning", MessageBoxButtons.YesNo) != DialogResult.Yes)
     //return;
     q    = "DELETE FROM holidays WHERE id='" + dataGrid.SelectedRows[0].Cells["id"].Value.ToString() + "'";
     done = false;
     using (var wf = new WaitForm(performeDelete, "Deleting..."))
     {
         wf.FormClosed += Wf_FormClosed;
         wf.ShowDialog();
     }
     if (done)
     {
         MetroFramework.MetroMessageBox.Show(this, "The holiday has been deleted", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MetroFramework.MetroMessageBox.Show(this, "Couldn't delete...", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
예제 #5
0
        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);
            }
        }
예제 #6
0
 public bool hasConnection()
 {
     hc = false;
     using (WaitForm wf = new WaitForm(check, "Connecting..."))
     {
         wf.ShowDialog();
     }
     return(hc);
 }
예제 #7
0
 private void LoadHolidays()
 {
     dataGrid.Visible = false;
     dt = null;
     using (var wf = new WaitForm(WaitAndLoad, "Loading..."))
     {
         wf.ShowDialog();
     }
     if (dt == null)
     {
         MetroFramework.MetroMessageBox.Show(this, "Data Loading Failed !", "ERROR !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Close();
         return;
     }
     dataGrid.DataSource = dt;
     dataGrid.Visible    = true;
     dataGrid.AutoResizeColumns();
 }
예제 #8
0
        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();
        }
예제 #9
0
        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);
            }
        }