コード例 #1
0
        // GET: /LedgerSettingMaster/Create

        public ActionResult Create(int id)//DocTypeId
        {
            List <string> UserRoles = (List <string>)System.Web.HttpContext.Current.Session["Roles"];

            if (!UserRoles.Contains("SysAdmin"))
            {
                return(View("~/Views/Shared/InValidSettings.cshtml"));
            }

            var DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];
            var SiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];

            PrepareViewBag(id);
            var settings = new LedgerSettingService(_unitOfWork).GetLedgerSettingForDocument(id, DivisionId, SiteId);

            if (settings == null)
            {
                LedgerSettingViewModel vm = new LedgerSettingViewModel();
                vm.DocTypeName = new DocumentTypeService(_unitOfWork).Find(id).DocumentTypeName;
                vm.SiteId      = SiteId;
                vm.DivisionId  = DivisionId;
                vm.DocTypeId   = id;
                return(View("Create", vm));
            }
            else
            {
                LedgerSettingViewModel temp = AutoMapper.Mapper.Map <LedgerSetting, LedgerSettingViewModel>(settings);
                temp.DocTypeName = new DocumentTypeService(_unitOfWork).Find(id).DocumentTypeName;
                return(View("Create", temp));
            }
        }
コード例 #2
0
        public JsonResult GetPendingCostCenterHelpList(string searchTerm, int pageSize, int pageNum, int filter)//Order Header ID
        {
            int DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];
            int SiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];

            var Settings = new LedgerSettingService(_unitOfWork).GetLedgerSettingForDocument(filter, DivisionId, SiteId);

            string[] contraDocTypes = null;
            if (!string.IsNullOrEmpty(Settings.filterContraDocTypes))
            {
                contraDocTypes = Settings.filterContraDocTypes.Split(",".ToCharArray());
            }
            else
            {
                contraDocTypes = new string[] { "NA" };
            }



            var Records = from p in db.LedgerLine
                          join ledger in db.Ledger on new { x = p.LedgerLineId, y = p.LedgerAccountId } equals new { x = ledger.LedgerLineId ?? 0, y = ledger.LedgerAccountId } into lgr
            from lgrtab in lgr.DefaultIfEmpty()
            join la in db.LedgerAdj on lgrtab.LedgerId equals la.CrLedgerId into ladjcr
            from ladjtabcr in ladjcr.DefaultIfEmpty()
            join lad in db.LedgerAdj on lgrtab.LedgerId equals lad.DrLedgerId into ladjDr
            from ladjtabdr in ladjDr.DefaultIfEmpty()
            join tab2 in db.LedgerHeader on p.LedgerHeaderId equals tab2.LedgerHeaderId
            where (string.IsNullOrEmpty(Settings.filterContraDocTypes) ? 1 == 1 : contraDocTypes.Contains(tab2.DocTypeId.ToString())) && tab2.SiteId == SiteId && tab2.DivisionId == DivisionId && ladjtabcr == null && ladjtabdr == null &&
            tab2.ProcessId == Settings.ProcessId
            select new ComboBoxResult
            {
                id   = p.CostCenterId.ToString(),
                text = p.CostCenter.CostCenterName,
            };

            var temp = Records.Skip(pageSize * (pageNum - 1)).Take(pageSize).ToList();

            var count = Records.Count();

            ComboBoxPagedResult Data = new ComboBoxPagedResult();

            Data.Results = temp;
            Data.Total   = count;

            return(new JsonpResult
            {
                Data = Data,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
コード例 #3
0
        public ActionResult _Create(int Id) //Id ==>Sale Order Header Id
        {
            LedgerAccountOpeningViewModel s = new LedgerAccountOpeningViewModel();

            s.LedgerAccountId = Id;

            s.DocTypeId = new DocumentTypeService(_unitOfWork).Find(TransactionDoctypeConstants.Opening).DocumentTypeId;
            //s.DocDate = DateTime.Now;

            DateTime TodayDate = DateTime.Now;
            var      temp      = (from Be in db.BusinessSession where TodayDate >= Be.FromDate && TodayDate <= Be.UptoDate select Be).FirstOrDefault();

            if (temp != null)
            {
                s.DocDate = temp.FromDate.AddDays(-1);
            }
            else
            {
                s.DocDate = DateTime.Now;
            }


            s.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];
            s.SiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];
            s.DocNo      = new DocumentTypeService(_unitOfWork).FGetNewDocNo("DocNo", ConfigurationManager.AppSettings["DataBaseSchema"] + ".LedgerHeaders", s.DocTypeId, s.DocDate, s.DivisionId, s.SiteId);


            var settings = new LedgerSettingService(_unitOfWork).GetLedgerSettingForDocument(s.DocTypeId, s.DivisionId, s.SiteId);

            if (settings == null && UserRoles.Contains("SysAdmin"))
            {
                return(RedirectToAction("Create", "LedgerSetting", new { id = s.DocTypeId }).Warning("Please create Ledger settings"));
            }
            else if (settings == null && !UserRoles.Contains("SysAdmin"))
            {
                return(View("~/Views/Shared/InValidSettings.cshtml"));
            }
            s.LedgerSetting = Mapper.Map <LedgerSetting, LedgerSettingViewModel>(settings);

            PrepareViewBag();
            return(PartialView("_Create", s));
        }
コード例 #4
0
        public ActionResult _Edit(int id)//LedgerHeaderId
        {
            PersonOpeningViewModel temp = _PersonOpeningService.GetPersonOpeningForEdit(id);

            var settings = new LedgerSettingService(_unitOfWork).GetLedgerSettingForDocument(temp.DocTypeId, temp.DivisionId, temp.SiteId);

            if (settings == null && UserRoles.Contains("SysAdmin"))
            {
                return(RedirectToAction("Create", "LedgerSetting", new { id = temp.DocTypeId }).Warning("Please create Ledger settings"));
            }
            else if (settings == null && !UserRoles.Contains("SysAdmin"))
            {
                return(View("~/Views/Shared/InValidSettings.cshtml"));
            }
            temp.LedgerSetting = Mapper.Map <LedgerSetting, LedgerSettingViewModel>(settings);

            if (temp == null)
            {
                return(HttpNotFound());
            }
            PrepareViewBag();
            return(PartialView("_Create", temp));
        }
コード例 #5
0
        public ActionResult PaymentCancelWizard(int id)//DocumentTypeId
        {
            PrepareViewBag(id);
            LedgerHeaderViewModel vm = new LedgerHeaderViewModel();

            vm.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];
            vm.SiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];

            //Getting Settings
            var settings = new LedgerSettingService(_unitOfWork).GetLedgerSettingForDocument(id, vm.DivisionId, vm.SiteId);

            if (settings == null && UserRoles.Contains("SysAdmin"))
            {
                return(RedirectToAction("CreateForCancel", "LedgerSetting", new { id = id }).Warning("Please create payment cancel settings"));
            }
            else if (settings == null && !UserRoles.Contains("SysAdmin"))
            {
                return(View("~/Views/Shared/InValidSettings.cshtml"));
            }

            ViewBag.ProcessId = settings.ProcessId;
            return(View());
        }
コード例 #6
0
        // here we simulate SQL search, sorting and paging operations
        private IQueryable <PaymentCancelWizardViewModel> FilterData(string search, int sortColumn, string sortDirection, int DocType
                                                                     , int?ProcessId, DateTime?FromDate, DateTime?ToDate, string LedgerHeaderId, string LedgerAcCr, string LedgerAcDr, string ChqNo, string CostCenter, decimal?Amount)
        {
            int DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];
            int SiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];

            var Settings = new LedgerSettingService(_unitOfWork).GetLedgerSettingForDocument(DocType, DivisionId, SiteId);

            string[] contraDocTypes = null;
            if (!string.IsNullOrEmpty(Settings.filterContraDocTypes))
            {
                contraDocTypes = Settings.filterContraDocTypes.Split(",".ToCharArray());
            }
            else
            {
                contraDocTypes = new string[] { "NA" };
            }

            List <int> LedgerHeaderIds = new List <int>();

            if (!string.IsNullOrEmpty(LedgerHeaderId))
            {
                foreach (var item in LedgerHeaderId.Split(','))
                {
                    LedgerHeaderIds.Add(Convert.ToInt32(item));
                }
            }

            List <int> LedgerAcCrIds = new List <int>();

            if (!string.IsNullOrEmpty(LedgerAcCr))
            {
                foreach (var item in LedgerAcCr.Split(','))
                {
                    LedgerAcCrIds.Add(Convert.ToInt32(item));
                }
            }

            List <int> LedgerAcDrIds = new List <int>();

            if (!string.IsNullOrEmpty(LedgerAcDr))
            {
                foreach (var item in LedgerAcDr.Split(','))
                {
                    LedgerAcDrIds.Add(Convert.ToInt32(item));
                }
            }


            IQueryable <PaymentCancelWizardViewModel> _data = from p in db.LedgerLine
                                                              join ledger in db.Ledger on new { x = p.LedgerLineId, y = p.LedgerAccountId } equals new { x = ledger.LedgerLineId ?? 0, y = ledger.LedgerAccountId } into lgr
            from lgrtab in lgr.DefaultIfEmpty()
            join la in db.LedgerAdj on lgrtab.LedgerId equals la.CrLedgerId into ladjcr
            from ladjtabcr in ladjcr.DefaultIfEmpty()
            join lad in db.LedgerAdj on lgrtab.LedgerId equals lad.DrLedgerId into ladjDr
            from ladjtabdr in ladjDr.DefaultIfEmpty()
            join tab2 in db.LedgerHeader on p.LedgerHeaderId equals tab2.LedgerHeaderId
            where (string.IsNullOrEmpty(Settings.filterContraDocTypes) ? 1 == 1 : contraDocTypes.Contains(tab2.DocTypeId.ToString())) && tab2.SiteId == SiteId && tab2.DivisionId == DivisionId && ladjtabcr == null && ladjtabdr == null &&
            (Settings.ProcessId.HasValue ? tab2.ProcessId == Settings.ProcessId : 1 == 1)
            select new PaymentCancelWizardViewModel
            {
                LedgerLineId   = p.LedgerLineId,
                LedgerHeaderId = p.LedgerHeaderId,
                LedgerAcCrId   = p.LedgerAccountId,
                LedgerAcDrId   = tab2.LedgerAccountId,
                LedgerAcCr     = p.LedgerAccount.LedgerAccountName,
                LedgerAcDr     = tab2.LedgerAccount.LedgerAccountName,
                ChqNo          = p.ChqNo,
                Amount         = p.Amount,
                CostCenterName = p.CostCenter.CostCenterName,
                DocNo          = tab2.DocNo,
                DocDate        = tab2.DocDate,
                Remark         = p.Remark,
                DocTypeName    = tab2.DocType.DocumentTypeName,
            };



            DateTime Date;
            bool     Success = DateTime.TryParse(search, out Date);

            List <PaymentCancelWizardViewModel> list = new List <PaymentCancelWizardViewModel>();

            if (string.IsNullOrEmpty(search))
            {
            }
            else
            {
                // simulate search

                //if (!Success)
                //{
                //    _data = from m in _data
                //            where (m.DocNo + m.Amount + m.ChqNo + m.CostCenterName + m.LedgerAcCr + m.LedgerAcDr).ToString().ToLower().Contains(search.ToLower())
                //            select m;
                //}
                //else
                //{
                //    _data = _data.Where(m => m.DocDate == Date);
                //}
            }



            if (FromDate.HasValue)
            {
                _data = _data.Where(m => m.DocDate >= FromDate);
            }

            if (ToDate.HasValue)
            {
                _data = _data.Where(m => m.DocDate <= ToDate);
            }

            if (Amount.HasValue && Amount.Value > 0)
            {
                _data = _data.Where(m => m.Amount == Amount.Value);
            }

            if (!string.IsNullOrEmpty(LedgerHeaderId))
            {
                _data = _data.Where(m => LedgerHeaderIds.Contains(m.LedgerHeaderId));
            }

            if (!string.IsNullOrEmpty(LedgerAcCr))
            {
                _data = _data.Where(m => LedgerAcCrIds.Contains(m.LedgerAcCrId ?? 0));
            }

            if (!string.IsNullOrEmpty(LedgerAcDr))
            {
                _data = _data.Where(m => LedgerAcDrIds.Contains(m.LedgerAcDrId ?? 0));
            }

            if (!string.IsNullOrEmpty(ChqNo))
            {
                _data = _data.Where(m => m.ChqNo.Contains(ChqNo));
            }


            // simulate sort
            //if (sortColumn == 0)
            //{// sort Name
            _data = _data.OrderByDescending(m => m.DocDate).ThenByDescending(m => m.DocNo);
            //}
            //else if (sortColumn == 1)
            //{// sort Age
            //    _data = sortDirection == "asc" ? _data.OrderBy(m => m.DocNo) : _data.OrderByDescending(m => m.DocNo);
            //}
            //else if (sortColumn == 2)
            //{   // sort DoB
            //    _data = sortDirection == "asc" ? _data.OrderBy(m => m.DocDate) : _data.OrderByDescending(m => m.DocDate);
            //}
            //else if (sortColumn == 3)
            //{   // sort DoB
            //    _data = sortDirection == "asc" ? _data.OrderBy(m => m.DueDate) : _data.OrderByDescending(m => m.DueDate);
            //}
            // get just one page of data



            return(_data.Select(m => new PaymentCancelWizardViewModel
            {
                LedgerLineId = m.LedgerLineId,
                LedgerHeaderId = m.LedgerHeaderId,
                LedgerAcCrId = m.LedgerAcCrId,
                LedgerAcDrId = m.LedgerAcDrId,
                LedgerAcCr = m.LedgerAcCr,
                LedgerAcDr = m.LedgerAcDr,
                ChqNo = m.ChqNo,
                Amount = m.Amount,
                CostCenterName = m.CostCenterName,
                DocNo = m.DocNo,
                DocDate = m.DocDate,
                Remark = m.Remark,
                DocTypeName = m.DocTypeName,
            }));
        }