Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            var   context = new DataClasses2DataContext();
            final ss      = new final();

            ss.Show();
            var result23 = (from t in context.comenzi3s
                            where t.id > 0
                            select t).First();

            System.Nullable <int> totalUnitsOnOrder = (from ord in context.PTcos
                                                       select ord.Pret).Sum();
            result23.suma = totalUnitsOnOrder;
            context.SubmitChanges();

            //var deleteorder = from detail in context.PTcos

            //                  select detail;
            //foreach (var detail in deleteorder)
            //{
            //    context.PTcos.DeleteOnSubmit(detail);
            //    context.SubmitChanges();
            //}
            //for (int n=0;n<dataGridView3.Rows.Count;n++)
            //dataGridView3.Rows.RemoveAt(n);
        }
Esempio n. 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            string clearText  = textBox2.Text.Trim();
            string cipherText = CryptorEngine.Encrypt(clearText, true);

            try
            {
                DataClasses2DataContext data = new DataClasses2DataContext();

                // string Insertstatement = "Insert into Useri values('textBox1.Text', textBox2.Text,textBox3.Text,textBox4.Text)";
                //data.ExecuteQuery<Useri>(Insertstatement);

                var employee = new Useri
                {
                    Username = textBox1.Text,
                    Parola   = cipherText,
                    email    = textBox3.Text,
                    adresa   = textBox4.Text
                };
                data.Useris.InsertOnSubmit(employee);
                data.SubmitChanges();
                MessageBox.Show("User inregistrat");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 3
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            if (checkBox4.Checked == true)
            {
                panel1.Enabled = false;
            }
            if (checkBox1.Enabled == true)
            {
                DataClasses2DataContext data = new DataClasses2DataContext();
                var result23 = (from t in data.comenzi3s
                                where t.id > 0
                                select t).First();

                var res = (from t in data.Shippers
                           where t.Nume == "Posta"
                           select t).First();
                result23.shipper_id = res.ID_shipper;
                data.SubmitChanges();
            }
            if (checkBox2.Checked == true)
            {
                DataClasses2DataContext data = new DataClasses2DataContext();
                var result23 = (from t in data.comenzi3s
                                where t.user_id > 0
                                select t).First();

                var res = (from t in data.Shippers
                           where t.Nume == "FanCourier"
                           select t).First();
                result23.shipper_id = res.ID_shipper;
                data.SubmitChanges();
            }
            if (checkBox3.Checked == true)
            {
                DataClasses2DataContext data = new DataClasses2DataContext();
                var result23 = (from t in data.comenzi2s
                                where t.user_id > 0
                                select t).First();

                var res = (from t in data.Shippers
                           where t.Nume == "DHL"
                           select t).First();
                data.UPDATESHIPPER(res.ID_shipper);
                data.SubmitChanges();
            }
            var context     = new DataClasses2DataContext();
            var deleteorder = from detail in context.PTcos

                              select detail;

            foreach (var detail in deleteorder)
            {
                context.PTcos.DeleteOnSubmit(detail);
                context.SubmitChanges();
            }
            MessageBox.Show("Multumim ca ati cumparat de la noi");
        }
Esempio n. 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            //App.CosCumparaturi.AddCosCumparaturiRow(App.CosCumparaturi.NewCosCumparaturiRow());
            //produseBindingSource.MoveLast();
            //var context = new DataClasses2DataContext();

            //// string cipherText = textBox2.Text.Trim();
            //// string decryptedText = CryptorEngine.Decrypt(cipherText, true);
            //var alex = from emp in context.Produses
            //           where (emp.Nume == "HP" && emp.Categorie_id == 1)
            //           select emp;
            //foreach(var a in alex)
            //{


            //    // string Insertstatement = "Insert into Useri values('textBox1.Text', textBox2.Text,textBox3.Text,textBox4.Text)";
            //    //data.ExecuteQuery<Useri>(Insertstatement);

            //    var employee = new CosCumparaturi
            //    {
            //        id_produs = a.Id_produs,
            //        numar_produse = 1,
            //        suma =a.Pret

            //    };
            //   context.CosCumparaturis.InsertOnSubmit(employee);
            //    context.SubmitChanges();
            //}
            //produseBindingSource.EndEdit();
            //App.CosCumparaturi.AcceptChanges();
            //App.CosCumparaturi.WriteXml(string.Format("{0}//data.dat", Application.StartupPath));
            var context = new DataClasses2DataContext();

            // string cipherText = textBox2.Text.Trim();
            // string decryptedText = CryptorEngine.Decrypt(cipherText, true);
            var alex = from emp in context.Produses
                       where (emp.Nume == "HP" && emp.Categorie_id == 1)
                       select emp;

            foreach (var a in alex)
            {
                var employee = new PTco
                {
                    Nume     = a.Nume.ToString(),
                    Pret     = a.Pret,
                    Cantitta = 1
                };
                context.PTcos.InsertOnSubmit(employee);
                context.SubmitChanges();
                frm1.BLA();
            }
            //dataGridView1.DataSource = alex;
        }
Esempio n. 5
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            var context = new DataClasses2DataContext();

            foreach (DataGridViewRow row in dataGridView3.SelectedRows)
            {
                int v = Convert.ToInt32(row.Cells[0].Value.ToString());
                dataGridView3.Rows.RemoveAt(row.Index);
                var deleteorder = from detail in context.PTcos
                                  where detail.id == v
                                  select detail;
                foreach (var detail in deleteorder)
                {
                    context.PTcos.DeleteOnSubmit(detail);
                    context.SubmitChanges();
                }
            }
        }
Esempio n. 6
0
        private void button3_Click_1(object sender, EventArgs e)
        {
            var context = new DataClasses2DataContext();

            // string cipherText = textBox2.Text.Trim();
            // string decryptedText = CryptorEngine.Decrypt(cipherText, true);
            var alex = from emp in context.Produses
                       where (emp.Nume == "Lenovo" && emp.Categorie_id == 1)
                       select emp;

            foreach (var a in alex)
            {
                var employee = new PTco
                {
                    Nume     = a.Nume.ToString(),
                    Pret     = a.Pret,
                    Cantitta = 1
                };
                context.PTcos.InsertOnSubmit(employee);
                context.SubmitChanges();
                frm1.BLA();
            }
        }
Esempio n. 7
0
        private void button2_Click(object sender, EventArgs e)
        {
            string decryptedText;

            try
            {
                var context = new DataClasses2DataContext();

                // string cipherText = textBox2.Text.Trim();
                // string decryptedText = CryptorEngine.Decrypt(cipherText, true);
                var alex = from emp in context.Useris
                           where (emp.Username == textBox1.Text)
                           select emp;
                if (alex.Any())
                {
                    foreach (var a in alex)
                    {
                        decryptedText = CryptorEngine.Decrypt(a.Parola, true);
                        var employees = from emp in context.Useris
                                        where (emp.Username == textBox1.Text) && (decryptedText == textBox2.Text && emp.Administrator.StartsWith("da"))
                                        select emp;
                        var employees2 = from emp in context.Useris
                                         where (emp.Username.Contains(textBox1.Text)) && (decryptedText == textBox2.Text) //&& emp.Administrator.StartsWith("nu"))
                                         select emp;


                        if (employees.Any())
                        {
                            this.Hide();
                            admin administrare = new admin();
                            administrare.Show();
                        }
                        else if (employees2.Any())
                        {
                            this.Hide();
                            Main ss = new Main();
                            ss.Show();
                            var    context3 = new DataClasses2DataContext();
                            Random rnd      = new Random();
                            foreach (var al in alex)
                            {
                                //    var emp = new comenzi2
                                //    {
                                //        id = rnd.Next(50000),
                                //        user_id = al.ID

                                context3.inserare(rnd.Next(50000), al.ID, 1, 1);
                                context3.SubmitChanges();
                            }
                            //    };
                            //    context3.comenzi2s.InsertOnSubmit(emp);
                            //    context3.SubmitChanges();}


                            //  frm.Show();
                        }
                        else
                        {
                            MessageBox.Show("USER sau PAROLA incorecta");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("USER incorect");
                }

                //        string decryptedText = CryptorEngine.Decrypt(alex, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }