Пример #1
0
        private MyMenu ChangeControl(MyMenu menu, int custid, int contractid)
        {
            Contract _cont;

            CustID      = custid;
            cust        = db.Custs.Find(custid);
            contracts   = repo.GetContracts(CustID);
            menu.CustId = CustID;
            menu.Cust   = cust.SmalName;
            if (contractid == 0)
            {
                //Новый вход или котрагент
                _cont = repo.GetContract(CustID);
                if (_cont == null)
                {
                    ContractID = 0;
                }
                else
                {
                    ContractID = _cont.ContractID;
                }

                menu.ContractId = ContractID;
            }
            else
            {
                ContractID      = contractid;
                menu.ContractId = ContractID;
            }

            return(menu);
        }
Пример #2
0
        public ActionResult Index(int SelectedCustId = -1, int SelectedContractId = -1)
        {
            string  auth    = GetCookie("Auth");
            AbzHash abzHash = hashRepo.GetHash(auth);
            string  usr     = abzHash.Email;

            if ((SelectedCustId > 0) && ((int)abzHash.CustID != SelectedCustId))
            {
                abzHash.CustID = SelectedCustId;
                contract       = repo.GetContract((int)abzHash.CustID);
                if (contract == null)
                {
                    ContractID = 0;
                }
                else
                {
                    ContractID = contract.ContractID;
                }
                abzHash.ContractID = ContractID;
                hashRepo.UpdateHash(abzHash);
            }
            else
            {
                if ((SelectedContractId > 0) && ((int)abzHash.ContractID != SelectedContractId))
                {
                    abzHash.ContractID = SelectedContractId;
                    hashRepo.UpdateHash(abzHash);
                }
            }
            contract = repo.GetContract((int)abzHash.CustID);
            if (contract == null)
            {
                ContractID = 0;
            }
            else
            {
                ContractID = contract.ContractID;
            }

            Cust cust = db.Custs.Find((int)abzHash.CustID);

            contracts            = repo.GetContracts((int)abzHash.CustID);
            ViewData["Contract"] = new SelectList(contracts, "ContractID", "Num", ContractID);

            IEnumerable <OrgView> orgView = repo.GetCust(usr);

            ViewData["Cust"] = new SelectList(orgView, "ID", "Txt", abzHash.CustID);
            ViewBag.MenuItem = "recv";
            ViewBag.User     = usr;


            BalanceRepository bl = new BalanceRepository();

            ViewBag.customer  = cust.SmalName;
            ViewBag.balance   = bl.GetBalance(CustID, (int)abzHash.ContractID).ToString();
            ViewBag.contractn = "";
            Contract contractcc = db.Contracts.Find((int)abzHash.ContractID);

            if (contractcc != null)
            {
                ViewBag.contractn = "Договор № " + contractcc.Num;
            }

            SetCookie("custid", CustID.ToString());
            SetCookie("contractid", abzHash.ContractID.ToString());
            SetCookie("customer", ViewBag.customer);
            SetCookie("balance", ViewBag.balance);
            SetCookie("contract", ViewBag.contractn);



            return(View("Index", cust));
        }
Пример #3
0
        public ActionResult Index(int SelectedCustId = -1, int SelectedContractId = -1)
        {
            string usr = User.Identity.Name;

            int state = CalcState(SelectedCustId, SelectedContractId);

            switch (state)
            {
            case 3:
                ContractID = SelectedContractId;
                break;

            case 4:
                CustID   = SelectedCustId;
                contract = repo.GetContract(CustID);
                if (contract == null)
                {
                    ContractID = 0;
                }
                else
                {
                    ContractID = contract.ContractID;
                }
                break;

            case 5:
                //1й вход после логина
                CustID   = repo.GetCustEmail(usr);
                contract = repo.GetContract(CustID);
                if (contract == null)
                {
                    ContractID = 0;
                }
                else
                {
                    ContractID = contract.ContractID;
                }
                break;
            }

            Cust cust = db.Custs.Find(CustID);

            try
            {
                abzHash.CustID = CustID;
            }
            catch
            {
                RedirectToAction("Logout", "Account");
            }

            contracts = repo.GetContracts(CustID);

            try
            {
                abzHash.ContractID = ContractID;
            }
            catch
            {
                RedirectToAction("Logout", "Account");
            }

            if (abzHash != null)
            {
                UpdateHash(abzHash);
            }
            else
            {
                RedirectToAction("Logout", "Account");
            }

            ViewData["Contract"] = new SelectList(contracts, "ContractID", "Num", ContractID);

            //не верно для админа, однако работает?
            IEnumerable <OrgView> orgView = repo.GetCust(usr);

            ViewData["Cust"] = new SelectList(orgView, "ID", "Txt", CustID);

            return(View("Index", cust));
        }