Exemple #1
0
        private static void AddTestData()
        {
            Employee emp;

            for (int x = 1; x <= 6; x++)
            {
                emp = new Employee();
                emp.name = string.Empty;
                emp.employeeID = 1;
                emp.checkpointType = ((x % 2) == 0) ? "Egreso" : "Ingreso";
                emp.branchID = 20;
                emp.checkpointSnapshotID = 0;
                emp.reasons = string.Empty;
                emp.readerSerialNumber = Guid.NewGuid().ToString();
                CheckinBox.Add(emp);

                Thread.Sleep(2000);
            }
        }
Exemple #2
0
        public static object GetByGUID(string GUID)
        {
            Employee emp = new Employee();
            SqlCeConnection sqlConn = new SqlCeConnection();

            try
            {
                string sql = "SELECT name, employeeid, checkpointtype, branchid, checkpointsnapshotid, reasons, readerserialnumber, dateadd, dateupdate, GUID"
                    + " FROM EMPLOYEE WHERE GUID = 'GUID_VALUE'";
                sql = sql.Replace("GUID_VALUE", sqlFixStringValue(GUID));

                sqlConn.ConnectionString = GetConnectionString();
                sqlConn.Open();

                SqlCeCommand cmd = new SqlCeCommand(sql);

                cmd.Connection = sqlConn;
                SqlCeDataReader rdr = cmd.ExecuteReader();

                if (rdr.Read())
                {
                    emp.name = rdr.GetString(0);
                    emp.employeeID = rdr.GetInt32(1);
                    emp.checkpointType = rdr.GetString(2);
                    emp.branchID = rdr.GetInt32(3);
                    emp.checkpointSnapshotID = rdr.GetInt32(4);
                    emp.reasons = rdr.GetString(5);
                    emp.readerSerialNumber = rdr.GetString(6);
                    emp.dateAdd = rdr.GetDateTime(7);
                    emp.dateUpdate = rdr.GetDateTime(8);
                    emp.GUID = rdr.GetGuid(9).ToString();
                }

                sqlConn.Close();
            }
            catch (Exception ex)
            {
                if (sqlConn.State == ConnectionState.Open) sqlConn.Close();
                throw ex;
            }

            return (object)emp;
        }
Exemple #3
0
        public static List<object> GetAll()
        {
            List<object> result = new List<object>();
            SqlCeConnection sqlConn = new SqlCeConnection();

            try
            {
                string sql = "SELECT name, employeeid, checkpointtype, branchid, checkpointsnapshotid, reasons, readerserialnumber, dateadd, dateupdate, GUID FROM EMPLOYEE"
                        + " ORDER BY dateadd ASC";

                sqlConn.ConnectionString = GetConnectionString();
                sqlConn.Open();

                SqlCeCommand cmd = new SqlCeCommand(sql);
                cmd.Connection = sqlConn;
                SqlCeDataReader rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    Employee emp = new Employee();
                    emp.name = rdr.GetString(0);
                    emp.employeeID = rdr.GetInt32(1);
                    emp.checkpointType = rdr.GetString(2);
                    emp.branchID = rdr.GetInt32(3);
                    emp.checkpointSnapshotID = rdr.GetInt32(4);
                    emp.reasons = rdr.GetString(5);
                    emp.readerSerialNumber = rdr.GetString(6);
                    emp.dateAdd = rdr.GetDateTime(7);
                    emp.dateUpdate = rdr.GetDateTime(8);
                    emp.GUID = rdr.GetGuid(9).ToString();
                    result.Add(emp);
                }

                sqlConn.Close();
            }
            catch (Exception ex)
            {
                if (sqlConn.State == ConnectionState.Open) sqlConn.Close();
                throw ex;
            }

            return result;
        }