コード例 #1
0
        public static OrgEmployeesData Load(IdType orgEmployeesID)
        {
            WhereClause w = new WhereClause();

            w.And("OrgEmployeesID", orgEmployeesID.DBValue);
            SqlDataReader dataReader = GetListReader(DatabaseEnum.INTRANET, TABLE, w, null, true);

            if (!dataReader.Read())
            {
                dataReader.Close();
                throw new FinderException("Load found no rows for OrgEmployees.");
            }
            OrgEmployeesData data = GetDataObjectFromReader(dataReader);

            dataReader.Close();
            return(data);
        }
コード例 #2
0
        public static void Update(OrgEmployeesData data)
        {
            // Create and execute the command
            OrgEmployeesData oldData = Load(data.OrgEmployeesID);
            string           sql     = "Update " + TABLE + " set ";

            if (!oldData.OrgDepartmentsID.Equals(data.OrgDepartmentsID))
            {
                sql = sql + "OrgDepartmentsID=@OrgDepartmentsID,";
            }
            if (!oldData.OrgLocationsID.Equals(data.OrgLocationsID))
            {
                sql = sql + "OrgLocationsID=@OrgLocationsID,";
            }
            if (!oldData.OrgWorkspacesID.Equals(data.OrgWorkspacesID))
            {
                sql = sql + "OrgWorkspacesID=@OrgWorkspacesID,";
            }
            if (!oldData.FirstName.Equals(data.FirstName))
            {
                sql = sql + "FirstName=@FirstName,";
            }
            if (!oldData.LastName.Equals(data.LastName))
            {
                sql = sql + "LastName=@LastName,";
            }
            if (!oldData.NTUserAccount.Equals(data.NTUserAccount))
            {
                sql = sql + "NTUserAccount=@NTUserAccount,";
            }
            if (!oldData.IsActive.Equals(data.IsActive))
            {
                sql = sql + "IsActive=@IsActive,";
            }
            if (!oldData.Email.Equals(data.Email))
            {
                sql = sql + "Email=@Email,";
            }
            if (!oldData.EmployeeTitle.Equals(data.EmployeeTitle))
            {
                sql = sql + "EmployeeTitle=@EmployeeTitle,";
            }
            if (!oldData.DateHired.Equals(data.DateHired))
            {
                sql = sql + "DateHired=@DateHired,";
            }
            if (!oldData.DateTerminated.Equals(data.DateTerminated))
            {
                sql = sql + "DateTerminated=@DateTerminated,";
            }
            if (!oldData.Manager.Equals(data.Manager))
            {
                sql = sql + "Manager=@Manager,";
            }
            if (!oldData.EmployeeNumber.Equals(data.EmployeeNumber))
            {
                sql = sql + "EmployeeNumber=@EmployeeNumber,";
            }
            if (!oldData.Style.Equals(data.Style))
            {
                sql = sql + "Style=@Style,";
            }
            if (!oldData.Map.Equals(data.Map))
            {
                sql = sql + "Map=@Map,";
            }
            if (!oldData.MapX.Equals(data.MapX))
            {
                sql = sql + "MapX=@MapX,";
            }
            if (!oldData.MapY.Equals(data.MapY))
            {
                sql = sql + "MapY=@MapY,";
            }
            WhereClause w = new WhereClause();

            w.And("OrgEmployeesID", data.OrgEmployeesID.DBValue);
            sql = sql.Substring(0, sql.Length - 1) + w.FormatSql();
            SqlCommand cmd = GetSqlCommand(DatabaseEnum.INTRANET, sql, CommandType.Text, COMMAND_TIMEOUT);

            //Create the parameters and append them to the command object
            if (!oldData.OrgEmployeesID.Equals(data.OrgEmployeesID))
            {
                cmd.Parameters.Add(new SqlParameter("@OrgEmployeesID", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "OrgEmployeesID", DataRowVersion.Proposed, data.OrgEmployeesID.DBValue));
            }
            if (!oldData.OrgDepartmentsID.Equals(data.OrgDepartmentsID))
            {
                cmd.Parameters.Add(new SqlParameter("@OrgDepartmentsID", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "OrgDepartmentsID", DataRowVersion.Proposed, data.OrgDepartmentsID.DBValue));
            }
            if (!oldData.OrgLocationsID.Equals(data.OrgLocationsID))
            {
                cmd.Parameters.Add(new SqlParameter("@OrgLocationsID", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "OrgLocationsID", DataRowVersion.Proposed, data.OrgLocationsID.DBValue));
            }
            if (!oldData.OrgWorkspacesID.Equals(data.OrgWorkspacesID))
            {
                cmd.Parameters.Add(new SqlParameter("@OrgWorkspacesID", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "OrgWorkspacesID", DataRowVersion.Proposed, data.OrgWorkspacesID.DBValue));
            }
            if (!oldData.FirstName.Equals(data.FirstName))
            {
                cmd.Parameters.Add(new SqlParameter("@FirstName", SqlDbType.VarChar, 30, ParameterDirection.Input, false, 0, 0, "FirstName", DataRowVersion.Proposed, data.FirstName.DBValue));
            }
            if (!oldData.LastName.Equals(data.LastName))
            {
                cmd.Parameters.Add(new SqlParameter("@LastName", SqlDbType.VarChar, 30, ParameterDirection.Input, false, 0, 0, "LastName", DataRowVersion.Proposed, data.LastName.DBValue));
            }
            if (!oldData.NTUserAccount.Equals(data.NTUserAccount))
            {
                cmd.Parameters.Add(new SqlParameter("@NTUserAccount", SqlDbType.VarChar, 20, ParameterDirection.Input, false, 0, 0, "NTUserAccount", DataRowVersion.Proposed, data.NTUserAccount.DBValue));
            }
            if (!oldData.IsActive.Equals(data.IsActive))
            {
                cmd.Parameters.Add(new SqlParameter("@IsActive", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, "IsActive", DataRowVersion.Proposed, !data.IsActive.IsValid ? data.IsActive.DBValue : data.IsActive.DBValue.Equals("Y") ? 1 : 0));
            }
            if (!oldData.Email.Equals(data.Email))
            {
                cmd.Parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar, 30, ParameterDirection.Input, false, 0, 0, "Email", DataRowVersion.Proposed, data.Email.DBValue));
            }
            if (!oldData.EmployeeTitle.Equals(data.EmployeeTitle))
            {
                cmd.Parameters.Add(new SqlParameter("@EmployeeTitle", SqlDbType.VarChar, 100, ParameterDirection.Input, false, 0, 0, "EmployeeTitle", DataRowVersion.Proposed, data.EmployeeTitle.DBValue));
            }
            if (!oldData.DateHired.Equals(data.DateHired))
            {
                cmd.Parameters.Add(new SqlParameter("@DateHired", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, "DateHired", DataRowVersion.Proposed, data.DateHired.DBValue));
            }
            if (!oldData.DateTerminated.Equals(data.DateTerminated))
            {
                cmd.Parameters.Add(new SqlParameter("@DateTerminated", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, "DateTerminated", DataRowVersion.Proposed, data.DateTerminated.DBValue));
            }
            if (!oldData.Manager.Equals(data.Manager))
            {
                cmd.Parameters.Add(new SqlParameter("@Manager", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "Manager", DataRowVersion.Proposed, data.Manager.DBValue));
            }
            if (!oldData.EmployeeNumber.Equals(data.EmployeeNumber))
            {
                cmd.Parameters.Add(new SqlParameter("@EmployeeNumber", SqlDbType.VarChar, 30, ParameterDirection.Input, false, 0, 0, "EmployeeNumber", DataRowVersion.Proposed, data.EmployeeNumber.DBValue));
            }
            if (!oldData.Style.Equals(data.Style))
            {
                cmd.Parameters.Add(new SqlParameter("@Style", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "Style", DataRowVersion.Proposed, data.Style.DBValue));
            }
            if (!oldData.Map.Equals(data.Map))
            {
                cmd.Parameters.Add(new SqlParameter("@Map", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "Map", DataRowVersion.Proposed, data.Map.DBValue));
            }
            if (!oldData.MapX.Equals(data.MapX))
            {
                cmd.Parameters.Add(new SqlParameter("@MapX", SqlDbType.Float, 0, ParameterDirection.Input, false, 0, 0, "MapX", DataRowVersion.Proposed, data.MapX.DBValue));
            }
            if (!oldData.MapY.Equals(data.MapY))
            {
                cmd.Parameters.Add(new SqlParameter("@MapY", SqlDbType.Float, 0, ParameterDirection.Input, false, 0, 0, "MapY", DataRowVersion.Proposed, data.MapY.DBValue));
            }

            // Execute the query
            if (cmd.Parameters.Count > 0)
            {
                cmd.ExecuteNonQuery();
            }
        }
コード例 #3
0
        public static IdType Insert(OrgEmployeesData data)
        {
            // Create and execute the command
            string sql = "Insert Into " + TABLE + "("
                         + "OrgDepartmentsID,"
                         + "OrgLocationsID,"
                         + "OrgWorkspacesID,"
                         + "FirstName,"
                         + "LastName,"
                         + "NTUserAccount,"
                         + "IsActive,"
                         + "Email,"
                         + "EmployeeTitle,"
                         + "DateHired,"
                         + "DateTerminated,"
                         + "Manager,"
                         + "EmployeeNumber,"
                         + "Style,"
                         + "Map,"
                         + "MapX,"
                         + "MapY,"
            ;

            sql = sql.Substring(0, sql.Length - 1) + ") values("
                  + "@OrgDepartmentsID,"
                  + "@OrgLocationsID,"
                  + "@OrgWorkspacesID,"
                  + "@FirstName,"
                  + "@LastName,"
                  + "@NTUserAccount,"
                  + "@IsActive,"
                  + "@Email,"
                  + "@EmployeeTitle,"
                  + "@DateHired,"
                  + "@DateTerminated,"
                  + "@Manager,"
                  + "@EmployeeNumber,"
                  + "@Style,"
                  + "@Map,"
                  + "@MapX,"
                  + "@MapY,"
            ;
            sql = sql.Substring(0, sql.Length - 1) + ");select Scope_Identity() Id";
            SqlCommand cmd = GetSqlCommand(DatabaseEnum.INTRANET, sql, CommandType.Text, COMMAND_TIMEOUT);

            //Create the parameters and append them to the command object
            cmd.Parameters.Add(new SqlParameter("@OrgDepartmentsID", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "OrgDepartmentsID", DataRowVersion.Proposed, data.OrgDepartmentsID.DBValue));
            cmd.Parameters.Add(new SqlParameter("@OrgLocationsID", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "OrgLocationsID", DataRowVersion.Proposed, data.OrgLocationsID.DBValue));
            cmd.Parameters.Add(new SqlParameter("@OrgWorkspacesID", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "OrgWorkspacesID", DataRowVersion.Proposed, data.OrgWorkspacesID.DBValue));
            cmd.Parameters.Add(new SqlParameter("@FirstName", SqlDbType.VarChar, 30, ParameterDirection.Input, false, 0, 0, "FirstName", DataRowVersion.Proposed, data.FirstName.DBValue));
            cmd.Parameters.Add(new SqlParameter("@LastName", SqlDbType.VarChar, 30, ParameterDirection.Input, false, 0, 0, "LastName", DataRowVersion.Proposed, data.LastName.DBValue));
            cmd.Parameters.Add(new SqlParameter("@NTUserAccount", SqlDbType.VarChar, 20, ParameterDirection.Input, false, 0, 0, "NTUserAccount", DataRowVersion.Proposed, data.NTUserAccount.DBValue));
            cmd.Parameters.Add(new SqlParameter("@IsActive", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, "IsActive", DataRowVersion.Proposed, !data.IsActive.IsValid ? data.IsActive.DBValue : data.IsActive.DBValue.Equals("Y") ? 1 : 0));
            cmd.Parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar, 30, ParameterDirection.Input, false, 0, 0, "Email", DataRowVersion.Proposed, data.Email.DBValue));
            cmd.Parameters.Add(new SqlParameter("@EmployeeTitle", SqlDbType.VarChar, 100, ParameterDirection.Input, false, 0, 0, "EmployeeTitle", DataRowVersion.Proposed, data.EmployeeTitle.DBValue));
            cmd.Parameters.Add(new SqlParameter("@DateHired", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, "DateHired", DataRowVersion.Proposed, data.DateHired.DBValue));
            cmd.Parameters.Add(new SqlParameter("@DateTerminated", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, "DateTerminated", DataRowVersion.Proposed, data.DateTerminated.DBValue));
            cmd.Parameters.Add(new SqlParameter("@Manager", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "Manager", DataRowVersion.Proposed, data.Manager.DBValue));
            cmd.Parameters.Add(new SqlParameter("@EmployeeNumber", SqlDbType.VarChar, 30, ParameterDirection.Input, false, 0, 0, "EmployeeNumber", DataRowVersion.Proposed, data.EmployeeNumber.DBValue));
            cmd.Parameters.Add(new SqlParameter("@Style", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "Style", DataRowVersion.Proposed, data.Style.DBValue));
            cmd.Parameters.Add(new SqlParameter("@Map", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "Map", DataRowVersion.Proposed, data.Map.DBValue));
            cmd.Parameters.Add(new SqlParameter("@MapX", SqlDbType.Float, 0, ParameterDirection.Input, false, 0, 0, "MapX", DataRowVersion.Proposed, data.MapX.DBValue));
            cmd.Parameters.Add(new SqlParameter("@MapY", SqlDbType.Float, 0, ParameterDirection.Input, false, 0, 0, "MapY", DataRowVersion.Proposed, data.MapY.DBValue));

            // Execute the query
            SqlDataReader returnValue = cmd.ExecuteReader();

            returnValue.Read();
            int returnId = (int)(returnValue.GetDecimal(0));

            returnValue.Close();
            // Set the output paramter value(s)
            return(new IdType(returnId));
        }
コード例 #4
0
        private static OrgEmployeesData GetDataObjectFromReader(SqlDataReader dataReader)
        {
            OrgEmployeesData data = new OrgEmployeesData();

            if (dataReader.IsDBNull(dataReader.GetOrdinal("OrgEmployeesID")))
            {
                data.OrgEmployeesID = IdType.UNSET;
            }
            else
            {
                data.OrgEmployeesID = new IdType(dataReader.GetInt32(dataReader.GetOrdinal("OrgEmployeesID")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("OrgDepartmentsID")))
            {
                data.OrgDepartmentsID = IntegerType.UNSET;
            }
            else
            {
                data.OrgDepartmentsID = new IntegerType(dataReader.GetInt32(dataReader.GetOrdinal("OrgDepartmentsID")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("OrgLocationsID")))
            {
                data.OrgLocationsID = IntegerType.UNSET;
            }
            else
            {
                data.OrgLocationsID = new IntegerType(dataReader.GetInt32(dataReader.GetOrdinal("OrgLocationsID")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("OrgWorkspacesID")))
            {
                data.OrgWorkspacesID = IntegerType.UNSET;
            }
            else
            {
                data.OrgWorkspacesID = new IntegerType(dataReader.GetInt32(dataReader.GetOrdinal("OrgWorkspacesID")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("FirstName")))
            {
                data.FirstName = StringType.UNSET;
            }
            else
            {
                data.FirstName = StringType.Parse(dataReader.GetString(dataReader.GetOrdinal("FirstName")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("LastName")))
            {
                data.LastName = StringType.UNSET;
            }
            else
            {
                data.LastName = StringType.Parse(dataReader.GetString(dataReader.GetOrdinal("LastName")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("NTUserAccount")))
            {
                data.NTUserAccount = StringType.UNSET;
            }
            else
            {
                data.NTUserAccount = StringType.Parse(dataReader.GetString(dataReader.GetOrdinal("NTUserAccount")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("IsActive")))
            {
                data.IsActive = BooleanType.UNSET;
            }
            else
            {
                data.IsActive = BooleanType.GetInstance(dataReader.GetBoolean(dataReader.GetOrdinal("IsActive")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("Email")))
            {
                data.Email = StringType.UNSET;
            }
            else
            {
                data.Email = StringType.Parse(dataReader.GetString(dataReader.GetOrdinal("Email")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("EmployeeTitle")))
            {
                data.EmployeeTitle = StringType.UNSET;
            }
            else
            {
                data.EmployeeTitle = StringType.Parse(dataReader.GetString(dataReader.GetOrdinal("EmployeeTitle")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("DateHired")))
            {
                data.DateHired = DateType.UNSET;
            }
            else
            {
                data.DateHired = new DateType(dataReader.GetDateTime(dataReader.GetOrdinal("DateHired")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("DateTerminated")))
            {
                data.DateTerminated = DateType.UNSET;
            }
            else
            {
                data.DateTerminated = new DateType(dataReader.GetDateTime(dataReader.GetOrdinal("DateTerminated")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("Manager")))
            {
                data.Manager = IntegerType.UNSET;
            }
            else
            {
                data.Manager = new IntegerType(dataReader.GetInt32(dataReader.GetOrdinal("Manager")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("EmployeeNumber")))
            {
                data.EmployeeNumber = StringType.UNSET;
            }
            else
            {
                data.EmployeeNumber = StringType.Parse(dataReader.GetString(dataReader.GetOrdinal("EmployeeNumber")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("Style")))
            {
                data.Style = StringType.UNSET;
            }
            else
            {
                data.Style = StringType.Parse(dataReader.GetString(dataReader.GetOrdinal("Style")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("Map")))
            {
                data.Map = StringType.UNSET;
            }
            else
            {
                data.Map = StringType.Parse(dataReader.GetString(dataReader.GetOrdinal("Map")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("MapX")))
            {
                data.MapX = DecimalType.UNSET;
            }
            else
            {
                data.MapX = new DecimalType(dataReader.GetDouble(dataReader.GetOrdinal("MapX")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("MapY")))
            {
                data.MapY = DecimalType.UNSET;
            }
            else
            {
                data.MapY = new DecimalType(dataReader.GetDouble(dataReader.GetOrdinal("MapY")));
            }

            return(data);
        }