Exemplo n.º 1
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to add data to IV_OnhandPeriod
        ///    </Description>
        ///    <Inputs>
        ///        IV_OnhandPeriodVO
        ///    </Inputs>
        ///    <Outputs>
        ///       newly inserted primarkey value
        ///    </Outputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <Authors>
        ///       Code generate
        ///    </Authors>
        ///    <History>
        ///       Thursday, October 05, 2006
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        public void Add(object pobjObjectVO)
        {
            const string METHOD_NAME = THIS + ".Add()";

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

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

                strSql = "INSERT INTO IV_OnhandPeriod("
                         + IV_OnhandPeriodTable.CODE_FLD + ","
                         + IV_OnhandPeriodTable.EFFECTDATE_FLD + ","
                         + IV_OnhandPeriodTable.STATUS_FLD + ")"
                         + "VALUES(?,?,?)";

                ocmdPCS.Parameters.Add(new OleDbParameter(IV_OnhandPeriodTable.CODE_FLD, OleDbType.WChar));
                ocmdPCS.Parameters[IV_OnhandPeriodTable.CODE_FLD].Value = objObject.Code;

                ocmdPCS.Parameters.Add(new OleDbParameter(IV_OnhandPeriodTable.EFFECTDATE_FLD, OleDbType.Date));
                ocmdPCS.Parameters[IV_OnhandPeriodTable.EFFECTDATE_FLD].Value = objObject.EffectDate;

                ocmdPCS.Parameters.Add(new OleDbParameter(IV_OnhandPeriodTable.STATUS_FLD, OleDbType.Boolean));
                ocmdPCS.Parameters[IV_OnhandPeriodTable.STATUS_FLD].Value = objObject.Status;


                ocmdPCS.CommandText = strSql;
                ocmdPCS.Connection.Open();
                ocmdPCS.ExecuteNonQuery();
            }
            catch (OleDbException ex)
            {
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }

            catch (InvalidOperationException ex)
            {
                throw new PCSDBException(ErrorCode.DUPLICATE_KEY, 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();
                    }
                }
            }
        }
Exemplo n.º 2
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to get data from IV_OnhandPeriod
        ///    </Description>
        ///    <Inputs>
        ///        ID
        ///    </Inputs>
        ///    <Outputs>
        ///       IV_OnhandPeriodVO
        ///    </Outputs>
        ///    <Returns>
        ///       IV_OnhandPeriodVO
        ///    </Returns>
        ///    <Authors>
        ///       Code Generate
        ///    </Authors>
        ///    <History>
        ///       Thursday, October 05, 2006
        ///    </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 "
                         + IV_OnhandPeriodTable.ONHANDPERIODID_FLD + ","
                         + IV_OnhandPeriodTable.CODE_FLD + ","
                         + IV_OnhandPeriodTable.EFFECTDATE_FLD + ","
                         + IV_OnhandPeriodTable.STATUS_FLD
                         + " FROM " + IV_OnhandPeriodTable.TABLE_NAME
                         + " WHERE " + IV_OnhandPeriodTable.ONHANDPERIODID_FLD + "=" + pintID;

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

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

                IV_OnhandPeriodVO objObject = new IV_OnhandPeriodVO();

                while (odrPCS.Read())
                {
                    objObject.OnhandPeriodID = int.Parse(odrPCS[IV_OnhandPeriodTable.ONHANDPERIODID_FLD].ToString());
                    objObject.Code           = odrPCS[IV_OnhandPeriodTable.CODE_FLD].ToString();
                    objObject.EffectDate     = DateTime.Parse(odrPCS[IV_OnhandPeriodTable.EFFECTDATE_FLD].ToString());
                    objObject.Status         = bool.Parse(odrPCS[IV_OnhandPeriodTable.STATUS_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();
                    }
                }
            }
        }
Exemplo n.º 3
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to update data to IV_OnhandPeriod
        ///    </Description>
        ///    <Inputs>
        ///       IV_OnhandPeriodVO
        ///    </Inputs>
        ///    <Outputs>
        ///
        ///    </Outputs>
        ///    <Returns>
        ///
        ///    </Returns>
        ///    <Authors>
        ///       Code Generate
        ///    </Authors>
        ///    <History>
        ///       09-Dec-2004
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        public void Update(object pobjObjecVO)
        {
            const string METHOD_NAME = THIS + ".Update()";

            IV_OnhandPeriodVO objObject = (IV_OnhandPeriodVO)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 IV_OnhandPeriod SET "
                          + IV_OnhandPeriodTable.CODE_FLD + "=   ?" + ","
                          + IV_OnhandPeriodTable.EFFECTDATE_FLD + "=   ?" + ","
                          + IV_OnhandPeriodTable.STATUS_FLD + "=  ?"
                          + " WHERE " + IV_OnhandPeriodTable.ONHANDPERIODID_FLD + "= ?";

                ocmdPCS.Parameters.Add(new OleDbParameter(IV_OnhandPeriodTable.CODE_FLD, OleDbType.WChar));
                ocmdPCS.Parameters[IV_OnhandPeriodTable.CODE_FLD].Value = objObject.Code;

                ocmdPCS.Parameters.Add(new OleDbParameter(IV_OnhandPeriodTable.EFFECTDATE_FLD, OleDbType.Date));
                ocmdPCS.Parameters[IV_OnhandPeriodTable.EFFECTDATE_FLD].Value = objObject.EffectDate;

                ocmdPCS.Parameters.Add(new OleDbParameter(IV_OnhandPeriodTable.STATUS_FLD, OleDbType.Boolean));
                ocmdPCS.Parameters[IV_OnhandPeriodTable.STATUS_FLD].Value = objObject.Status;

                ocmdPCS.Parameters.Add(new OleDbParameter(IV_OnhandPeriodTable.ONHANDPERIODID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[IV_OnhandPeriodTable.ONHANDPERIODID_FLD].Value = objObject.OnhandPeriodID;


                ocmdPCS.CommandText = strSql;
                ocmdPCS.Connection.Open();
                ocmdPCS.ExecuteNonQuery();
            }
            catch (OleDbException ex)
            {
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }

            catch (InvalidOperationException ex)
            {
                throw new PCSDBException(ErrorCode.DUPLICATE_KEY, 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();
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// AddAndReturnID
        /// </summary>
        /// <param name="pobjOnHandPeriodVO"></param>
        /// <returns></returns>
        /// <author>Trada</author>
        /// <date>Friday, October 6 2006</date>
        public int AddAndReturnID(object pobjOnHandPeriodVO)
        {
            const string METHOD_NAME = THIS + ".AddAndReturnID()";

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

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

                strSql = "INSERT INTO IV_OnhandPeriod("
                         + IV_OnhandPeriodTable.CODE_FLD + ","
                         + IV_OnhandPeriodTable.EFFECTDATE_FLD + ","
                         + IV_OnhandPeriodTable.STATUS_FLD + ")"
                         + "VALUES(?,?,?)";

                ocmdPCS.Parameters.Add(new OleDbParameter(IV_OnhandPeriodTable.CODE_FLD, OleDbType.WChar));
                ocmdPCS.Parameters[IV_OnhandPeriodTable.CODE_FLD].Value = objObject.Code;

                ocmdPCS.Parameters.Add(new OleDbParameter(IV_OnhandPeriodTable.EFFECTDATE_FLD, OleDbType.Date));
                ocmdPCS.Parameters[IV_OnhandPeriodTable.EFFECTDATE_FLD].Value = objObject.EffectDate;

                ocmdPCS.Parameters.Add(new OleDbParameter(IV_OnhandPeriodTable.STATUS_FLD, OleDbType.Boolean));
                ocmdPCS.Parameters[IV_OnhandPeriodTable.STATUS_FLD].Value = objObject.Status;

                strSql += " ; SELECT @@IDENTITY AS NEWID";

                ocmdPCS.CommandText = strSql;
                ocmdPCS.Connection.Open();
                object objReturn = ocmdPCS.ExecuteScalar();
                if (objReturn != null)
                {
                    return(int.Parse(objReturn.ToString()));
                }
                else
                {
                    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.DUPLICATE_KEY, 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();
                    }
                }
            }
        }