private void button2_Click(object sender, EventArgs e) { MydbDataContext cntx = new MydbDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Oyan Computer\Desktop\Project\Project\Forms\Mydb.mdf;Integrated Security=True"); var str = from a in cntx.Booking_Histories where a.No == int.Parse(textBox1.Text) select a; // Person p = new Person(); Booking_History B = str.First(); if (B != null) { cntx.Booking_Histories.DeleteOnSubmit(B); MessageBox.Show("Data Deleted"); cntx.SubmitChanges(); } else { MessageBox.Show("Data not found"); } BookingGetData(ps); }
private void Orderbutton_Click(object sender, EventArgs e) { if (Lfrom.Equals(Lto)) { MessageBox.Show("From and to can not be same"); } int s =int.Parse( SeatBox.Text); var str = from a in cnt.Flights where a.Flight_Name == fl select a; Flight F = str.First(); string fo=F.TotalSeatLeft.ToString(); string DD = F.Departure_Date.ToString(); string TT = F.Departure_Time.ToString(); int t =int.Parse( F.FlighCost.ToString()); Booking_History B = new Booking_History(); if (F != null) { B.CustomerName = ps; B.FlightName = fl; B.No_Of_Orders = s; B.Cost_Per_Order_ = t; B.Total_Cost = s*t; F.TotalSeatLeft = (int.Parse(fo)) - s; if (F.TotalSeatLeft < 0) { MessageBox.Show("Invalid input"); } // B.De { cnt.Booking_Histories.InsertOnSubmit(B); cnt.SubmitChanges(); fo = F.TotalSeatLeft.ToString(); cnt.SubmitChanges(); MessageBox.Show("Successfully inserted"); } else { MessageBox.Show("Data not found"); } manage_grid2(); // dataGridView2.DataSource = str; }
private void button4_Click(object sender, EventArgs e) { // MydbDataContext cnt = new MydbDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\USER\Desktop\Project\Project\Forms\Mydb.mdf;Integrated Security=True"); // MydbDataContext cnt = new MydbDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Oyan Computer\Desktop\Project\Project\Forms\Mydb.mdf;Integrated Security=True"); var str = from a in cntx.Booking_Histories where a.No == int.Parse(textBox1.Text) select a; Booking_History B = str.First(); if (B != null) { textBox2.Text = B.CustomerName; textBox3.Text = B.FlightName; textBox4.Text = B.No_Of_Orders.ToString(); textBox5.Text = B.Cost_Per_Order_.ToString(); textBox6.Text = B.Total_Cost.ToString(); cntx.SubmitChanges(); } else { MessageBox.Show("Data not found"); } // Person p = str.Where(obj=>obj.Id==int.Parse(textBox1.Text)).First(); // dataGridView1.DataSource = str.Where(obj=>obj.Id==int.Parse(textBox1.Text)); dataGridView1.DataSource = str; textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; }
private void button1_Click(object sender, EventArgs e) { MydbDataContext cntx = new MydbDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Oyan Computer\Desktop\Project\Project\Forms\Mydb.mdf;Integrated Security=True"); var str = from a in cntx.Flights where a.Flight_Name == textBox2.Text select a; Flight F = str.First(); var st = from b in cntx.Persons where b.UserName == textBox3.Text select b; Person P = st.First(); Booking_History B = new Booking_History(); if (F != null && P != null) { B.CustomerName = textBox2.Text; B.FlightName = textBox3.Text; B.No_Of_Orders = int.Parse(textBox4.Text); B.Cost_Per_Order_ = int.Parse(textBox5.Text); B.Total_Cost = int.Parse(textBox6.Text); cntx.Booking_Histories.InsertOnSubmit(B); cntx.SubmitChanges(); MessageBox.Show("Successfully inserted"); } else { MessageBox.Show("Data not found"); } BookingGetData(ps); }