//************************************************************************** /// <Description> /// This method uses to add data to sys_ReportHistoryPara /// </Description> /// <Inputs> /// sys_ReportHistoryParaVO /// </Inputs> /// <Outputs> /// newly inserted primarkey value /// </Outputs> /// <Returns> /// void /// </Returns> /// <Authors> /// HungLa /// </Authors> /// <History> /// Monday, December 27, 2004 /// </History> /// <Notes> /// </Notes> //************************************************************************** public void Add(object pobjObjectVO) { const string METHOD_NAME = THIS + ".Add()"; OleDbConnection oconPCS = null; OleDbCommand ocmdPCS = null; try { sys_ReportHistoryParaVO objObject = (sys_ReportHistoryParaVO)pobjObjectVO; string strSql = String.Empty; strSql = "INSERT INTO " + sys_ReportHistoryParaTable.TABLE_NAME + "(" + sys_ReportHistoryParaTable.HISTORYID_FLD + "," + sys_ReportHistoryParaTable.PARANAME_FLD + "," + sys_ReportHistoryParaTable.PARAVALUE_FLD + "," + sys_ReportHistoryParaTable.TAGVALUE_FLD + "," + sys_ReportHistoryParaTable.FILTERFIELD1VALUE_FLD + "," + sys_ReportHistoryParaTable.FILTERFIELD2VALUE_FLD + ")" + " VALUES(?,?,?,?,?,?)"; Utils utils = new Utils(); oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString); ocmdPCS = new OleDbCommand(strSql, oconPCS); ocmdPCS.Parameters.Add(new OleDbParameter(sys_ReportHistoryParaTable.HISTORYID_FLD, OleDbType.Integer)); ocmdPCS.Parameters[sys_ReportHistoryParaTable.HISTORYID_FLD].Value = objObject.HistoryID; ocmdPCS.Parameters.Add(new OleDbParameter(sys_ReportHistoryParaTable.PARANAME_FLD, OleDbType.VarWChar)); ocmdPCS.Parameters[sys_ReportHistoryParaTable.PARANAME_FLD].Value = objObject.ParaName; ocmdPCS.Parameters.Add(new OleDbParameter(sys_ReportHistoryParaTable.PARAVALUE_FLD, OleDbType.VarWChar)); if (objObject.ParaValue != string.Empty) { ocmdPCS.Parameters[sys_ReportHistoryParaTable.PARAVALUE_FLD].Value = objObject.ParaValue; } else { ocmdPCS.Parameters[sys_ReportHistoryParaTable.PARAVALUE_FLD].Value = DBNull.Value; } ocmdPCS.Parameters.Add(new OleDbParameter(sys_ReportHistoryParaTable.TAGVALUE_FLD, OleDbType.VarWChar)); ocmdPCS.Parameters[sys_ReportHistoryParaTable.TAGVALUE_FLD].Value = objObject.TagValue; ocmdPCS.Parameters.Add(new OleDbParameter(sys_ReportHistoryParaTable.FILTERFIELD1VALUE_FLD, OleDbType.VarWChar)); ocmdPCS.Parameters[sys_ReportHistoryParaTable.FILTERFIELD1VALUE_FLD].Value = objObject.FilterField1Value; ocmdPCS.Parameters.Add(new OleDbParameter(sys_ReportHistoryParaTable.FILTERFIELD2VALUE_FLD, OleDbType.VarWChar)); ocmdPCS.Parameters[sys_ReportHistoryParaTable.FILTERFIELD2VALUE_FLD].Value = objObject.FilterField2Value; ocmdPCS.CommandText = strSql; ocmdPCS.Connection.Open(); ocmdPCS.ExecuteNonQuery(); } catch (OleDbException ex) { if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE) { throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex); } else { throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex); } } catch (InvalidOperationException ex) { throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex); } catch (Exception ex) { throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex); } finally { if (oconPCS != null) { if (oconPCS.State != ConnectionState.Closed) { oconPCS.Close(); } } } }
//************************************************************************** /// <Description> /// This method uses to get all data from sys_ReportHistoryPara of specified History /// </Description> /// <Inputs> /// HistoryID /// </Inputs> /// <Outputs> /// ArrayList /// </Outputs> /// <Returns> /// ArrayList /// </Returns> /// <Authors> /// DungLA /// </Authors> /// <History> /// 21-Jan-2005 /// 12/Oct/2005 Thachnn: fix bug injection /// </History> /// <Notes> /// </Notes> //************************************************************************** public ArrayList ListByHistory(string pstrHistoryID) { const string METHOD_NAME = THIS + ".ListByHistory()"; ArrayList arrObjects = new ArrayList(); OleDbConnection oconPCS = null; OleDbCommand ocmdPCS = null; OleDbDataReader odrPCS = null; try { string strSql = String.Empty; strSql = "SELECT " + sys_ReportHistoryParaTable.HISTORYID_FLD + "," + sys_ReportHistoryParaTable.PARANAME_FLD + "," + sys_ReportHistoryParaTable.PARAVALUE_FLD + "," + sys_ReportHistoryParaTable.TAGVALUE_FLD + "," + sys_ReportHistoryParaTable.FILTERFIELD1VALUE_FLD + "," + sys_ReportHistoryParaTable.FILTERFIELD2VALUE_FLD + " FROM " + sys_ReportHistoryParaTable.TABLE_NAME + " WHERE " + sys_ReportHistoryParaTable.HISTORYID_FLD + "= ? "; // + pstrHistoryID; Utils utils = new Utils(); oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString); ocmdPCS = new OleDbCommand(strSql, oconPCS); ocmdPCS.Parameters.Add(new OleDbParameter(sys_ReportHistoryParaTable.HISTORYID_FLD, OleDbType.VarWChar)); ocmdPCS.Parameters[sys_ReportHistoryParaTable.HISTORYID_FLD].Value = pstrHistoryID; ocmdPCS.Connection.Open(); odrPCS = ocmdPCS.ExecuteReader(); while (odrPCS.Read()) { sys_ReportHistoryParaVO voHistoryPara = new sys_ReportHistoryParaVO(); voHistoryPara.HistoryID = int.Parse(odrPCS[sys_ReportHistoryParaTable.HISTORYID_FLD].ToString().Trim()); voHistoryPara.ParaName = odrPCS[sys_ReportHistoryParaTable.PARANAME_FLD].ToString().Trim(); voHistoryPara.ParaValue = odrPCS[sys_ReportHistoryParaTable.PARAVALUE_FLD].ToString().Trim(); voHistoryPara.TagValue = odrPCS[sys_ReportHistoryParaTable.TAGVALUE_FLD].ToString().Trim(); voHistoryPara.FilterField1Value = odrPCS[sys_ReportHistoryParaTable.FILTERFIELD1VALUE_FLD].ToString().Trim(); voHistoryPara.FilterField2Value = odrPCS[sys_ReportHistoryParaTable.FILTERFIELD2VALUE_FLD].ToString().Trim(); arrObjects.Add(voHistoryPara); } arrObjects.TrimToSize(); return(arrObjects); } catch (OleDbException ex) { throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex); } catch (Exception ex) { throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex); } finally { if (oconPCS != null) { if (oconPCS.State != ConnectionState.Closed) { oconPCS.Close(); } } } }
//************************************************************************** /// <Description> /// This method uses to get data from sys_ReportHistoryPara /// </Description> /// <Inputs> /// ID /// </Inputs> /// <Outputs> /// sys_ReportHistoryParaVO /// </Outputs> /// <Returns> /// sys_ReportHistoryParaVO /// </Returns> /// <Authors> /// HungLa /// </Authors> /// <History> /// Monday, December 27, 2004 /// </History> /// <Notes> /// </Notes> //************************************************************************** public object GetObjectVO(int pintID) { const string METHOD_NAME = THIS + ".GetObjectVO()"; DataSet dstPCS = new DataSet(); OleDbDataReader odrPCS = null; OleDbConnection oconPCS = null; OleDbCommand ocmdPCS = null; try { string strSql = String.Empty; strSql = "SELECT " + sys_ReportHistoryParaTable.HISTORYID_FLD + "," + sys_ReportHistoryParaTable.PARANAME_FLD + "," + sys_ReportHistoryParaTable.PARAVALUE_FLD + "," + sys_ReportHistoryParaTable.TAGVALUE_FLD + "," + sys_ReportHistoryParaTable.FILTERFIELD1VALUE_FLD + "," + sys_ReportHistoryParaTable.FILTERFIELD2VALUE_FLD + " FROM " + sys_ReportHistoryParaTable.TABLE_NAME + " WHERE " + sys_ReportHistoryParaTable.HISTORYID_FLD + "=" + pintID; Utils utils = new Utils(); oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString); ocmdPCS = new OleDbCommand(strSql, oconPCS); ocmdPCS.Connection.Open(); odrPCS = ocmdPCS.ExecuteReader(); sys_ReportHistoryParaVO objObject = new sys_ReportHistoryParaVO(); while (odrPCS.Read()) { objObject.HistoryID = int.Parse(odrPCS[sys_ReportHistoryParaTable.HISTORYID_FLD].ToString().Trim()); objObject.ParaName = odrPCS[sys_ReportHistoryParaTable.PARANAME_FLD].ToString().Trim(); objObject.ParaValue = odrPCS[sys_ReportHistoryParaTable.PARAVALUE_FLD].ToString().Trim(); objObject.TagValue = odrPCS[sys_ReportHistoryParaTable.TAGVALUE_FLD].ToString().Trim(); objObject.FilterField1Value = odrPCS[sys_ReportHistoryParaTable.FILTERFIELD1VALUE_FLD].ToString().Trim(); objObject.FilterField2Value = odrPCS[sys_ReportHistoryParaTable.FILTERFIELD2VALUE_FLD].ToString().Trim(); } return(objObject); } catch (OleDbException ex) { throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex); } catch (Exception ex) { throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex); } finally { if (oconPCS != null) { if (oconPCS.State != ConnectionState.Closed) { oconPCS.Close(); } } } }