Пример #1
0
        private List <VTFormObject> helperSummary(string str_cmd)
        {
            connect();

            List <VTFormObject> list_VTFormObject = new List <VTFormObject>();

            OdbcCommand    cmd = new OdbcCommand(str_cmd, conn);
            OdbcDataReader reader;
            VTFormObject   formObject  = null;
            string         header_name = string.Empty;

            reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            while (reader.Read())
            {
                string _return = reader["return"].ToString().Trim();
                string _msg    = reader["message"].ToString().Trim();
                // If the query passes
                if (_return == "0")
                {
                    // Check if it is the first call
                    if (header_name != reader["Header_Name"].ToString().Trim())
                    {
                        if (!(header_name == ""))
                        {
                            list_VTFormObject.Add(formObject);
                        }

                        header_name             = reader["Header_Name"].ToString().Trim();
                        formObject              = new VTFormObject();
                        formObject.HeaderTitle  = header_name;
                        formObject.SerialNumber = reader["Serial_Number"].ToString().Trim();
                        formObject.ProductLine  = reader["Product_Line"].ToString().Trim();
                        formObject.TubeType     = reader["Tube_Type"].ToString().Trim();
                        formObject.TimeStamp    = reader["Header_Date"].ToString().Trim();
                        formObject.return_num   = _return;
                    }

                    VTFieldObject fieldObject = new VTFieldObject();
                    fieldObject.HeaderName = header_name;
                    fieldObject.Token      = reader["Detail_Token"].ToString().Trim();
                    fieldObject.Label      = reader["Default_Label"].ToString().Trim() + ": ";
                    fieldObject.Spec       = reader["Default_Spec"].ToString().Trim();
                    fieldObject.Value      = reader["Detail_Data"].ToString().Trim();
                    // Add the object to the formObjects list of fieldObjects
                    formObject.FieldList.Add(fieldObject);
                }

                // Cover the error case
                else
                {
                    formObject = new VTFormObject();
                    formObject.error_message = _msg;
                    formObject.return_num    = _return;
                    list_VTFormObject.Add(formObject);
                    return(list_VTFormObject); // Returns, due to an error case
                }
            }
            list_VTFormObject.Add(formObject); // Adds the last header
            return(list_VTFormObject);
        }
Пример #2
0
 /**
  * Method : expandList
  * Function : Expands the multidimension list whenever an item to be inserted.
  * Paramaters : A multidimensional list, int a number for a row, number for the column
  * Return : None, just expands the list
  * */
 public void expandList(List <List <VTFieldObject> > list, int row, int col)
 {
     while (list.Count < row)
     {
         //list.Add(default(String));
         List <VTFieldObject> tmp = new List <VTFieldObject>();
         list.Add(tmp);
     }
     row = row - 1;
     while (list[row] == null || list[row].Count < col)
     {
         VTFieldObject tmpObject = new VTFieldObject(); // An empty VTFieldObject
         if (list[row] == null)
         {
             list[0].Add(tmpObject);
         }
         else
         {
             list[row].Add(tmpObject);
         }
     }
 }
Пример #3
0
        /**
         * Method : SetLayoutList
         * Function : Reads the command. Sets the Field with the correct data from the database.
         * Paramat  ers : string cmd, the cmd in a string format
         * Return : A List filled with FieldObjects
         * */
        private List <List <VTFieldObject> > SetLayoutList(string str_cmd)
        {
            connect();

            List <List <VTFieldObject> > field_obj_list = new List <List <VTFieldObject> >();

            OdbcCommand    cmd = new OdbcCommand(str_cmd, conn);
            OdbcDataReader reader;

            reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            while (reader.Read())
            {
                VTFieldObject field_obj = new VTFieldObject();
                string        _return   = reader["rtn"].ToString().Trim();
                string        _msg      = reader["msg"].ToString().Trim();

                if (_return == "0")
                {
                    field_obj.HeaderToken = reader["Header_Type"].ToString().Trim();

                    field_obj.HeaderName = reader["Header_Name"].ToString().Trim();

                    field_obj.Token = reader["Detail_Token"].ToString().Trim();

                    field_obj.Label = reader["Default_Label"].ToString().Trim() + reader["Default_Spec"].ToString().Trim() + " " + reader["Detail_Data"].ToString().Trim();

                    field_obj.Spec = reader["Default_Spec"].ToString().Trim();

                    field_obj.ProductLine = reader["Product_Line"].ToString().Trim();

                    field_obj.TubeType = reader["Tube_Type"].ToString().Trim();

                    field_obj.DataType = reader["Detail_Data_Type"].ToString().Trim();

                    field_obj.Username = reader["Username"].ToString().Trim();

                    field_obj.Value = reader["Detail_Data"].ToString().Trim();

                    field_obj.DetailOptionsString = reader["Detail_Options"].ToString().Trim();

                    field_obj.DetailOptions = helper.parseDetailOptions(reader["Detail_Options"].ToString().Trim());

                    bool isHidden = helper.intToBool(Int32.Parse(reader["IsHidden"].ToString().Trim()));
                    field_obj.isHidden = isHidden;

                    bool isDefault = helper.intToBool(Int32.Parse(reader["IsDefault"].ToString().Trim()));
                    field_obj.Default = isDefault;

                    field_obj.return_num = _return;
                }
                // If doesn't pass, set the error message and return number
                else
                {
                    field_obj.return_num    = _return;
                    field_obj.error_message = _msg;
                }

                int row = Int32.Parse(reader["row"].ToString().Trim());
                int col = Int32.Parse(reader["col"].ToString().Trim());

                helper.expandList(field_obj_list, row, col);
                field_obj_list[row][col] = field_obj;
            }

            conn.Close();
            cmd.Dispose();
            reader.Close();
            return(field_obj_list);
        }
Пример #4
0
        /**
         * Method : helperReadCmdSetField
         * Function : Reads the command. Sets the Field Object with the correct data from the database.
         * Paramaters : string cmd, the cmd in a string format
         * Return : A List filled with FieldObjects
         * */
        private List <VTFieldObject> helperReadCmdSetField(string str_cmd)
        {
            connect();

            List <VTFieldObject> field_obj_list = new List <VTFieldObject>();

            OdbcCommand    cmd = new OdbcCommand(str_cmd, conn);
            OdbcDataReader reader;

            reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            while (reader.Read())
            {
                VTFieldObject field_obj = new VTFieldObject();
                string        _return   = reader["return"].ToString().Trim();
                string        _msg      = reader["message"].ToString().Trim();

                // If return is 0, this mean success
                if (_return == "0")
                {
                    // Getting all the database calls and setting the model properties

                    field_obj.HeaderToken = reader["Header_Type"].ToString().Trim();

                    field_obj.HeaderName = reader["Header_Name"].ToString().Trim();

                    field_obj.Token = reader["Detail_Token"].ToString().Trim();

                    //// Covers TMS case to convert
                    if (field_obj.Token == "TMS")
                    {
                        string temp_value = reader["Detail_Data"].ToString().Trim();
                        if (temp_value != null)
                        {
                            field_obj.Value = parseTMS(temp_value);
                        }
                    }
                    else
                    {
                        field_obj.Value = reader["Detail_Data"].ToString().Trim();
                    }


                    field_obj.Spec = reader["Default_Spec"].ToString().Trim();

                    field_obj.ProductLine = reader["Product_Line"].ToString().Trim();

                    field_obj.TubeType = reader["Tube_Type"].ToString().Trim();

                    field_obj.DataType = reader["Detail_Data_Type"].ToString().Trim();

                    field_obj.Username = reader["Username"].ToString().Trim();

                    field_obj.DetailOptionsString = reader["Detail_Options"].ToString().Trim();

                    field_obj.DetailOptions = helper.parseDetailOptions(reader["Detail_Options"].ToString().Trim());

                    bool isHidden = helper.intToBool(Int32.Parse(reader["IsHidden"].ToString().Trim()));
                    field_obj.isHidden = isHidden;

                    bool isDefault = helper.intToBool(Int32.Parse(reader["IsDefault"].ToString().Trim()));
                    field_obj.Default = isDefault;

                    if (isDefault)
                    {
                        field_obj.Label = reader["Default_Label"].ToString().Trim() + reader["Default_Spec"].ToString().Trim() + " " + field_obj.Value;
                    }
                    else
                    {
                        field_obj.Label = reader["Default_Label"].ToString().Trim() + reader["Default_Spec"].ToString().Trim() + " ";// +field_obj.Value;
                    }

                    field_obj.return_num = _return;
                }
                // If doesn't pass, set the error message and return number
                else
                {
                    field_obj.return_num    = _return;
                    field_obj.error_message = _msg;
                }
                field_obj_list.Add(field_obj);
            }

            conn.Close();
            cmd.Dispose();
            reader.Close();
            return(field_obj_list);
        }