コード例 #1
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to add data to CST_RecoverMaterialDetail
        ///    </Description>
        ///    <Inputs>
        ///        CST_RecoverMaterialDetailVO
        ///    </Inputs>
        ///    <Outputs>
        ///       newly inserted primarkey value
        ///    </Outputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       Friday, February 24, 2006
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************


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

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

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

                strSql = "INSERT INTO CST_RecoverMaterialDetail("
                         + CST_RecoverMaterialDetailTable.RECOVERMATERIALMASTERID_FLD + ","
                         + CST_RecoverMaterialDetailTable.PRODUCTID_FLD + ","
                         + CST_RecoverMaterialDetailTable.RECOVERQUANTITY_FLD + ","
                         + CST_RecoverMaterialDetailTable.UNITOFMEASUREID_FLD + ","
                         + CST_RecoverMaterialDetailTable.TOBINID_FLD + ","
                         + CST_RecoverMaterialDetailTable.TOLOCATIONID_FLD + ","
                         + CST_RecoverMaterialDetailTable.PARTYID_FLD + ")"
                         + "VALUES(?,?,?,?,?,?,?)";

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_RecoverMaterialDetailTable.RECOVERMATERIALMASTERID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[CST_RecoverMaterialDetailTable.RECOVERMATERIALMASTERID_FLD].Value = objObject.RecoverMaterialMasterID;

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_RecoverMaterialDetailTable.PRODUCTID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[CST_RecoverMaterialDetailTable.PRODUCTID_FLD].Value = objObject.ProductID;

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_RecoverMaterialDetailTable.RECOVERQUANTITY_FLD, OleDbType.Decimal));
                ocmdPCS.Parameters[CST_RecoverMaterialDetailTable.RECOVERQUANTITY_FLD].Value = objObject.RecoverQuantity;

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_RecoverMaterialDetailTable.UNITOFMEASUREID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[CST_RecoverMaterialDetailTable.UNITOFMEASUREID_FLD].Value = objObject.UnitOfMeasureID;

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_RecoverMaterialDetailTable.TOBINID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[CST_RecoverMaterialDetailTable.TOBINID_FLD].Value = objObject.ToBinID;

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_RecoverMaterialDetailTable.TOLOCATIONID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[CST_RecoverMaterialDetailTable.TOLOCATIONID_FLD].Value = objObject.ToLocationID;

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_RecoverMaterialDetailTable.PARTYID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[CST_RecoverMaterialDetailTable.PARTYID_FLD].Value = objObject.PartyID;



                ocmdPCS.CommandText = strSql;
                ocmdPCS.Connection.Open();
                ocmdPCS.ExecuteNonQuery();
            }
            catch (OleDbException ex)
            {
                if (ex.Errors.Count > 1)
                {
                    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 CST_RecoverMaterialDetail
        ///    </Description>
        ///    <Inputs>
        ///        ID
        ///    </Inputs>
        ///    <Outputs>
        ///       CST_RecoverMaterialDetailVO
        ///    </Outputs>
        ///    <Returns>
        ///       CST_RecoverMaterialDetailVO
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       Friday, February 24, 2006
        ///    </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 "
                         + CST_RecoverMaterialDetailTable.RECOVERMATERIALDETAILID_FLD + ","
                         + CST_RecoverMaterialDetailTable.RECOVERMATERIALMASTERID_FLD + ","
                         + CST_RecoverMaterialDetailTable.PRODUCTID_FLD + ","
                         + CST_RecoverMaterialDetailTable.RECOVERQUANTITY_FLD + ","
                         + CST_RecoverMaterialDetailTable.UNITOFMEASUREID_FLD + ","
                         + CST_RecoverMaterialDetailTable.TOBINID_FLD + ","
                         + CST_RecoverMaterialDetailTable.TOLOCATIONID_FLD + ","
                         + CST_RecoverMaterialDetailTable.PARTYID_FLD
                         + " FROM " + CST_RecoverMaterialDetailTable.TABLE_NAME
                         + " WHERE " + CST_RecoverMaterialDetailTable.RECOVERMATERIALDETAILID_FLD + "=" + pintID;

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

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

                CST_RecoverMaterialDetailVO objObject = new CST_RecoverMaterialDetailVO();

                while (odrPCS.Read())
                {
                    objObject.RecoverMaterialDetailID = int.Parse(odrPCS[CST_RecoverMaterialDetailTable.RECOVERMATERIALDETAILID_FLD].ToString().Trim());
                    objObject.RecoverMaterialMasterID = int.Parse(odrPCS[CST_RecoverMaterialDetailTable.RECOVERMATERIALMASTERID_FLD].ToString().Trim());
                    objObject.ProductID       = int.Parse(odrPCS[CST_RecoverMaterialDetailTable.PRODUCTID_FLD].ToString().Trim());
                    objObject.RecoverQuantity = Decimal.Parse(odrPCS[CST_RecoverMaterialDetailTable.RECOVERQUANTITY_FLD].ToString().Trim());
                    objObject.UnitOfMeasureID = int.Parse(odrPCS[CST_RecoverMaterialDetailTable.UNITOFMEASUREID_FLD].ToString().Trim());
                    objObject.ToBinID         = int.Parse(odrPCS[CST_RecoverMaterialDetailTable.TOBINID_FLD].ToString().Trim());
                    objObject.ToLocationID    = int.Parse(odrPCS[CST_RecoverMaterialDetailTable.TOLOCATIONID_FLD].ToString().Trim());
                    objObject.PartyID         = int.Parse(odrPCS[CST_RecoverMaterialDetailTable.PARTYID_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();
                    }
                }
            }
        }