コード例 #1
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (i == 0)
            {
                try
                {
                    context.SaveChanges();
                    MessageBox.Show("保存成功!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "保存失败");
                }
            }
            else
            {
                try
                {
                    context.SaveChanges();
                    MessageBox.Show("保存成功!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "保存失败");
                }

                var q1 = from t in context.Salary
                         select t;
                this.dataGrid.ItemsSource = q1.ToList();
            }
        }
コード例 #2
0
ファイル: ratePage.xaml.cs プロジェクト: tomyqg/CSHomework
 //保存
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     try
     {
         context.SaveChanges();
         MessageBox.Show("保存成功!");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "保存失败");
     }
 }
コード例 #3
0
        public ActionResult SignUp(BanksCustomer banks_Customer)
        {
            if (ModelState.IsValid)
            {
                using (var db = new BankEntities1())
                {
                    banks_Customer.UserRole       = "Customer";
                    banks_Customer.CurrentBalance = 0;
                    banks_Customer.Fund           = 0;
                    db.BanksCustomers.Add(banks_Customer);

                    db.SaveChanges();
                    return(RedirectToAction("Login", "Login"));
                }
            }
            return(View());
        }
コード例 #4
0
        private void button3_Click(object sender, RoutedEventArgs e)
        {
            if (i == 0)
            {
                context = new BankEntities1();
                var q = from t in context.EmployeeInfo
                        where t.EmployeeNo == textBox2.Text
                        select t;
                var q1 = from t in context.LoginInfo
                         where t.Bno == textBox2.Text
                         select t;
                foreach (var w in q)
                {
                    context.EmployeeInfo.Remove(w);
                }
                foreach (var w in q1)
                {
                    context.LoginInfo.Remove(w);
                }
                context.SaveChanges();
                textBox2.Text = "";
                var s = from t in context.EmployeeInfo

                        select t;
                this.dataGrid.ItemsSource = s.ToList();
            }
            else
            {
                context = new BankEntities1();
                var q = from t in context.Salary
                        where t.Id == textBox2.Text
                        select t;
                foreach (var w in q)
                {
                    context.Salary.Remove(w);
                }
                context.SaveChanges();
                textBox2.Text = "";
                var s = from t in context.Salary

                        select t;
                this.dataGrid.ItemsSource = s.ToList();
            }
        }
コード例 #5
0
        public ActionResult AddFund(Fund fund)
        {
            if (ModelState.IsValid)
            {
                //Customers Fund Increases into BanksCustomer Table
                BanksCustomer banksCustomer = db.BanksCustomers.Where(u => u.AccountNumber == fund.AccountNumber).FirstOrDefault();
                LoginDetails  updateFund    = db2.LoginDetails.Where(u => u.AccountNumber1 == fund.AccountNumber).FirstOrDefault();
                updateFund.Fund = banksCustomer.Fund + fund.Fund1;
                db2.Entry(updateFund).Property("Fund").IsModified = true;
                db2.SaveChanges();

                //Save Funds History into Fund Table
                db.Funds.Add(fund);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View());
        }
コード例 #6
0
        //更改密码
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            var query = from t in context.AccountInfo
                        where t.accountNo == this.txtAccount.Text
                        select t;

            if (query.Count() > 0)
            {
                var q = query.First();
                if (txtNewPass.Password == txtPassConf.Password && txtPassConf.Password.Length != 0)
                {
                    q.accountPass = this.txtNewPass.Password;
                }
                else if (txtPassConf.Password.Length == 0)
                {
                    MessageBox.Show("密码不能为空");
                    return;
                }
                else
                {
                    MessageBox.Show("两次输入的密码不一样");
                    this.txtNewPass.Clear();
                    this.txtPassConf.Clear();
                    return;
                }
                try
                {
                    context.SaveChanges();
                    MessageBox.Show("更改密码成功!");
                }
                catch
                {
                    MessageBox.Show("更改密码失败!");
                }
            }
            else
            {
                MessageBox.Show("此账号不存在");
                this.txtAccount.Clear();
            }
        }
コード例 #7
0
        public ActionResult Transfer([Bind(Include = "AccountNumber,TransferFrom,TransferTo,TransferAmount,TransferDate,CurrentBalance,Funds,CustomerName")] TransactionDetail transactionDetail)
        {
            if (Session["UserName"] != null && Session["UserRole"].ToString().Contains("Customer"))
            {
                if (ModelState.IsValid)
                {
                    transactionDetail.TransferDate  = DateTime.Now;
                    transactionDetail.AccountNumber = Convert.ToInt32(Session["AccountNumber"]);
                    transactionDetail.TransferFrom  = Convert.ToInt32(Session["AccountNumber"]);
                    transactionDetail.CustomerName  = Convert.ToString(Session["CustomerName"]);
                    db2.TransactionDetails.Add(transactionDetail);
                    db2.SaveChanges();

                    //Receivers Balance Increases
                    BanksCustomer banksCustomer = new BanksCustomer();
                    banksCustomer = db2.BanksCustomers.Where(u => u.AccountNumber == transactionDetail.TransferTo).FirstOrDefault();
                    LoginDetails updateBalanceReveiver = db.LoginDetails.Where(u => u.AccountNumber1 == transactionDetail.TransferTo).FirstOrDefault();
                    updateBalanceReveiver.CurrentBalance += transactionDetail.TransferAmount;
                    db.Entry(updateBalanceReveiver).Property("CurrentBalance").IsModified = true;
                    db.SaveChanges();

                    //Senders Balance Decreases
                    banksCustomer = db2.BanksCustomers.Where(u => u.AccountNumber == transactionDetail.TransferFrom).FirstOrDefault();
                    LoginDetails updateBalanceSender = db.LoginDetails.Where(u => u.AccountNumber1 == transactionDetail.TransferFrom).FirstOrDefault();
                    updateBalanceSender.CurrentBalance -= transactionDetail.TransferAmount;
                    db.Entry(updateBalanceSender).Property("CurrentBalance").IsModified = true;
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }

                ViewBag.ReceiversAccountNumber = new SelectList(db2.BanksCustomers.Where(u => u.UserRole.ToString().Contains("Customer")), "AccountNumber", "AccountNumber", transactionDetail.AccountNumber);
                return(View(transactionDetail));
            }

            Response.Write("<script>alert('Session logged out. Sign in again');</script>");
            FormsAuthentication.SignOut();
            Session.Clear();
            return(RedirectToAction("SignIn", "Auth"));
        }
コード例 #8
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            context = new BankEntities1();
            if (i == 0)
            {
                EmployeeInfo p = new EmployeeInfo()
                {
                    EmployeeName = null,
                    EmployeeNo   = textBox2.Text,
                    idCard       = null,
                    telphone     = null,
                    workDate     = null,
                    sex          = null,
                    photo        = null
                };
                LoginInfo l = new LoginInfo()
                {
                    Bno = textBox2.Text, Password = "******"
                };
                try
                {
                    context.EmployeeInfo.Add(p);
                    context.LoginInfo.Add(l);
                    context.SaveChanges();
                    textBox2.Text = "";
                }
                catch (Exception e2)
                {
                    MessageBox.Show("添加失败" + e2.Message);
                    textBox2.Text = "";
                }
                var q = from t in context.EmployeeInfo

                        select t;
                this.dataGrid.ItemsSource = q.ToList();
            }
            else
            {
                Salary sa = new Salary()
                {
                    Id   = textBox2.Text,
                    姓名   = null,
                    基本工资 = null,
                    车补贴  = null,
                    房补贴  = null,
                    奖金   = null,
                    罚款   = null,
                    总和   = null,
                };
                try
                {
                    context.Salary.Add(sa);
                    context.SaveChanges();
                    textBox2.Text = "";
                }
                catch (Exception e2)
                {
                    MessageBox.Show("添加失败" + e2.Message);
                    textBox2.Text = "";
                }
                var q = from t in context.Salary

                        select t;
                this.dataGrid.ItemsSource = q.ToList();
            }
        }