Пример #1
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to update data to MST_UMRate
        ///    </Description>
        ///    <Inputs>
        ///       MST_UMRateVO
        ///    </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()";

            MST_UMRateVO objObject = (MST_UMRateVO)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 MST_UMRate SET "
                          + MST_UMRateTable.SCALE_FLD + "=   ?" + ","
                          + MST_UMRateTable.DESCRIPTION_FLD + "=   ?" + ","
                          + MST_UMRateTable.UNITOFMEASUREOUTID_FLD + "=   ?" + ","
                          + MST_UMRateTable.UNITOFMEASUREINID_FLD + "=  ?"
                          + " WHERE " + MST_UMRateTable.UMRATEID_FLD + "= ?";

                ocmdPCS.Parameters.Add(new OleDbParameter(MST_UMRateTable.SCALE_FLD, OleDbType.Decimal));
                ocmdPCS.Parameters[MST_UMRateTable.SCALE_FLD].Value = objObject.Scale;

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

                ocmdPCS.Parameters.Add(new OleDbParameter(MST_UMRateTable.UNITOFMEASUREOUTID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[MST_UMRateTable.UNITOFMEASUREOUTID_FLD].Value = objObject.UnitOfMeasureOutID;

                ocmdPCS.Parameters.Add(new OleDbParameter(MST_UMRateTable.UNITOFMEASUREINID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[MST_UMRateTable.UNITOFMEASUREINID_FLD].Value = objObject.UnitOfMeasureInID;

                ocmdPCS.Parameters.Add(new OleDbParameter(MST_UMRateTable.UMRATEID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[MST_UMRateTable.UMRATEID_FLD].Value = objObject.UMRateID;


                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();
                    }
                }
            }
        }
Пример #2
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to get data from MST_UMRate
        ///    </Description>
        ///    <Inputs>
        ///        ID
        ///    </Inputs>
        ///    <Outputs>
        ///       MST_UMRateVO
        ///    </Outputs>
        ///    <Returns>
        ///       MST_UMRateVO
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       Tuesday, January 25, 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 "
                         + MST_UMRateTable.UMRATEID_FLD + ","
                         + MST_UMRateTable.SCALE_FLD + ","
                         + MST_UMRateTable.DESCRIPTION_FLD + ","
                         + MST_UMRateTable.UNITOFMEASUREOUTID_FLD + ","
                         + MST_UMRateTable.UNITOFMEASUREINID_FLD
                         + " FROM " + MST_UMRateTable.TABLE_NAME
                         + " WHERE " + MST_UMRateTable.UMRATEID_FLD + "=" + pintID;

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

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

                MST_UMRateVO objObject = new MST_UMRateVO();

                while (odrPCS.Read())
                {
                    objObject.UMRateID           = int.Parse(odrPCS[MST_UMRateTable.UMRATEID_FLD].ToString().Trim());
                    objObject.Scale              = Decimal.Parse(odrPCS[MST_UMRateTable.SCALE_FLD].ToString().Trim());
                    objObject.Description        = odrPCS[MST_UMRateTable.DESCRIPTION_FLD].ToString().Trim();
                    objObject.UnitOfMeasureOutID = int.Parse(odrPCS[MST_UMRateTable.UNITOFMEASUREOUTID_FLD].ToString().Trim());
                    objObject.UnitOfMeasureInID  = int.Parse(odrPCS[MST_UMRateTable.UNITOFMEASUREINID_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();
                    }
                }
            }
        }