public object GetObjectVO(int pintPartyID, int pintCCNID) { 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 " + SO_CustomerItemRefMasterTable.CUSTOMERITEMREFMASTERID_FLD + "," + SO_CustomerItemRefMasterTable.CCNID_FLD + "," + SO_CustomerItemRefMasterTable.PARTYID_FLD + " FROM " + SO_CustomerItemRefMasterTable.TABLE_NAME + " WHERE " + SO_CustomerItemRefMasterTable.PARTYID_FLD + "=" + pintPartyID + " AND " + SO_CustomerItemRefMasterTable.CCNID_FLD + "=" + pintCCNID; Utils utils = new Utils(); oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString); ocmdPCS = new OleDbCommand(strSql, oconPCS); ocmdPCS.Connection.Open(); odrPCS = ocmdPCS.ExecuteReader(); SO_CustomerItemRefMasterVO objObject = new SO_CustomerItemRefMasterVO(); while (odrPCS.Read()) { objObject.CustomerItemRefMasterID = int.Parse(odrPCS[SO_CustomerItemRefMasterTable.CUSTOMERITEMREFMASTERID_FLD].ToString()); objObject.CCNID = int.Parse(odrPCS[SO_CustomerItemRefMasterTable.CCNID_FLD].ToString()); objObject.PartyID = int.Parse(odrPCS[SO_CustomerItemRefMasterTable.PARTYID_FLD].ToString()); } 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(); } } } }
/// <summary> /// Add and return MasterID /// </summary> /// <param name="pobjObjectVO"></param> /// <returns></returns> /// <author>TuanDM 18 - 10 - 2005</author> public int AddAndReturnID(object pobjObjectVO) { const string METHOD_NAME = THIS + ".AddAndReturnID()"; OleDbConnection oconPCS = null; OleDbCommand ocmdPCS = null; try { SO_CustomerItemRefMasterVO objObject = (SO_CustomerItemRefMasterVO)pobjObjectVO; string strSql = String.Empty; Utils utils = new Utils(); oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString); ocmdPCS = new OleDbCommand("", oconPCS); strSql = "INSERT INTO SO_CustomerItemRefMaster(" + SO_CustomerItemRefMasterTable.CCNID_FLD + "," + SO_CustomerItemRefMasterTable.PARTYID_FLD + ")" + "VALUES(?,?) SELECT @@IDENTITY"; ocmdPCS.Parameters.Add(new OleDbParameter(SO_CustomerItemRefMasterTable.CCNID_FLD, OleDbType.Integer)); ocmdPCS.Parameters[SO_CustomerItemRefMasterTable.CCNID_FLD].Value = objObject.CCNID; ocmdPCS.Parameters.Add(new OleDbParameter(SO_CustomerItemRefMasterTable.PARTYID_FLD, OleDbType.Integer)); ocmdPCS.Parameters[SO_CustomerItemRefMasterTable.PARTYID_FLD].Value = objObject.PartyID; ocmdPCS.CommandText = strSql; ocmdPCS.Connection.Open(); object objResult = ocmdPCS.ExecuteScalar(); if (objResult != null && objResult != DBNull.Value) { return(int.Parse(objResult.ToString())); } return(0); } 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 update data to SO_CustomerItemRefMaster /// </Description> /// <Inputs> /// SO_CustomerItemRefMasterVO /// </Inputs> /// <Outputs> /// /// </Outputs> /// <Returns> /// /// </Returns> /// <Authors> /// HungLa /// </Authors> /// <History> /// 09-Dec-2004 /// </History> /// <Notes> /// </Notes> //************************************************************************** public void Update(object pobjObjecVO) { const string METHOD_NAME = THIS + ".Update()"; SO_CustomerItemRefMasterVO objObject = (SO_CustomerItemRefMasterVO)pobjObjecVO; //prepare value for parameters OleDbConnection oconPCS = null; OleDbCommand ocmdPCS = null; try { string strSql = String.Empty; Utils utils = new Utils(); oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString); ocmdPCS = new OleDbCommand(strSql, oconPCS); strSql = "UPDATE SO_CustomerItemRefMaster SET " + SO_CustomerItemRefMasterTable.CCNID_FLD + "= ?" + "," + SO_CustomerItemRefMasterTable.PARTYID_FLD + "= ?" + " WHERE " + SO_CustomerItemRefMasterTable.CUSTOMERITEMREFMASTERID_FLD + "= ?"; ocmdPCS.Parameters.Add(new OleDbParameter(SO_CustomerItemRefMasterTable.CCNID_FLD, OleDbType.Integer)); ocmdPCS.Parameters[SO_CustomerItemRefMasterTable.CCNID_FLD].Value = objObject.CCNID; ocmdPCS.Parameters.Add(new OleDbParameter(SO_CustomerItemRefMasterTable.PARTYID_FLD, OleDbType.Integer)); ocmdPCS.Parameters[SO_CustomerItemRefMasterTable.PARTYID_FLD].Value = objObject.PartyID; ocmdPCS.Parameters.Add(new OleDbParameter(SO_CustomerItemRefMasterTable.CUSTOMERITEMREFMASTERID_FLD, OleDbType.Integer)); ocmdPCS.Parameters[SO_CustomerItemRefMasterTable.CUSTOMERITEMREFMASTERID_FLD].Value = objObject.CustomerItemRefMasterID; 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(); } } } }