示例#1
0
        private void createButton_Click(object sender, EventArgs e)
        {
            if (courtNameTextBox2.Text == "" || sportTextBox4.Text == "" || remarksTextBox.Text == "")
            {
                MessageBox.Show("Please fill in all fields!");
            }

            else
            {
                SA46Team10BsportsEntities ctx = new SA46Team10BsportsEntities();
                CourtTable ct = new CourtTable();

                try
                {
                    ct.CourtType  = courtNameTextBox2.Text;
                    ct.SportsType = sportTextBox4.Text;
                    ct.MaintDate  = lastDOM.Value;
                    ct.Remarks    = remarksTextBox.Text;
                    ct.Flag       = "active";
                    ctx.CourtTables.Add(ct);
                    ctx.SaveChanges();
                    MessageBox.Show("New Court " + ct.CourtID + " successfully created!");
                    ClearContent();
                }

                catch (System.FormatException)
                {
                    MessageBox.Show("Please fill in the correct values for the fields!");
                }
            }
        }
示例#2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            SA46Team10BsportsEntities ctx = new SA46Team10BsportsEntities();
            TransactionTable          tt  = new TransactionTable();

            try
            {
                tt.CustomerID = Convert.ToInt32(CIDTextBox.Text);
                CourtTable ct = ctx.CourtTables.Where(x => x.CourtType == comboBox1.Text).First();
                tt.CourtTable = ct;
                tt.DateBook   = dateTimePicker1.Value.Date;
                SlotTable st = ctx.SlotTables.Where(x => x.Time == timeSlotListBox1.Text).First();
                tt.SlotTable = st;
                tt.Status    = "Booked";

                ctx.TransactionTables.Add(tt);
                ctx.SaveChanges();
                MessageBox.Show("Booking for " + comboBox1.Text + " on " + dateTimePicker1.Value.ToString("dd/MM/yyyy") + " at " + timeSlotListBox1.Text + " is completed.");
                ClearContent();
            }

            catch (System.FormatException)
            {
                MessageBox.Show("Please ensure all fields are manually selected");
            }
        }
示例#3
0
        private void deleteButtom_Click(object sender, EventArgs e)
        {
            SA46Team10BsportsEntities ctx = new SA46Team10BsportsEntities();
            int        CID = Convert.ToInt32(courtIDTextBox.Text);
            CourtTable c   = ctx.CourtTables.Where(x => x.CourtID == CID && x.Flag == "active").First();

            c.Flag = "inactive";
            ctx.SaveChanges();
            MessageBox.Show(c.CourtType + " record has been deleted");
            ClearContent();
        }
示例#4
0
        private void searchButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (!(string.IsNullOrWhiteSpace(courtIDTextBox.Text)))
                {
                    SA46Team10BsportsEntities ctx = new SA46Team10BsportsEntities();
                    int        CID = Convert.ToInt32(courtIDTextBox.Text);
                    CourtTable c   = ctx.CourtTables.Where(x => x.CourtID == CID && x.Flag == "active").First();
                    LockCourtIDTextBox();
                    courtNameTextBox2.Text = c.CourtType;
                    sportTextBox4.Text     = c.SportsType;
                    lastDOM.Text           = c.MaintDate.Value.ToString("dd-MM-yyyy");
                    remarksTextBox.Text    = c.Remarks;
                }
                else
                {
                    CourtLookOutFormcs clof = new CourtLookOutFormcs();
                    clof.ShowDialog();
                    this.courtIDTextBox.Text = clof.CIDFromGrid;
                    LockCourtIDTextBox();
                    this.courtNameTextBox2.Text = clof.CTFromGrid;
                    this.sportTextBox4.Text     = clof.STFromGrid;
                    this.lastDOM.Text           = clof.MDFromGrid;
                    this.remarksTextBox.Text    = clof.RFromGrid;
                }
            }
            catch (System.ArgumentOutOfRangeException)
            {
                MessageBox.Show("Please ensure all fields have relevant data before updating.");
            }

            catch (System.FormatException)
            {
                MessageBox.Show("Please enter the correct ID");
            }
            catch (System.InvalidOperationException)
            {
                MessageBox.Show("This ID does not exist");
            }
        }
示例#5
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (courtNameTextBox2.Text == "" || sportTextBox4.Text == "" || remarksTextBox.Text == "")
                {
                    MessageBox.Show("Please leave no field blank");
                }

                else
                {
                    SA46Team10BsportsEntities ctx = new SA46Team10BsportsEntities();
                    int        CID = Convert.ToInt32(courtIDTextBox.Text);
                    CourtTable c   = ctx.CourtTables.Where(x => x.CourtID == CID && x.Flag == "active").First();
                    c.CourtType  = courtNameTextBox2.Text;
                    c.SportsType = sportTextBox4.Text;
                    c.MaintDate  = lastDOM.Value;
                    c.Remarks    = remarksTextBox.Text;
                    ctx.SaveChanges();
                    MessageBox.Show("Update Successful");
                    ClearContent();
                }
            }



            catch (System.ArgumentOutOfRangeException)
            {
                MessageBox.Show("Please ensure all fields are filled before updating");
            }

            catch (System.FormatException)
            {
                MessageBox.Show("Please ensure all fields are filled before updating");
            }
        }