Example #1
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to add data to IV_StockTaking
        ///    </Description>
        ///    <Inputs>
        ///        IV_StockTakingVO
        ///    </Inputs>
        ///    <Outputs>
        ///       newly inserted primarkey value
        ///    </Outputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <Authors>
        ///       Code generate
        ///    </Authors>
        ///    <History>
        ///       Monday, November 20, 2006
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        public void Add(object pobjObjectVO)
        {
            const string METHOD_NAME = THIS + ".Add()";

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

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

                strSql = "INSERT INTO IV_StockTaking("
                         + IV_StockTakingTable.QUANTITY_FLD + ","
                         + IV_StockTakingTable.SLIPCODE_FLD + ","
                         + IV_StockTakingTable.NOTE_FLD + ","
                         + IV_StockTakingTable.BOOKQUANTITY_FLD + ","
                         + IV_StockTakingTable.PRODUCTID_FLD + ","
                         + IV_StockTakingTable.STOCKUMID_FLD + ","
                         + IV_StockTakingTable.COUNTINGMETHODID_FLD + ","
                         + IV_StockTakingTable.STOCKTAKINGMASTERID_FLD + ")"
                         + "VALUES(?,?,?,?,?,?,?,?)";

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

                ocmdPCS.Parameters.Add(new OleDbParameter(IV_StockTakingTable.SLIPCODE_FLD, OleDbType.WChar));
                ocmdPCS.Parameters[IV_StockTakingTable.SLIPCODE_FLD].Value = objObject.SlipCode;

                ocmdPCS.Parameters.Add(new OleDbParameter(IV_StockTakingTable.NOTE_FLD, OleDbType.WChar));
                ocmdPCS.Parameters[IV_StockTakingTable.NOTE_FLD].Value = objObject.Note;

                ocmdPCS.Parameters.Add(new OleDbParameter(IV_StockTakingTable.BOOKQUANTITY_FLD, OleDbType.Decimal));
                ocmdPCS.Parameters[IV_StockTakingTable.BOOKQUANTITY_FLD].Value = objObject.BookQuantity;

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

                ocmdPCS.Parameters.Add(new OleDbParameter(IV_StockTakingTable.STOCKUMID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[IV_StockTakingTable.STOCKUMID_FLD].Value = objObject.StockUMID;

                ocmdPCS.Parameters.Add(new OleDbParameter(IV_StockTakingTable.COUNTINGMETHODID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[IV_StockTakingTable.COUNTINGMETHODID_FLD].Value = objObject.CountingMethodID;

                ocmdPCS.Parameters.Add(new OleDbParameter(IV_StockTakingTable.STOCKTAKINGMASTERID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[IV_StockTakingTable.STOCKTAKINGMASTERID_FLD].Value = objObject.StockTakingMasterID;


                ocmdPCS.CommandText = strSql;
                ocmdPCS.Connection.Open();
                ocmdPCS.ExecuteNonQuery();
            }
            catch (OleDbException ex)
            {
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }

            catch (InvalidOperationException ex)
            {
                throw new PCSDBException(ErrorCode.DUPLICATE_KEY, 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();
                    }
                }
            }
        }
Example #2
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to get data from IV_StockTaking
        ///    </Description>
        ///    <Inputs>
        ///        ID
        ///    </Inputs>
        ///    <Outputs>
        ///       IV_StockTakingVO
        ///    </Outputs>
        ///    <Returns>
        ///       IV_StockTakingVO
        ///    </Returns>
        ///    <Authors>
        ///       Code Generate
        ///    </Authors>
        ///    <History>
        ///       Monday, November 20, 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 "
                         + IV_StockTakingTable.STOCKTAKINGID_FLD + ","
                         + IV_StockTakingTable.QUANTITY_FLD + ","
                         + IV_StockTakingTable.SLIPCODE_FLD + ","
                         + IV_StockTakingTable.NOTE_FLD + ","
                         + IV_StockTakingTable.BOOKQUANTITY_FLD + ","
                         + IV_StockTakingTable.PRODUCTID_FLD + ","
                         + IV_StockTakingTable.STOCKUMID_FLD + ","
                         + IV_StockTakingTable.COUNTINGMETHODID_FLD + ","
                         + IV_StockTakingTable.STOCKTAKINGMASTERID_FLD
                         + " FROM " + IV_StockTakingTable.TABLE_NAME
                         + " WHERE " + IV_StockTakingTable.STOCKTAKINGID_FLD + "=" + pintID;

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

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

                IV_StockTakingVO objObject = new IV_StockTakingVO();

                while (odrPCS.Read())
                {
                    objObject.StockTakingID       = int.Parse(odrPCS[IV_StockTakingTable.STOCKTAKINGID_FLD].ToString());
                    objObject.Quantity            = Decimal.Parse(odrPCS[IV_StockTakingTable.QUANTITY_FLD].ToString());
                    objObject.SlipCode            = odrPCS[IV_StockTakingTable.SLIPCODE_FLD].ToString();
                    objObject.Note                = odrPCS[IV_StockTakingTable.NOTE_FLD].ToString();
                    objObject.BookQuantity        = Decimal.Parse(odrPCS[IV_StockTakingTable.BOOKQUANTITY_FLD].ToString());
                    objObject.ProductID           = int.Parse(odrPCS[IV_StockTakingTable.PRODUCTID_FLD].ToString());
                    objObject.StockUMID           = int.Parse(odrPCS[IV_StockTakingTable.STOCKUMID_FLD].ToString());
                    objObject.CountingMethodID    = int.Parse(odrPCS[IV_StockTakingTable.COUNTINGMETHODID_FLD].ToString());
                    objObject.StockTakingMasterID = int.Parse(odrPCS[IV_StockTakingTable.STOCKTAKINGMASTERID_FLD].ToString());
                }
                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();
                    }
                }
            }
        }