public void AddUnPaidPurchaseScaleExpenses(int scaleId)
        {
            // Search for all expenses that matches scaleId.
            ExpensesRequestLibrary lib             = new ExpensesRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
            string refTableName                    = new Model.Scale().GetType().Name;
            IEnumerable <ExpensesRequest> expenses = lib.GetAllPurchasingExepneseByRefTableAndRefId(scaleId, refTableName, new[] { "Payment", "Paid_Party_To" });
            ScaleLibrary scaleLib                  = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());

            foreach (var item in expenses)
            {
                // If scale expense already exists.
                if (TempEntityList.FirstOrDefault(m => m.ID == item.ID) == null)
                {
                    // Get scale entity
                    Scale scale = scaleLib.GetByID(item.Reference_ID.ToString(), new string[] { "Dispatch_Request_No" });
                    if (item.Paid_Party_To == null)
                    {
                        item.Paid_Party_To = new Party();
                    }
                    // Add eexpense to TempList.
                    TempEntityList.Add(item);
                    // Add dispatcher expense.
                    if (scale.Dispatch_Request_No != null && scale.Dispatch_Request_No.ID > 0)
                    {
                        AddUnPaidPurchaseDispatcherExpenses(scale.Dispatch_Request_No.ID);
                    }
                }
            }
        }
        private void AddNonInvoiceSellingDispatcherExpenses(int bookingId, string containerNo)
        {
            // Search for expenses that matches dispatcher id.
            DispatcherRequestLibrary        dispathcerRequestLib = new DispatcherRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
            IEnumerable <DispatcherRequest> dispatcherReqs       = dispathcerRequestLib.GetDispatcherByBookingAndContainerNo(bookingId, containerNo, new string[] { "Booking_Ref_No", "Container" });

            foreach (DispatcherRequest dispatcherReq in dispatcherReqs)
            {
                ExpensesRequestLibrary lib             = new ExpensesRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                string refTableName                    = new Model.DispatcherRequest().GetType().Name;
                IEnumerable <ExpensesRequest> expenses = lib.GetAllPurchasingExepneseByRefTableAndRefId(dispatcherReq.ID, refTableName, new[] { "Payment", "Paid_Party_To", "Invoice" });
                foreach (var item in expenses)
                {
                    // If expense already exists.
                    if (TempEntityList.FirstOrDefault(m => m.ID == item.ID) == null)
                    {
                        // If party is null.
                        if (item.Paid_Party_To == null)
                        {
                            item.Paid_Party_To = new Party();
                        }

                        // Add to TempList.
                        TempEntityList.Add(item);
                    }
                }
            }
        }
        //[HttpPost]
        //public void RemoveUnPaidSellingExpenses(string bookingId) {
        //  // If TEmpEntityList has no Items.
        //  if (TempEntityList != null) {
        //    int intBookingId = Convert.ToInt32(bookingId);
        //    if (intBookingId > 0) {
        //      // Get all scale exepenses.
        //      IEnumerable<ExpensesRequest> scaleExps = from exp in TempEntityList
        //                                               where exp.Reference_Table == "Scale" && exp.Reference_ID == intBookingId
        //                                               select exp;
        //      if (scaleExps != null) {
        //        IList<ExpensesRequest> removeExpenses = new List<ExpensesRequest>();
        //        ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
        //        foreach (var item in scaleExps) {
        //          // Get scale entity.
        //          Scale scale = scaleLib.GetByID(item.Reference_ID.ToString(), new string[] { "Dispatch_Request_No" });
        //          if (scale != null && scale.Dispatch_Request_No != null && scale.Dispatch_Request_No.ID > 0) {
        //            // Get dispatcher id.
        //            int dispatcherId = scale.Dispatch_Request_No.ID;
        //            // Get all dispatcher expenses.
        //            IEnumerable<ExpensesRequest> dispatcherExps = from exp in TempEntityList
        //                                                          where exp.Reference_Table == "DispatcherRequest" && exp.Reference_ID == dispatcherId
        //                                                          select exp;
        //            if (dispatcherExps != null) {
        //              foreach (var dispExp in dispatcherExps) {
        //                // Add dispatcher expense in removeExpense list.
        //                removeExpenses.Add(dispExp);
        //              }
        //            }

        //          }
        //          // Add scale expense in removeExpense list.
        //          removeExpenses.Add(item);
        //        }
        //        // Delete scale and dispatcher expense.
        //        foreach (var removeExp in removeExpenses) {
        //          TempEntityList.Remove(removeExp);
        //        }
        //      }
        //    }
        //  }
        //}

        public void AddNonInvoiceSellingScaleExpenses(int bookingId)
        {
            TempEntityList.Clear();
            ScaleLibrary        scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
            IEnumerable <Scale> scales   = scaleLib.GetScalesByBookingId(bookingId);
            // Search for all expenses that matches scaleId.
            ExpensesRequestLibrary lib = new ExpensesRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
            string refTableName        = new Model.Scale().GetType().Name;

            foreach (var scale in scales)
            {
                IEnumerable <ExpensesRequest> expenses = lib.GetAllSellingExepneseByRefTableAndRefId(scale.ID, refTableName, new[] { "Payment", "Paid_Party_To", "Invoice" });
                foreach (var expense in expenses)
                {
                    // If scale expense already exists.
                    if (TempEntityList.FirstOrDefault(m => m.ID == expense.ID) == null)
                    {
                        if (expense.Paid_Party_To == null)
                        {
                            expense.Paid_Party_To = new Party();
                        }
                        // Add eexpense to TempList.
                        TempEntityList.Add(expense);
                        // Add dispatcher expense.
                    }
                }
                AddNonInvoiceSellingDispatcherExpenses(bookingId, scale.ContainerNo);
            }
        }
Пример #4
0
        //protected override ActionResult Display(GridCommand command, string id, bool isNew)
        //{
        //    int totalRows = 0;
        //    IEnumerable<LOV> resultList;    // = ((IParentChildLibrary<TEntity>)Library).GetAllByPagingByParentID(out totalRows, int.Parse(id.ToString()), command.Page, command.PageSize==0?20:command.PageSize, "", "Asc", IncludePredicates);

        //    if (Convert.ToInt32(id)>0)
        //      ViewBag.Parent_Type_ID = id;

        //    if (isNew || id == "0")
        //    {
        //        resultList = TempEntityList;
        //        totalRows = TempEntityList.Count;
        //    }
        //    else
        //    {
        //        resultList = (Library.GetAllByPagingByParentID(out totalRows, int.Parse(id.ToString()), command.Page, command.PageSize == 0 ? 20 : command.PageSize, "", "Asc", IncludePredicates));
        //        //resultList = ((IParentChildLibrary<TEntity>)Library).GetAllByPagingByParentID(out totalRows, int.Parse(id.ToString()), command.Page, command.PageSize, "", "Asc", IncludePredicates);
        //    }

        //    return View(new GridModel { Data = resultList, Total = totalRows });
        //}

        //protected override ActionResult Display(GridCommand command, LOV entity, bool isNew = false)
        //{
        //    if (entity.LOVType != null && entity.LOVType.ID != 0)
        //        return Display(command, entity.LOVType.ID.ToString(), isNew);
        //    else
        //        return base.Display(command, entity, isNew);
        //}

        //[HttpPost]
        //public virtual ActionResult GetByParentID(string id)
        //{
        //    IEnumerable<LOV> resultList = Library.GetAllByParentID(int.Parse(id));
        //    SelectList list = new SelectList(resultList, "ListValue", "ListText");

        //    return Json(list);
        //}


        //[HttpPost]
        //[GridAction(EnableCustomBinding = true)]
        //public ActionResult _GetAllLOV(GridCommand command) {
        //  int totalRows = 0;
        //  IEnumerable<LOV> resultList = new LOVLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()).GetAllByPaging(
        //                                                                                                  out totalRows, command.Page,
        //                                                                                                  (command.PageSize == 0 ? 20 : command.PageSize),
        //                                                                                                  "", "Asc", new string[] { "LOVType" },
        //                                                                                                  (command.FilterDescriptors.Count == 0 ? null : command.FilterDescriptors)
        //                                                                                                  );
        //  return View(new GridModel {
        //    Data = resultList,
        //    Total = totalRows
        //  });
        //}

        protected override void ValidateEntity(smART.ViewModel.CycleDetails entity)
        {
            ModelState.Clear();
            if (entity.Item == null || entity.Item.ID == 0)
            {
                ModelState.AddModelError("EmptyItem", "Item is required.");
            }

            // Check duplicate item
            if (entity.Cycle.ID == 0)
            {
                CycleDetails cycleDetails = TempEntityList.FirstOrDefault <CycleDetails>(s => s.Item.ID == entity.Item.ID && s.ID != entity.ID);
                if (cycleDetails != null)
                {
                    ModelState.AddModelError("EmptyItem", "Similar transaction already exists. Please click on search button and fetch existing record.");
                }
            }
        }
 public ActionResult _InsertUpdate(ScaleDetails data, GridCommand command, bool isNew = false)
 {
     data.Split_Value = 100;
     if (data.ID > 0)
     {
         return(_Update(data, command, isNew));
     }
     else
     {
         ScaleDetails tempItem = TempEntityList.FirstOrDefault(i => i.Item_Received.ID == data.Item_Received.ID);
         if (tempItem == null)
         {
             return(_Insert(data, command, isNew));
         }
         else
         {
             data.ID = tempItem.ID;
             return(_Update(data, command, isNew));
         }
     }
 }
Пример #6
0
        public override ActionResult _Delete(string id, GridCommand command, string MasterID = null, bool isNew = false)
        {
            AddressBook entity;

            if (isNew)
            {
                //TODO: Delete entity with id
                entity = TempEntityList.FirstOrDefault(m => m.ID == int.Parse(id));
            }
            else
            {
                entity = Library.GetByID(id);
            }

            if (entity.Primary_Flag == true)
            {
                ModelState.AddModelError("delete", "Can't delete primary address");
            }

            return(base._Delete(id, command, MasterID, isNew));
        }
        private void AddUnPaidPurchaseDispatcherExpenses(int dispathcerId)
        {
            // Search for expenses that matches dispatcher id.
            ExpensesRequestLibrary lib             = new ExpensesRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
            string refTableName                    = new Model.DispatcherRequest().GetType().Name;
            IEnumerable <ExpensesRequest> expenses = lib.GetAllPurchasingExepneseByRefTableAndRefId(dispathcerId, refTableName, new[] { "Payment", "Paid_Party_To" });

            foreach (var item in expenses)
            {
                // If expense already exists.
                if (TempEntityList.FirstOrDefault(m => m.ID == item.ID) == null)
                {
                    // If party is null.
                    if (item.Paid_Party_To == null)
                    {
                        item.Paid_Party_To = new Party();
                    }

                    // Add to TempList.
                    TempEntityList.Add(item);
                }
            }
        }