private static CustomerRmaLineAllocation PopulateFromDBDetailsObject(CustomerRmaLineAllocationDetails obj)
        {
            CustomerRmaLineAllocation objNew = new CustomerRmaLineAllocation();

            objNew.CustomerRMALineAllocationId = obj.CustomerRMALineAllocationId;
            objNew.CustomerRMALineNo           = obj.CustomerRMALineNo;
            objNew.InvoiceLineAllocationNo     = obj.InvoiceLineAllocationNo;
            objNew.Quantity            = obj.Quantity;
            objNew.GoodsInLineNo       = obj.GoodsInLineNo;
            objNew.UpdatedBy           = obj.UpdatedBy;
            objNew.DLUP                = obj.DLUP;
            objNew.CustomerRMAId       = obj.CustomerRMAId;
            objNew.CustomerRMANumber   = obj.CustomerRMANumber;
            objNew.CustomerRMADate     = obj.CustomerRMADate;
            objNew.ReturnDate          = obj.ReturnDate;
            objNew.ClientNo            = obj.ClientNo;
            objNew.Reason              = obj.Reason;
            objNew.InvoiceNumber       = obj.InvoiceNumber;
            objNew.InvoiceNo           = obj.InvoiceNo;
            objNew.InvoiceLineNo       = obj.InvoiceLineNo;
            objNew.CompanyNo           = obj.CompanyNo;
            objNew.CompanyName         = obj.CompanyName;
            objNew.PurchaseOrderLineNo = obj.PurchaseOrderLineNo;
            objNew.AuthorisedBy        = obj.AuthorisedBy;
            objNew.AuthoriserName      = obj.AuthoriserName;
            objNew.StockNo             = obj.StockNo;
            objNew.RowNum              = obj.RowNum;
            return(objNew);
        }
        /// <summary>
        /// GetListForPurchaseOrderLine
        /// Calls [usp_selectAll_CustomerRMALineAllocation_for_PurchaseOrderLine]
        /// </summary>
        public override List <CustomerRmaLineAllocationDetails> GetListForPurchaseOrderLine(System.Int32?purchaseOrderLineId, System.Int32?pageIndex, System.Int32?pageSize)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_selectAll_CustomerRMALineAllocation_for_PurchaseOrderLine", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@PurchaseOrderLineId", SqlDbType.Int).Value = purchaseOrderLineId;
                cmd.Parameters.Add("@PageIndex", SqlDbType.Int).Value           = pageIndex;
                cmd.Parameters.Add("@PageSize", SqlDbType.Int).Value            = pageSize;
                cn.Open();
                DbDataReader reader = ExecuteReader(cmd);
                List <CustomerRmaLineAllocationDetails> lst = new List <CustomerRmaLineAllocationDetails>();
                while (reader.Read())
                {
                    CustomerRmaLineAllocationDetails obj = new CustomerRmaLineAllocationDetails();
                    obj.CustomerRMALineAllocationId = GetReaderValue_Int32(reader, "CustomerRMALineAllocationId", 0);
                    obj.CustomerRMALineNo           = GetReaderValue_Int32(reader, "CustomerRMALineNo", 0);
                    obj.InvoiceLineAllocationNo     = GetReaderValue_Int32(reader, "InvoiceLineAllocationNo", 0);
                    obj.Quantity            = GetReaderValue_Int32(reader, "Quantity", 0);
                    obj.GoodsInLineNo       = GetReaderValue_NullableInt32(reader, "GoodsInLineNo", null);
                    obj.CustomerRMAId       = GetReaderValue_Int32(reader, "CustomerRMAId", 0);
                    obj.CustomerRMANumber   = GetReaderValue_Int32(reader, "CustomerRMANumber", 0);
                    obj.CustomerRMADate     = GetReaderValue_DateTime(reader, "CustomerRMADate", DateTime.MinValue);
                    obj.ReturnDate          = GetReaderValue_NullableDateTime(reader, "ReturnDate", null);
                    obj.ClientNo            = GetReaderValue_Int32(reader, "ClientNo", 0);
                    obj.Reason              = GetReaderValue_String(reader, "Reason", "");
                    obj.InvoiceNumber       = GetReaderValue_Int32(reader, "InvoiceNumber", 0);
                    obj.InvoiceNo           = GetReaderValue_NullableInt32(reader, "InvoiceNo", null);
                    obj.InvoiceLineNo       = GetReaderValue_Int32(reader, "InvoiceLineNo", 0);
                    obj.CompanyNo           = GetReaderValue_Int32(reader, "CompanyNo", 0);
                    obj.CompanyName         = GetReaderValue_String(reader, "CompanyName", "");
                    obj.PurchaseOrderLineNo = GetReaderValue_NullableInt32(reader, "PurchaseOrderLineNo", null);
                    obj.AuthorisedBy        = GetReaderValue_Int32(reader, "AuthorisedBy", 0);
                    obj.AuthoriserName      = GetReaderValue_String(reader, "AuthoriserName", "");
                    obj.StockNo             = GetReaderValue_NullableInt32(reader, "StockNo", null);
                    lst.Add(obj);
                    obj = null;
                }
                return(lst);
            } catch (SqlException sqlex) {
                //LogException(sqlex);
                throw new Exception("Failed to get CustomerRmaLineAllocations", sqlex);
            } finally {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
        /// <summary>
        /// Get
        /// Calls [usp_select_CustomerRMALineAllocation]
        /// </summary>
        public override CustomerRmaLineAllocationDetails Get(System.Int32?customerRmaLineAllocationId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_select_CustomerRMALineAllocation", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@CustomerRMALineAllocationId", SqlDbType.Int).Value = customerRmaLineAllocationId;
                cn.Open();
                DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    //return GetCustomerRmaLineAllocationFromReader(reader);
                    CustomerRmaLineAllocationDetails obj = new CustomerRmaLineAllocationDetails();
                    obj.CustomerRMALineAllocationId = GetReaderValue_Int32(reader, "CustomerRMALineAllocationId", 0);
                    obj.CustomerRMALineNo           = GetReaderValue_Int32(reader, "CustomerRMALineNo", 0);
                    obj.InvoiceLineAllocationNo     = GetReaderValue_Int32(reader, "InvoiceLineAllocationNo", 0);
                    obj.Quantity      = GetReaderValue_Int32(reader, "Quantity", 0);
                    obj.GoodsInLineNo = GetReaderValue_NullableInt32(reader, "GoodsInLineNo", null);
                    obj.UpdatedBy     = GetReaderValue_NullableInt32(reader, "UpdatedBy", null);
                    obj.DLUP          = GetReaderValue_DateTime(reader, "DLUP", DateTime.MinValue);
                    return(obj);
                }
                else
                {
                    return(null);
                }
            } catch (SqlException sqlex) {
                //LogException(sqlex);
                throw new Exception("Failed to get CustomerRmaLineAllocation", sqlex);
            } finally {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }