Exemple #1
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to add data to PRO_Shift
        ///    </Description>
        ///    <Inputs>
        ///        PRO_ShiftVO
        ///    </Inputs>
        ///    <Outputs>
        ///       newly inserted primarkey value
        ///    </Outputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       Tuesday, May 31, 2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************


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

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

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

                strSql = "INSERT INTO PRO_Shift("
                         + PRO_ShiftTable.SHIFTDESC_FLD + ")"
                         + "VALUES(?)";

                ocmdPCS.Parameters.Add(new OleDbParameter(PRO_ShiftTable.SHIFTDESC_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[PRO_ShiftTable.SHIFTDESC_FLD].Value = objObject.ShiftDesc;



                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();
                    }
                }
            }
        }
Exemple #2
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to get data from PRO_Shift
        ///    </Description>
        ///    <Inputs>
        ///        ID
        ///    </Inputs>
        ///    <Outputs>
        ///       PRO_ShiftVO
        ///    </Outputs>
        ///    <Returns>
        ///       PRO_ShiftVO
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       Tuesday, May 31, 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 "
                         + PRO_ShiftTable.SHIFTID_FLD + ","
                         + PRO_ShiftTable.SHIFTDESC_FLD
                         + " FROM " + PRO_ShiftTable.TABLE_NAME
                         + " WHERE " + PRO_ShiftTable.SHIFTID_FLD + "=" + pintID;

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

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

                PRO_ShiftVO objObject = new PRO_ShiftVO();

                while (odrPCS.Read())
                {
                    objObject.ShiftID   = int.Parse(odrPCS[PRO_ShiftTable.SHIFTID_FLD].ToString().Trim());
                    objObject.ShiftDesc = odrPCS[PRO_ShiftTable.SHIFTDESC_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();
                    }
                }
            }
        }