Ejemplo n.º 1
0
 /// <summary>
 /// Getting the custom fields data from EquipData table
 /// </summary>
 /// <param name="bIsComponent">The boolean argument using for defining owner of data: the Equipment or the its component.</param>
 /// <param name="iTypeId">The integer argument for defining type of data</param>
 /// <param name="sContext_User_Identity">The Org string</param>
 /// <returns>Return the array containing data of custom fields in the clsCustomFieldsDef classes</returns>
 public static ArrayList GetCustomFields(CFDataType cfdDataTypeId, int iTypeId, string sContext_User_Identity)
 {
     ArrayList arrCFD = null;
     clsCustomFieldsDef cfd = null;
     clsCustFields custfield = null;
     DataTable dtFields = null;
     try
     {
         custfield = new clsCustFields();
         arrCFD = new ArrayList();
         custfield.iOrgId = GetUserOrgId(sContext_User_Identity, false);
         custfield.iDataTypeId = (int)cfdDataTypeId;
         custfield.iComponentTypeID = (SqlInt32)iTypeId;
         dtFields = custfield.GetCustFields();
         if(dtFields.Rows.Count == 0)
         {
             return null;
         }
         for(int i = 0; i < dtFields.Rows.Count; i++)
         {
             cfd = new clsCustomFieldsDef();
             cfd.Id = Convert.ToInt32(dtFields.Rows[i]["Id"]);
             cfd.NumberColumn = Convert.ToInt32(dtFields.Rows[i]["NumberColumn"]);
             cfd.Name = Convert.ToString(dtFields.Rows[i]["vchName"]);
             cfd.NameText = Convert.ToString(dtFields.Rows[i]["vchNameText"]);
             cfd.NameLookupTable = Convert.ToString(dtFields.Rows[i]["vchNameLookupTable"]);
             cfd.NameFieldLookup = Convert.ToString(dtFields.Rows[i]["vchNameFieldLookup"]);
             cfd.Required = Convert.ToBoolean(dtFields.Rows[i]["btRequired"]);
             cfd.FieldTypeId = (DBFieldType)Convert.ToInt32(dtFields.Rows[i]["intFieldTypeId"]);
             cfd.Default = Convert.ToString(dtFields.Rows[i]["vchDefault"]);
             cfd.Help = Convert.ToString(dtFields.Rows[i]["vchHelp"]);
             arrCFD.Add(cfd);
             cfd = null;
         }
         return arrCFD;
     }
     catch(Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
     finally
     {
         if(custfield != null)
         {
             custfield.Dispose();
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Parsing the data string from EquipData table for defining the custom fields
        /// The function doesn't using in the application by now.
        /// </summary>
        /// <param name="dtInput">The DataTable containing data of one record of EquipData table of database</param>
        /// <param name="iTypeId">The type of equipment</param>
        /// <returns>Return the array containing data of custom fields in the clsCustomFieldsDef classes</returns>
        public static ArrayList CustomFieldsParse(DataTable dtInput, int iTypeId)
        {
            int j;
            ArrayList arrCFD = null;
            clsCustomFieldsDef cfd = null;
            clsCustFields custfield = null;
            try
            {
                custfield = new clsCustFields();
                arrCFD = new ArrayList();
                custfield.cAction = "S";
                custfield.iOrgId = 1; // will change
                // processing nvarchar's fields type
                for(j = 1; j <= MAXFIELDS.MAX_NVARCHAR; j++)
                {
                    if( dtInput.Rows[0]["nvarchar" + j.ToString()] != DBNull.Value)
                    {
                        cfd = new clsCustomFieldsDef();
                        cfd.FieldTypeId = DBFieldType._nvarchar;
                        custfield.iFieldTypeId = (int)DBFieldType._nvarchar;
                        cfd.NumberColumn = j;
                        custfield.iNumberColumn = j;

                        cfd.IsComponent = false;
                        custfield.bitIsComponent = false;
                        cfd.ComponentTypeID = iTypeId;
                        custfield.iComponentTypeID = iTypeId;
                        custfield.CustFieldsEquipment();
                        cfd.Id = custfield.iId.Value;
                        cfd.Name = custfield.sName.Value;
                        cfd.NameText = custfield.sNameText.Value;
                        cfd.NameLookupTable = custfield.sNameLookupTable.Value;
                        cfd.NameFieldLookup = custfield.sNameFieldLookup.Value;
                        cfd.Required = custfield.bitRequired.Value;
                        cfd.Default = custfield.sDefault.Value;
                        cfd.Help = custfield.sHelp.Value;
                        arrCFD.Add(cfd);
                        cfd = null;
                    }
                }

                // processing int's fields type
                for(j = 1; j <= MAXFIELDS.MAX_INT; j++)
                {
                    if( dtInput.Rows[0]["int" + j.ToString()] != DBNull.Value)
                    {
                        cfd = new clsCustomFieldsDef();
                        cfd.FieldTypeId = DBFieldType._int;
                        custfield.iFieldTypeId = (int)DBFieldType._int;
                        cfd.NumberColumn = j;
                        custfield.iNumberColumn = j;
                        cfd.IsComponent = false;
                        custfield.bitIsComponent = false;
                        cfd.ComponentTypeID = iTypeId;
                        custfield.iComponentTypeID = iTypeId;
                        custfield.CustFieldsEquipment();
                        cfd.Id = (int)custfield.iId;
                        cfd.Name = (string)custfield.sName;
                        cfd.NameText = (string)custfield.sNameText;
                        cfd.NameLookupTable = (string)custfield.sNameLookupTable;
                        cfd.NameFieldLookup = (string)custfield.sNameFieldLookup;
                        cfd.Required = (bool)custfield.bitRequired;
                        cfd.Default = (string)custfield.sDefault;
                        arrCFD.Add(cfd);
                        cfd = null;
                    }
                }

                // processing lookup's fields type
                for(j = 1; j <= MAXFIELDS.MAX_LOOKUP; j++)
                {
                    if( dtInput.Rows[0]["lookup" + j.ToString()] != DBNull.Value)
                    {
                        cfd = new clsCustomFieldsDef();
                        cfd.FieldTypeId = DBFieldType._lookup;
                        custfield.iFieldTypeId = (int)DBFieldType._lookup;
                        cfd.NumberColumn = j;
                        custfield.iNumberColumn = j;
                        cfd.IsComponent = false;
                        custfield.bitIsComponent = false;
                        cfd.ComponentTypeID = iTypeId;
                        custfield.iComponentTypeID = iTypeId;
                        custfield.CustFieldsEquipment();
                        cfd.Id = (int)custfield.iId;
                        cfd.Name = (string)custfield.sName;
                        cfd.NameText = (string)custfield.sNameText;
                        cfd.NameLookupTable = (string)custfield.sNameLookupTable;
                        cfd.NameFieldLookup = (string)custfield.sNameFieldLookup;
                        cfd.Required = (bool)custfield.bitRequired;
                        cfd.Default = (string)custfield.sDefault;
                        arrCFD.Add(cfd);
                        cfd = null;
                    }
                }

                // processing float's fields type
                for(j = 1; j <= MAXFIELDS.MAX_FLOAT; j++)
                {
                    if( dtInput.Rows[0]["float" + j.ToString()] != DBNull.Value)
                    {
                        cfd = new clsCustomFieldsDef();
                        custfield.cAction = "S";
                        custfield.iOrgId = 1; // will change
                        cfd.FieldTypeId = DBFieldType._float;
                        custfield.iFieldTypeId = (int)DBFieldType._float;
                        cfd.NumberColumn = j;
                        custfield.iNumberColumn = j;
                        cfd.IsComponent = false;
                        custfield.bitIsComponent = false;
                        cfd.ComponentTypeID = iTypeId;
                        custfield.iComponentTypeID = iTypeId;
                        custfield.CustFieldsEquipment();
                        cfd.Id = (int)custfield.iId;
                        cfd.Name = (string)custfield.sName;
                        cfd.NameText = (string)custfield.sNameText;
                        cfd.NameLookupTable = (string)custfield.sNameLookupTable;
                        cfd.NameFieldLookup = (string)custfield.sNameFieldLookup;
                        cfd.Required = (bool)custfield.bitRequired;
                        cfd.Default = (string)custfield.sDefault;
                        arrCFD.Add(cfd);
                        cfd = null;
                    }
                }

                // processing datetime's fields type
                for(j = 1; j <= MAXFIELDS.MAX_DATETIME; j++)
                {
                    if( dtInput.Rows[0]["datetime" + j.ToString()] != DBNull.Value)
                    {
                        cfd = new clsCustomFieldsDef();
                        cfd.FieldTypeId = DBFieldType._datetime;
                        custfield.iFieldTypeId = (int)DBFieldType._datetime;
                        cfd.NumberColumn = j;
                        custfield.iNumberColumn = j;
                        cfd.IsComponent = false;
                        custfield.bitIsComponent = false;
                        cfd.ComponentTypeID = iTypeId;
                        custfield.iComponentTypeID = iTypeId;
                        custfield.CustFieldsEquipment();
                        cfd.Id = (int)custfield.iId;
                        cfd.Name = (string)custfield.sName;
                        cfd.NameText = (string)custfield.sNameText;
                        cfd.NameLookupTable = (string)custfield.sNameLookupTable;
                        cfd.NameFieldLookup = (string)custfield.sNameFieldLookup;
                        cfd.Required = (bool)custfield.bitRequired;
                        cfd.Default = (string)custfield.sDefault;
                        arrCFD.Add(cfd);
                        cfd = null;
                    }
                }

                // processing bit's fields type
                for(j = 1; j <= MAXFIELDS.MAX_BIT; j++)
                {
                    if( dtInput.Rows[0]["bit" + j.ToString()] != DBNull.Value)
                    {
                        cfd = new clsCustomFieldsDef();
                        cfd.FieldTypeId = DBFieldType._bit;
                        custfield.iFieldTypeId = (int)DBFieldType._bit;
                        cfd.NumberColumn = j;
                        custfield.iNumberColumn = j;
                        cfd.IsComponent = false;
                        custfield.bitIsComponent = false;
                        cfd.ComponentTypeID = iTypeId;
                        custfield.iComponentTypeID = iTypeId;
                        custfield.CustFieldsEquipment();
                        cfd.Id = (int)custfield.iId;
                        cfd.Name = (string)custfield.sName;
                        cfd.NameText = (string)custfield.sNameText;
                        cfd.NameLookupTable = (string)custfield.sNameLookupTable;
                        cfd.NameFieldLookup = (string)custfield.sNameFieldLookup;
                        cfd.Required = (bool)custfield.bitRequired;
                        cfd.Default = (string)custfield.sDefault;
                        arrCFD.Add(cfd);
                        cfd = null;
                    }
                }
                return arrCFD;
            }
            catch(Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                if(custfield != null)
                {
                    custfield.Dispose();
                }
            }
        }