Esempio n. 1
0
        public static Page getComision(string accNr)
        {
            Page pg = new Page();

            using (var context = new MitBankDBEntities())
            {
                if (IDSession != 0 && accNr != "")
                {
                    var result = context.takeComision(4, accNr).ToArray();

                    foreach (var item in result)
                    {
                        if (item.HasValue == true)
                        {
                            pg.Data = item.ToString();
                        }
                        else
                        {
                            pg.Data = "";
                        }
                    }
                }
            }



            return(pg);
        }
Esempio n. 2
0
        private void bunifuFlatButton3_Click(object sender, EventArgs e)
        {
            lastMenupanel.Visible     = false;
            panelMainTransfer.Visible = true;
            lastMenupanel.SendToBack();
            lastMenupanel = panelMainTransfer;


            using (var context = new MitBankDBEntities())
            {
                List <Page> listIban = new List <Page>();
                listIban = DataManagement.getIbanList();
                foreach (var item in listIban)
                {
                    int index = -1;
                    index = comboBoxIBAN.FindString(item.Data.ToString());

                    if (index == -1)
                    {
                        comboBoxIBAN.Items.Add(item.Data.ToString());
                    }
                }
                if (listIban.Count() != 0)
                {
                    comboBoxIBAN.SelectedIndex           = 0;
                    comboBoxSelectTransfer.SelectedIndex = 0;
                }
            }
        }
Esempio n. 3
0
        public static bool tryConnection(string username, string password)
        {
            using (var context = new MitBankDBEntities())
            {
                if (context.getUandPProcedure(username, password).FirstOrDefault().HasValue)
                {
                    IDSession = context.getUandPProcedure(username, password).FirstOrDefault().Value;

                    // exemplu de intoarcere parametru din procedura stocata
                    //
                    ObjectParameter output = new ObjectParameter("result", typeof(bool));
                    context.IsAdmin(IDSession, output);
                    if (Convert.ToBoolean(output.Value))
                    {
                        Form1.isAdmin = true;
                    }
                    //

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Esempio n. 4
0
        private void textBoxWriteIBAN_OnValueChanged(object sender, EventArgs e)
        {
            string getIBANfromTextBox = textBoxWriteIBAN.Text;
            Page   pg = new Page();

            using (var context = new MitBankDBEntities())
            {
                var result = context.getAnyoneCurrency(getIBANfromTextBox).ToArray();
                if (result.Length != 0)
                {
                    pictureValid.Visible  = true;
                    pictureFailed.Visible = false;
                    var result2 = context.getAnyoneCurrency(getIBANfromTextBox.ToString()).ToArray();
                    foreach (var item in result2)
                    {
                        labelcurrencyToIban.Text = item.ToString();
                    }
                }
                else
                {
                    pictureFailed.Visible    = true;
                    pictureValid.Visible     = false;
                    labelcurrencyToIban.Text = "-";
                }
            }
        }
Esempio n. 5
0
        public static List <string> getAllInfoAccunts()
        {
            List <string> lc = new List <string>();

            using (var context = new MitBankDBEntities())
            {
                var result = context.showAllMyAccounts(IDSession);

                foreach (var item in result)
                {
                    var result2 = context.showIBANInformations(item.ToString()).ToArray();

                    foreach (var item2 in result2)
                    {
                        string info = item.ToString();

                        info = item2.ID + "       " + info + "       " + "       " + item2.BankPacket + "       " + item2.ValabilityUntil +
                               "       " + item2.Sold + "       " + item2.Currency;
                        lc.Add(info);
                    }
                }
            }


            return(lc);
        }
Esempio n. 6
0
 private void label11_Click(object sender, EventArgs e)
 {
     using (var context = new MitBankDBEntities())
     {
         var result = context.insertLastLogin(DataManagement.getIdUsername(), DateTime.Now.ToString());
     }
     Application.Exit();
 }
 public static string getIbanCurrency(string iban)
 {
     using (var context = new MitBankDBEntities())
     {
         var result = context.showIBANInformations(iban).FirstOrDefault();
         return(result.Currency.ToString());
     }
 }
 public static string getIbanDate(string iban)
 {
     using (var context = new MitBankDBEntities())
     {
         var result = context.showIBANInformations(iban).FirstOrDefault();
         return(result.ValabilityUntil.ToString());
     }
 }
 public static string getIbanPacket(string iban)
 {
     using (var context = new MitBankDBEntities())
     {
         var ibanInfo             = context.showIBANInformations(iban).FirstOrDefault();
         TypeBankingPacket packet = (from c in context.TypeBankingPackets
                                     where c.ID == ibanInfo.BankPacket
                                     select c).First();
         return(packet.NameTypePacket.ToString());
     }
 }
Esempio n. 10
0
        public static void addOnHistory(string userAccountIban,
                                        string toWichAccount, int TypeTransaction, double val)
        {
            using (var context = new MitBankDBEntities())
            {
                var result = context.addHistoryTransaction(IDSession, userAccountIban
                                                           , toWichAccount, TypeTransaction, -val, DateTime.Now.ToString());

                var result2 = context.addHistoryTransaction(IDSession, toWichAccount, userAccountIban
                                                            , TypeTransaction, +val, DateTime.Now.ToString());
            }
        }
Esempio n. 11
0
        public static List <string> getDashboardInfo()
        {
            List <string> list = new List <string>();

            using (var context = new MitBankDBEntities())
            {
                var conturi = context.showAllMyAccounts(IDSession).ToArray();
                foreach (var item in conturi)
                {
                    list.Add(item.ToString());
                }
            }
            return(list);
        }
Esempio n. 12
0
        public Form2()
        {
            InitializeComponent();
            panelMainDashboard.BackColor    = System.Drawing.Color.FromArgb(100, 100, 40);
            panelMainPaySomething.BackColor = System.Drawing.Color.FromArgb(100, 100, 40);
            panelMainSendMail.BackColor     = System.Drawing.Color.FromArgb(100, 100, 40);
            panelMainSettings.BackColor     = System.Drawing.Color.FromArgb(100, 100, 40);
            panelMainTransfer.BackColor     = System.Drawing.Color.FromArgb(100, 100, 40);

            panelMainDashboard.Visible    = true;
            panelMainPaySomething.Visible = false;
            panelMainSendMail.Visible     = false;
            panelMainTransfer.Visible     = false;
            panelMainSettings.Visible     = false;

            pictureFailed.Visible = false;
            pictureValid.Visible  = false;
            lastMenupanel         = panelMainDashboard;

            UIDashboardAccountFrame.generateDashboard(ibanList, panelMainDashboard, exchangeTbl);
            labelLastName.Text = DataManagement.getLastName();
            using (var context = new MitBankDBEntities())
            {
                var result2 = context.getLastLogin(DataManagement.getIdUsername());
                foreach (var item in result2)
                {
                    labelLastLogin.Text = item.ToString();
                }
            }

            labelChangeEmail.Visible   = false;
            textBoxChangeEmail.Visible = false;

            using (var context = new MitBankDBEntities())
            {
                var result = context.selectOnIndividuals(DataManagement.getIdUsername()).ToArray();

                foreach (var items in result)
                {
                    labelLastNameSettings.Text  = items.LastName;
                    labelFirstNameSettings.Text = items.FirstName;
                    labelEmailSettings.Text     = items.Email;
                    labelBirthdateSettings.Text = items.Birthday.ToShortDateString();

                    int idInd = items.ID;
                }
            }
        }
Esempio n. 13
0
 public static double getCurrencyValueSell(string curr)
 {
     using (var context = new MitBankDBEntities())
     {
         var exchInfo = from c in context.CurrentCurrencies
                        select c;
         foreach (var item in exchInfo)
         {
             if (item.CurrencyName == curr)
             {
                 return(item.ValueSel);
             }
         }
     }
     return(0);
 }
Esempio n. 14
0
        public static string getLastName()
        {
            string lastName = "Guest";


            using (var context = new MitBankDBEntities())
            {
                var result = context.selectOnIndividuals(IDSession);

                foreach (var item in result)
                {
                    lastName = item.LastName.ToString();
                }
            }
            return(lastName);
        }
Esempio n. 15
0
 public static Page getCurrencyAnyone(string iban)
 {
     using (var context = new MitBankDBEntities())
     {
         Page pg = new Page();
         if (IDSession != 0)
         {
             var result = context.getAnyoneCurrency(iban);
             foreach (var item in result)
             {
                 pg.Data = item.ToString();
             }
         }
         return(pg);
     }
 }
Esempio n. 16
0
 public static Page getCurrency(string iban)
 {
     using (var context = new MitBankDBEntities())
     {
         Page pg = new Page();
         if (IDSession != 0)
         {
             var result = context.showIBANInformations(iban).ToArray();
             foreach (var item in result)
             {
                 pg.Data = item.Currency.ToString();
             }
         }
         return(pg);
     }
 }
        public static string getExchange()
        {
            string data = "";

            using (var context = new MitBankDBEntities())
            {
                var exchInfo = from c in context.CurrentCurrencies
                               select c;
                foreach (var item in exchInfo)
                {
                    data += item.CurrencyName.ToString() + " ";
                    data += item.ValueBuy + " ";
                    data += item.ValueSel + " ";
                }
            }
            return(data);
        }
Esempio n. 18
0
        private void comboBoxToTransferMyIBAN_SelectedIndexChanged(object sender, EventArgs e)
        {
            string currencyFromIBAN = "-";
            string currencyToIBAN   = "-";

            using (var context = new MitBankDBEntities())
            {
                if (comboBoxToTransferMyIBAN.SelectedIndex != -1)
                {
                    var result = context.getAnyoneCurrency(comboBoxToTransferMyIBAN.Text).ToArray();
                    foreach (var item in result)
                    {
                        currencyToIBAN = item.ToString();
                    }
                    labelcurrencyToIban.Text = currencyToIBAN;
                }
            }
        }
Esempio n. 19
0
        public static List <Page> getIbanList()
        {
            List <Page> listIban = new List <Page>();

            using (var context = new MitBankDBEntities())
            {
                if (IDSession != 0)
                {
                    var result = context.showAllMyAccounts(IDSession).ToArray();
                    foreach (var item in result)
                    {
                        Page pg = new Page();
                        pg.Data = item.ToString();
                        listIban.Add(pg);
                    }
                }
            }

            return(listIban);
        }
Esempio n. 20
0
        private void logoutButton_Click(object sender, EventArgs e)
        {
            var result = MessageBox.Show("Are you sure?", "Info",
                                         MessageBoxButtons.YesNo,
                                         MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                using (var context = new MitBankDBEntities())
                {
                    var result2 = context.insertLastLogin(DataManagement.getIdUsername(), DateTime.Now.ToString());
                }
                this.Hide();
                Form1 frm = new Form1();
                this.Refresh();
                this.Invalidate();
                frm.Refresh();
                frm.Invalidate();
                frm.Show();
            }
        }
        public static void cashDeposit()
        {
            using (var context = new MitBankDBEntities())
            {
                // exemplu de utilizare tranzactie din Entity Framework
                //
                using (var transaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        string iban = "RO93MITB0410120579132411";
                        int    sum  = -123;
                        if (sum < 1)
                        {
                            throw new MitException("Poti depune cel putin o unitate monetara");
                        }

                        var account = context.UserAccounts.Single(obj => obj.AccountNumber.Trim() == iban);
                        if (account != null)
                        {
                            account.Sold += sum;
                        }
                        else
                        {
                            throw new MitException("Cont negasit!");
                        }

                        transaction.Commit();
                        MessageBox.Show("depunereNumerar");
                    }

                    catch (Exception e)
                    {
                        transaction.Rollback();
                        MessageBox.Show(e.Message);
                    }
                }
            }
        }
        public static void generateDashboard(List <Label> ibanList, Panel panelMainDashboard, Label exchangeTbl)
        {
            ibanList.Clear();
            int           i    = 0;
            List <string> list = DataManagement.getDashboardInfo();

            foreach (string iban in list)
            {
                var context = new MitBankDBEntities();

                Label lb = UIDashboardAccountFrame.createFrame(iban, i);
                i++;
                ibanList.Add(lb);
            }

            foreach (Label lb in ibanList)
            {
                panelMainDashboard.Controls.Add(lb);
                lb.BringToFront();
            }

            exchangeTbl = UIDashboardAccountFrame.getExchangeTable();
            panelMainDashboard.Controls.Add(exchangeTbl);
        }
Esempio n. 23
0
        private void buttonGenerateHistoryTranz_Click(object sender, EventArgs e)
        {
            char delim = ';';

            DataTable  tb    = new DataTable();
            DataColumn ordId = new DataColumn("IdTranzaction");

            ordId.DataType = typeof(int);
            tb.Columns.Add(ordId);

            DataColumn usAccount = new DataColumn("UserId");

            usAccount.DataType  = typeof(string);
            usAccount.MaxLength = 100;
            tb.Columns.Add(usAccount);

            DataColumn fAccount = new DataColumn("From Account");

            fAccount.DataType  = typeof(string);
            fAccount.MaxLength = 100;
            tb.Columns.Add(fAccount);

            DataColumn tAccount = new DataColumn("To Account");

            tAccount.DataType  = typeof(string);
            tAccount.MaxLength = 100;
            tb.Columns.Add(tAccount);


            DataColumn typeTranz = new DataColumn("Type Transaction");

            typeTranz.DataType  = typeof(string);
            typeTranz.MaxLength = 100;
            tb.Columns.Add(typeTranz);

            DataColumn val = new DataColumn("Value");

            val.DataType = typeof(float);
            tb.Columns.Add(val);

            DataColumn dateTrans = new DataColumn("Date");

            dateTrans.DataType = typeof(DateTime);
            tb.Columns.Add(dateTrans);

            DataColumn tipTranz = new DataColumn("Type Trnsaction");

            tipTranz.DataType = typeof(string);
            tb.Columns.Add(tipTranz);

            using (var context = new MitBankDBEntities())
            {
                var result = context.HistoryTransactionProc(DataManagement.getIdUsername()).ToArray();
                foreach (var items in result)
                {
                    if (items.TypeTransaction.Value == 4)
                    {
                        tb.Rows.Add(items.ID, items.UserAccountID, items.fromAccount, items.toWichAccount, items.TypeTransaction
                                    , items.Value, items.DateTransaction, "transfer");
                    }
                    else
                    {
                        if (items.TypeTransaction.Value == 3)
                        {
                            tb.Rows.Add(items.ID, items.UserAccountID, items.fromAccount, items.toWichAccount, items.TypeTransaction
                                        , items.Value, items.DateTransaction, "pay bill");
                        }
                    }
                }
                StringBuilder sb = new StringBuilder();
                foreach (DataRow row in tb.Rows)
                {
                    string[] fields = row.ItemArray.Select(field => field.ToString()).
                                      ToArray();
                    sb.AppendLine(string.Join(",", fields));
                }
                if (comboBoxTakeFormat.SelectedItem == "Excel Format")
                {
                    WriteToExcel(tb, "C:\\Users\\" + Environment.UserName + "\\Desktop\\History Transaction " + DataManagement.getLastName() + ".xlsx");
                    MessageBox.Show("It`s saved. Please see file on desktop!");
                }
                else
                if (comboBoxTakeFormat.SelectedItem == "CSV Format")
                {
                    File.WriteAllText("C:\\Users\\" + Environment.UserName + "\\Desktop\\History Transaction " + DataManagement.getLastName() + ".csv", sb.ToString());
                    MessageBox.Show("It`s saved. Please see file on desktop!");
                }
            }

            //order.Rows.Add("O9876", 10, 2001);
        }
Esempio n. 24
0
        private void buttonSubmitTransfer_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure?", "Warning", MessageBoxButtons.YesNo);

            try
            {
                if (dialogResult == DialogResult.Yes)
                {
                    double ValWithouComiss = 0;

                    ValWithouComiss = double.Parse(textoxValueToTransfer.Text);

                    double comiss = 0;

                    comiss = double.Parse(labelComisionValue.Text);

                    double valToTransfer = 1;
                    if (labelExchangeValue.Text != "-")
                    {
                        valToTransfer = double.Parse(labelExchangeValue.Text);
                    }

                    double getsold = 0;
                    if (labelComisionValue.Text != "-")
                    {
                        using (var context = new MitBankDBEntities())
                        {
                            var result = DataManagement.getSold(comboBoxIBAN.SelectedItem.ToString());

                            getsold = double.Parse(result.Data);
                        }
                        if (getsold > (ValWithouComiss + comiss))
                        {
                            using (var context = new MitBankDBEntities())
                            {
                                if (comboBoxSelectTransfer.SelectedItem.ToString() == "My another account")
                                {
                                    var result = context.transferMoney(comboBoxIBAN.SelectedItem.ToString(),
                                                                       comboBoxToTransferMyIBAN.SelectedItem.ToString(), ((ValWithouComiss + comiss)),
                                                                       valToTransfer);
                                    DataManagement.addOnHistory(comboBoxIBAN.SelectedItem.ToString(),
                                                                comboBoxToTransferMyIBAN.SelectedItem.ToString(), 4, (ValWithouComiss + comiss));
                                }
                                else if (comboBoxSelectTransfer.SelectedItem.ToString() == "Anyone else account")
                                {
                                    var result = context.transferMoney(comboBoxIBAN.SelectedItem.ToString(),
                                                                       textBoxWriteIBAN.Text, ((ValWithouComiss + comiss)),
                                                                       valToTransfer);

                                    DataManagement.addOnHistory(comboBoxIBAN.SelectedItem.ToString(),
                                                                textBoxWriteIBAN.Text, 4, (ValWithouComiss + comiss));
                                }
                                labelComisionValue.Text = "-";
                                labelExchangeValue.Text = "-";
                                MessageBox.Show("Done!");
                            }
                        }
                        else
                        {
                            MessageBox.Show("You dont have enought money!!!");
                        }
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Put all informations or something wrong!");
            }
        }
        public static void addIndividualCustomer(Individual individ, string username, string password)
        {
            // Detached Entities
            //

            using (var context = new MitBankDBEntities())
            {
                using (var transaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        var verificat = from entry in context.Individuals
                                        where entry.CNP == individ.CNP
                                        select entry;

                        if (!verificat.Any())
                        {
                            context.Individuals.Add(individ);


                            var customer = new Customer
                            {
                                CustomerType = 1
                            };
                            context.Customers.Add(customer);


                            var individualCustomer = new IndividualCustomer
                            {
                                Customer   = customer,
                                Individual = individ
                            };
                            context.IndividualCustomers.Add(individualCustomer);
                            context.SaveChanges();

                            var uname = new Username
                            {
                                UserType  = 1,
                                Username1 = username,
                                Pass      = password
                            };
                            context.Usernames.Add(uname);

                            var normalu = new NormalUser
                            {
                                Username = uname,
                                Customer = customer
                            };
                            context.NormalUsers.Add(normalu);
                            context.SaveChanges();
                        }
                        else
                        {
                            throw new MitException("CNP deja existent in baza de date");
                        }

                        transaction.Commit();
                    }
                    catch (MitException e)
                    {
                        MessageBox.Show(e.Message);
                        transaction.Rollback();
                    }

                    catch (Exception e)
                    {
                        MessageBox.Show("Eroare netratata:" + e.Message);
                        MessageBox.Show(e.InnerException.GetBaseException().Message);
                        transaction.Rollback();
                    }
                }
            }
        }