Ejemplo n.º 1
0
        private void click2(object sender, RoutedEventArgs e)
        {
            var item = datagrid.SelectedItem as EmployeeInfo;

            if (item == null)
            {
                MessageBox.Show("请先选择要删除的信息!");
                return;
            }
            MessageBoxResult result = MessageBox.Show("您确定要删除该信息吗?", "删除确认", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                context = new BankEntities2();
                var q = from t in context.EmployeeInfo
                        where t.EmployeeNo == item.EmployeeNo
                        select t;
                if (q != null)
                {
                    try
                    {
                        context.EmployeeInfo.Remove(q.FirstOrDefault());
                        int i = context.SaveChanges();
                        MessageBox.Show(string.Format("成功删除", i));
                    }
                    catch
                    {
                        MessageBox.Show("删除失败!");
                    }
                }
            }
            ShowResult();
        }
Ejemplo n.º 2
0
        public ActionResult AddCustomer(Customer custObj)
        {
            try
            {
                custObj.userId      = custObj.email;
                custObj.createdDate = DateTime.Now.ToShortDateString();
                custObj.editedDate  = DateTime.Now.ToShortDateString();
                //custObj.type = "Bronze";
                string        managerId  = Session["userId"].ToString();
                BankEntities2 dbContext  = new BankEntities2();
                Manager       mgrDetails = dbContext.Managers.Single(x => x.userId == managerId);
                custObj.managerId = mgrDetails.managerId;
                custObj.branchId  = mgrDetails.branchId;

                ManagerClass classcustObj = new ManagerClass();
                classcustObj.addLogin(custObj.email, Encrypt("123456"), "Customer");
                int rows_affected = classcustObj.addCustomer(custObj);
                if (rows_affected == 0)
                {
                    ViewBag.Error = "Customer Not added";
                }
                else
                {
                    ModelState.Clear();
                    ViewBag.Success = "Customer Added";
                }
            }
            catch (Exception ex)
            {
                ViewBag.Error = "Exception";
            }
            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult ManageCustomer(int customerId)
        {
            BankEntities2 dbContext = new BankEntities2();
            string        managerId = Session["userId"].ToString();

            Session["CustomerId"] = customerId;
            Manager  mgrDetails   = dbContext.Managers.Single(x => x.userId == managerId);
            Customer objCheckUser = dbContext.Customers.SingleOrDefault(x => (x.customerId == customerId));

            if (objCheckUser == null) // No customer exists
            {
                ViewBag.Error = "No customer Exists";
            }
            else
            {
                if (objCheckUser.managerId != mgrDetails.managerId)
                {
                    ViewBag.Error = "You cannot access this customer";
                }
                else
                {
                    return(View(objCheckUser));
                }
            }
            ViewBag.customerId = customerId;
            return(View());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取存款用户信息,并初始化余额
        /// </summary>
        /// <param name="accountNumber"></param>
        /// <returns></returns>
        public static Custom GetCustom(string accountNumber)
        {
            Custom        custom = null;
            BankEntities2 c      = new BankEntities2();

            try
            {
                var query = from t in c.AccountInfo
                            where t.accountNo == accountNumber
                            select t;
                if (query.Count() > 0)
                {
                    var q = query.Single();
                    custom = CreateCustom(q.accountType);
                    custom.AccountInfo.accountNo   = accountNumber;
                    custom.AccountInfo.accountName = q.accountName;
                    custom.AccountInfo.accountPass = q.accountPass;
                    custom.AccountInfo.IdCard      = q.IdCard;
                }
            }
            catch
            {
                return(null);
            }
            var qt = from t in c.MoneyInfo
                     where t.accountNo == accountNumber
                     select t;

            if (qt != null && qt.Count() > 0)
            {
                custom.AccountBalance = qt.Sum(x => x.dealMoney);
            }
            return(custom);
        }
Ejemplo n.º 5
0
        public ActionResult EditCustomer(Customer custObj)
        {
            try
            {
                custObj.customerId = int.Parse(Session["CustomerId"].ToString());
                custObj.editedDate = DateTime.Now.ToShortDateString();
                BankEntities2 dbContext    = new BankEntities2();
                ManagerClass  classcustObj = new ManagerClass();


                int rows_affected = classcustObj.updateCustomer(custObj);
                if (rows_affected == 0)
                {
                    ViewBag.Error = "Customer Not updated";
                }
                else
                {
                    ModelState.Clear();
                    ViewBag.Success = "Customer Editted successfully";
                }
            }
            catch (Exception ex)
            {
                ViewBag.Error = "Exception";
            }
            return(View());
        }
Ejemplo n.º 6
0
        public ActionResult ManagersList()
        {
            BankEntities2  newObj   = new BankEntities2();
            List <Manager> managers = newObj.Managers.ToList();

            return(View(managers));
        }
Ejemplo n.º 7
0
        public ActionResult EditCustomer()
        {
            BankEntities2 dbContext = new BankEntities2();
            int           custId    = int.Parse(Session["CustomerId"].ToString());
            Customer      obj       = dbContext.Customers.Single(x => x.customerId == custId);

            return(View(obj));
        }
Ejemplo n.º 8
0
        public ActionResult ManageManager(int managerId)
        {
            BankEntities2 dbContext = new BankEntities2();
            Manager       managers  = dbContext.Managers.Single(x => x.managerId == managerId);

            ViewBag.mgrId = managerId;
            return(View(managers));
        }
Ejemplo n.º 9
0
        public ActionResult BalanceEnquiry()
        {
            long          accountNo = long.Parse((Session["accountNumber"]).ToString());
            BankEntities2 dbContext = new BankEntities2();
            Account       account   = (Account)(dbContext.Accounts.Single(x => x.accountNo == accountNo));

            return(View(account));
        }
Ejemplo n.º 10
0
        //
        // GET: /Manager/

        public ActionResult Index()
        {
            string          userId    = Convert.ToString(Session["userId"]);
            BankEntities2   dbContext = new BankEntities2();
            Manager         manager   = dbContext.Managers.Where(val => val.userId == userId).Single <Manager>();
            List <Customer> customer  = dbContext.Customers.Where(x => manager.branchId == x.branchId).ToList <Customer>();

            return(View(customer));
        }
Ejemplo n.º 11
0
        public ChangePay()
        {
            InitializeComponent();
            BankEntities2 context2   = new BankEntities2();
            var           Infosalary = from t in context2.Salary
                                       select t;

            this.datagrid.ItemsSource = Infosalary.ToList();
        }
Ejemplo n.º 12
0
        public OperateRecord()
        {
            InitializeComponent();
            BankEntities2 context = new BankEntities2();
            var           query   = from t in context.MoneyInfo
                                    select t;

            this.datagrid1.ItemsSource = query.ToList();
        }
        public ActionResult MiniStatement()
        {
            long          accountNo = long.Parse((Session["accountNumber"]).ToString());
            BankEntities2 dbContext = new BankEntities2();

            List <Transaction> transactions = (List <Transaction>)(dbContext.Transactions.Where(x => x.fromAccountNo == accountNo || x.toAccountNo == accountNo).OrderByDescending(x => x.transactionId).ToList());

            return(View(transactions));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 获取指定类别的利率
        /// </summary>
        /// <param name="rateType">利率类别</param>
        /// <returns>对应类别的利率值</returns>
        public static double GetRate(RateType rateType)
        {
            string        type = rateType.ToString();
            BankEntities2 c    = new BankEntities2();
            var           q    = (from t in c.RateInfo
                                  where t.rationType == type
                                  select t.rationValue).Single();

            return(q.Value);
        }
Ejemplo n.º 15
0
        public ActionResult editAccount(long selectedAccount)
        {
            BankEntities2 dbContext = new BankEntities2();

            Session["EditedAccount"] = selectedAccount;
            ManagerClass obj = new ManagerClass();
            Account      acc = dbContext.Accounts.Single(x => x.accountNo == selectedAccount);

            return(View(acc));
        }
Ejemplo n.º 16
0
        public ActionResult ShowAllCustomers()
        {
            BankEntities2 dbContext  = new BankEntities2();
            string        managerId  = Session["userId"].ToString();
            Manager       mgrDetails = dbContext.Managers.Single(x => x.userId == managerId);

            List <Customer> list = dbContext.Customers.Where(x => x.managerId == mgrDetails.managerId).ToList();

            return(View(list));
        }
Ejemplo n.º 17
0
        public EmployeeBase()
        {
            InitializeComponent();
            BankEntities2 content = new BankEntities2();

            var InforManger = from t1 in content.EmployeeInfo
                              select t1;

            this.datagrid.ItemsSource = InforManger.ToList();
        }
        //
        // GET: /Customer/

        public ActionResult Index()
        {
            string userId = Convert.ToString(Session["userId"]);

            Session["medal"] = null;
            BankEntities2  dbContext = new BankEntities2();
            Customer       customer  = dbContext.Customers.Single(x => x.userId == userId);
            List <Account> accounts  = (dbContext.Accounts.Where(x => x.customerId == customer.customerId)).ToList();

            return(View(accounts));
        }
Ejemplo n.º 19
0
        private void ShowResult()
        {
            if (context != null)
            {
                context.Dispose();
                context = new BankEntities2();
            }

            var q = from T in context.EmployeeInfo
                    select T;

            this.datagrid.ItemsSource = q.ToList();
        }
Ejemplo n.º 20
0
        public ActionResult Index()
        {
            BankEntities2  newObj   = new BankEntities2();
            List <Manager> managers = newObj.Managers.ToList();

            if (Session["mgrId"] != null)
            {
                Session["mgrId"] = null;
                //BankEntities2 newObj = new BankEntities2();
                //List<Manager> managers = newObj.Managers.ToList();
                return(View(managers));
                // return View();
            }
            return(View(managers));
        }
Ejemplo n.º 21
0
        public ActionResult Menu()
        {
            if (Session["accountNumber"] != null)
            {
                long          accountNo = long.Parse((Session["accountNumber"]).ToString());
                BankEntities2 dbContext = new BankEntities2();
                Account       account   = (Account)(dbContext.Accounts.Single(x => x.accountNo == accountNo));


                return(View(account));
            }
            else
            {
                return(View("Index"));
            }
        }
Ejemplo n.º 22
0
 /// <summary>
 /// 获取操作员姓名
 /// </summary>
 /// <param name="id">操作员编号</param>
 /// <returns></returns>
 public static string GetOperateName(string id)
 {
     using (BankEntities2 c = new BankEntities2())
     {
         var q = from t in c.EmployeeInfo
                 where t.EmployeeNo == id
                 select t;
         if (q != null && q.Count() >= 1)
         {
             return(q.First().EmployeeName);
         }
         else
         {
             return("");
         }
     }
 }
Ejemplo n.º 23
0
 public ActionResult Index(string selectedAccount)
 {
     if (string.IsNullOrEmpty(selectedAccount))
     {
         return(RedirectToAction("Index"));
     }
     else
     {
         Session["accountNumber"] = selectedAccount;
         int           selectedAccount2 = int.Parse(selectedAccount);
         BankEntities2 dbContext        = new BankEntities2();
         Account       account          = dbContext.Accounts.Single(x => x.accountNo == selectedAccount2);
         var           amount           = account.amount;
         CustomerMedal cmedal           = dbContext.CustomerMedals.Single(x => amount > x.min && amount < x.max);
         Session["medal"] = cmedal.type;
         return(RedirectToAction("Menu"));
     }
 }
Ejemplo n.º 24
0
        private void comboBoxAccountType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string s = comboBoxAccountType.SelectedItem.ToString();

            using (BankEntities2 c = new BankEntities2())
            {
                var q = from t in c.AccountInfo
                        where t.accountType == s
                        select t;
                if (q.Count() > 0)
                {
                    this.txtAccountNo.Text = string.Format("{0}", int.Parse(q.Max(x => x.accountNo)) + 1);
                }
                else
                {
                    txtAccountNo.Text = string.Format("{0}00001", comboBoxAccountType.SelectedIndex + 1);
                }
            }
        }
Ejemplo n.º 25
0
        public ActionResult EditManager(int id)
        {
            ViewBag.mgrId    = id;
            Session["mgrId"] = id;
            BankEntities2 newObj = new BankEntities2();

            try
            {
                SuperManagerClass superManagerClass = new SuperManagerClass();
                List <string>     branchesList      = superManagerClass.getNonAssignedBranches();
            }
            catch (Exception e)
            {
                ViewBag.Error = "Exception " + e;
            }
            Manager obj = newObj.Managers.Single(x => x.managerId == id);

            return(View(obj));
        }
Ejemplo n.º 26
0
        public ActionResult Account(int customerId)
        {
            BankEntities2 dbContext = new BankEntities2();

            Session["customerId"] = customerId;
            string branchId = Session["Branch"].ToString();

            try
            {
                Customer       allcustomer = dbContext.Customers.Single(x => x.customerId == customerId && x.branchId == branchId);
                List <Account> accounts    = (dbContext.Accounts.Where(x => x.customerId == allcustomer.customerId)).ToList();
                return(View("AccountsList", accounts));
            }
            catch (Exception e)
            {
                ViewBag.msg = "This is not your branch customer";
                return(View("Account"));
            }
        }