Esempio n. 1
0
 public OrgPositionGroupType()
 {
     this.GroupTypeID   = -1;
     this.GroupTypeName = string.Empty;
     this.GroupType     = enumOrgPositionGroupType.Undefined;
 }
Esempio n. 2
0
        public void Include(int organizationChartID, int parentWFPPositionID, enumOrgPositionType orgPositionType, enumOrgPositionGroupType groupType, enumOrgPositionPlacementType placementType, List <int> positionIDList, int UpdatedByID)
        {
            if (base.ValidateKeyField(organizationChartID) && base.ValidateKeyField(parentWFPPositionID))
            {
                if (positionIDList != null && positionIDList.Count > 0)
                {
                    try
                    {
                        DbCommand commandWrapper = GetDbCommand("spr_IncludePositionsInOrgChart");

                        commandWrapper.Parameters.Add(new SqlParameter("@OrganizationChartID", organizationChartID));
                        commandWrapper.Parameters.Add(new SqlParameter("@ParentWFPPositionID", parentWFPPositionID));

                        if (orgPositionType == enumOrgPositionType.Undefined)
                        {
                            commandWrapper.Parameters.Add(new SqlParameter("@OrgPositionTypeID", DBNull.Value));
                        }
                        else
                        {
                            commandWrapper.Parameters.Add(new SqlParameter("@OrgPositionTypeID", (int)orgPositionType));
                        }

                        if (groupType == enumOrgPositionGroupType.Undefined)
                        {
                            commandWrapper.Parameters.Add(new SqlParameter("@GroupTypeID", DBNull.Value));
                        }
                        else
                        {
                            commandWrapper.Parameters.Add(new SqlParameter("@GroupTypeID", (int)groupType));
                        }

                        if (placementType == enumOrgPositionPlacementType.Undefined)
                        {
                            commandWrapper.Parameters.Add(new SqlParameter("@PlacementTypeID", DBNull.Value));
                        }
                        else
                        {
                            commandWrapper.Parameters.Add(new SqlParameter("@PlacementTypeID", (int)placementType));
                        }

                        DataTable parameterTable = new DataTable("ParameterTable");
                        int       rowCount       = 0;

                        // build table format
                        parameterTable.Columns.Add("ID", typeof(System.Int32));
                        parameterTable.Columns.Add("DataValue", typeof(System.Int32));

                        foreach (int itemValue in positionIDList)
                        {
                            parameterTable.Rows.Add(++rowCount, itemValue);
                        }

                        commandWrapper.Parameters.Add(new SqlParameter("@PositionIDList", parameterTable));
                        commandWrapper.Parameters.Add(new SqlParameter("@UpdatedByUserID", UpdatedByID));
                        ExecuteNonQuery(commandWrapper);
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message == "Circular Reference")
                        {
                            throw new CircularPositionReferenceException();
                        }
                        else if (ex.Message == "Invalid Position In List")
                        {
                            throw new InvalidChartPositionException();
                        }
                        else
                        {
                            HandleException(ex);
                        }
                    }
                }
            }
        }