Exemplo n.º 1
0
        ///    <summary>
        ///       This method uses to add data to PRO_DCOptionDetail
        ///    </summary>
        ///    <Inputs>
        ///        PRO_DCOptionDetailVO
        ///    </Inputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <History>
        ///       Tuesday, August 02, 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_DCOptionDetailTable.DCOPTIONDETAILID_FLD + ","
                         + PRO_DCOptionDetailTable.MASTERLOCATIONID_FLD + ","
                         + PRO_DCOptionDetailTable.WORKORDER_FLD + ","
                         + PRO_DCOptionDetailTable.DCOPTIONMASTERID_FLD
                         + " FROM " + PRO_DCOptionDetailTable.TABLE_NAME
                         + " WHERE " + PRO_DCOptionDetailTable.DCOPTIONDETAILID_FLD + "=" + pintID;

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

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

                PRO_DCOptionDetailVO objObject = new PRO_DCOptionDetailVO();

                while (odrPCS.Read())
                {
                    objObject.DCOptionDetailID = int.Parse(odrPCS[PRO_DCOptionDetailTable.DCOPTIONDETAILID_FLD].ToString().Trim());
                    objObject.MasterLocationID = int.Parse(odrPCS[PRO_DCOptionDetailTable.MASTERLOCATIONID_FLD].ToString().Trim());
                    objObject.WorkOrder        = bool.Parse(odrPCS[PRO_DCOptionDetailTable.WORKORDER_FLD].ToString().Trim());
                    objObject.DCOptionMasterID = int.Parse(odrPCS[PRO_DCOptionDetailTable.DCOPTIONMASTERID_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();
                    }
                }
            }
        }
Exemplo n.º 2
0
        ///    <summary>
        ///       This method uses to add data to PRO_DCOptionDetail
        ///    </summary>
        ///    <Inputs>
        ///        PRO_DCOptionDetailVO
        ///    </Inputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <History>
        ///       Tuesday, August 02, 2005
        ///    </History>


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

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

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

                strSql = "INSERT INTO PRO_DCOptionDetail("
                         + PRO_DCOptionDetailTable.MASTERLOCATIONID_FLD + ","
                         + PRO_DCOptionDetailTable.WORKORDER_FLD + ","
                         + PRO_DCOptionDetailTable.DCOPTIONMASTERID_FLD + ")"
                         + "VALUES(?,?,?)";

                ocmdPCS.Parameters.Add(new OleDbParameter(PRO_DCOptionDetailTable.MASTERLOCATIONID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[PRO_DCOptionDetailTable.MASTERLOCATIONID_FLD].Value = objObject.MasterLocationID;

                ocmdPCS.Parameters.Add(new OleDbParameter(PRO_DCOptionDetailTable.WORKORDER_FLD, OleDbType.Boolean));
                ocmdPCS.Parameters[PRO_DCOptionDetailTable.WORKORDER_FLD].Value = objObject.WorkOrder;

                ocmdPCS.Parameters.Add(new OleDbParameter(PRO_DCOptionDetailTable.DCOPTIONMASTERID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[PRO_DCOptionDetailTable.DCOPTIONMASTERID_FLD].Value = objObject.DCOptionMasterID;



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