コード例 #1
0
        private void btn_vinde_masina_Click(object sender, EventArgs e)
        {
            var    context      = new Parc_AutoDataContext();
            string nume_angajat = textBox_nume_vanzator.Text.ToString();
            string nume_client  = textBox_nume_client.Text.ToString();

            var id_angajat = from db in context.Angajatis
                             where db.Nume.Equals(nume_angajat)
                             select db.AngajatID;

            var contract = new Vanzari
            {
                Angajat_ID   = id_angajat.First(),
                Client       = nume_client,
                Vanzator     = nume_angajat,
                VIN          = vvv,
                Pret_vanzare = ppp,
                Data         = DateTime.Now
            };

            var car = from db in context.Masinis
                      where db.VIN.Equals(vvv)
                      select db;

            foreach (var masina in car)
            {
                context.Masinis.DeleteOnSubmit(masina);
            }
            context.Vanzaris.InsertOnSubmit(contract);
            context.SubmitChanges();
            this.Close();
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string user     = textBox1.Text.ToString();
            string password = textBox2.Text.ToString();

            if (user == "" || password == "")
            {
                MessageBox.Show("Campuri incomplete !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                var context = new Parc_AutoDataContext();

                //--------------criptare------------
                Encryption enc = new Encryption();
                password = enc.EncryptPassword(password);
                //----------------------------------

                var admin1 = new Admin_user
                {
                    Admin_name = nume,
                    Username   = user,
                    Password   = password
                };

                context.Admin_users.InsertOnSubmit(admin1);
                context.SubmitChanges();

                this.Close();
                return;
            }
        }
コード例 #3
0
        private void btn_concediaza_Click(object sender, EventArgs e)
        {
            var context = new Parc_AutoDataContext();

            if (dataGridView1.SelectedRows.Count > 0)
            {
                int id_angajat = Int32.Parse(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());

                var angajati = from db in context.Angajatis
                               where db.AngajatID == id_angajat
                               select db;

                foreach (var angajat in angajati)
                {
                    context.Angajatis.DeleteOnSubmit(angajat);
                }
                context.SubmitChanges();

                var query_listare_angajati = from db in context.Angajatis
                                             select db;

                dataGridView1.DataSource = query_listare_angajati.ToList();


                return;
            }
            else
            {
                MessageBox.Show("nu ati selectat niciun angajat");
            }
        }
コード例 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            string nume     = textBox1.Text.ToString();
            string password = textBox2.Text.ToString();

            if (nume == "" || password == "")
            {
                MessageBox.Show("Campuri incomplete !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                var context = new Parc_AutoDataContext();

                //--------------criptare------------

                Encryption enc = new Encryption();
                password = enc.EncryptPassword(password);

                //----------------------------------

                var selected_admin = (from db in context.Admin_users
                                      where db.Admin_name.Equals(nume)
                                      select db).First();

                if (selected_admin == null)
                {
                    MessageBox.Show("Adminul nu exista in baza de date !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.Close();
                    return;
                }
                if (CCurent_user == nume)
                {
                    MessageBox.Show("Nu puteti sterge adminul curent !", "Confirmare", MessageBoxButtons.OK);

                    this.Close();
                    return;
                }

                if (selected_admin.Password == password)
                {
                    context.Admin_users.DeleteOnSubmit(selected_admin);
                    context.SubmitChanges();

                    MessageBox.Show("Adminul a fost concediat !", "Confirmare", MessageBoxButtons.OK);

                    this.Close();
                    return;
                }
                else
                {
                    MessageBox.Show("Parola incorecta !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    this.Close();
                    return;
                }
            }
        }
コード例 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            string functie = textBox2.Text.ToString();
            string sal     = textBox3.Text.ToString();

            float sal1    = 0;
            bool  salariu = float.TryParse(sal, out sal1);

            var context = new Parc_AutoDataContext();

            var angajat = (from db in context.Angajatis
                           where db.Nume.Equals(nume)
                           select db).First();

            if (functie == "" && sal == "")
            {
                MessageBox.Show("Campuri Incomplete !", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (functie != "" && sal == "")
            {
                angajat.Functie = functie;
                context.SubmitChanges();
                this.Close();
                return;
            }
            else if (functie == "" && sal != "")
            {
                angajat.Salariu_baza = sal1;
                context.SubmitChanges();
                this.Close();
                return;
            }
            else
            {
                angajat.Functie      = functie;
                angajat.Salariu_baza = sal1;
                context.SubmitChanges();
                this.Close();
                return;
            }
        }
コード例 #6
0
        private void btn_add_avarie_Click(object sender, EventArgs e)
        {
            var context = new Parc_AutoDataContext();

            var issue = (from db in context.Issues
                         where db.Denumire.Equals(comboBox1.SelectedItem.ToString())
                         select db).First();
            int id_is = Int32.Parse(issue.ID_Issues.ToString());

            Cars_Issue prob = new Cars_Issue
            {
                ID_car   = id_car,
                ID_Issue = issue.ID_Issues
            };

            context.Cars_Issues.InsertOnSubmit(prob);
            context.SubmitChanges();

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
コード例 #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            string nume    = textBox1.Text.ToString();
            string functie = textBox2.Text.ToString();
            string sal     = textBox3.Text.ToString();


            float sal1    = 0;
            bool  salariu = float.TryParse(sal, out sal1);


            if (nume == "" || functie == "" || sal == "")
            {
                MessageBox.Show("Campuri incomplete !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                var context = new Parc_AutoDataContext();


                var angajat = new Angajati
                {
                    Nume         = nume,
                    Functie      = functie,
                    Salariu_baza = sal1
                };

                context.Angajatis.InsertOnSubmit(angajat);
                context.SubmitChanges();

                MessageBox.Show("Ati adaugat cu succes !", "Confirmare", MessageBoxButtons.OK);

                this.Close();
                return;
            }
        }
コード例 #8
0
        private void btn_addcar_Click(object sender, EventArgs e)
        {
            var context = new Parc_AutoDataContext();

            float pret1      = 0;
            bool  parsepret1 = float.TryParse(textBox_Pret_addmasina.Text.ToString(), out pret1);


            string sup = comboBox_Supplier.SelectedItem.ToString();

            var supplier = from db in context.Suppliers
                           where db.Company_Name.Equals(sup)
                           select db.ID_Suppliers;

            float pret      = 0;
            bool  parsepret = float.TryParse(textBox_Pret_addmasina.Text.ToString(), out pret);

            int  fabricatie = 0;
            bool parseOK    = Int32.TryParse(comboBox_An_fabricatie.SelectedItem.ToString(), out fabricatie);

            if (comboBox_Marca.SelectedIndex > -1 && textBox_VIN.Text.ToString() != null &&
                comboBox_Model.SelectedIndex > -1 && comboBox_An_fabricatie.SelectedIndex > -1 && parsepret1 != false)
            {
                MessageBox.Show("Campuri Complete !");
            }
            else
            {
                this.Close();
                MessageBox.Show("Campuri Incomplete !", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var masina = new Masini
            {
                ID_Suppliers  = supplier.First(),
                Marca         = comboBox_Marca.SelectedItem.ToString(),
                Model         = comboBox_Model.SelectedItem.ToString(),
                VIN           = textBox_VIN.Text.ToString(),
                An_Fabricatie = fabricatie,
                Pret_Vanzare  = pret
            };

            if (parsepret == true)
            {
                context.Masinis.InsertOnSubmit(masina);
            }

            context.SubmitChanges();

            var masina_id = from db in context.Masinis
                            where db.VIN.Equals(masina.VIN)
                            select db.ID_Masina;
            string faruri;

            if (comboBox_faruri.SelectedIndex > -1)
            {
                faruri = comboBox_faruri.SelectedItem.ToString();
            }
            else
            {
                faruri = null;
            }

            string clima;

            if (comboBox_climatizare.SelectedIndex > -1)
            {
                clima = comboBox_climatizare.SelectedItem.ToString();
            }
            else
            {
                clima = null;
            }

            string Tapiterie1;

            if (comboBox_tapiterie.SelectedIndex > -1)
            {
                Tapiterie1 = comboBox_tapiterie.SelectedItem.ToString();
            }
            else
            {
                Tapiterie1 = null;
            }

            string cul;

            if (comboBox_culoare.SelectedIndex > -1)
            {
                cul = comboBox_culoare.SelectedItem.ToString();
            }
            else
            {
                cul = null;
            }

            Optiuni op_car = null;

            op_car = new Optiuni
            {
                ID_Masina        = masina_id.First(),
                Climatizare      = clima,
                Faruri           = faruri,
                Tapiterie        = Tapiterie1,
                Faruri_ceata     = checkBox_faruri_ceata.Checked,
                Culoare          = cul,
                Tractiune4x4     = checkBox_4x4.Checked,
                Avariat          = checkBox_avarie.Checked,
                Comenzi_volan    = checkBox_volan_multifunctional.Checked,
                Cruise_control   = checkBox_adaptive_cruise.Checked,
                Navigatie        = checkBox_navigatie.Checked,
                Scaune_incalzite = checkBox_scaune_incalzite.Checked,
                Senzori_parcare  = checkBox_senzori_parcare.Checked
            };

            context.Optiunis.InsertOnSubmit(op_car);

            context.SubmitChanges();

            // MessageBox.Show(masina_id.First().ToString());
            // Dgv = all;

            this.DialogResult = DialogResult.OK;
            this.Close();
        }