コード例 #1
0
ファイル: AddAngajati_Form.cs プロジェクト: helmeseanu/Final
        private void Button_AddOk_Click(object sender, EventArgs e)
        {
            try
            {
                var context = new Asociatie_ProprietariEntities();

                var newCategory = new Membri_Asociatie()
                {
                    //Nume = _nume,
                    Prenume        = _prenume,
                    Numar_telefon  = _numar_telefon,
                    Emai           = _email,
                    Functie        = _functie,
                    Data_Inscriere = DateTime.Parse(_data_inscriere)
                };

                context.Membri_Asociatie.Add(newCategory);

                context.SaveChanges();
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Eroare de contectare la server");
            }
        }
コード例 #2
0
ファイル: DeleteUser_Form.cs プロジェクト: helmeseanu/Final
        private void Button_AddOk_Click(object sender, EventArgs e)
        {
            Asociatie_ProprietariEntities context = new Asociatie_ProprietariEntities();

            try
            {
                _ID = Int32.Parse(textBox_ID.Text);

                var results = (from row in context.Membri_Asociatie
                               where row.ID.Equals(_ID)
                               select row).First();

                context.Membri_Asociatie.Remove(results);

                context.SaveChanges();

                textBox_ID.Clear();
            }
            catch
            {
                textBox_ID.Clear();

                MessageBox.Show("Incorrect ID");
            }
        }
コード例 #3
0
ファイル: User_Form.cs プロジェクト: helmeseanu/Final
        //////////////my funtions
        private bool verifyContracteInd(int nrApartamente, string serviciu)
        {
            try
            {
                var context = new Asociatie_ProprietariEntities();


                var t_contracte = from c in context.Contracte_Individuale
                                  where c.IdApartament.Equals(nrApartamente) && c.Serviciu.TrimEnd().Equals(serviciu)
                                  select new
                {
                    c
                };

                if (t_contracte.Count() == 0)
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Contacteaza dezvoltatorul!");
            }

            return(false);
        }
コード例 #4
0
ファイル: User_Form.cs プロジェクト: helmeseanu/Final
        private void trimite_info_cont_Click(object sender, EventArgs e)
        {
            if (trimite_info_cont.Enabled == false)
            {
                MessageBox.Show("Nu ati facut modificari");
            }
            else
            {
                try
                {
                    var context = new Asociatie_ProprietariEntities();

                    var t_membrei = (from c in context.Membri_Asociatie
                                     where c.ID.Equals(Id_Membru_asociatie)
                                     select c).First();

                    t_membrei.Nume          = nume_tb.Text;
                    t_membrei.Prenume       = prenume_tb.Text;
                    t_membrei.Emai          = prenume_tb.Text;
                    t_membrei.Numar_telefon = nrtel_tb.Text;

                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                    string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                    File.AppendAllText("errors.txt", New);
                    MessageBox.Show("Eroare");
                }

                MessageBox.Show("Succes!");
            }
        }
コード例 #5
0
ファイル: ShowUser_Form.cs プロジェクト: helmeseanu/Final
        private void Button_ShowOk_Click(object sender, EventArgs e)
        {
            dataGridView_Show.Visible = true;

            Asociatie_ProprietariEntities context = new Asociatie_ProprietariEntities();
            DataTable table = new DataTable();

            var results = from row in context.Membri_Asociatie
                          select new
            { row.ID, row.Nume, row.Prenume, row.Numar_telefon, row.Emai, row.Functie, row.Data_Inscriere };

            table.Columns.Add("ID");
            table.Columns.Add("Nume");
            table.Columns.Add("Prenume");
            table.Columns.Add("Numar_telefon");
            table.Columns.Add("Emai");
            table.Columns.Add("Functie");
            table.Columns.Add("Data_Inscriere");

            foreach (var item in results)
            {
                table.Rows.Add(new object[] { item.ID, item.Nume, item.Prenume, item.Numar_telefon, item.Emai, item.Functie, item.Data_Inscriere });
            }

            dataGridView_Show.DataSource = table;
        }
コード例 #6
0
ファイル: registerForm.cs プロジェクト: helmeseanu/Final
        private void finishRegister()
        {
            try
            {
                var context = new Asociatie_ProprietariEntities();

                context.Membri_Asociatie.Add(datePersonale);
                context.Conturi_de_Utilizator.Add(contUtilizator);

                for (int i = 0; i < nr_ap_detinute; i++)
                {
                    ap_detinute[i].Numar_locatari = calculeazaNumarulLocatarilor(ap_detinute[i].Numar);
                    context.Apartamente.Add(ap_detinute[i]);
                }

                for (int i = 0; i < locatar_cur - 1; i++)
                {
                    context.Locatari.Add(locatari[i]);
                }

                context.SaveChanges();

                this.Close();
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Contacteaza dezvoltatorul!");
            }
        }
コード例 #7
0
        public FormVizualizareFurnizori()
        {
            try
            {
                InitializeComponent();

                using (var context = new Asociatie_ProprietariEntities())
                {
                    var results = (from c in context.Furnizori
                                   select new
                    {
                        c.CUI,
                        c.Nume,
                        c.Email,
                        c.Serviciu,
                        c.Data_semnare_contract,
                        c.Data_expirare_contract
                    });

                    dataGridView1.DataSource = results.ToList();
                    dataGridView1.Refresh();
                }
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Contacteaza dezvoltatorul!");
            }
        }
コード例 #8
0
        private void button_cod_Click(object sender, EventArgs e)
        {
            using (var context = new Asociatie_ProprietariEntities())
            {
                var results = (from c in context.Coduri
                               where c.Cod.TrimEnd().Equals(textBox_cod.Text)
                               select c);

                if (results.Count() != 0)
                {
                    this.Hide();
                    foreach (var i in results)
                    {
                        context.Coduri.Remove(i);
                    }
                    context.SaveChanges();
                    Form reg = new registerForm();
                    reg.FormClosed += new FormClosedEventHandler(RegFormClosed);
                    reg.ShowDialog();
                }
                else
                {
                    user_label.Show();
                    password_label.Show();
                    panel_cod.Hide();
                    MessageBox.Show("Cod invalid!", "Avertisment", MessageBoxButtons.OK);
                }
            }
        }
コード例 #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.All(Char.IsDigit) != true || textBox1.Text.Length == 0)
            {
                MessageBox.Show("CUI invalid!", "Avertisment", MessageBoxButtons.OK);
            }
            else
            {
                using (var context = new Asociatie_ProprietariEntities())
                {
                    var furn = (from c in context.Furnizori
                                where c.CUI.ToString().Equals(textBox1.Text)
                                select c);

                    if (furn.ToList().Count != 0)
                    {
                        context.Furnizori.Remove(furn.ToList()[0]);
                        context.SaveChanges();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("CUI inexistent!", "Avertisment", MessageBoxButtons.OK);
                    }
                }
            }
        }
コード例 #10
0
ファイル: User_Form.cs プロジェクト: helmeseanu/Final
        private void adauga_card_button_Click(object sender, EventArgs e)
        {
            int _cvc;

            try
            {
                var context = new Asociatie_ProprietariEntities();

                var carduri = from c in context.Carduri
                              where c.Numar_Card.TrimEnd().Equals(nr_cont_textBox.Text) && c.IdMembru.Equals(Id_Membru_asociatie)
                              select c;
                if (carduri.Count() != 0)
                {
                    MessageBox.Show("Cardul deja exista");
                }
                else
                {
                    if (nr_cont_textBox.Text.Length != 16)
                    {
                        nr_cont_textBox.Clear();
                        cvc_textBox.Clear();
                        dateexp_textBox.Clear();
                        MessageBox.Show("nr cont gresit");
                    }
                    else
                    {
                        if (Int32.TryParse(cvc_textBox.Text, out _cvc) && _cvc.ToString().Length != 3)
                        {
                            nr_cont_textBox.Clear();
                            cvc_textBox.Clear();
                            dateexp_textBox.Clear();
                            MessageBox.Show("cvc gresit");
                        }
                        else
                        {
                            var t_carduri = new Carduri();
                            {
                                t_carduri.CVC           = Int32.Parse(cvc_textBox.Text);
                                t_carduri.Numar_Card    = nr_cont_textBox.Text;
                                t_carduri.Data_Expirare = DateTime.Parse(dateexp_textBox.Text);
                                t_carduri.IdMembru      = Id_Membru_asociatie;
                            };


                            context.Carduri.Add(t_carduri);
                            context.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Contacteaza dezvoltatorul!");
            }
        }
コード例 #11
0
        private void login_button_Click(object sender, EventArgs e)
        {
            if (user_textbox.Text.Length != 0)
            {
                if (password_textbox.Text.Length != 0)
                {
                    using (var context = new Asociatie_ProprietariEntities())
                    {
                        var results = (from c in context.Conturi_de_Utilizator
                                       where c.Username.Trim().Equals(user_textbox.Text)
                                       select new
                        {
                            c.Username,
                            c.Parola,
                            c.IdMembru,
                            c.Tip
                        });

                        if (results.Count() != 0 && results.ToList()[0].Username.TrimEnd() == user_textbox.Text)
                        {
                            if (results.ToList()[0].Parola.TrimEnd() == sha256(password_textbox.Text))
                            {
                                this.Hide();

                                /*if (results.ToList()[0].Tip.TrimEnd().Equals("User"))
                                 * {
                                 *  Form user_form = new User_Form(results.ToList()[0].IdMembru);
                                 *  user_form.ShowDialog();
                                 * }
                                 * else
                                 * {
                                 *  Form admin_form = new Admin_Form();
                                 *  admin_form.ShowDialog();
                                 * }*/
                            }
                            else
                            {
                                MessageBox.Show("Parola gresita!", "Avertisment", MessageBoxButtons.OK);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Utilizator inexistent!", "Avertisment", MessageBoxButtons.OK);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Nu ai introdus parola!", "Avertisment", MessageBoxButtons.OK);
                }
            }
            else
            {
                MessageBox.Show("Nu ai introdus utilizatorul!", "Avertisment", MessageBoxButtons.OK);
            }
        }
コード例 #12
0
ファイル: User_Form.cs プロジェクト: helmeseanu/Final
        private void button_trimite_Click(object sender, EventArgs e)
        {
            DateTime d;

            Int32.TryParse(ComBoxApartamente.Text, out Numar_Apartament);

            if (textBox_contracte_inv.Text.Equals(""))
            {
                label_error.Show();
            }
            else
            {
                if (!DateTime.TryParse(textBox_contracte_inv.Text, out d))
                {
                    textBox_contracte_inv.Clear();
                    label_error.Show();
                }
                else
                {
                    try
                    {
                        var context = new Asociatie_ProprietariEntities();


                        var t_contracte = from c in context.Contracte_Individuale
                                          where c.IdApartament.Equals(Numar_Apartament) && c.Serviciu.TrimEnd().Equals(comboBox_Servicii.Text)
                                          select c;


                        if (t_contracte.Count() == 0)
                        {
                            context.Contracte_Individuale.Add(new Contracte_Individuale {
                                IdApartament = Numar_Apartament, Serviciu = comboBox_Servicii.Text, Data = DateTime.Parse(textBox_contracte_inv.Text)
                            });
                            context.SaveChanges();
                        }
                        else
                        {
                            MessageBox.Show("Contractul exista in baza de date");
                        }
                    }
                    catch (Exception ex)
                    {
                        File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                        string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                        File.AppendAllText("errors.txt", New);
                        MessageBox.Show("Nu s-a putut adauga contractul");
                    }
                }
                textBox_contracte_inv.Clear();
            }
        }
コード例 #13
0
ファイル: Factura_Form.cs プロジェクト: helmeseanu/Final
        public Factura_Form(int numar_apartament, int Id_membru)
        {
            this.id_membru        = Id_membru;
            this.numar_apartament = numar_apartament;


            InitializeComponent();
            try
            {
                var context = new Asociatie_ProprietariEntities();

                var t_facturi = from c in context.Facturi_Clienti
                                where c.IdApartament.Equals(numar_apartament) && c.Data_emitere.Month.Equals(DateTime.Today.Month)
                                select c;
                if (t_facturi.Count() == 0)
                {
                    lipsa_facturi_panel.Show();
                    dataGridView1.Hide();
                    Servicii_contor_dataGridView.Hide();
                }
                else
                {
                    data_emitere_label.Text       += t_facturi.ToList()[0].Data_emitere.ToString();
                    data_scadenta_label.Text      += t_facturi.ToList()[0].Data_Scadenta.ToString();
                    perioada_facturare_label.Text += t_facturi.ToList()[0].Perioada_Facturare.ToString();
                    suma_label.Text += t_facturi.ToList()[0].Total_de_Plata.ToString();



                    var result = from c in context.detaliiFactura1(DateTime.Today.Month.ToString(), numar_apartament, DateTime.Today.Year.ToString())
                                 select c;
                    Servicii_contor_dataGridView.DataSource = result.ToList();
                    Servicii_contor_dataGridView.Refresh();
                    var result1 = from c in context.detaliiFactuaCotaParte1(DateTime.Today.Month.ToString(), numar_apartament, DateTime.Today.Year.ToString())
                                  select c;
                    dataGridView1.DataSource = result1.ToList();
                    dataGridView1.Refresh();

                    dataGridView1.Show();
                    Servicii_contor_dataGridView.Show();
                }
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Contacteaza dezvoltatorul!");
            }
        }
コード例 #14
0
ファイル: Restante_Form.cs プロジェクト: helmeseanu/Final
        public Restante_Form(int numar_apartament, int Id_membru)
        {
            this.id_membru = Id_membru;

            InitializeComponent();
            try
            {
                var context = new Asociatie_ProprietariEntities();

                var t_restante = from c in context.Facturi_Clienti
                                 join q in context.Restante on c.ID equals q.IDFactura
                                 where c.IdApartament.Equals(numar_apartament)
                                 select new
                {
                    c.ID,
                    c.Total_de_Plata,
                    q.Restante1,
                    q.Penalizari_zi,
                    c.Data_emitere,
                    c.Data_Scadenta
                };

                if (t_restante.Count() == 0)
                {
                    restante_facturi_panel.Show();
                }
                else
                {
                    restante_facturi_panel.Hide();
                    dataGridView1.DataSource = t_restante.ToList();
                    dataGridView1.Refresh();
                    dataGridView1.Show();
                }
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Contacteaza dezvoltatorul!");
            }
        }
コード例 #15
0
        public FormVizualizareFurnizori()
        {
            InitializeComponent();

            using (var context = new Asociatie_ProprietariEntities())
            {
                var results = (from c in context.Furnizori
                               select new
                {
                    c.CUI,
                    c.Nume,
                    c.Email,
                    c.Serviciu,
                    c.Data_semnare_contract,
                    c.Data_expirare_contract
                });

                dataGridView1.DataSource = results.ToList();
                dataGridView1.Refresh();
            }
        }
コード例 #16
0
        private void button_cod_Click(object sender, EventArgs e)
        {
            try
            {
                using (var context = new Asociatie_ProprietariEntities())
                {
                    var results = (from c in context.Coduri
                                   where c.Cod.TrimEnd().Equals(textBox_cod.Text)
                                   select c);

                    if (results.Count() != 0)
                    {
                        this.Hide();
                        foreach (var i in results)
                        {
                            context.Coduri.Remove(i);
                        }
                        context.SaveChanges();
                        Form reg = new registerForm();
                        reg.FormClosed += new FormClosedEventHandler(RegFormClosed);
                        reg.ShowDialog();
                    }
                    else
                    {
                        user_label.Show();
                        password_label.Show();
                        panel_cod.Hide();
                        MessageBox.Show("Cod invalid!", "Avertisment", MessageBoxButtons.OK);
                    }
                }
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Contacteaza dezvoltatorul!");
            }
        }
コード例 #17
0
        private void finishRegister()
        {
            var context = new Asociatie_ProprietariEntities();

            context.Membri_Asociatie.Add(datePersonale);
            context.Conturi_de_Utilizator.Add(contUtilizator);

            for (int i = 0; i < nr_ap_detinute; i++)
            {
                ap_detinute[i].Numar_locatari = calculeazaNumarulLocatarilor(ap_detinute[i].Numar);
                context.Apartamente.Add(ap_detinute[i]);
            }

            for (int i = 0; i < locatar_cur - 1; i++)
            {
                context.Locatari.Add(locatari[i]);
            }

            context.SaveChanges();

            this.Close();
        }
コード例 #18
0
ファイル: User_Form.cs プロジェクト: helmeseanu/Final
        private void button_info_Click(object sender, EventArgs e)
        {
            contracteIndv_panel.Hide();
            apartamente_panel.Hide();
            card_panel.Hide();
            label_principal.Text = "Informatii Cont";
            Info_cont_panel.Show();
            label_principal.Show();

            try
            {
                var context = new Asociatie_ProprietariEntities();

                var t_membrei = from c in context.Membri_Asociatie
                                where c.ID.Equals(Id_Membru_asociatie)
                                select c;

                nume_tb.Text    = t_membrei.ToList()[0].Nume.TrimEnd().ToString();
                prenume_tb.Text = t_membrei.ToList()[0].Prenume.TrimEnd().ToString();
                nrtel_tb.Text   = t_membrei.ToList()[0].Numar_telefon.TrimEnd().ToString();
                email_tb.Text   = t_membrei.ToList()[0].Emai.TrimEnd().ToString();
                statut_tb.Text  = t_membrei.ToList()[0].Functie.TrimEnd().ToString();
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Contacteaza dezvoltatorul!");
            }

            trimite_info_cont.Enabled = false;
            nume_tb.ReadOnly          = true;
            prenume_tb.ReadOnly       = true;
            nrtel_tb.ReadOnly         = true;
            email_tb.ReadOnly         = true;
            statut_tb.ReadOnly        = true;
        }
コード例 #19
0
ファイル: Factura_Form.cs プロジェクト: helmeseanu/Final
        private void factura_buton_Click(object sender, EventArgs e)
        {
            try
            {
                var context = new Asociatie_ProprietariEntities();

                var carduri = from c in context.Carduri
                              where c.IdMembru.Equals(id_membru)
                              select c;

                if (carduri.Count() == 0)
                {
                    MessageBox.Show("nu exista carduri introduse");
                }
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Contacteaza dezvoltatorul!");
            }
        }
コード例 #20
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox1.Text.All(Char.IsDigit) != true || textBox1.Text.Length == 0)
                {
                    MessageBox.Show("CUI invalid!", "Avertisment", MessageBoxButtons.OK);
                }
                else
                {
                    using (var context = new Asociatie_ProprietariEntities())
                    {
                        var furn = (from c in context.Furnizori
                                    where c.CUI.ToString().Equals(textBox1.Text)
                                    select c);

                        if (furn.ToList().Count != 0)
                        {
                            context.Furnizori.Remove(furn.ToList()[0]);
                            context.SaveChanges();
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("CUI inexistent!", "Avertisment", MessageBoxButtons.OK);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Contacteaza dezvoltatorul!");
            }
        }
コード例 #21
0
ファイル: User_Form.cs プロジェクト: helmeseanu/Final
        private void setNrapartament()
        {
            try
            {
                var context = new Asociatie_ProprietariEntities();

                var t_apartamene = from c in context.Apartamente
                                   where c.IdProprietar.Equals(Id_Membru_asociatie)
                                   select new
                {
                    c.Numar
                };

                ComBoxApartamente.DataSource    = t_apartamene.ToList();
                ComBoxApartamente.DisplayMember = "Numar";
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Contacteaza dezvoltatorul!");
            }
        }
コード例 #22
0
ファイル: registerForm.cs プロジェクト: helmeseanu/Final
        private void informatii_personale_next_Click(object sender, EventArgs e)
        {
            int canProcessNextStep = 1;

            warning_label.Text = "";

            //verific daca exista text in casete
            if (Nume_textBox.Text.Length == 0)
            {
                nume_error_label.Show();
                canProcessNextStep = 0;
            }
            else
            {
                if (char.IsUpper(Nume_textBox.Text.ToString().First()) != true)
                {
                    canProcessNextStep = 0;
                    warning_label.Text = "Numele pot incepe doar cu litera mare!";
                }
                if (Nume_textBox.Text.All(Char.IsLetter) != true)
                {
                    canProcessNextStep = 0;
                    warning_label.Text = "Numele pot contine doar litere!";
                }
                nume_error_label.Hide();
            }

            if (prenume_textBox.Text.Length == 0)
            {
                prenume_error_label.Show();
                canProcessNextStep = 0;
            }
            else
            {
                if (char.IsUpper(prenume_textBox.Text.ToString().First()) != true)
                {
                    canProcessNextStep = 0;
                    warning_label.Text = "Prenumele pot incepe doar cu litera mare!";
                }
                if (prenume_textBox.Text.All(Char.IsLetter) != true)
                {
                    canProcessNextStep = 0;
                    warning_label.Text = "Prenumele pot contine doar litere!";
                }
                prenume_error_label.Hide();
            }

            if (numar_telefon_textBox.Text.Length == 0)
            {
                numar_telefon_error_label.Show();
                canProcessNextStep = 0;
            }
            else
            {
                if (Regex.Match(numar_telefon_textBox.Text, @"^0[1-9][0-9]{8}$").Success != true)
                {
                    warning_label.Text = "Format numar telefon invalid!";
                    canProcessNextStep = 0;
                }
                numar_telefon_error_label.Hide();
            }

            if (email_text_box.Text.Length == 0)
            {
                email_error_label.Show();
                canProcessNextStep = 0;
            }
            else
            {
                if (Regex.Match(email_text_box.Text, @"^(?!\.)(""([^""\r\\]|\\[""\r\\])*""|" +
                                @"([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)" +
                                @"@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$").Success != true)
                {
                    warning_label.Text = "Format e-mail invalid!";
                    canProcessNextStep = 0;
                }
                email_error_label.Hide();
            }

            if (canProcessNextStep == 1)
            {
                var context = new Asociatie_ProprietariEntities();

                var membruAsociatieNou = new Membri_Asociatie()                  //salvam datele personale ale utilizatorului
                {
                    Nume           = Nume_textBox.Text,
                    Prenume        = prenume_textBox.Text,
                    Numar_telefon  = numar_telefon_textBox.Text,
                    Emai           = email_text_box.Text,
                    Functie        = "Membru",
                    Data_Inscriere = DateTime.Today
                };

                datePersonale = membruAsociatieNou;
                personalDataPanel.Hide();
                panel_inregistrare_apartamente.Show();
                panel_date_apartament.Hide();
            }
        }
コード例 #23
0
ファイル: registerForm.cs プロジェクト: helmeseanu/Final
        private void nextButton1_Click(object sender, EventArgs e)
        {
            int canCreateAccount = 1, canProcessNextStep = 1;

            warning_label.Text = "";

            //verific daca exista text in casete
            if (user_name_text_box.Text.Length == 0)
            {
                username_error_label.Show();
                canProcessNextStep = 0;
            }
            else
            {
                username_error_label.Hide();
            }

            if (password_text_box.Text.Length == 0)
            {
                password_error_label.Show();
                canProcessNextStep = 0;
            }
            else
            {
                password_error_label.Hide();
            }

            if (confirm_password_text_box.Text.Length == 0)
            {
                confirm_password_error_label.Show();
                canProcessNextStep = 0;
            }
            else
            {
                confirm_password_error_label.Hide();
            }

            //verific daca usernameul exista si parolele coincid
            try
            {
                if (canProcessNextStep == 1)
                {
                    using (var context = new Asociatie_ProprietariEntities())
                    {
                        var nume_utilizatori = (from c in context.Conturi_de_Utilizator
                                                where c.Username.TrimEnd().Equals(user_name_text_box.Text)
                                                select new
                        {
                            c.Username
                        });

                        if (nume_utilizatori.Count() != 0)
                        {
                            if (nume_utilizatori.ToList()[0].Username.ToString().TrimEnd() == user_name_text_box.Text.TrimEnd())
                            {
                                warning_label.Text = "Userul exista!";
                                canCreateAccount   = 0;
                            }
                        }

                        if (canCreateAccount == 1)
                        {
                            if (password_text_box.Text.Equals(confirm_password_text_box.Text) != true)
                            {
                                warning_label.Text = "Parolele nu coincid!";
                                canCreateAccount   = 0;
                            }
                        }

                        if (canCreateAccount == 1)
                        {
                            user_register_panel.Hide();
                            personalDataPanel.Show();
                            nume_error_label.Hide();
                            prenume_error_label.Hide();
                            numar_telefon_error_label.Hide();
                            email_error_label.Hide();

                            var contNou = new Conturi_de_Utilizator()                  //salvam datele personale ale utilizatorului
                            {
                                Username = user_name_text_box.Text,
                                Parola   = sha256(password_text_box.Text),
                                Tip      = "User"
                            };
                            contUtilizator = contNou;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Contacteaza dezvoltatorul!");
            }
        }
コード例 #24
0
        private void Button_ModifyOK_Click(object sender, EventArgs e)
        {
            Asociatie_ProprietariEntities context = new Asociatie_ProprietariEntities();

            try
            {
                _ID             = Int32.Parse(textBox_ID.Text);
                _nume           = textBox_Nume.Text;
                _prenume        = textBox_Prenume.Text;
                _numar_telefon  = textBox_NrTel.Text;
                _email          = textBox_Email.Text;
                _functie        = textBox_Functie.Text;
                _data_inscriere = textBox_DataInscriere.Text;


                var results = (from row in context.Membri_Asociatie
                               where row.ID.Equals(_ID)
                               select row).First();

                if (_nume != "")
                {
                    results.Nume = _nume;
                }

                if (_prenume != "")
                {
                    results.Prenume = _prenume;
                }

                if (_numar_telefon != "")
                {
                    results.Numar_telefon = _numar_telefon;
                }

                if (_email != "")
                {
                    results.Emai = _email;
                }

                if (_functie != "")
                {
                    results.Functie = _functie;
                }

                if (_data_inscriere != "")
                {
                    results.Data_Inscriere = DateTime.Parse(_data_inscriere);
                }

                context.SaveChanges();

                textBox_ID.Clear();
                textBox_Nume.Clear();
                textBox_Prenume.Clear();
                textBox_NrTel.Clear();
                textBox_Email.Clear();
                textBox_Functie.Clear();
                textBox_DataInscriere.Clear();
            }
            catch
            {
                textBox_ID.Clear();
                textBox_Nume.Clear();
                textBox_Prenume.Clear();
                textBox_NrTel.Clear();
                textBox_Email.Clear();
                textBox_Functie.Clear();
                textBox_DataInscriere.Clear();

                MessageBox.Show("Incorrect ID");
            }
        }
コード例 #25
0
        private void login_button_Click(object sender, EventArgs e)
        {
            try
            {
                if (user_textbox.Text.Length != 0)
                {
                    if (password_textbox.Text.Length != 0)
                    {
                        using (var context = new Asociatie_ProprietariEntities())
                        {
                            var results = (from c in context.Conturi_de_Utilizator
                                           where c.Username.Trim().Equals(user_textbox.Text)
                                           select new
                            {
                                c.Username,
                                c.Parola,
                                c.IdMembru,
                                c.Tip
                            });

                            if (results.Count() != 0 && results.ToList()[0].Username.TrimEnd() == user_textbox.Text)
                            {
                                if (results.ToList()[0].Parola.TrimEnd() == sha256(password_textbox.Text))
                                {
                                    this.Hide();
                                    if (results.ToList()[0].Tip.TrimEnd().Equals("User"))
                                    {
                                        Form user_form = new User_Form(results.ToList()[0].IdMembru);
                                        user_form.FormClosed += new FormClosedEventHandler(UserFormClosed);
                                        user_form.ShowDialog();
                                    }
                                    else
                                    {
                                        Form admin_form = new Admin_Form();
                                        admin_form.FormClosed += new FormClosedEventHandler(AdminFormClosed);
                                        admin_form.ShowDialog();
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Parola gresita!", "Avertisment", MessageBoxButtons.OK);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Utilizator inexistent!", "Avertisment", MessageBoxButtons.OK);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Nu ai introdus parola!", "Avertisment", MessageBoxButtons.OK);
                    }
                }
                else
                {
                    MessageBox.Show("Nu ai introdus utilizatorul!", "Avertisment", MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Contacteaza dezvoltatorul!");
            }
        }
コード例 #26
0
ファイル: User_Form.cs プロジェクト: helmeseanu/Final
        private void trimite_gaz_Click(object sender, EventArgs e)
        {
            int     index;
            decimal consum;

            try
            {
                var context = new Asociatie_ProprietariEntities();

                var t_gaz = (from c in context.Gaz
                             where c.IdApartament.Equals(Numar_Apartament)
                             orderby c.Data_Emitere descending
                             select c).Take(1);


                if (!Int32.TryParse(textBox_index.Text, out index))
                {
                    index_error_ac.Show();
                    textBox_index.Clear();
                }
                else
                {
                    if (t_gaz.Count() != 0)
                    {
                        if (t_gaz.ToList()[0].Data_Emitere.Month.Equals(DateTime.Today.Month) && t_gaz.ToList()[0].Data_Emitere.Year.Equals(DateTime.Today.Year))
                        {
                            MessageBox.Show("Citire deja inregistrata pentru luna curenta");
                            textBox_index.Clear();
                        }

                        else
                        {
                            if (index < t_gaz.ToList()[0].Index_Nou)
                            {
                                MessageBox.Show("Indexul este gresit!");
                                textBox_index.Clear();
                            }
                            else
                            {
                                consum = index - t_gaz.ToList()[0].Index_Vechi;
                                var newEnry = new Gaz()
                                {
                                    IdApartament  = Numar_Apartament,
                                    Consum        = index - t_gaz.ToList()[0].Index_Nou,
                                    Index_Vechi   = t_gaz.ToList()[0].Index_Nou,
                                    Index_Nou     = index,
                                    Suma_de_plata = t_gaz.ToList()[0].Pret_m_cub * consum,
                                    Pret_m_cub    = t_gaz.ToList()[0].Pret_m_cub,
                                    Data_Emitere  = DateTime.Today
                                };

                                context.Gaz.Add(newEnry);
                                context.SaveChanges();
                            }
                        }
                    }
                    else
                    {
                        if (t_gaz.Count() == 0)
                        {
                            var newEntry = new Gaz()
                            {
                                Index         = 1,
                                IdApartament  = Numar_Apartament,
                                Index_Vechi   = 0,
                                Index_Nou     = index,
                                Consum        = index,
                                Pret_m_cub    = 6,
                                Suma_de_plata = 6 * index,
                                Data_Emitere  = DateTime.Today
                            };

                            context.Gaz.Add(newEntry);
                            context.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Contacteaza dezvoltatorul!");
            }
        }
コード例 #27
0
ファイル: Admin_Form.cs プロジェクト: helmeseanu/Final
        private void ListBox_Utilitati_Click(object sender, EventArgs e)
        {
            try
            {
                string curItem = listBox_Utilitati.SelectedItem.ToString();

                int index = listBox_Utilitati.FindString(curItem);

                switch (curItem)
                {
                case "Agent Termic":
                {
                    Asociatie_ProprietariEntities context = new Asociatie_ProprietariEntities();
                    DataTable table = new DataTable();

                    var results = from row in context.Agent_Termic
                                  select new
                    { row.Index, row.IdApartament, row.Suma_de_plata, row.Data_emitere };

                    table.Columns.Add("Index");
                    table.Columns.Add("IdApartament");
                    table.Columns.Add("Suma_de_plata");
                    table.Columns.Add("Data_emitere");

                    foreach (var item in results)
                    {
                        table.Rows.Add(new object[] { item.Index, item.IdApartament, item.Suma_de_plata, item.Data_emitere });
                    }

                    dataGridView_Afisare.DataSource = table;

                    break;
                }

                case "Apa Calda":
                {
                    Asociatie_ProprietariEntities context = new Asociatie_ProprietariEntities();
                    DataTable table = new DataTable();

                    var results = from row in context.ApaCalda
                                  select new
                    { row.Index, row.IdApartament, row.Index_Vechi, row.Index_Nou, row.Consum, row.Pret_m_cub, row.Suma_de_Plata, row.Data_emitere };

                    table.Columns.Add("Index");
                    table.Columns.Add("IdApartament");
                    table.Columns.Add("Index_Vechi");
                    table.Columns.Add("Index_Nou");
                    table.Columns.Add("Consum");
                    table.Columns.Add("Pret_m_cub");
                    table.Columns.Add("Suma_de_plata");
                    table.Columns.Add("Data_emitere");

                    foreach (var item in results)
                    {
                        table.Rows.Add(new object[] { item.Index, item.IdApartament, item.Index_Vechi, item.Index_Nou, item.Consum, item.Pret_m_cub, item.Suma_de_Plata, item.Data_emitere });
                    }

                    dataGridView_Afisare.DataSource = table;

                    break;
                }

                case "Apa Rece":
                {
                    Asociatie_ProprietariEntities context = new Asociatie_ProprietariEntities();
                    DataTable table = new DataTable();

                    var results = from row in context.ApaRece
                                  select new
                    { row.Index, row.IdApartament, row.Index_Vechi, row.Index_Nou, row.Consum, row.Pret_m_cub, row.Suma_de_plata, row.Data_emitere };

                    table.Columns.Add("Index");
                    table.Columns.Add("IdApartament");
                    table.Columns.Add("Index_Vechi");
                    table.Columns.Add("Index_Nou");
                    table.Columns.Add("Consum");
                    table.Columns.Add("Pret_m_cub");
                    table.Columns.Add("Suma_de_plata");
                    table.Columns.Add("Data_emitere");

                    foreach (var item in results)
                    {
                        table.Rows.Add(new object[] { item.Index, item.IdApartament, item.Index_Vechi, item.Index_Nou, item.Consum, item.Pret_m_cub, item.Suma_de_plata, item.Data_emitere });
                    }

                    dataGridView_Afisare.DataSource = table;

                    break;
                }

                case "Canalizare":
                {
                    Asociatie_ProprietariEntities context = new Asociatie_ProprietariEntities();
                    DataTable table = new DataTable();

                    var results = from row in context.Canalizare
                                  select new
                    { row.Index, row.IdApartament, row.Suma_de_plata, row.Data_emitere };

                    table.Columns.Add("Index");
                    table.Columns.Add("IdApartament");
                    table.Columns.Add("Suma_de_plata");
                    table.Columns.Add("Data_emitere");

                    foreach (var item in results)
                    {
                        table.Rows.Add(new object[] { item.Index, item.IdApartament, item.Suma_de_plata, item.Data_emitere });
                    }

                    dataGridView_Afisare.DataSource = table;

                    break;
                }

                case "Curatenie":
                {
                    Asociatie_ProprietariEntities context = new Asociatie_ProprietariEntities();
                    DataTable table = new DataTable();

                    var results = from row in context.Curatenie
                                  select new
                    { row.Index, row.IdApartament, row.Suma_de_plata, row.Data_emitere };

                    table.Columns.Add("Index");
                    table.Columns.Add("IdApartament");
                    table.Columns.Add("Suma_de_plata");
                    table.Columns.Add("Data_emitere");

                    foreach (var item in results)
                    {
                        table.Rows.Add(new object[] { item.Index, item.IdApartament, item.Suma_de_plata, item.Data_emitere });
                    }

                    dataGridView_Afisare.DataSource = table;

                    break;
                }

                case "Energie Electrica":
                {
                    Asociatie_ProprietariEntities context = new Asociatie_ProprietariEntities();
                    DataTable table = new DataTable();

                    var results = from row in context.EnergieElectrica
                                  select new
                    { row.Index, row.IdApartament, row.Index_Vechi, row.Index_Nou, row.Consum, row.Pret_Kw, row.Suma_de_plata, row.Data_emitere };

                    table.Columns.Add("Index");
                    table.Columns.Add("IdApartament");
                    table.Columns.Add("Index_Vechi");
                    table.Columns.Add("Index_Nou");
                    table.Columns.Add("Consum");
                    table.Columns.Add("Pret_Kw");
                    table.Columns.Add("Suma_de_plata");
                    table.Columns.Add("Data_Emitere");

                    foreach (var item in results)
                    {
                        table.Rows.Add(new object[] { item.Index, item.IdApartament, item.Index_Vechi, item.Index_Nou, item.Consum, item.Pret_Kw, item.Suma_de_plata, item.Data_emitere });
                    }

                    dataGridView_Afisare.DataSource = table;

                    break;
                }

                case "Gaz":
                {
                    Asociatie_ProprietariEntities context = new Asociatie_ProprietariEntities();
                    DataTable table = new DataTable();

                    var results = from row in context.Gaz
                                  select new
                    { row.Index, row.IdApartament, row.Index_Vechi, row.Index_Nou, row.Consum, row.Pret_m_cub, row.Suma_de_plata, row.Data_Emitere };

                    table.Columns.Add("Index");
                    table.Columns.Add("IdApartament");
                    table.Columns.Add("Index_Vechi");
                    table.Columns.Add("Index_Nou");
                    table.Columns.Add("Consum");
                    table.Columns.Add("Pret_m_cub");
                    table.Columns.Add("Suma_de_plata");
                    table.Columns.Add("Data_Emitere");

                    foreach (var item in results)
                    {
                        table.Rows.Add(new object[] { item.Index, item.IdApartament, item.Index_Vechi, item.Index_Nou, item.Consum, item.Pret_m_cub, item.Suma_de_plata, item.Data_Emitere });
                    }

                    dataGridView_Afisare.DataSource = table;

                    break;
                }

                case "Lift":
                {
                    Asociatie_ProprietariEntities context = new Asociatie_ProprietariEntities();
                    DataTable table = new DataTable();

                    var results = from row in context.Lift
                                  select new
                    { row.Index, row.IdApartament, row.Suma_de_plata, row.Data_emitere };

                    table.Columns.Add("Index");
                    table.Columns.Add("IdApartament");
                    table.Columns.Add("Suma_de_plata");
                    table.Columns.Add("Data_emitere");

                    foreach (var item in results)
                    {
                        table.Rows.Add(new object[] { item.Index, item.IdApartament, item.Suma_de_plata, item.Data_emitere });
                    }

                    dataGridView_Afisare.DataSource = table;

                    break;
                }

                case "Salubritate":
                {
                    Asociatie_ProprietariEntities context = new Asociatie_ProprietariEntities();
                    DataTable table = new DataTable();

                    var results = from row in context.Salubritate
                                  select new
                    { row.Index, row.IdApartament, row.Suma_de_plata, row.Data_emitere };

                    table.Columns.Add("Index");
                    table.Columns.Add("IdApartament");
                    table.Columns.Add("Suma_de_plata");
                    table.Columns.Add("Data_emitere");

                    foreach (var item in results)
                    {
                        table.Rows.Add(new object[] { item.Index, item.IdApartament, item.Suma_de_plata, item.Data_emitere });
                    }

                    dataGridView_Afisare.DataSource = table;

                    break;
                }

                case "Membri Asociatie":
                {
                    Asociatie_ProprietariEntities context = new Asociatie_ProprietariEntities();
                    DataTable table = new DataTable();

                    var results = from row in context.Membri_Asociatie
                                  select new
                    { row.ID, row.Nume, row.Prenume, row.Numar_telefon, row.Emai, row.Functie, row.Data_Inscriere };

                    table.Columns.Add("ID");
                    table.Columns.Add("Nume");
                    table.Columns.Add("Prenume");
                    table.Columns.Add("Numar_telefon");
                    table.Columns.Add("Emai");
                    table.Columns.Add("Functie");
                    table.Columns.Add("Data_Inscriere");

                    foreach (var item in results)
                    {
                        table.Rows.Add(new object[] { item.ID, item.Nume, item.Prenume, item.Numar_telefon, item.Emai, item.Functie, item.Data_Inscriere });
                    }

                    dataGridView_Afisare.DataSource = table;

                    break;
                }

                default:
                {
                    MessageBox.Show("Error!");
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Select an Item");
            }
        }
コード例 #28
0
        private void nextButton1_Click(object sender, EventArgs e)
        {
            int canCreateAccount = 1, canProcessNextStep = 1;

            warning_label.Text = "";

            //verific daca exista text in casete
            if (user_name_text_box.Text.Length == 0)
            {
                username_error_label.Show();
                canProcessNextStep = 0;
            }
            else
            {
                username_error_label.Hide();
            }

            if (password_text_box.Text.Length == 0)
            {
                password_error_label.Show();
                canProcessNextStep = 0;
            }
            else
            {
                password_error_label.Hide();
            }

            if (confirm_password_text_box.Text.Length == 0)
            {
                confirm_password_error_label.Show();
                canProcessNextStep = 0;
            }
            else
            {
                confirm_password_error_label.Hide();
            }

            //verific daca usernameul exista si parolele coincid
            if (canProcessNextStep == 1)
            {
                using (var context = new Asociatie_ProprietariEntities())
                {
                    var nume_utilizatori = (from c in context.Conturi_de_Utilizator
                                            where c.Username.TrimEnd().Equals(user_name_text_box.Text)
                                            select new
                    {
                        c.Username
                    });

                    if (nume_utilizatori.Count() != 0)
                    {
                        if (nume_utilizatori.ToList()[0].Username.ToString().TrimEnd() == user_name_text_box.Text.TrimEnd())
                        {
                            warning_label.Text = "Userul exista!";
                            canCreateAccount   = 0;
                        }
                    }

                    if (canCreateAccount == 1)
                    {
                        if (password_text_box.Text.Equals(confirm_password_text_box.Text) != true)
                        {
                            warning_label.Text = "Parolele nu coincid!";
                            canCreateAccount   = 0;
                        }
                    }

                    if (canCreateAccount == 1)
                    {
                        user_register_panel.Hide();
                        personalDataPanel.Show();
                        nume_error_label.Hide();
                        prenume_error_label.Hide();
                        numar_telefon_error_label.Hide();
                        email_error_label.Hide();

                        var contNou = new Conturi_de_Utilizator()                  //salvam datele personale ale utilizatorului
                        {
                            Username = user_name_text_box.Text,
                            Parola   = sha256(password_text_box.Text),
                            Tip      = "User"
                        };
                        contUtilizator = contNou;
                    }
                }
            }
        }
コード例 #29
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int canAdd = 1;

                if (textBox1.ToString().Length != 0 && textBox1.Text.All(Char.IsDigit) != true)
                {
                    canAdd            = 0;
                    label_eroare.Text = "CUI-ul contine doar cifre!";
                }
                else
                {
                    label_eroare.Text = "";
                }

                if (textBox2.ToString().Length != 0 && char.IsUpper(textBox2.Text.ToString().First()) != true)
                {
                    canAdd            = 0;
                    label_eroare.Text = "Numele pot incepe doar cu litera mare!";
                }
                else
                {
                    label_eroare.Text = "";
                }

                if (textBox3.ToString().Length != 0 && Regex.Match(textBox3.Text, @"^(?!\.)(""([^""\r\\]|\\[""\r\\])*""|" +
                                                                   @"([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)" +
                                                                   @"@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$").Success != true)
                {
                    label_eroare.Text = "Format e-mail invalid!";
                    canAdd            = 0;
                }
                else
                {
                    label_eroare.Text = "";
                }

                if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0 || textBox4.Text.Length == 0)
                {
                    label_eroare.Text = "Completeaza toate casetele!";
                    canAdd            = 0;
                }
                else
                {
                    label_eroare.Text = "";
                }

                if (canAdd == 1)
                {
                    var context      = new Asociatie_ProprietariEntities();
                    var furnizor_nou = new Furnizori()
                    {
                        CUI      = System.Convert.ToDecimal(textBox1.Text),
                        Nume     = textBox2.Text,
                        Email    = textBox3.Text,
                        Serviciu = textBox4.Text,
                        Data_semnare_contract  = DateTime.Today.AddYears(-1),
                        Data_expirare_contract = DateTime.Today.AddYears(+1)
                    };

                    context.Furnizori.Add(furnizor_nou);
                    context.SaveChanges();
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine;
                File.AppendAllText("errors.txt", New);
                MessageBox.Show("Contacteaza dezvoltatorul!");
            }
        }
コード例 #30
0
        private void button1_Click(object sender, EventArgs e)
        {
            int canAdd = 1;

            if (textBox1.Text.All(Char.IsDigit) != true)
            {
                canAdd            = 0;
                label_eroare.Text = "CUI-ul contine doar cifre!";
            }
            else
            {
                label_eroare.Text = "";
            }

            if (char.IsUpper(textBox2.Text.ToString().First()) != true)
            {
                canAdd            = 0;
                label_eroare.Text = "Numele pot incepe doar cu litera mare!";
            }
            else
            {
                label_eroare.Text = "";
            }

            if (Regex.Match(textBox3.Text, @"^(?!\.)(""([^""\r\\]|\\[""\r\\])*""|" +
                            @"([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)" +
                            @"@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$").Success != true)
            {
                label_eroare.Text = "Format e-mail invalid!";
                canAdd            = 0;
            }
            else
            {
                label_eroare.Text = "";
            }

            if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0 || textBox4.Text.Length == 0)
            {
                label_eroare.Text = "Completeaza toate casetele!";
                canAdd            = 0;
            }
            else
            {
                label_eroare.Text = "";
            }

            if (canAdd == 1)
            {
                var context      = new Asociatie_ProprietariEntities();
                var furnizor_nou = new Furnizori()
                {
                    CUI      = System.Convert.ToDecimal(textBox1.Text),
                    Nume     = textBox2.Text,
                    Email    = textBox3.Text,
                    Serviciu = textBox4.Text,
                    Data_semnare_contract  = DateTime.Today.AddYears(-1),
                    Data_expirare_contract = DateTime.Today.AddYears(+1)
                };

                context.Furnizori.Add(furnizor_nou);
                context.SaveChanges();
                this.Close();
            }
        }