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); }
/** * Method : helperReadCmdAllHeaders * Fuction : Reads the cmd, parses all of the header titles and header token into a list. * Paramaters : string cmd to the db * Return : A list filled with tokens and titles of the forms.@ * */ private List <VTFormObject> helperReadCmdAllHeaders(string str_cmd) { connect(); List <VTFormObject> list_VTFormObject = new List <VTFormObject>(); OdbcCommand cmd = new OdbcCommand(str_cmd, conn); OdbcDataReader reader; reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { string _return = reader["return"].ToString().Trim(); string _msg = reader["message"].ToString().Trim(); VTFormObject formObject = new VTFormObject(); if (_return == "0") { // Sets the form object properties formObject.HeaderTitle = reader["Obj_Name"].ToString().Trim(); formObject.HeaderToken = reader["Obj_Token"].ToString().Trim(); formObject.Username = reader["Username"].ToString().Trim(); formObject.TubeType = reader["Tube_Type"].ToString().Trim(); formObject.ProductLine = reader["Product_Line"].ToString().Trim(); formObject.HasActivity = reader["hasActivity"].ToString().Trim(); formObject.Status = reader["Status"].ToString().Trim(); if (formObject.Status == "0") { formObject.Status = "1"; } formObject.return_num = _return; } else { formObject.error_message = _msg; formObject.return_num = _return; } list_VTFormObject.Add(formObject); } return(list_VTFormObject); }