Ejemplo n.º 1
0
        private void btn_checkin_Click(object sender, EventArgs e)
        {
            /*   This method will record check-out time into database along with
             *   other attributes such as hostname, ip_address, etc. That is user details
             *   related to the machine he is using the application.
             */
            var culture = new CultureInfo("en-US"); // specific to English(United States)

            connectObject.ConnectionOpen();         // create connection with the database again for inserting
            try
            {
                checkin_time = localDate.ToString(culture); // considering current system date and time
                status       = "CHECKIN-SUCCESS";
                sql          = "insert into " + ConnectionClass.database + ".employee_details values (" + SunyID.ToString() + ",'" + checkin_time + "','','" + status + "','" + user_name + "','" + hostname + "','" + MAC_Address + "','" + IP_Address + "','" + domain_name + "','DXADMIN',now())";
                connectObject.ExecuteCommand(sql);

                btn_checkin.Enabled    = false;
                btn_checkin.ForeColor  = System.Drawing.Color.Black;
                btn_checkout.Enabled   = true;
                btn_checkout.ForeColor = System.Drawing.Color.Red;
                lbl_status.Text        = "Ready";
                lbl_status.ForeColor   = System.Drawing.Color.Black;
                CreateMailItem("CHECK-IN");

                MessageBox.Show("Check-IN time recorded for user - " + employee_name, "Time Management System");
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Error in Checking IN Functionality - " + ex.ToString(), "Time Management System");
            }
        }
Ejemplo n.º 2
0
        private void btn_checkout_Click(object sender, EventArgs e)
        {
            /*   This method will record check-in time into database along with
             *   other attributes such as hostname, ip_address, etc. That is user details
             *   related to the machine he is using the application.
             */
            var culture = new CultureInfo("en-US"); // specific to English(United States)

            localDate   = DateTime.Now;
            currentDate = localDate;
            strDateTime = "     Local date and time: " + localDate.ToString(culture) + " " + localDate.Kind;

            lbl_systime.Text = strDateTime; // display current system date and time according to the local setting
            connectObject.ConnectionOpen(); // create connection with the database again for inserting
            int result = 0;                 // local scope for only use in this param only

            try
            {
                //checkout_time = localDate.ToString(culture); // considering current system date and time
                checkout_time = currentDate.ToString(culture);
                sql           = "SELECT COUNT(*) FROM employee_details WHERE employeeid = " + SunyID.ToString() + " and status='CHECKIN-SUCCESS'";
                result        = Convert.ToInt32(connectObject.ExecuteScalar(sql));

                if (result > 0)
                {
                    status = "CHECKOUT-SUCCESS";
                    sql    = "update " + ConnectionClass.database + ".employee_details set checkout_time = '" + checkout_time + "', timestamp=now(),status='" + status + "' where employeeid=" + SunyID.ToString();
                    connectObject.ExecuteCommand(sql);

                    btn_checkin.Enabled    = false;
                    btn_checkin.ForeColor  = System.Drawing.Color.Black;
                    btn_checkout.Enabled   = false;
                    btn_checkout.ForeColor = System.Drawing.Color.Black;
                    lbl_status.Text        = "Checked out for the day!";
                    lbl_status.ForeColor   = System.Drawing.Color.Green;
                    CreateMailItem("CHECK-OUT");

                    MessageBox.Show("Check-OUT time recorded for user - " + employee_name, "Time Management System");
                }

                else if (result == 0)
                {
                    MessageBox.Show("No CHECK-IN record found - " + employee_name, "Time Management System");
                }
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Error in Checking Out Functionality - " + ex.ToString(), "Time Management System");
            }
        }
Ejemplo n.º 3
0
        private void txtBox_sunyid_KeyDown(object sender, KeyEventArgs e)
        {
            connectObject.ConnectionOpen();
            if (e.KeyData == Keys.Enter)
            {
                int result = 0;              // local scope for only use in this param only
                SunyID = txtBox_sunyid.Text; // assign textbox value to string variable
                try
                {
                    // validation process to check if the employee is a SUNY employee with valid SUNY ID
                    sql    = "SELECT COUNT(*) FROM employeeID WHERE employeeid = " + SunyID.ToString();
                    result = Convert.ToInt32(connectObject.ExecuteScalar(sql));
                    if (result > 0)
                    {
                        sql           = "SELECT employee_name FROM employeeID WHERE employeeid = " + SunyID.ToString();
                        employee_name = connectObject.ExecuteScalar(sql);

                        lbl_status.Text       = "Valid Employee";
                        lbl_status.ForeColor  = System.Drawing.Color.Green;
                        btn_checkin.Enabled   = true;
                        btn_checkin.ForeColor = System.Drawing.Color.Red;
                    }
                    else if (result == 0)
                    {
                        MessageBox.Show("Please enter valid SUNY ID", "Time Management System");
                    }
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show("Error in Authentication - " + ex.ToString(), "Time Management System");
                }
            }
            connectObject.ConnectionClose(); // Calls close connection method to close the connection made to the database
        }