Exemple #1
0
        /// <summary>
        /// Get CostCenterRateDetailVO object from ID
        /// </summary>
        /// <param name="pintID"></param>
        /// <returns></returns>
        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 "
                         + STD_CostCenterRateDetailTable.COSTCENTERRATEDETAILID_FLD + ","
                         + STD_CostCenterRateDetailTable.COSTCENTERRATEMASTERID_FLD + ","
                         + STD_CostCenterRateDetailTable.COSTELEMENTID_FLD + ","
                         + STD_CostCenterRateDetailTable.COST_FLD
                         + " FROM " + STD_CostCenterRateDetailTable.TABLE_NAME
                         + " WHERE " + STD_CostCenterRateDetailTable.COSTCENTERRATEDETAILID_FLD + "=" + pintID;

                Utils utils = new Utils();
                oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
                ocmdPCS = new OleDbCommand(strSql, oconPCS);

                ocmdPCS.Connection.Open();
                odrPCS = ocmdPCS.ExecuteReader();

                STD_CostCenterRateDetailVO objObject = new STD_CostCenterRateDetailVO();

                while (odrPCS.Read())
                {
                    objObject.CostCenterRateDetailID = int.Parse(odrPCS[STD_CostCenterRateDetailTable.COSTCENTERRATEDETAILID_FLD].ToString().Trim());
                    objObject.CostCenterRateMasterID = int.Parse(odrPCS[STD_CostCenterRateDetailTable.COSTCENTERRATEMASTERID_FLD].ToString().Trim());
                    objObject.CostElementID          = int.Parse(odrPCS[STD_CostCenterRateDetailTable.COSTELEMENTID_FLD].ToString().Trim());
                    objObject.Cost = Decimal.Parse(odrPCS[STD_CostCenterRateDetailTable.COST_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();
                    }
                }
            }
        }
Exemple #2
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to add data to STD_CostCenterRateDetail
        ///    </Description>
        ///    <Inputs>
        ///        STD_CostCenterRateDetailVO
        ///    </Inputs>
        ///    <Outputs>
        ///       newly inserted primarkey value
        ///    </Outputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       Tuesday, February 07, 2006
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        public void Add(object pobjObjectVO)
        {
            const string METHOD_NAME = THIS + ".Add()";

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

            try
            {
                STD_CostCenterRateDetailVO objObject = (STD_CostCenterRateDetailVO)pobjObjectVO;
                string strSql = String.Empty;
                Utils  utils  = new Utils();
                oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
                ocmdPCS = new OleDbCommand("", oconPCS);

                strSql = "INSERT INTO STD_CostCenterRateDetail("
                         + STD_CostCenterRateDetailTable.COSTCENTERRATEMASTERID_FLD + ","
                         + STD_CostCenterRateDetailTable.COSTELEMENTID_FLD + ","
                         + STD_CostCenterRateDetailTable.COST_FLD + ")"
                         + "VALUES(?,?,?)";

                ocmdPCS.Parameters.Add(new OleDbParameter(STD_CostCenterRateDetailTable.COSTCENTERRATEMASTERID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[STD_CostCenterRateDetailTable.COSTCENTERRATEMASTERID_FLD].Value = objObject.CostCenterRateMasterID;

                ocmdPCS.Parameters.Add(new OleDbParameter(STD_CostCenterRateDetailTable.COSTELEMENTID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[STD_CostCenterRateDetailTable.COSTELEMENTID_FLD].Value = objObject.CostElementID;

                ocmdPCS.Parameters.Add(new OleDbParameter(STD_CostCenterRateDetailTable.COST_FLD, OleDbType.Decimal));
                ocmdPCS.Parameters[STD_CostCenterRateDetailTable.COST_FLD].Value = objObject.Cost;


                ocmdPCS.CommandText = strSql;
                ocmdPCS.Connection.Open();
                ocmdPCS.ExecuteNonQuery();
            }
            catch (OleDbException ex)
            {
                if (ex.Errors.Count > 1)
                {
                    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();
                    }
                }
            }
        }