Esempio n. 1
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to get data from ITM_FormatCode
        ///    </Description>
        ///    <Inputs>
        ///        ID
        ///    </Inputs>
        ///    <Outputs>
        ///       ITM_FormatCodeVO
        ///    </Outputs>
        ///    <Returns>
        ///       ITM_FormatCodeVO
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       Wednesday, January 19, 2005
        ///    </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 "
                         + ITM_FormatCodeTable.FORMATCODEID_FLD + ","
                         + ITM_FormatCodeTable.CODE_FLD + ","
                         + ITM_FormatCodeTable.DESCRIPTION_FLD
                         + " FROM " + ITM_FormatCodeTable.TABLE_NAME
                         + " WHERE " + ITM_FormatCodeTable.FORMATCODEID_FLD + "=" + pintID;

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

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

                ITM_FormatCodeVO objObject = new ITM_FormatCodeVO();

                while (odrPCS.Read())
                {
                    objObject.FormatCodeID = int.Parse(odrPCS[ITM_FormatCodeTable.FORMATCODEID_FLD].ToString().Trim());
                    objObject.Code         = odrPCS[ITM_FormatCodeTable.CODE_FLD].ToString().Trim();
                    objObject.Description  = odrPCS[ITM_FormatCodeTable.DESCRIPTION_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();
                    }
                }
            }
        }
Esempio n. 2
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to add data to ITM_FormatCode
        ///    </Description>
        ///    <Inputs>
        ///        ITM_FormatCodeVO
        ///    </Inputs>
        ///    <Outputs>
        ///       newly inserted primarkey value
        ///    </Outputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       Wednesday, January 19, 2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************


        public void Add(object pobjObjectVO)
        {
            const string METHOD_NAME = THIS + ".Add()";

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

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

                strSql = "INSERT INTO ITM_FormatCode("
                         + ITM_FormatCodeTable.CODE_FLD + ","
                         + ITM_FormatCodeTable.DESCRIPTION_FLD + ")"
                         + "VALUES(?,?)";

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

                ocmdPCS.Parameters.Add(new OleDbParameter(ITM_FormatCodeTable.DESCRIPTION_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[ITM_FormatCodeTable.DESCRIPTION_FLD].Value = objObject.Description;



                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();
                    }
                }
            }
        }
Esempio n. 3
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to update data to ITM_FormatCode
        ///    </Description>
        ///    <Inputs>
        ///       ITM_FormatCodeVO
        ///    </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()";

            ITM_FormatCodeVO objObject = (ITM_FormatCodeVO)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 ITM_FormatCode SET "
                          + ITM_FormatCodeTable.CODE_FLD + "=   ?" + ","
                          + ITM_FormatCodeTable.DESCRIPTION_FLD + "=  ?"
                          + " WHERE " + ITM_FormatCodeTable.FORMATCODEID_FLD + "= ?";

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

                ocmdPCS.Parameters.Add(new OleDbParameter(ITM_FormatCodeTable.DESCRIPTION_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[ITM_FormatCodeTable.DESCRIPTION_FLD].Value = objObject.Description;

                ocmdPCS.Parameters.Add(new OleDbParameter(ITM_FormatCodeTable.FORMATCODEID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[ITM_FormatCodeTable.FORMATCODEID_FLD].Value = objObject.FormatCodeID;


                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();
                    }
                }
            }
        }