示例#1
0
        public int SaveTransaction(PURPurchaseReturnHeader pURPurchaseReturnHeader, PURPurchaseReturnLineCollection pURPurchaseReturnLineCollection)
        {
            oDatabaseHelper = new DatabaseHelper();
            bool ExecutionState      = false;
            int  salesReturnHeaderID = -1;

            oDatabaseHelper.BeginTransaction();
            if (InsertHeader(oDatabaseHelper, pURPurchaseReturnHeader, out salesReturnHeaderID))
            {
                foreach (PURPurchaseReturnLine pURPurchaseLine in pURPurchaseReturnLineCollection)
                {
                    if (!InsertDetails(oDatabaseHelper, pURPurchaseLine, salesReturnHeaderID))
                    {
                        ExecutionState = false;
                        break;
                    }
                    else
                    {
                        ExecutionState = true;
                    }
                }
                if (ExecutionState)
                {
                    oDatabaseHelper.CommitTransaction();
                }
                else
                {
                    oDatabaseHelper.RollbackTransaction();
                }
            }
            return(salesReturnHeaderID);
        }
        /// <summary>
        /// This method will get row(s) from the database using the value of the field specified
        /// along with the details of the child table.
        /// </summary>
        ///
        /// <param name="pk" type="PURPurchaseLinePrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class PURPurchaseReturnLineCollection</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			3/7/2015 2:37:26 PM				Created function
        ///
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static PURPurchaseReturnLineCollection SelectAllByForeignKeyOriginalpurchaseLineID(PURPurchaseLinePrimaryKey pk)
        {
            DatabaseHelper oDatabaseHelper      = new DatabaseHelper();
            bool           ExecutionState       = false;
            PURPurchaseReturnLineCollection obj = null;

            // Pass the values of all key parameters to the stored procedure.
            System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues();
            foreach (string key in nvc.Keys)
            {
                oDatabaseHelper.AddParameter("@" + key, nvc[key]);
            }

            // The parameter '@dlgErrorCode' will contain the status after execution of the stored procedure.
            oDatabaseHelper.AddParameter("@dlgErrorCode", -1, System.Data.ParameterDirection.Output);

            IDataReader dr = oDatabaseHelper.ExecuteReader("gsp_PURPurchaseReturnLine_SelectAllByForeignKeyOriginalpurchaseLineID", ref ExecutionState);

            obj = new PURPurchaseReturnLineCollection();
            obj = PURPurchaseReturnLine.PopulateObjectsFromReaderWithCheckingReader(dr, oDatabaseHelper);

            dr.Close();
            oDatabaseHelper.Dispose();
            return(obj);
        }
        /// <summary>
        /// Populates the fields for multiple objects from the columns found in an open reader.
        /// </summary>
        ///
        /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
        ///
        /// <returns>Object of PURPurchaseReturnLineCollection</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			3/7/2015 2:37:26 PM		Created function
        ///
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        internal static PURPurchaseReturnLineCollection PopulateObjectsFromReader(IDataReader rdr)
        {
            PURPurchaseReturnLineCollection list = new PURPurchaseReturnLineCollection();

            while (rdr.Read())
            {
                PURPurchaseReturnLine obj = new PURPurchaseReturnLine();
                PopulateObjectFromReader(obj, rdr);
                list.Add(obj);
            }
            return(list);
        }
        /// <summary>
        /// This method will return a list of objects representing all records in the table.
        /// </summary>
        ///
        /// <returns>list of objects of class PURPurchaseReturnLine in the form of object of PURPurchaseReturnLineCollection </returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			3/7/2015 2:37:26 PM		Created function
        ///
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static PURPurchaseReturnLineCollection SelectAll()
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper();
            bool           ExecutionState  = false;

            // The parameter '@dlgErrorCode' will contain the status after execution of the stored procedure.
            oDatabaseHelper.AddParameter("@dlgErrorCode", -1, System.Data.ParameterDirection.Output);

            IDataReader dr = oDatabaseHelper.ExecuteReader("gsp_PURPurchaseReturnLine_SelectAll", ref ExecutionState);
            PURPurchaseReturnLineCollection PURPurchaseReturnLineCollection = PopulateObjectsFromReader(dr);

            dr.Close();
            oDatabaseHelper.Dispose();
            return(PURPurchaseReturnLineCollection);
        }
        /// <summary>
        /// This method will return a list of objects representing the specified number of entries from the specified record number in the table.
        /// </summary>
        ///
        /// <param name="pageSize" type="int">Number of records returned.</param>
        /// <param name="skipPages" type="int">The number of missing pages.</param>
        /// <param name="orderByStatement" type="string">The field value to number</param>
        ///
        /// <returns>list of objects of class PURPurchaseReturnLine in the form of object of PURPurchaseReturnLineCollection </returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			3/7/2015 2:37:26 PM		Created function
        ///
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static PURPurchaseReturnLineCollection SelectAllPaged(int?pageSize, int?skipPages, string orderByStatement)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper();
            bool           ExecutionState  = false;

            // Pass the specified field and its value to the stored procedure.
            oDatabaseHelper.AddParameter("@PageSize", pageSize);
            oDatabaseHelper.AddParameter("@SkipPages", skipPages);
            oDatabaseHelper.AddParameter("@OrderByStatement", orderByStatement);

            // The parameter '@dlgErrorCode' will contain the status after execution of the stored procedure.
            oDatabaseHelper.AddParameter("@dlgErrorCode", -1, System.Data.ParameterDirection.Output);

            IDataReader dr = oDatabaseHelper.ExecuteReader("gsp_PURPurchaseReturnLine_SelectAllPaged", ref ExecutionState);
            PURPurchaseReturnLineCollection PURPurchaseReturnLineCollection = PopulateObjectsFromReader(dr);

            dr.Close();
            oDatabaseHelper.Dispose();
            return(PURPurchaseReturnLineCollection);
        }
        /// <summary>
        /// This method will get row(s) from the database using the value of the field specified
        /// </summary>
        ///
        /// <param name="field" type="string">Field of the class PURPurchaseReturnLine</param>
        /// <param name="fieldValue" type="object">Value for the field specified.</param>
        /// <param name="fieldValue2" type="object">Value for the field specified.</param>
        /// <param name="typeOperation" type="TypeOperation">Operator that is used if fieldValue2=null or fieldValue2="".</param>
        ///
        /// <returns>List of object of class PURPurchaseReturnLine in the form of an object of class PURPurchaseReturnLineCollection</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			3/7/2015 2:37:26 PM		Created function
        ///
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static PURPurchaseReturnLineCollection SelectByField(string field, object fieldValue, object fieldValue2, TypeOperation typeOperation)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper();
            bool           ExecutionState  = false;

            // Pass the specified field and its value to the stored procedure.
            oDatabaseHelper.AddParameter("@Field", field);
            oDatabaseHelper.AddParameter("@Value", fieldValue);
            oDatabaseHelper.AddParameter("@Value2", fieldValue2);
            oDatabaseHelper.AddParameter("@Operation", OperationCollection.Operation[(int)typeOperation]);

            // The parameter '@dlgErrorCode' will contain the status after execution of the stored procedure.
            oDatabaseHelper.AddParameter("@dlgErrorCode", -1, System.Data.ParameterDirection.Output);

            IDataReader dr = oDatabaseHelper.ExecuteReader("gsp_PURPurchaseReturnLine_SelectByField", ref ExecutionState);
            PURPurchaseReturnLineCollection PURPurchaseReturnLineCollection = PopulateObjectsFromReader(dr);

            dr.Close();
            oDatabaseHelper.Dispose();
            return(PURPurchaseReturnLineCollection);
        }
        /// <summary>
        /// Populates the fields for multiple objects from the columns found in an open reader.
        /// </summary>
        ///
        /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
        ///
        /// <returns>Object of PURPurchaseReturnLineCollection</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			3/7/2015 2:37:26 PM		Created function
        ///
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        internal static PURPurchaseReturnLineCollection PopulateObjectsFromReaderWithCheckingReader(IDataReader rdr, DatabaseHelper oDatabaseHelper)
        {
            PURPurchaseReturnLineCollection list = new PURPurchaseReturnLineCollection();

            if (rdr.Read())
            {
                PURPurchaseReturnLine obj = new PURPurchaseReturnLine();
                PopulateObjectFromReader(obj, rdr);
                list.Add(obj);
                while (rdr.Read())
                {
                    obj = new PURPurchaseReturnLine();
                    PopulateObjectFromReader(obj, rdr);
                    list.Add(obj);
                }
                oDatabaseHelper.Dispose();
                return(list);
            }
            else
            {
                oDatabaseHelper.Dispose();
                return(null);
            }
        }
示例#8
0
        public bool UpdateTransaction(PURPurchaseReturnHeader pURPurchaseReturnHeader, PURPurchaseReturnLineCollection pURPurchaseReturnLineCollection)
        {
            oDatabaseHelper = new DatabaseHelper();
            bool ExecutionState = false;

            oDatabaseHelper.BeginTransaction();
            if (UpdateHeader(oDatabaseHelper, pURPurchaseReturnHeader))
            {
                if (DeleteDetails(oDatabaseHelper, (int)pURPurchaseReturnHeader.PurchaseReturnID, (int)pURPurchaseReturnHeader.UpdatedBy))
                {
                    foreach (PURPurchaseReturnLine pURPurchaseReturnLine in pURPurchaseReturnLineCollection)
                    {
                        if (!InsertDetails(oDatabaseHelper, pURPurchaseReturnLine, (int)pURPurchaseReturnHeader.PurchaseReturnID))
                        {
                            ExecutionState = false;
                            break;
                        }
                        else
                        {
                            ExecutionState = true;
                        }
                    }
                    if (ExecutionState)
                    {
                        oDatabaseHelper.CommitTransaction();
                    }
                    else
                    {
                        oDatabaseHelper.RollbackTransaction();
                    }
                }
                else
                {
                    ExecutionState = false;
                }
            }
            else
            {
                ExecutionState = false;
            }
            return(ExecutionState);
        }
 public Enumerator(PURPurchaseReturnLineCollection t)
 {
     this.t = t;
 }