Exemple #1
0
 private void btnWplata_Click(object sender, EventArgs e)
 {
     if (Convert.ToDecimal(txbKwotaWplata1.Text) % 10 == 0)
     {
         try
         {
             using (bankingmachineEntities context = new bankingmachineEntities())
             {
                 user uzytkownikUser = context.users.Where(i => i.login == loggedUser).SingleOrDefault();
                 uzytkownikUser.accbalance = +Convert.ToDecimal(txbKwotaWplata1.Text);
                 context.users.AddOrUpdate(uzytkownikUser);
                 history historiaHistory = new history();
                 historiaHistory.users_id = uzytkownikUser.id;
                 historiaHistory.datetime = DateTime.Now;
                 historiaHistory.amount   = Convert.ToDecimal(txbKwotaWplata1.Text);
                 historiaHistory.type     = "I";
                 context.histories.Add(historiaHistory);
                 context.SaveChanges();
             }
             MessageBox.Show("Wpłata przebiegła prawidłowo", "Wpłata", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
         }
         catch
         {
         }
     }
     else
     {
         MessageBox.Show("Wprowadzona kwota musi być wielokrotnością 10", "Błąd wpłaty", MessageBoxButtons.OK,
                         MessageBoxIcon.Warning);
         txbKwotaWplata1.Text = "";
     }
 }
Exemple #2
0
        public void odswiezHistorie(string uzytkownikUser)
        {
            try
            {
                using (bankingmachineEntities context = new bankingmachineEntities())
                {
                    var tmp = context.users.Where(i => i.login == uzytkownikUser).SingleOrDefault();
                    histories = new history[context.histories.Where(p => p.users_id == tmp.id).Count()];
                    histories = context.histories.Where(p => p.users_id == tmp.id).ToArray();

                    if (dataGridView1.Columns.Count == 0)
                    {
                        dataGridView1.Columns.Add("Data", "Data");
                        dataGridView1.Columns.Add("Kwota", "Kwota");
                        dataGridView1.Columns.Add("operacji", "Rodzaj operacji");
                    }

                    while (dataGridView1.Rows.Count > 0)
                    {
                        dataGridView1.Rows.RemoveAt(0);
                    }

                    foreach (history o in histories)
                    {
                        if (o.type == "O")
                        {
                            dataGridView1.Rows.Add(o.datetime, o.amount, "Wypłata");
                        }
                        if (o.type == "I")
                        {
                            dataGridView1.Rows.Add(o.datetime, o.amount, "Wpłata");
                        }
                        if (o.type == "T")
                        {
                            dataGridView1.Rows.Add(o.datetime, o.amount, "Przelew");
                        }
                    }
                }
            }
            catch
            {
            }
        }
Exemple #3
0
 public void wyplac(decimal kwotaDecimal)
 {
     if (
         MessageBox.Show("Potwierdź wypłatę", "Potwierdź wypłatę", MessageBoxButtons.OKCancel,
                         MessageBoxIcon.Question) == DialogResult.OK)
     {
         using (bankingmachineEntities context = new bankingmachineEntities())
         {
             user logUser = context.users.Where(i => i.login == loggedUser).SingleOrDefault();
             logUser.accbalance = -kwotaDecimal;
             context.users.AddOrUpdate(logUser);
             history wpis = new history();
             wpis.users_id = logUser.id;
             wpis.amount   = kwotaDecimal;
             wpis.type     = "O";
             wpis.datetime = DateTime.Now;
             context.histories.AddOrUpdate(wpis);
             context.SaveChanges();
         }
     }
 }
Exemple #4
0
        private void btnWyslijPrzelew_Click(object sender, EventArgs e)
        {
            decimal kwotaPrzelewu = Convert.ToDecimal(textBox1.Text);

            using (bankingmachineEntities context = new bankingmachineEntities())
            {
                user uzytkownikUser = context.users.Where(i => i.login == loggedUser).SingleOrDefault();
                uzytkownikUser.accbalance = -kwotaPrzelewu;
                context.users.AddOrUpdate(uzytkownikUser);

                history historiaHistory = new history();
                historiaHistory.type     = "T";
                historiaHistory.amount   = kwotaPrzelewu;
                historiaHistory.datetime = DateTime.Now;
                historiaHistory.users_id = uzytkownikUser.id;
                context.histories.Add(historiaHistory);
                context.SaveChanges();
            }

            MessageBox.Show("Przelew wykonany prawidłowo", "Przelew", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
 private void btnZaloguj_Click(object sender, EventArgs e)
 {
     try
     {
         using (bankingmachineEntities context = new bankingmachineEntities())
         {
             user logowanieUser = context.users.Where(i => i.login == textBox1.Text.ToString()).SingleOrDefault();
             if (logowanieUser.passhash == textBox2.Text)
             {
                 form1.bLogged    = true;
                 form1.loggedUser = logowanieUser.login.ToString();
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Błąd logowania. Wprowadź dane ponownie", "Błąd", MessageBoxButtons.OK,
                                 MessageBoxIcon.Error);
             }
         }
     }
     catch
     {
     }
 }
Exemple #6
0
        private void sprawdzAdresata(object sender, EventArgs e)
        {
            int tmp = 0;

            try
            {
                using (bankingmachineEntities context = new bankingmachineEntities())
                {
                    tmp           = Convert.ToInt32(textBox1.Text);
                    textBox2.Text = context.users.Where(i => i.id == tmp).SingleOrDefault().login.ToString();
                }
            }
            catch
            {
                if (!(textBox1.Text == ""))
                {
                    textBox2.Text = "błędny numer konta";
                }
                else
                {
                    textBox2.Text = "";
                }
            }
        }