public IActionResult Edit(mtAgentProfitShared item)
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            item.agentId     = (item.agentId == 0 ? null : item.agentId);
            item.shipperId   = (item.shipperId == 0 ? null : item.shipperId);
            item.containerId = (item.containerId == 0 ? null : item.containerId);

            string   user   = HttpContext.Session.GetString("fullname");
            DateTime txDate = DateTime.Now;

            item.updatedBy = user;
            item.updatedOn = txDate;

            if (ModelState.IsValid)
            {
                mContext.Entry(item).State = EntityState.Modified;
                mContext.SaveChanges();

                return(RedirectToAction("Index"));
            }

            ICollection <sysModule> moduleLvl1 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 1)
                .Select(x => x.module).ToList();

            ICollection <sysModule> moduleLvl2 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 2)
                .Select(x => x.module).ToList();

            ViewBag.moduleLvl1 = moduleLvl1.OrderBy(x => x.orderModule);
            ViewBag.moduleLvl2 = moduleLvl2.OrderBy(x => x.orderModule);
            ViewBag.user       = HttpContext.Session.GetString("fullname");

            try
            {
                sysModule menu2 = moduleLvl2.Where(x => x.code == "AgentProfitShared").SingleOrDefault();
                sysModule menu1 = moduleLvl1.Where(x => x.id == menu2.parentId).SingleOrDefault();

                ViewData["Menu"]        = menu1.name;
                ViewData["SubMenuLvl1"] = menu2.name;
                ViewData["Title"]       = menu2.name;
            }
            catch
            {
                return(RedirectToAction("index", "login"));
            }

            ViewBag.Container = mContext.mtContainer.Where(x => x.isActive == true).ToList();
            ViewBag.Agent     = mContext.mtAgent.Where(x => x.isActive == true).ToList();
            ViewBag.Shipper   = mContext.mtShipper.Where(x => x.isActive == true).ToList();

            ViewBag.Error = true;
            return(View("edit"));
        }
示例#2
0
        public IActionResult Create(mtPortTerminal item)
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            if (ModelState.IsValid)
            {
                string   user   = HttpContext.Session.GetString("fullname");
                DateTime txDate = DateTime.Now;

                item.createdBy = user;
                item.createdOn = txDate;
                item.updatedBy = user;
                item.updatedOn = txDate;

                mContext.mtPortTerminal.Add(item);
                mContext.SaveChanges();

                return(RedirectToAction("Index"));
            }

            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <sysModule> moduleLvl1 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 1)
                .Select(x => x.module).ToList();

            ICollection <sysModule> moduleLvl2 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 2)
                .Select(x => x.module).ToList();

            ViewBag.moduleLvl1 = moduleLvl1.OrderBy(x => x.orderModule);
            ViewBag.moduleLvl2 = moduleLvl2.OrderBy(x => x.orderModule);
            ViewBag.user       = HttpContext.Session.GetString("fullname");

            try
            {
                sysModule menu2 = moduleLvl2.Where(x => x.code == "PortTerminal").SingleOrDefault();
                sysModule menu1 = moduleLvl1.Where(x => x.id == menu2.parentId).SingleOrDefault();

                ViewData["Menu"]        = menu1.name;
                ViewData["SubMenuLvl1"] = menu2.name;
                ViewData["Title"]       = menu2.name;
            }
            catch
            {
                return(RedirectToAction("index", "login"));
            }

            ViewBag.PortOfLoading = mContext.mtPortOfLoading.Where(x => x.isActive == true).ToList();
            ViewBag.Error         = true;
            return(View("Create"));
        }
示例#3
0
        public IActionResult Delete(int id)
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <sysModule> moduleLvl1 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 1)
                .Select(x => x.module).ToList();

            ICollection <sysModule> moduleLvl2 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 2)
                .Select(x => x.module).ToList();

            ViewBag.moduleLvl1 = moduleLvl1.OrderBy(x => x.orderModule);
            ViewBag.moduleLvl2 = moduleLvl2.OrderBy(x => x.orderModule);
            ViewBag.user       = HttpContext.Session.GetString("fullname");

            sysModule menu2 = moduleLvl2.Where(x => x.code == "Agent").SingleOrDefault();
            sysModule menu1 = moduleLvl1.Where(x => x.id == menu2.parentId).SingleOrDefault();

            ViewData["Menu"]        = menu1.name;
            ViewData["SubMenuLvl1"] = menu2.name;
            ViewData["Title"]       = menu2.name;

            mContext.Remove(mContext.mtAgent.Find(id));
            mContext.RemoveRange(mContext.mtAgentDetails.Where(x => x.agentId == id).ToList());
            mContext.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#4
0
        public IActionResult Create()
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <sysModule> moduleLvl1 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 1)
                .Select(x => x.module).ToList();

            ICollection <sysModule> moduleLvl2 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 2)
                .Select(x => x.module).ToList();

            ViewBag.moduleLvl1 = moduleLvl1.OrderBy(x => x.orderModule);
            ViewBag.moduleLvl2 = moduleLvl2.OrderBy(x => x.orderModule);
            ViewBag.user       = HttpContext.Session.GetString("fullname");

            try
            {
                sysModule menu2 = moduleLvl2.Where(x => x.code == "Service").SingleOrDefault();
                sysModule menu1 = moduleLvl1.Where(x => x.id == menu2.parentId).SingleOrDefault();

                ViewData["Menu"]        = menu1.name;
                ViewData["SubMenuLvl1"] = menu2.name;
                ViewData["Title"]       = menu2.name;
            }
            catch
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <mtChartOfAccount> CoaIdr =
                mContext.mtChartOfAccount
                .Include(a => a.currency)
                .Where(x => x.isActive == true && x.currency.code == "IDR").ToList();

            ICollection <mtChartOfAccount> CoaUsd =
                mContext.mtChartOfAccount
                .Include(a => a.currency)
                .Where(x => x.isActive == true && x.currency.code == "USD").ToList();

            ICollection <mtGroups> Groups =
                mContext.mtGroups
                .Where(x => x.isActive == true).ToList();

            ViewBag.CoaIdr = CoaIdr;
            ViewBag.coausd = CoaUsd;
            ViewBag.Groups = Groups;

            ViewBag.Error = false;
            return(View("Create", new mtServices()));
        }
示例#5
0
        public IActionResult Index()
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <sysModule> moduleLvl1 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 1)
                .Select(x => x.module).ToList();

            ICollection <sysModule> moduleLvl2 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 2)
                .Select(x => x.module).ToList();

            ViewBag.moduleLvl1 = moduleLvl1.OrderBy(x => x.orderModule);
            ViewBag.moduleLvl2 = moduleLvl2.OrderBy(x => x.orderModule);
            ViewBag.user       = HttpContext.Session.GetString("fullname");

            try
            {
                sysModule menu2 = moduleLvl2.Where(x => x.code == "CurrencyRate").SingleOrDefault();
                sysModule menu1 = moduleLvl1.Where(x => x.id == menu2.parentId).SingleOrDefault();

                ViewData["Menu"]        = menu1.name;
                ViewData["SubMenuLvl1"] = menu2.name;
                ViewData["Title"]       = menu2.name;
            }
            catch
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <mtCurrencyRatePreview> mtCurrencyRate =
                mContext.mtCurrencyRate.Include(x => x.currencyFrom).Include(x => x.currencyTo)
                .Select(x => new mtCurrencyRatePreview
            {
                id             = x.id,
                currencyIdFrom = (x.currencyFrom == null ? "" : x.currencyFrom.code + " - " + x.currencyFrom.description),
                currencyIdTo   = (x.currencyTo == null ? "" : x.currencyTo.code + " - " + x.currencyTo.description),
                category       = (x.category == 1 ? "BI" : "Pelayaran"),
                rate           = x.rate.ToString(SystemFormat.decimalFormat),
                validFrom      = x.validFrom.ToString(SystemFormat.dateFormat),
                validTo        = x.validTo.ToString(SystemFormat.dateFormat),
                isActive       = x.isActive,
                createdBy      = x.createdBy,
                createdOn      = x.createdOn.ToString(SystemFormat.datetimeFormat),
                updatedBy      = x.updatedBy,
                updatedOn      = x.updatedOn.ToString(SystemFormat.datetimeFormat)
            }).ToList();

            ViewBag.Items = mtCurrencyRate;
            return(View());
        }
示例#6
0
        public IActionResult Edit(int id)
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <sysModule> moduleLvl1 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 1)
                .Select(x => x.module).ToList();

            ICollection <sysModule> moduleLvl2 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 2)
                .Select(x => x.module).ToList();

            ViewBag.moduleLvl1 = moduleLvl1.OrderBy(x => x.orderModule);
            ViewBag.moduleLvl2 = moduleLvl2.OrderBy(x => x.orderModule);
            ViewBag.user       = HttpContext.Session.GetString("fullname");

            try
            {
                sysModule menu2 = moduleLvl2.Where(x => x.code == "Shipper").SingleOrDefault();
                sysModule menu1 = moduleLvl1.Where(x => x.id == menu2.parentId).SingleOrDefault();

                ViewData["Menu"]        = menu1.name;
                ViewData["SubMenuLvl1"] = menu2.name;
                ViewData["Title"]       = menu2.name;
            }
            catch
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <mtEmployee>       Employee           = mContext.mtEmployee.Where(x => x.isActive == true).ToList();
            ICollection <mtChartOfAccount> ChartOfAccountsIdr =
                mContext.mtChartOfAccount.Include(x => x.currency).Where(x => x.isActive == true && x.currency.code == "IDR").ToList();
            ICollection <mtChartOfAccount> ChartOfAccountsUsd =
                mContext.mtChartOfAccount.Include(x => x.currency).Where(x => x.isActive == true && x.currency.code == "USD").ToList();

            ViewBag.ChartOfAccountsIdr = ChartOfAccountsIdr;
            ViewBag.ChartOfAccountsUsd = ChartOfAccountsUsd;
            ViewBag.Employee           = Employee;

            ICollection <mtShipperDetails> Details =
                mContext.mtShipperDetails.Where(x => x.isActive == true && x.shipperId == id).ToList();

            ViewBag.Details = Details;

            ViewBag.Error = false;
            return(View("Edit", mContext.mtShipper.Find(id)));
        }
示例#7
0
        public IActionResult Index()
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <sysModule> moduleLvl1 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 1)
                .Select(x => x.module).ToList();

            ICollection <sysModule> moduleLvl2 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 2)
                .Select(x => x.module).ToList();

            ViewBag.moduleLvl1 = moduleLvl1.OrderBy(x => x.orderModule);
            ViewBag.moduleLvl2 = moduleLvl2.OrderBy(x => x.orderModule);
            ViewBag.user       = HttpContext.Session.GetString("fullname");

            try
            {
                sysModule menu2 = moduleLvl2.Where(x => x.code == "Tax").SingleOrDefault();
                sysModule menu1 = moduleLvl1.Where(x => x.id == menu2.parentId).SingleOrDefault();

                ViewData["Menu"]        = menu1.name;
                ViewData["SubMenuLvl1"] = menu2.name;
                ViewData["Title"]       = menu2.name;
            }
            catch
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <mtTaxPreview> mtTax =
                mContext.mtTax.Select(x => new mtTaxPreview {
                id        = x.id,
                code      = x.code,
                amount    = x.amount.ToString(SystemFormat.decimalFormat),
                isActive  = x.isActive,
                createdBy = x.createdBy,
                createdOn = x.createdOn.ToString(SystemFormat.datetimeFormat),
                updatedBy = x.updatedBy,
                updatedOn = x.updatedOn.ToString(SystemFormat.datetimeFormat)
            }).ToList();

            ViewBag.Items = mtTax;
            return(View());
        }
示例#8
0
        public IActionResult Edit(int id)
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <sysModule> moduleLvl1 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 1)
                .Select(x => x.module).ToList();

            ICollection <sysModule> moduleLvl2 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 2)
                .Select(x => x.module).ToList();

            ViewBag.moduleLvl1 = moduleLvl1.OrderBy(x => x.orderModule);
            ViewBag.moduleLvl2 = moduleLvl2.OrderBy(x => x.orderModule);
            ViewBag.user       = HttpContext.Session.GetString("fullname");

            try
            {
                sysModule menu2 = moduleLvl2.Where(x => x.code == "ProfitShared").SingleOrDefault();
                sysModule menu1 = moduleLvl1.Where(x => x.id == menu2.parentId).SingleOrDefault();

                ViewData["Menu"]        = menu1.name;
                ViewData["SubMenuLvl1"] = menu2.name;
                ViewData["Title"]       = menu2.name;
            }
            catch
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <mtProfitSharedDetails> Details =
                mContext.mtProfitSharedDetails.Include(x => x.container).Where(x => x.isActive == true && x.profitSharedId == id).ToList();
            ICollection <mtCountry>   Countries = mContext.mtCountry.Where(x => x.isActive == true).ToList();
            ICollection <mtAgent>     Agents    = mContext.mtAgent.Where(x => x.isActive == true).ToList();
            ICollection <mtContainer> Container = mContext.mtContainer.Where(x => x.isActive == true).ToList();

            ViewBag.Container = Container;
            ViewBag.Countries = Countries;
            ViewBag.Agents    = Agents;
            ViewBag.Details   = Details;

            ViewBag.Error = false;
            return(View("Edit", mContext.mtProfitShared.Find(id)));
        }
示例#9
0
        public IActionResult Create()
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <sysModule> moduleLvl1 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 1)
                .Select(x => x.module).ToList();

            ICollection <sysModule> moduleLvl2 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 2)
                .Select(x => x.module).ToList();

            ViewBag.moduleLvl1 = moduleLvl1.OrderBy(x => x.orderModule);
            ViewBag.moduleLvl2 = moduleLvl2.OrderBy(x => x.orderModule);
            ViewBag.user       = HttpContext.Session.GetString("fullname");

            try
            {
                sysModule menu2 = moduleLvl2.Where(x => x.code == "Agent").SingleOrDefault();
                sysModule menu1 = moduleLvl1.Where(x => x.id == menu2.parentId).SingleOrDefault();

                ViewData["Menu"]        = menu1.name;
                ViewData["SubMenuLvl1"] = menu2.name;
                ViewData["Title"]       = menu2.name;
            }
            catch
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <mtPortOfDestination> PortOfDestination = mContext.mtPortOfDestination.Where(x => x.isActive == true).ToList();
            ICollection <mtShipper>           Shipper           = mContext.mtShipper.Where(x => x.isActive == true).ToList();
            ICollection <mtType> Type = mContext.mtType.Where(x => x.isActive == true && x.category == 3).ToList();

            ViewBag.PortOfDestination = PortOfDestination;
            ViewBag.Shipper           = Shipper;
            ViewBag.Type = Type;

            ViewBag.Error = false;
            return(View("Create", new mtAgent()));
        }
示例#10
0
        public IActionResult Index()
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <sysModule> moduleLvl1 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 1)
                .Select(x => x.module).ToList();

            ICollection <sysModule> moduleLvl2 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 2)
                .Select(x => x.module).ToList();

            ViewBag.moduleLvl1 = moduleLvl1.OrderBy(x => x.orderModule);
            ViewBag.moduleLvl2 = moduleLvl2.OrderBy(x => x.orderModule);
            ViewBag.user       = HttpContext.Session.GetString("fullname");

            try
            {
                sysModule menu2 = moduleLvl2.Where(x => x.code == "Service").SingleOrDefault();
                sysModule menu1 = moduleLvl1.Where(x => x.id == menu2.parentId).SingleOrDefault();

                ViewData["Menu"]        = menu1.name;
                ViewData["SubMenuLvl1"] = menu2.name;
                ViewData["Title"]       = menu2.name;
            }
            catch
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <mtServices> services =
                mContext.mtServices
                .Include(x => x.coaIdr)
                .Include(x => x.coaUsd)
                .Include(x => x.groups).ToList();

            ViewBag.Items = services;
            return(View());
        }
        public IActionResult Edit(int id)
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <sysModule> moduleLvl1 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 1)
                .Select(x => x.module).ToList();

            ICollection <sysModule> moduleLvl2 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 2)
                .Select(x => x.module).ToList();

            ViewBag.moduleLvl1 = moduleLvl1.OrderBy(x => x.orderModule);
            ViewBag.moduleLvl2 = moduleLvl2.OrderBy(x => x.orderModule);
            ViewBag.user       = HttpContext.Session.GetString("fullname");

            try
            {
                sysModule menu2 = moduleLvl2.Where(x => x.code == "ChartOfAccount").SingleOrDefault();
                sysModule menu1 = moduleLvl1.Where(x => x.id == menu2.parentId).SingleOrDefault();

                ViewData["Menu"]        = menu1.name;
                ViewData["SubMenuLvl1"] = menu2.name;
                ViewData["Title"]       = menu2.name;
            }
            catch
            {
                return(RedirectToAction("index", "login"));
            }

            ViewBag.Currency       = mContext.mtCurrency.Where(x => x.isActive == true).ToList();
            ViewBag.ChartOfAccount = mContext.mtChartOfAccount.Where(x => x.isActive == true).ToList();

            ViewBag.Error = false;
            return(View("Edit", mContext.mtChartOfAccount.Find(id)));
        }
示例#12
0
        public IActionResult Index()
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <sysModule> moduleLvl1 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 1)
                .Select(x => x.module).ToList();

            ICollection <sysModule> moduleLvl2 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 2)
                .Select(x => x.module).ToList();

            ViewBag.moduleLvl1 = moduleLvl1.OrderBy(x => x.orderModule);
            ViewBag.moduleLvl2 = moduleLvl2.OrderBy(x => x.orderModule);
            ViewBag.user       = HttpContext.Session.GetString("fullname");

            try
            {
                sysModule menu = moduleLvl1.Where(x => x.code == "Dashboard").SingleOrDefault();

                ViewData["Menu"]        = menu.name;
                ViewData["SubMenuLvl1"] = "";
                ViewData["Title"]       = menu.name;
            }
            catch {
                return(RedirectToAction("index", "login"));
            }


            return(View());
        }
示例#13
0
        public IActionResult Index()
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <sysModule> moduleLvl1 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 1)
                .Select(x => x.module).ToList();

            ICollection <sysModule> moduleLvl2 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 2)
                .Select(x => x.module).ToList();

            ViewBag.moduleLvl1 = moduleLvl1.OrderBy(x => x.orderModule);
            ViewBag.moduleLvl2 = moduleLvl2.OrderBy(x => x.orderModule);
            ViewBag.user       = HttpContext.Session.GetString("fullname");

            try
            {
                sysModule menu2 = moduleLvl2.Where(x => x.code == "Company").SingleOrDefault();
                sysModule menu1 = moduleLvl1.Where(x => x.id == menu2.parentId).SingleOrDefault();

                ViewData["Menu"]        = menu1.name;
                ViewData["SubMenuLvl1"] = menu2.name;
                ViewData["Title"]       = menu2.name;
            }
            catch
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <mtCompanyPreview> mtCompany =
                mContext.mtCompany.Include(x => x.coaIdr).Include(x => x.coaUsd).Include(x => x.type)
                .Select(x => new mtCompanyPreview
            {
                id        = x.id,
                company   = x.company,
                name      = x.name,
                address   = x.address,
                email     = x.email,
                website   = x.website,
                telepon   = x.telepon,
                fax       = x.fax,
                taxNo     = x.taxNo,
                typeId    = (x.type == null ? "" : x.type.code + " - " + x.type.description),
                coaIdUsd  = (x.coaUsd == null ? "" : x.coaUsd.code + " - " + x.coaUsd.description),
                coaIdIdr  = (x.coaIdr == null ? "" : x.coaIdr.code + " - " + x.coaIdr.description),
                remark    = x.remark,
                isActive  = x.isActive,
                createdBy = x.createdBy,
                createdOn = x.createdOn.ToString(SystemFormat.datetimeFormat),
                updatedBy = x.updatedBy,
                updatedOn = x.updatedOn.ToString(SystemFormat.datetimeFormat)
            }).ToList();

            ViewBag.Items = mtCompany;
            return(View());
        }
示例#14
0
        public IActionResult Edit(mtServices item)
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            if (ModelState.IsValid)
            {
                string   user   = HttpContext.Session.GetString("fullname");
                DateTime txDate = DateTime.Now;

                item.updatedBy = user;
                item.updatedOn = txDate;

                item.coaIdIdr = (item.coaIdIdr == 0 ? null : item.coaIdIdr);
                item.coaIdUsd = (item.coaIdUsd == 0 ? null : item.coaIdUsd);
                item.groupId  = (item.groupId == 0 ? null : item.groupId);

                mContext.Entry(item).State = EntityState.Modified;
                mContext.SaveChanges();

                return(RedirectToAction("Index"));
            }

            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <sysModule> moduleLvl1 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 1)
                .Select(x => x.module).ToList();

            ICollection <sysModule> moduleLvl2 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 2)
                .Select(x => x.module).ToList();

            ViewBag.moduleLvl1 = moduleLvl1.OrderBy(x => x.orderModule);
            ViewBag.moduleLvl2 = moduleLvl2.OrderBy(x => x.orderModule);
            ViewBag.user       = HttpContext.Session.GetString("fullname");

            try
            {
                sysModule menu2 = moduleLvl2.Where(x => x.code == "Service").SingleOrDefault();
                sysModule menu1 = moduleLvl1.Where(x => x.id == menu2.parentId).SingleOrDefault();

                ViewData["Menu"]        = menu1.name;
                ViewData["SubMenuLvl1"] = menu2.name;
                ViewData["Title"]       = menu2.name;
            }
            catch
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <mtChartOfAccount> CoaIdr =
                mContext.mtChartOfAccount
                .Include(a => a.currency)
                .Where(x => x.isActive == true && x.currency.code == "IDR").ToList();

            ICollection <mtChartOfAccount> CoaUsd =
                mContext.mtChartOfAccount
                .Include(a => a.currency)
                .Where(x => x.isActive == true && x.currency.code == "USD").ToList();

            ICollection <mtGroups> Groups =
                mContext.mtGroups
                .Where(x => x.isActive == true).ToList();

            ViewBag.CoaIdr = CoaIdr;
            ViewBag.coausd = CoaUsd;
            ViewBag.Groups = Groups;

            ViewBag.Error = true;
            return(View("edit"));
        }
示例#15
0
        public IActionResult Edit(mtEmployee item, IFormFile pictureUrl)
        {
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            SystemDocumentNo sysDocNo = new SystemDocumentNo(mContext);

            if (pictureUrl == null || pictureUrl.Length == 0)
            {
                item.pictureUrl = item.pictureUrl;
            }
            else
            {
                string fileName = sysDocNo.getDocNo("Employee", "Image", true) + Path.GetExtension(pictureUrl.FileName);
                string path     = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/employeeImages", fileName);
                pictureUrl.CopyTo(new FileStream(path, FileMode.Create));
                item.pictureUrl = fileName;
            }

            if (ModelState.IsValid)
            {
                string   user   = HttpContext.Session.GetString("fullname");
                DateTime txDate = DateTime.Now;

                item.updatedBy = user;
                item.updatedOn = txDate;

                mContext.Entry(item).State = EntityState.Modified;
                mContext.SaveChanges();

                return(RedirectToAction("Index"));
            }

            if (string.IsNullOrEmpty(HttpContext.Session.GetString("fullname")))
            {
                return(RedirectToAction("index", "login"));
            }

            ICollection <sysModule> moduleLvl1 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 1)
                .Select(x => x.module).ToList();

            ICollection <sysModule> moduleLvl2 =
                mContext.sysModuleRole.Include(x => x.module)
                .Where(x => x.userRoleId == HttpContext.Session.GetInt32("roleId") && x.isActive == true && x.module.level == 2)
                .Select(x => x.module).ToList();

            ViewBag.moduleLvl1 = moduleLvl1.OrderBy(x => x.orderModule);
            ViewBag.moduleLvl2 = moduleLvl2.OrderBy(x => x.orderModule);
            ViewBag.user       = HttpContext.Session.GetString("fullname");

            try
            {
                sysModule menu2 = moduleLvl2.Where(x => x.code == "Employee").SingleOrDefault();
                sysModule menu1 = moduleLvl1.Where(x => x.id == menu2.parentId).SingleOrDefault();

                ViewData["Menu"]        = menu1.name;
                ViewData["SubMenuLvl1"] = menu2.name;
                ViewData["Title"]       = menu2.name;
            }
            catch
            {
                return(RedirectToAction("index", "login"));
            }

            ViewBag.Error = true;
            return(View("edit"));
        }