Exemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            CarDataContext c = new CarDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\adi\Documents\New folder\csms.mdf;Integrated Security=True;Connect Timeout=30");

            try
            {
                VehicleInfo ct = new VehicleInfo
                {
                    Category  = catcombo.SelectedItem.ToString(),
                    Car_Brand = textBox1.Text,
                    Car_Model = textBox4.Text,
                    Color     = textBox7.Text,
                    Quantity  = int.Parse(textBox5.Text),
                    Price     = int.Parse(textBox6.Text)
                };

                c.VehicleInfos.InsertOnSubmit(ct);
                c.SubmitChanges();
                GridViewUpdate();

                MessageBox.Show("vehicle added");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Add failed. Please try again");
            }
        }
Exemplo n.º 2
0
        private void orderInformation_Load(object sender, EventArgs e)
        {
            CarDataContext c = new CarDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\adi\Documents\New folder\csms.mdf;Integrated Security=True;Connect Timeout=30");

            dataGridView1.DataSource = c.OrderTables;
            textBox1.Hide();
        }
Exemplo n.º 3
0
        private void Customer_Load(object sender, EventArgs e)
        {
            CarDataContext c = new CarDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\adi\Documents\New folder\csms.mdf;Integrated Security=True;Connect Timeout=30");

            dataGridView1.DataSource = c.CustomerTables;
            textBox1.Hide();
            dataGridView1.Columns[7].Visible = false;
        }
Exemplo n.º 4
0
        private void Customer_product_Load(object sender, EventArgs e)
        {
            CarDataContext c = new CarDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\adi\Documents\New folder\csms.mdf;Integrated Security=True;Connect Timeout=30");

            dataGridView1.DataSource = c.VehicleInfos;
            textBox2.Hide();
            textBox3.Hide();
        }
Exemplo n.º 5
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            CarDataContext c = new CarDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\adi\Documents\New folder\csms.mdf;Integrated Security=True;Connect Timeout=30");

            if (e.RowIndex >= 0)
            {
                DataGridViewRow dr = this.dataGridView1.Rows[e.RowIndex];
                textBox2.Text = dr.Cells["Id"].Value.ToString();
                try
                {
                    textBox1.Text = dr.Cells["Car_Brand"].Value.ToString();
                }
                catch (Exception ex)
                {
                    catcombo.Text = "";
                }
                try
                {
                    catcombo.Text = dr.Cells["Category"].Value.ToString();
                }
                catch (Exception ex)
                {
                    catcombo.Text = "";
                }
                try
                {
                    textBox4.Text = dr.Cells["Car_Model"].Value.ToString();
                }
                catch (Exception ex)
                {
                    catcombo.Text = "";
                }
                try
                {
                    textBox5.Text = dr.Cells["Quantity"].Value.ToString();
                }
                catch (Exception ex)
                {
                    catcombo.Text = "";
                }
                try
                {
                    textBox6.Text = dr.Cells["Price"].Value.ToString();
                }
                catch (Exception ex)
                {
                    catcombo.Text = "";
                }
                try
                {
                    textBox7.Text = dr.Cells["Color"].Value.ToString();
                }
                catch (Exception ex)
                {
                    catcombo.Text = "";
                }
            }
        }
Exemplo n.º 6
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            CarDataContext c = new CarDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\adi\Documents\New folder\csms.mdf;Integrated Security=True;Connect Timeout=30");

            if (e.RowIndex >= 0)
            {
                DataGridViewRow dr = this.dataGridView1.Rows[e.RowIndex];
                textBox1.Text = dr.Cells["Customer_Id"].Value.ToString();
            }
        }
Exemplo n.º 7
0
        private void button4_Click(object sender, EventArgs e)
        {
            CarDataContext c = new CarDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\adi\Documents\New folder\csms.mdf;Integrated Security=True;Connect Timeout=30");
            var            x = from a in c.VehicleInfos
                               where a.Id == int.Parse(textBox2.Text)
                               select a;

            foreach (VehicleInfo vi in x)
            {
                c.VehicleInfos.DeleteOnSubmit(vi);
            }
            c.SubmitChanges();
            GridViewUpdate();
        }
Exemplo n.º 8
0
        private void button6_Click_1(object sender, EventArgs e)
        {
            CarDataContext c = new CarDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\adi\Documents\New folder\csms.mdf;Integrated Security=True;Connect Timeout=30");
            var            x = from a in c.CustomerTables
                               where a.First_Name == search.Text
                               select a;

            try
            {
                search.Text = x.First().First_Name.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Not found. Try again");
            }

            dataGridView1.DataSource = x.ToList();
        }
Exemplo n.º 9
0
        private void button6_Click(object sender, EventArgs e)
        {
            CarDataContext c = new CarDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\adi\Documents\New folder\csms.mdf;Integrated Security=True;Connect Timeout=30");
            var            x = from a in c.VehicleInfos
                               where a.Car_Brand == textBox1.Text
                               select a;

            try
            {
                textBox5.Text = x.First().Quantity.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Not found. Try again");
            }

            dataGridView1.DataSource = x.ToList();
        }
Exemplo n.º 10
0
        private void login_Click(object sender, EventArgs e)
        {
            string         uname = username.Text;
            string         pass  = password.Text;
            CarDataContext c     = new CarDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\adi\Documents\New folder\csms.mdf;Integrated Security=True;Connect Timeout=30");


            if (uname == "" || pass == "")
            {
                MessageBox.Show("Provide Your Username and Password");
            }

            else
            {
                var i = (from a in c.RegistationTables
                         where a.Username == uname && a.Password == pass
                         select a);


                if (i.Any())
                {
                    if (uname == "admin" && pass == "admin")
                    {
                        Home h = new Home();
                        h.Show();
                        Visible = false;
                    }
                    else
                    {
                        ClientView cv = new ClientView();
                        OrderInfo  co = new OrderInfo();
                        cv.textBox3.Text = uname;
                        cv.Show();
                        Visible = false;
                    }
                }

                else
                {
                    MessageBox.Show("Invalid Username or Password ");
                }
            }
        }
Exemplo n.º 11
0
 private void button3_Click_1(object sender, EventArgs e)
 {
     try
     {
         CarDataContext c = new CarDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\adi\Documents\New folder\csms.mdf;Integrated Security=True;Connect Timeout=30");
         var            x = from a in c.VehicleInfos
                            where a.Id == int.Parse(textBox2.Text.ToString())
                            select a;
         x.First().Category  = catcombo.SelectedItem.ToString();
         x.First().Quantity  = int.Parse(textBox5.Text.ToString());
         x.First().Car_Model = textBox4.Text;
         x.First().Price     = float.Parse(textBox6.Text.ToString());
         x.First().Car_Brand = textBox1.Text;
         x.First().Color     = textBox7.Text;
         c.SubmitChanges();
         GridViewUpdate();
         MessageBox.Show("Updated");
     }
     catch
     {
         MessageBox.Show("failed");
     }
 }
Exemplo n.º 12
0
        public void GridViewUpdate()
        {
            CarDataContext c = new CarDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\adi\Documents\New folder\csms.mdf;Integrated Security=True;Connect Timeout=30");

            dataGridView1.DataSource = c.CustomerTables;
        }
Exemplo n.º 13
0
        private void button1_Click(object sender, EventArgs e)
        {
            CarDataContext c = new CarDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\adi\Documents\New folder\csms.mdf;Integrated Security=True;Connect Timeout=30");

            try
            {
                RegistationTable rt = new RegistationTable
                {
                    First_Name = textBox1.Text,
                    Last_Name  = textBox2.Text,
                    Gender     = gcombo.SelectedItem.ToString(),
                    phone      = textBox4.Text,
                    Email      = textBox5.Text,
                    Address    = textBox6.Text,
                    Username   = textBox7.Text,
                    Password   = textBox8.Text
                };

                CustomerTable cta = new CustomerTable
                {
                    First_Name = textBox1.Text,
                    Last_Name  = textBox2.Text,
                    Email      = textBox5.Text,
                    Phone      = textBox4.Text
                };

                try
                {
                    if (textBox1.Text == "")
                    {
                        MessageBox.Show("Provide Your First Name");
                    }
                    else if (textBox2.Text == "")
                    {
                        MessageBox.Show("Provide Your Last Name");
                    }
                    else if (textBox4.Text == "")
                    {
                        MessageBox.Show("Phone Number can't be empty");
                    }
                    else if (!textBox4.Text.StartsWith("016") && !textBox4.Text.StartsWith("017"))
                    {
                        MessageBox.Show("Provide a valid phone number ");
                    }
                    else if (textBox4.Text.Length < 11)
                    {
                        MessageBox.Show("Provide a 11 digit valid phone number");
                    }
                    else if (textBox5.Text == "")
                    {
                        MessageBox.Show("Provide your email address");
                    }
                    else if (textBox7.Text == "")
                    {
                        MessageBox.Show("Provide your username");
                    }
                    else if (textBox8.Text == "")
                    {
                        MessageBox.Show("Provide a password");
                    }
                    else if (textBox7.Text != "")
                    {
                        var j = (from a in c.RegistationTables
                                 where a.Username == textBox7.Text
                                 select a);
                        if (textBox7.Text == j.First().Username)
                        {
                            MessageBox.Show("username is not available. provide anything new");
                        }
                    }
                }
                catch (Exception ex)
                {
                    c.RegistationTables.InsertOnSubmit(rt);
                    c.CustomerTables.InsertOnSubmit(cta);
                    c.SubmitChanges();
                    MessageBox.Show("Registration Succesfull");
                    this.Hide();
                    LoginPage f1 = new LoginPage();
                    f1.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Registration failed. Please provide all the information correctly.");
            }
        }