Esempio n. 1
0
        ///    <summary>
        ///       This method uses to add data to PRO_ShiftCapacity
        ///    </summary>
        ///    <Inputs>
        ///        PRO_ShiftCapacityVO
        ///    </Inputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <History>
        ///       Friday, August 12, 2005
        ///    </History>

        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_ShiftCapacityTable.SHIFTCAPACITYID_FLD + ","
                         + PRO_ShiftCapacityTable.WCCAPACITYID_FLD + ","
                         + PRO_ShiftCapacityTable.SHIFTID_FLD
                         + " FROM " + PRO_ShiftCapacityTable.TABLE_NAME
                         + " WHERE " + PRO_ShiftCapacityTable.SHIFTCAPACITYID_FLD + "=" + pintID;

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

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

                PRO_ShiftCapacityVO objObject = new PRO_ShiftCapacityVO();

                while (odrPCS.Read())
                {
                    objObject.ShiftCapacityID = int.Parse(odrPCS[PRO_ShiftCapacityTable.SHIFTCAPACITYID_FLD].ToString().Trim());
                    objObject.WCCapacityID    = int.Parse(odrPCS[PRO_ShiftCapacityTable.WCCAPACITYID_FLD].ToString().Trim());
                    objObject.ShiftID         = int.Parse(odrPCS[PRO_ShiftCapacityTable.SHIFTID_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
        ///    <summary>
        ///       This method uses to add data to PRO_ShiftCapacity
        ///    </summary>
        ///    <Inputs>
        ///        PRO_ShiftCapacityVO
        ///    </Inputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <History>
        ///       Friday, August 12, 2005
        ///    </History>


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

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

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

                strSql = "INSERT INTO PRO_ShiftCapacity("
                         + PRO_ShiftCapacityTable.WCCAPACITYID_FLD + ","
                         + PRO_ShiftCapacityTable.SHIFTID_FLD + ")"
                         + "VALUES(?,?)";

                ocmdPCS.Parameters.Add(new OleDbParameter(PRO_ShiftCapacityTable.WCCAPACITYID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[PRO_ShiftCapacityTable.WCCAPACITYID_FLD].Value = objObject.WCCapacityID;

                ocmdPCS.Parameters.Add(new OleDbParameter(PRO_ShiftCapacityTable.SHIFTID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[PRO_ShiftCapacityTable.SHIFTID_FLD].Value = objObject.ShiftID;



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