예제 #1
0
        private void FixupRETURN(RETURN previousValue)
        {
            if (previousValue != null && previousValue.RETURN_DETAILS.Contains(this))
            {
                previousValue.RETURN_DETAILS.Remove(this);
            }

            if (RETURN != null)
            {
                if (!RETURN.RETURN_DETAILS.Contains(this))
                {
                    RETURN.RETURN_DETAILS.Add(this);
                }
                if (ReturnID != RETURN.ID)
                {
                    ReturnID = RETURN.ID;
                }
            }
            else if (!_settingFK)
            {
                ReturnID = null;
            }
        }
예제 #2
0
 public void Update(RETURN upReturn)
 {
     Context.RETURN.Attach(upReturn);
     Context.ObjectStateManager.ChangeObjectState(upReturn, System.Data.EntityState.Modified);
 }
예제 #3
0
 public void Insert(RETURN Return)
 {
     Context.RETURN.AddObject(Return);
 }
예제 #4
0
        public List<RETURN> Search(RETURN Return, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.RETURN.Include("ORDERS").Include("ORDERS.CUSTOMER").AsQueryable();
            if (Return != null)
            {
                if (Return.ID != 0)
                {
                    result = result.Where(b => b.ID == Return.ID);
                }

                if (!String.IsNullOrEmpty(Return.Comments))
                {
                    result = result.Where(b => b.Comments.Contains(Return.Comments));
                }

                if (Return.OrderID.HasValue)
                {
                    result = result.Where(b => b.OrderID == Return.OrderID.Value);
                }

                if (Return.ORDERS != null)
                {
                    result = result.Where(b => b.ORDERS == Return.ORDERS);
                }

                if (Return.ReceivedDate.HasValue)
                {
                    result = result.Where(b => b.ReceivedDate == Return.ReceivedDate);
                }

                if (Return.RequestDate.HasValue)
                {
                    result = result.Where(b => b.RequestDate == Return.RequestDate);
                }

                if (!string.IsNullOrEmpty(Return.CustomerName))
                {
                    result = result.Where(r => (r.ORDERS.CUSTOMER.Name + " " + r.ORDERS.CUSTOMER.Surname).Contains(Return.CustomerName));
                }

                if (!string.IsNullOrEmpty(Return.VerificationNumber))
                {
                    result = result.Where(r => r.VerificationNumber == Return.VerificationNumber);
                }
            }

            TotalRecords = result.Count();
            if (!String.IsNullOrEmpty(OrderExp))
            {
                if (SortDirection == SortDirection.Ascending)
                    result = result.OrderBy(c => c.ID).ThenBy(c => c.OrderID);
                else
                    result = result.OrderByDescending(c => c.ID).ThenBy(c => c.OrderID);
            }
            else
            {
                var sorter = new GenericSorterCaller<RETURN>();
                result = sorter.Sort(result, string.IsNullOrEmpty(OrderExp) ? DEFAULT_ORDER_EXP : OrderExp, SortDirection);
            }

            // pagination
            return result.Skip(PageIndex * PageSize).Take(PageSize).ToList();
        }
예제 #5
0
 public void Delete(RETURN delReturn)
 {
     Context.RETURN.Attach(delReturn);
     Context.DeleteObject(delReturn);
 }
예제 #6
0
 public void Delete(RETURN Return)
 {
     _returnDAO.Delete(Return);
     Context.SaveChanges();
 }
예제 #7
0
 public void Update(RETURN Return)
 {
     _returnDAO.Update(Return);
     Context.SaveChanges();
 }
예제 #8
0
 public void Insert(RETURN Return)
 {
     _returnDAO.Insert(Return);
     Context.SaveChanges();
 }
예제 #9
0
 public List<RETURN> Search(RETURN Return, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, Util.SortDirection SortDirection)
 {
     return _returnDAO.Search(Return, PageSize, PageIndex, out TotalRecords, OrderExp, SortDirection);
 }
예제 #10
0
        private void FixupRETURN(RETURN previousValue)
        {
            if (previousValue != null && previousValue.RETURN_DETAILS.Contains(this))
            {
                previousValue.RETURN_DETAILS.Remove(this);
            }

            if (RETURN != null)
            {
                if (!RETURN.RETURN_DETAILS.Contains(this))
                {
                    RETURN.RETURN_DETAILS.Add(this);
                }
                if (ReturnID != RETURN.ID)
                {
                    ReturnID = RETURN.ID;
                }
            }
            else if (!_settingFK)
            {
                ReturnID = null;
            }
        }