Beispiel #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            modelEntities2 context = new modelEntities2();
            int            bid     = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString());

            var query = from x in context.bookingdetails
                        where x.bookingid == bid
                        select x;

            bookingdetail bd = query.First <bookingdetail>();

            context.bookingdetails.DeleteObject(bd);
            context.SaveChanges();
            RefreshDataGridView();
        }
        /// <summary>
        /// Create a new bookingdetail object.
        /// </summary>
        /// <param name="bookingid">Initial value of the bookingid property.</param>
        /// <param name="memberid">Initial value of the memberid property.</param>
        /// <param name="equipmentid">Initial value of the equipmentid property.</param>
        /// <param name="dateofbooking">Initial value of the dateofbooking property.</param>
        /// <param name="c8_9_am">Initial value of the C8_9_am property.</param>
        /// <param name="c9_10_am">Initial value of the C9_10_am property.</param>
        /// <param name="c10_11_am">Initial value of the C10_11_am property.</param>
        /// <param name="c11_12_noon">Initial value of the C11_12_noon property.</param>
        /// <param name="c2_3_pm">Initial value of the C2_3_pm property.</param>
        /// <param name="c3_4_pm">Initial value of the C3_4_pm property.</param>
        /// <param name="c_4_5_pm">Initial value of the C_4_5_pm property.</param>
        /// <param name="c5_6_pm">Initial value of the C5_6_pm property.</param>
        /// <param name="c6_7_pm">Initial value of the C6_7_pm property.</param>
        /// <param name="c7_8_pm">Initial value of the C7_8_pm property.</param>
        public static bookingdetail Createbookingdetail(global::System.Int32 bookingid, global::System.Int32 memberid, global::System.Int32 equipmentid, global::System.DateTime dateofbooking, global::System.Int16 c8_9_am, global::System.Int16 c9_10_am, global::System.Int16 c10_11_am, global::System.Int16 c11_12_noon, global::System.Int16 c2_3_pm, global::System.Int16 c3_4_pm, global::System.Int16 c_4_5_pm, global::System.Int16 c5_6_pm, global::System.Int16 c6_7_pm, global::System.Int16 c7_8_pm)
        {
            bookingdetail bookingdetail = new bookingdetail();

            bookingdetail.bookingid     = bookingid;
            bookingdetail.memberid      = memberid;
            bookingdetail.equipmentid   = equipmentid;
            bookingdetail.dateofbooking = dateofbooking;
            bookingdetail.C8_9_am       = c8_9_am;
            bookingdetail.C9_10_am      = c9_10_am;
            bookingdetail.C10_11_am     = c10_11_am;
            bookingdetail.C11_12_noon   = c11_12_noon;
            bookingdetail.C2_3_pm       = c2_3_pm;
            bookingdetail.C3_4_pm       = c3_4_pm;
            bookingdetail.C_4_5_pm      = c_4_5_pm;
            bookingdetail.C5_6_pm       = c5_6_pm;
            bookingdetail.C6_7_pm       = c6_7_pm;
            bookingdetail.C7_8_pm       = c7_8_pm;
            return(bookingdetail);
        }
Beispiel #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            modelEntities2 context     = new modelEntities2();
            DateTime       bookingDate = BookingDateDTP.Value.Date;

            int r = Convert.ToInt16(comboBox1.SelectedValue);

            var q = (from x in context.sportfacilities
                     where x.equipmentid == (r)
                     select(x.facilityavailable));

            String x1    = Convert.ToString(q.First());
            Int16  temp1 = Convert.ToInt16(x1);

            int temp2 = (from x in context.bookingdetails
                         where x.equipmentid == (r) && x.dateofbooking == bookingDate
                         select x.memberid).Count();



            if (temp2 <= temp1)
            {
                int read = temp1 - temp2;
                MessageBox.Show("Currently have" + "\t" + read + "\t" + "facility available");


                int           memId = Convert.ToInt32(MemberCombo.SelectedItem.ToString());
                bookingdetail bk    = new bookingdetail();
                int           eqId  = Convert.ToInt32(comboBox1.SelectedItem.ToString());

                bk.memberid      = memId;
                bk.equipmentid   = eqId;
                bk.dateofbooking = bookingDate;

                if ((string)comboBox2.SelectedItem == "8-9am")
                {                            //used to set slot , member id,date of playing(date of booking),sports required to play
                    bk.C8_9_am     = 1;
                    bk.C9_10_am    = 0; bk.C10_11_am = 0; bk.C11_12_noon = 0; bk.C2_3_pm = 0;
                    bk.C3_4_pm     = 0; bk.C_4_5_pm = 0; bk.C5_6_pm = 0; bk.C6_7_pm = 0; bk.C7_8_pm = 0;
                    bk.equipmentid = Convert.ToInt16(comboBox1.SelectedItem);
                }
                else if ((string)comboBox2.SelectedItem == "9-10am")
                {
                    bk.C9_10_am    = 1;
                    bk.C8_9_am     = 0; bk.C10_11_am = 0; bk.C11_12_noon = 0; bk.C2_3_pm = 0;
                    bk.C3_4_pm     = 0; bk.C_4_5_pm = 0; bk.C5_6_pm = 0; bk.C6_7_pm = 0; bk.C7_8_pm = 0;
                    bk.equipmentid = Convert.ToInt16(comboBox1.SelectedItem);
                }
                else if ((string)comboBox2.SelectedItem == "10-11am")
                {
                    bk.C10_11_am   = 1;
                    bk.C9_10_am    = 0; bk.C8_9_am = 0; bk.C11_12_noon = 0; bk.C2_3_pm = 0;
                    bk.C3_4_pm     = 0; bk.C_4_5_pm = 0; bk.C5_6_pm = 0; bk.C6_7_pm = 0; bk.C7_8_pm = 0;
                    bk.equipmentid = Convert.ToInt16(comboBox1.SelectedItem);
                }
                else if ((string)comboBox2.SelectedItem == "11-12noon")
                {
                    bk.C11_12_noon = 1;
                    bk.C9_10_am    = 0; bk.C10_11_am = 0; bk.C8_9_am = 0; bk.C2_3_pm = 0;
                    bk.C3_4_pm     = 0; bk.C_4_5_pm = 0; bk.C5_6_pm = 0; bk.C6_7_pm = 0; bk.C7_8_pm = 0;
                    bk.equipmentid = Convert.ToInt16(comboBox1.SelectedItem);
                }
                else if ((string)comboBox2.SelectedItem == "2-3pm")
                {
                    bk.C2_3_pm     = 1;
                    bk.C9_10_am    = 0; bk.C10_11_am = 0; bk.C11_12_noon = 0; bk.C8_9_am = 0;
                    bk.C3_4_pm     = 0; bk.C_4_5_pm = 0; bk.C5_6_pm = 0; bk.C6_7_pm = 0; bk.C7_8_pm = 0;
                    bk.equipmentid = Convert.ToInt16(comboBox1.SelectedItem);
                }
                else if ((string)comboBox2.SelectedItem == "3-4pm")
                {
                    bk.C3_4_pm     = 1;
                    bk.C9_10_am    = 0; bk.C10_11_am = 0; bk.C11_12_noon = 0; bk.C2_3_pm = 0;
                    bk.C8_9_am     = 0; bk.C_4_5_pm = 0; bk.C5_6_pm = 0; bk.C6_7_pm = 0; bk.C7_8_pm = 0;
                    bk.equipmentid = Convert.ToInt16(comboBox1.SelectedItem);
                }
                else if ((string)comboBox2.SelectedItem == "4-5pm")
                {
                    bk.C_4_5_pm    = 1;
                    bk.C9_10_am    = 0; bk.C10_11_am = 0; bk.C11_12_noon = 0; bk.C2_3_pm = 0;
                    bk.C3_4_pm     = 0; bk.C8_9_am = 0; bk.C5_6_pm = 0; bk.C6_7_pm = 0; bk.C7_8_pm = 0;
                    bk.equipmentid = Convert.ToInt16(comboBox1.SelectedItem);
                }
                else if ((string)comboBox2.SelectedItem == "5-6pm")
                {
                    bk.C5_6_pm     = 1;
                    bk.C9_10_am    = 0; bk.C10_11_am = 0; bk.C11_12_noon = 0; bk.C2_3_pm = 0;
                    bk.C3_4_pm     = 0; bk.C_4_5_pm = 0; bk.C8_9_am = 0; bk.C6_7_pm = 0; bk.C7_8_pm = 0;
                    bk.equipmentid = Convert.ToInt16(comboBox1.SelectedItem);
                }
                else if ((string)comboBox2.SelectedItem == "6-7pm")
                {
                    bk.C6_7_pm     = 1;
                    bk.C9_10_am    = 0; bk.C10_11_am = 0; bk.C11_12_noon = 0; bk.C2_3_pm = 0;
                    bk.C3_4_pm     = 0; bk.C_4_5_pm = 0; bk.C5_6_pm = 0; bk.C8_9_am = 0; bk.C7_8_pm = 0;
                    bk.equipmentid = Convert.ToInt16(comboBox1.SelectedItem);
                }
                else if (Convert.ToString(comboBox2.SelectedItem) == "7-8pm")
                {
                    bk.C7_8_pm     = 1;
                    bk.C9_10_am    = 0; bk.C10_11_am = 0; bk.C11_12_noon = 0; bk.C2_3_pm = 0;
                    bk.C3_4_pm     = 0; bk.C_4_5_pm = 0; bk.C5_6_pm = 0; bk.C6_7_pm = 0; bk.C8_9_am = 0;
                    bk.equipmentid = Convert.ToInt16(comboBox1.SelectedItem);
                }
                else
                {
                    MessageBox.Show("enter valid member or time slot");
                }
                context.AddTobookingdetails(bk);
                context.SaveChanges();
            }
            else
            {
                MessageBox.Show("Cannot book all Facility are filled");
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the bookingdetails EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTobookingdetails(bookingdetail bookingdetail)
 {
     base.AddObject("bookingdetails", bookingdetail);
 }