Ejemplo n.º 1
0
        ///    <summary>
        ///       This method uses to add data to PRO_DCPResultDetail
        ///    </summary>
        ///    <Inputs>
        ///        PRO_DCPResultDetailVO
        ///    </Inputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <History>
        ///       Monday, September 05, 2005
        ///    </History>
        public void Update(object pobjObjecVO)
        {
            const string METHOD_NAME = THIS + ".Update()";

            PRO_DCPResultDetailVO objObject = (PRO_DCPResultDetailVO)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 PRO_DCPResultDetail SET "
                          + PRO_DCPResultDetailTable.STARTTIME_FLD + "=   ?" + ","
                          + PRO_DCPResultDetailTable.ENDTIME_FLD + "=   ?" + ","
                          + PRO_DCPResultDetailTable.TOTALSECOND_FLD + "=   ?" + ","
                          + PRO_DCPResultDetailTable.QUANTITY_FLD + "=   ?" + ","
                          + PRO_DCPResultDetailTable.PERCENTAGE_FLD + "=   ?" + ","
                          + PRO_DCPResultDetailTable.DCPRESULTMASTERID_FLD + "=  ?"
                          + " WHERE " + PRO_DCPResultDetailTable.DCPRESULTDETAILID_FLD + "= ?";

                ocmdPCS.Parameters.Add(new OleDbParameter(PRO_DCPResultDetailTable.STARTTIME_FLD, OleDbType.Date));
                ocmdPCS.Parameters[PRO_DCPResultDetailTable.STARTTIME_FLD].Value = objObject.StartTime;

                ocmdPCS.Parameters.Add(new OleDbParameter(PRO_DCPResultDetailTable.ENDTIME_FLD, OleDbType.Date));
                ocmdPCS.Parameters[PRO_DCPResultDetailTable.ENDTIME_FLD].Value = objObject.EndTime;

                ocmdPCS.Parameters.Add(new OleDbParameter(PRO_DCPResultDetailTable.TOTALSECOND_FLD, OleDbType.Decimal));
                ocmdPCS.Parameters[PRO_DCPResultDetailTable.TOTALSECOND_FLD].Value = objObject.TotalSecond;

                ocmdPCS.Parameters.Add(new OleDbParameter(PRO_DCPResultDetailTable.QUANTITY_FLD, OleDbType.Decimal));
                ocmdPCS.Parameters[PRO_DCPResultDetailTable.QUANTITY_FLD].Value = objObject.Quantity;

                ocmdPCS.Parameters.Add(new OleDbParameter(PRO_DCPResultDetailTable.PERCENTAGE_FLD, OleDbType.Decimal));
                ocmdPCS.Parameters[PRO_DCPResultDetailTable.PERCENTAGE_FLD].Value = objObject.Percentage;

                ocmdPCS.Parameters.Add(new OleDbParameter(PRO_DCPResultDetailTable.DCPRESULTMASTERID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[PRO_DCPResultDetailTable.DCPRESULTMASTERID_FLD].Value = objObject.DCPResultMasterID;

                ocmdPCS.Parameters.Add(new OleDbParameter(PRO_DCPResultDetailTable.DCPRESULTDETAILID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[PRO_DCPResultDetailTable.DCPRESULTDETAILID_FLD].Value = objObject.DCPResultDetailID;


                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();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        ///    <summary>
        ///       This method uses to add data to PRO_DCPResultDetail
        ///    </summary>
        ///    <Inputs>
        ///        PRO_DCPResultDetailVO
        ///    </Inputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <History>
        ///       Monday, September 05, 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_DCPResultDetailTable.DCPRESULTDETAILID_FLD + ","
                         + PRO_DCPResultDetailTable.STARTTIME_FLD + ","
                         + PRO_DCPResultDetailTable.ENDTIME_FLD + ","
                         + PRO_DCPResultDetailTable.TOTALSECOND_FLD + ","
                         + PRO_DCPResultDetailTable.QUANTITY_FLD + ","
                         + PRO_DCPResultDetailTable.PERCENTAGE_FLD + ","
                         + PRO_DCPResultDetailTable.DCPRESULTMASTERID_FLD
                         + " FROM " + PRO_DCPResultDetailTable.TABLE_NAME
                         + " WHERE " + PRO_DCPResultDetailTable.DCPRESULTDETAILID_FLD + "=" + pintID;

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

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

                PRO_DCPResultDetailVO objObject = new PRO_DCPResultDetailVO();

                while (odrPCS.Read())
                {
                    objObject.DCPResultDetailID = int.Parse(odrPCS[PRO_DCPResultDetailTable.DCPRESULTDETAILID_FLD].ToString().Trim());
                    objObject.StartTime         = DateTime.Parse(odrPCS[PRO_DCPResultDetailTable.STARTTIME_FLD].ToString().Trim());
                    objObject.EndTime           = DateTime.Parse(odrPCS[PRO_DCPResultDetailTable.ENDTIME_FLD].ToString().Trim());
                    objObject.TotalSecond       = Decimal.Parse(odrPCS[PRO_DCPResultDetailTable.TOTALSECOND_FLD].ToString().Trim());
                    objObject.Quantity          = Decimal.Parse(odrPCS[PRO_DCPResultDetailTable.QUANTITY_FLD].ToString().Trim());
                    objObject.Percentage        = Decimal.Parse(odrPCS[PRO_DCPResultDetailTable.PERCENTAGE_FLD].ToString().Trim());
                    objObject.DCPResultMasterID = int.Parse(odrPCS[PRO_DCPResultDetailTable.DCPRESULTMASTERID_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();
                    }
                }
            }
        }