Exemplo n.º 1
0
        private void displayCreditFromTxtFile(Object path)
        {
            BinaryFormatter bf     = new BinaryFormatter();
            StringReader    reader = null;

            if (path is OpenFileDialog)
            {
                FileStream stream = new FileStream(((OpenFileDialog)path).FileName, FileMode.Open, FileAccess.Read);
                reader = new StringReader((string)bf.Deserialize(stream));
            }
            else if (path is string)
            {
                FileStream stream = new FileStream((string)path, FileMode.Open, FileAccess.Read);
                reader = new StringReader((string)bf.Deserialize(stream));
            }

            string computedHashForCurrentUserEmail = encryptionClassInstance.calculHash(currentUserEmailAddress);

            if (computedHashForCurrentUserEmail.Equals(reader.ReadLine()))
            {
                string[] creditParsed = new string[9];
                string   creditTxt;
                while ((creditTxt = reader.ReadLine()) != null)
                {
                    if (creditTxt != null)
                    {
                        creditParsed = creditTxt.Split(',');
                    }

                    try
                    {
                        if (creditParsed.Length > 8)
                        {
                            if (creditParsed[8].Equals("perioadaDeGratie"))
                            {
                                CreditStudiu nouCredit = new CreditStudiu(DateTime.Parse(creditParsed[1]), double.Parse(creditParsed[3]),
                                                                          int.Parse(creditParsed[5]), int.Parse(creditParsed[9]));
                                MessageBox.Show(nouCredit.ToString());
                            }
                        }
                        else
                        {
                            Credite nouCredit = new Credite(DateTime.Parse(creditParsed[1]), double.Parse(creditParsed[3]), int.Parse(creditParsed[5]));
                            MessageBox.Show(nouCredit.ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Integritatea datelor a fost compromisa, nu se pot prelucra!" + Environment.NewLine + ex.StackTrace);
                        break;
                    }
                }
            }
            else
            {
                MessageBox.Show("Aceste date nu va apartin! Va rugam sa utilizati doar date asociate sau trimise contului dvs.!");
            }
            reader.Close();
        }
 public Masteranzi(string numeClient,
                   DateTime dataNasterii,
                   long cnp, CreditStudiu credit,
                   string numarMatricol,
                   string numeInstitutie) : base(numeClient, dataNasterii, cnp, credit)
 {
     this.numarMatricol  = numarMatricol;
     this.numeInstitutie = numeInstitutie;
 }
Exemplo n.º 3
0
        private void btn_aplicaCredit_Click(object sender, EventArgs e)
        {
            string creditQuery = Settings.Default.CreditQuery;

            MessageBox.Show(creditQuery);
            OleDbCommand command = new OleDbCommand(creditQuery, connection);

            if (clbPerioadaDeCreditare.CheckedItems.Count == 0 || (tb_sumaCeruta.Text.Length) == 0)
            {
                if ((tb_sumaCeruta.Text.Length) == 0 || Int32.Parse(tb_sumaCeruta.Text) < 100)
                {
                    MessageBox.Show("Valoarea creditului trebuie sa fie mai mare de 99 lei!");
                }
                else
                {
                    MessageBox.Show("Trebuie sa selectezi o perioada de creditare din cele oferite!");
                }
            }
            else
            {
                try
                {
                    command.Parameters.AddWithValue("sumaAprobata", tb_sumaCeruta.Text);
                    command.Parameters.AddWithValue("perioadaCredit", clbPerioadaDeCreditare.CheckedItems[0].ToString());
                    string perioadaDeGratiere;
                    if (isStudent && cbStudent.Checked == true)
                    {
                        if (clbPerioadaDeGratiere.CheckedItems.Count == 0)
                        {
                            perioadaDeGratiere = "0";
                        }
                        else
                        {
                            perioadaDeGratiere = clbPerioadaDeGratiere.CheckedItems[0].ToString();
                        }
                    }
                    else
                    {
                        perioadaDeGratiere = "0";
                    }
                    CreditStudiu creditNouStudii = new CreditStudiu(DateTime.Now, int.Parse(tb_sumaCeruta.Text),
                                                                    int.Parse(clbPerioadaDeCreditare.CheckedItems[0].ToString()),
                                                                    int.Parse(perioadaDeGratiere));
                    Credite creditNouSimplu = new Credite(DateTime.Now, int.Parse(tb_sumaCeruta.Text),
                                                          int.Parse(clbPerioadaDeCreditare.CheckedItems[0].ToString()));

                    if (isStudent)
                    {
                        if (cbStudent.CheckState == CheckState.Checked)
                        {
                            command.Parameters.AddWithValue("dobanda", "3");
                            command.Parameters.AddWithValue("totalDePlata", ((CreditStudiu)creditNouStudii).CalculeazaCredit().ToString());
                            command.Parameters.AddWithValue("dataCredit", DateTime.Now.ToShortDateString());
                            command.Parameters.AddWithValue("perioadaDeGratie", perioadaDeGratiere);
                            command.Parameters.AddWithValue("CNP", this.CNP);
                        }
                        else
                        {
                            command.Parameters.AddWithValue("dobanda", "12");
                            command.Parameters.AddWithValue("totalDePlata", (creditNouSimplu).CalculeazaCredit().ToString());
                            command.Parameters.AddWithValue("dataCredit", DateTime.Now.ToShortDateString());
                            command.Parameters.AddWithValue("perioadaDeGratie", perioadaDeGratiere);
                            command.Parameters.AddWithValue("CNP", this.CNP);
                        }
                    }
                    else
                    {
                        command.Parameters.AddWithValue("dobanda", "12");
                        command.Parameters.AddWithValue("totalDePlata", (creditNouSimplu).CalculeazaCredit().ToString());
                        command.Parameters.AddWithValue("dataCredit", DateTime.Now.ToShortDateString());
                        command.Parameters.AddWithValue("perioadaDeGratie", perioadaDeGratiere);
                        command.Parameters.AddWithValue("CNP", this.CNP);
                    }

                    connection.Open();
                    command.ExecuteNonQuery();
                    MessageBox.Show("Credit accesat cu succes!");
                    if (isStudent && cbStudent.Checked == true)
                    {
                        referenceForm.GetListaCredite.Add(creditNouStudii);
                    }
                    else
                    {
                        referenceForm.GetListaCredite.Add(creditNouSimplu);
                    }
                    this.Hide();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemplo n.º 4
0
        public Account(String s, String CNP, String emailAddress, Hash_SHA256 encryptionInstance, Login loginFormInstance)
        {
            InitializeComponent();
            loginInstance = loginFormInstance;
            helperNightMode.setColorTheme(Settings.Default.isNightMode, this);
            userReceiverText            += s + "!";
            lbUser_Logged.Text          += userReceiverText;
            this.CNP                     = CNP;
            this.currentUserEmailAddress = emailAddress;
            verifyIfStudent();
            encryptionClassInstance = encryptionInstance;

            hashingForm = new Hashing(this, encryptionClassInstance);
            try
            {
                string       query   = "Select * from Credite where CNP='" + CNP + "'";
                OleDbCommand command = new OleDbCommand(query, connection);
                connection.Open();
                OleDbDataReader reader = command.ExecuteReader();
                if (isStudent)
                {
                    lvCredite.Columns.Add("Perioada de gratie");
                    lvCredite.Size = new Size(lvCredite.Width + 150, lvCredite.Height);
                    lvCredite.Columns[lvCredite.Columns.Count - 1].Width = 150;
                }

                while (reader.Read())
                {
                    if (reader["dobanda"].ToString() == "3")
                    {
                        CreditStudiu c = new CreditStudiu(DateTime.Parse(reader["dataCredit"].ToString()), double.Parse(reader["sumaAprobata"].ToString()),
                                                          int.Parse(reader["perioadaCredit"].ToString()), int.Parse(reader["perioadaDeGratie"].ToString()));
                        ListViewItem item = lvCredite.Items.Add((lvCredite.Items.Count + 1).ToString());
                        item.SubItems.Add(c.GetDateTime.ToShortDateString());
                        item.SubItems.Add(c.CuantumCredit.ToString());
                        item.SubItems.Add(c.PerioadaCredit.ToString());
                        item.SubItems.Add(c.CalculeazaDobanda().ToString());
                        item.SubItems.Add(c.CalculeazaCredit().ToString());
                        item.SubItems.Add(CreditStudiu.DOBANDA.ToString() + "%");
                        item.SubItems.Add(c.PerioadaDeGratie.ToString() + " luni");
                        listaCredite.Add(c);
                        cuantumTotalCredite += c.CalculeazaCredit();
                    }
                    else
                    {
                        Credite c = new Credite(DateTime.Parse(reader["dataCredit"].ToString()), double.Parse(reader["sumaAprobata"].ToString()),
                                                int.Parse(reader["perioadaCredit"].ToString()));
                        ListViewItem item = lvCredite.Items.Add((lvCredite.Items.Count + 1).ToString());
                        item.SubItems.Add(c.GetDateTime.ToShortDateString());
                        item.SubItems.Add(c.CuantumCredit.ToString());
                        item.SubItems.Add(c.PerioadaCredit.ToString());
                        item.SubItems.Add(c.CalculeazaDobanda().ToString());
                        item.SubItems.Add(c.CalculeazaCredit().ToString());
                        item.SubItems.Add(Credite.DOBANDA.ToString() + "%");
                        listaCredite.Add(c);
                        cuantumTotalCredite += c.CalculeazaCredit();
                    }
                }
                reader.Close();
                connection.Close();
                counterForListaCredite = listaCredite.Count;
                //Console.WriteLine("Counter initial: " + counterForListaCredite);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }