예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            ControlMembers a = new ControlMembers();

            using (modelEntities2 am = new modelEntities2())
            {
                string name    = textBox2.Text;
                string emailid = textBox5.Text;
                string number  = textBox4.Text;
                string adds    = textBox6.Text;
                string icno    = textBox1.Text;
                bool   r       = radioButton1.Checked;
                value = a.addmembers(r);
                // Demonstrated via controlmember class (implemented)
                //if (radioButton1.Checked == true)
                //{
                //    value = "male";
                //}
                //else
                //    value = "female";
                member m = new member();
                m.address     = adds;
                m.membername  = name;
                m.phonenumber = number;
                m.membericno  = icno;
                m.Emailid     = emailid;
                m.Sex         = value;
                am.AddTomembers(m);
                am.SaveChanges();
                MessageBox.Show("Member Created successful");
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            // Get value from the text box and save changes in db
            sp.equipmentname     = textBox2.Text;
            sp.facilityavailable = Convert.ToInt16(textBox3.Text);
            sp.remarks           = textBox4.Text;

            context.SaveChanges();
        }
예제 #3
0
 public List <sportfacility> addsportfacility(string sportname, int number, string remarks)
 {
     using (modelEntities2 context = new modelEntities2())
     {
         sportfacility sf = new sportfacility();
         sf.equipmentname     = sportname;
         sf.facilityavailable = (Int16)number;
         sf.remarks           = remarks;
         context.AddTosportfacilities(sf);
         context.SaveChanges();
         return(context.sportfacilities.ToList());
     }
 }
예제 #4
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();
        }
예제 #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     context.SaveChanges();
 }
예제 #6
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");
            }
        }