Пример #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");
            }
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var x = from a in c.OrderTables
                    where a.Order_Id == int.Parse(textBox1.Text)
                    select a;

            foreach (OrderTable vi in x)
            {
                c.OrderTables.DeleteOnSubmit(vi);
            }
            c.SubmitChanges();
            GridViewUpdate();
        }
Пример #3
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();
        }
Пример #4
0
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                var x = from a in c.CustomerTables
                        where a.Customer_Id == int.Parse(textBox1.Text.ToString())
                        select a;

                foreach (CustomerTable b in x)
                {
                    c.CustomerTables.DeleteOnSubmit(b);
                }
                c.SubmitChanges();
                MessageBox.Show(" Deleted");
                GridViewUpdate();
            }
            catch
            {
                MessageBox.Show("Failed to Delete");
            }
        }
Пример #5
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");
     }
 }
Пример #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                OrderTable ot = new OrderTable
                {
                    Vehicle_Id     = int.Parse(textBox4.Text),
                    Customer_Id    = textBox1.Text,
                    Catagory       = textBox9.Text,
                    Brand_Name     = textBox8.Text,
                    Car_Model      = textBox2.Text,
                    Order_Quantity = int.Parse(textBox5.Text),
                    Price          = int.Parse(textBox6.Text),
                    Color          = textBox7.Text,
                    Order_Date     = dateTimePicker1.Text
                };
                c.OrderTables.InsertOnSubmit(ot);
                c.SubmitChanges();
                GridViewUpdate();

                var x = from a in c.VehicleInfos
                        where a.Id == int.Parse(textBox4.Text.ToString())
                        select a;
                int oq = int.Parse(textBox5.Text.ToString());
                int vq;
                int rslt;
                vq = x.First().Quantity;
                if ((vq > 0) && (oq < vq))
                {
                    rslt = vq - oq;
                    x.First().Quantity = rslt;
                    c.SubmitChanges();
                    GridViewUpdate();
                    MessageBox.Show("Your order has been placed in queue. Please be with us untill we contact with you");
                }
                else
                {
                    var z = from a in c.OrderTables
                            where a.Customer_Id == textBox1.Text
                            select a;
                    foreach (OrderTable vi in z)
                    {
                        c.OrderTables.DeleteOnSubmit(vi);
                    }
                    c.SubmitChanges();
                    GridViewUpdate();
                    MessageBox.Show(oq + " cars is not available right now");
                }
            }
            catch (Exception ex)
            {
                if (textBox5.Text == "" && textBox8.Text != "")
                {
                    MessageBox.Show("Please provide order quantity");
                }
                else
                {
                    MessageBox.Show("Please provide all the information correctly");
                }
            }
        }
Пример #7
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.");
            }
        }