コード例 #1
0
        public static List <EmployeeDevice> GetEmployeeDeviceList(int employeeId)
        {
            List <EmployeeDevice> list = new List <EmployeeDevice>();

            Database  db         = DatabaseFactory.CreateDatabase("Spar-StoreRep");
            string    sqlCommand = "GetEmployeeDeviceList";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "@EmployeeId", DbType.Int32, employeeId);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    EmployeeDevice employeeDevice = new EmployeeDevice();
                    employeeDevice.EmployeeDeviceId = Convert.ToInt32(dataReader["EmployeeDeviceId"]);
                    employeeDevice.EmployeeId       = Convert.ToInt32(dataReader["EmployeeId"]);
                    employeeDevice.Description      = dataReader["Description"].ToString();
                    employeeDevice.Mobile           = dataReader["Mobile"].ToString();
                    employeeDevice.SIM           = dataReader["SIM"].ToString();
                    employeeDevice.IMEI          = dataReader["IMEI"].ToString();
                    employeeDevice.PUCK          = dataReader["PUCK"].ToString();
                    employeeDevice.Serial        = dataReader["Serial"].ToString();
                    employeeDevice.DeviceType    = dataReader["DeviceType"].ToString();
                    employeeDevice.MobileNetwork = dataReader["MobileNetwork"].ToString();
                    employeeDevice.DateReceived  = Convert.ToDateTime(dataReader["DateReceived"]);
                    employeeDevice.DeviceId      = Convert.ToInt32(dataReader["DeviceId"]);

                    list.Add(employeeDevice);
                }
            }
            return(list);
        }
コード例 #2
0
        public static EmployeeDevice GetEmployeeDeviceByEmployeeDeviceId(int employeeDeviceId)
        {
            Database  db         = DatabaseFactory.CreateDatabase("Spar-StoreRep");
            string    sqlCommand = "GetEmployeeDeviceByEmployeeDeviceId";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "@EmployeeDeviceId", DbType.Int32, employeeDeviceId);
            db.AddOutParameter(dbCommand, "@EmployeeId", DbType.Int32, 4);
            db.AddOutParameter(dbCommand, "@DeviceId", DbType.Int32, 4);
            db.AddOutParameter(dbCommand, "@DateReceived", DbType.DateTime, 8);

            db.ExecuteNonQuery(dbCommand);
            EmployeeDevice employeeDevice = new EmployeeDevice();

            employeeDevice.EmployeeDeviceId = employeeDeviceId;
            employeeDevice.EmployeeId       = Convert.ToInt32(db.GetParameterValue(dbCommand, "EmployeeId"));
            employeeDevice.DeviceId         = Convert.ToInt32(db.GetParameterValue(dbCommand, "DeviceId"));
            employeeDevice.DateReceived     = Convert.ToDateTime(db.GetParameterValue(dbCommand, "DateReceived"));

            return(employeeDevice);
        }