Example #1
0
        private bool PunchIn()
        {
            //punchin a second time on same date only if they punched out the previous time
            if (sol_EmployeesLog.PunchInTime.ToShortDateString() == Main.rc.FechaActual.ToShortDateString())
            {
                if (sol_EmployeesLog.PunchOutTime.ToShortDateString() != sol_EmployeesLog.PunchInTime.ToShortDateString())
                {
                    MessageBox.Show("Cannot punch in the same date without punch out first!");
                    return(false);
                }
            }

            sol_EmployeesLog              = new Sol_EmployeesLog();
            sol_EmployeesLog.UserId       = userId;
            sol_EmployeesLog.PunchInTime  = Main.rc.FechaActual;
            sol_EmployeesLog.PunchOutTime = DateTime.Parse("1753-1-1 12:00:00");
            try
            {
                sol_EmployeesLog_Sp.Insert(sol_EmployeesLog);
            }
            catch (Exception e)
            {
                CajaDeMensaje.Show("", "Unable to Punch In, try again later please...", e.Message, CajaDeMensajeImagen.Error);
                return(false);
            }
            return(true);
        }
Example #2
0
        private void CheckLastPunch()
        {
            if (listBoxEmployees.SelectedValue == null)
            {
                return;
            }

            string[] resultPunchDatesString = new string[2];
            //DateTime[] resultDate;
            try { userId = (Guid)listBoxEmployees.SelectedValue; } catch { return; }

            try
            {
                sol_EmployeesLog = sol_EmployeesLog_Sp.LastPunch(userId.ToString());
                if (sol_EmployeesLog.PunchInTime.Year == 1753)
                {
                    resultPunchDatesString[0] = "<none>";
                }
                else
                {
                    resultPunchDatesString[0] = sol_EmployeesLog.PunchInTime.ToString();
                }

                if (sol_EmployeesLog.PunchOutTime.Year == 1753)
                {
                    resultPunchDatesString[1] = "<none>";
                }
                else
                {
                    resultPunchDatesString[1] = sol_EmployeesLog.PunchOutTime.ToString();
                }
            }
            catch
            {
                sol_EmployeesLog              = new Sol_EmployeesLog();
                sol_EmployeesLog.UserId       = userId;
                sol_EmployeesLog.PunchInTime  = DateTime.Parse("1753-1-1 12:00:00");
                sol_EmployeesLog.PunchOutTime = DateTime.Parse("1753-1-1 12:00:00");
                resultPunchDatesString[0]     = "<none>";
                resultPunchDatesString[1]     = "<none>";
            }

            //punch out
            if (resultPunchDatesString[1] != "<none>")
            {
                pictureBoxPunch.Image = Properties.Resources.Big_Red_Button;
                labelLasPunchOut.Text = "Last punch out: " + resultPunchDatesString[1];  //1 = last punch out
            }
            //punch in
            else
            {
                pictureBoxPunch.Image = Properties.Resources.Big_Green_Button;
                labelLasPunchOut.Text = "Last punch in: " + resultPunchDatesString[0];  //0 = last punch in
            }
        }
Example #3
0
        /// <summary>
        /// Creates a new instance of the Sol_EmployeesLog class and populates it with data from the specified SqlDataReader.
        /// </summary>
        protected virtual Sol_EmployeesLog MakeSol_EmployeesLog(SqlDataReader dataReader)
        {
            Sol_EmployeesLog sol_EmployeesLog = new Sol_EmployeesLog();

            sol_EmployeesLog.LogId        = SqlClientUtility.GetInt64(dataReader, "LogId", 0);
            sol_EmployeesLog.UserId       = SqlClientUtility.GetGuid(dataReader, "UserId", Guid.Empty);
            sol_EmployeesLog.PunchInTime  = SqlClientUtility.GetDateTime(dataReader, "PunchInTime", new DateTime(0));
            sol_EmployeesLog.PunchOutTime = SqlClientUtility.GetDateTime(dataReader, "PunchOutTime", new DateTime(0));
            sol_EmployeesLog.Comments     = SqlClientUtility.GetString(dataReader, "Comments", String.Empty);
            sol_EmployeesLog.Approved     = SqlClientUtility.GetBoolean(dataReader, "Approved", false);
            sol_EmployeesLog.Modified     = SqlClientUtility.GetBoolean(dataReader, "Modified", false);

            return(sol_EmployeesLog);
        }
Example #4
0
        /// <summary>
        /// Selects all records from the Sol_EmployeesLog table.
        /// </summary>
        public virtual List <Sol_EmployeesLog> SelectAll()
        {
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "Sol_EmployeesLog_SelectAll"))
            {
                List <Sol_EmployeesLog> sol_EmployeesLogList = new List <Sol_EmployeesLog>();
                while (dataReader.Read())
                {
                    Sol_EmployeesLog sol_EmployeesLog = MakeSol_EmployeesLog(dataReader);
                    sol_EmployeesLogList.Add(sol_EmployeesLog);
                }

                return(sol_EmployeesLogList);
            }
        }
Example #5
0
        /// <summary>
        /// Saves a record to the Sol_EmployeesLog table.
        /// </summary>
        public virtual void Insert(Sol_EmployeesLog sol_EmployeesLog)
        {
            ValidationUtility.ValidateArgument("sol_EmployeesLog", sol_EmployeesLog);

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@UserId", sol_EmployeesLog.UserId),
                new SqlParameter("@PunchInTime", sol_EmployeesLog.PunchInTime),
                new SqlParameter("@PunchOutTime", sol_EmployeesLog.PunchOutTime),
                new SqlParameter("@Comments", sol_EmployeesLog.Comments),
                new SqlParameter("@Approved", sol_EmployeesLog.Approved),
                new SqlParameter("@Modified", sol_EmployeesLog.Modified)
            };

            sol_EmployeesLog.LogId = (long)SqlClientUtility.ExecuteScalar(connectionStringName, CommandType.StoredProcedure, "Sol_EmployeesLog_Insert", parameters);
        }
Example #6
0
        /// <summary>
        /// Selects all records from the Sol_EmployeesLog table by a foreign key.
        /// </summary>
        public virtual List <Sol_EmployeesLog> _SelectAllByUserId(Guid userId)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@UserId", userId)
            };

            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "Sol_EmployeesLog_SelectAllByUserId", parameters))
            {
                List <Sol_EmployeesLog> sol_EmployeesLogList = new List <Sol_EmployeesLog>();
                while (dataReader.Read())
                {
                    Sol_EmployeesLog sol_EmployeesLog = MakeSol_EmployeesLog(dataReader);
                    sol_EmployeesLogList.Add(sol_EmployeesLog);
                }

                return(sol_EmployeesLogList);
            }
        }
Example #7
0
        private void Attendance_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dataSetEmployees.Sol_Employees_SelectAll' table. You can move, or remove it, as needed.
            this.sol_Employees_SelectAllTableAdapter.Fill(this.dataSetEmployees.Sol_Employees_SelectAll);
            if (Properties.Settings.Default.TouchOriented)
            {
                toolStripButtonVirtualKb.Visible = true;
            }

            // TODO: This line of code loads data into the 'dataSetEmployeesLookup.Sol_Employees' table. You can move, or remove it, as needed.
            this.sol_EmployeesTableAdapter.Fill(this.dataSetEmployeesLookup.Sol_Employees);

            controlWithFocus    = passwordTextBox;
            sol_EmployeesLog    = new Sol_EmployeesLog();
            sol_EmployeesLog_Sp = new Sol_EmployeesLog_Sp(Properties.Settings.Default.WsirConnectionString);

            //clock
            //this.timer1.Interval = 1000;
            //this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
            //timer1.Enabled = true;

            object obj1 = null;// toolStripStatusLabelToday;
            object obj2 = labelCurrentTimeTimer;

            Main.rc.CambiarControlFecha(ref obj1);
            Main.rc.CambiarControlHora(ref obj2);

            //select pre-selected employee
            if (itemIndex >= 0)
            {
                listBoxEmployees.SelectedIndex = itemIndex;
                passwordTextBox.Focus();
            }

            //last punch out
            if (listBoxEmployees.Items.Count > 0)
            {
                CheckLastPunch();
            }
        }