Exemplo n.º 1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            cxt = new SportsFacilitiesEntities();
            fac = new Facility();
            SubFacility subf = new SubFacility();
            Rate        rate = new Rate();
            string      r;

            try
            {
                fac = cxt.Facilities.Where(x => x.facilityname == cmbSearchBy.Text).First();
                gbSearchResults.Visible = true;
                //Facility Name / ID Display
                txtFacilityID.Text = fac.facilityid.ToString();
                facilityidtemp     = txtFacilityID.Text;
                txtName.Text       = fac.facilityname.ToString();
                nametemp           = txtName.Text;
                // Rates Display
                r             = fac.rateid.ToString();
                rate          = cxt.Rates.Where(x => x.rateid.ToString() == r).First();
                ratesWOsymbol = rate.ratepertimeslot.ToString();
                cmbRates.Text = "$ " + ratesWOsymbol + ".00";
                ratestemp     = ratesWOsymbol;
                // Subfacility Display
                var q = from x in cxt.SubFacilities where x.facilityid.ToString() == txtFacilityID.Text select x;
                txtFacilitiesNo.Text = q.Count().ToString();
                facilitiesnotemp     = txtFacilitiesNo.Text;
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Search Results cannot be empty", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void InsertData()
        {
            SportsFacilitiesEntities ctx = new SportsFacilitiesEntities();

            newmember      = new Member();
            newmember.name = txtName.Text;
            newmember.icno = txtICNo.Text;
            if (rdbMale.Checked == true)
            {
                newmember.gender = rdbMale.Text;
            }
            else
            {
                newmember.gender = rdbFemale.Text;
            }
            newmember.address     = txtAddress.Text;
            newmember.mobileno    = Convert.ToInt32(txtMobile.Text);
            newmember.email       = txtEmail.Text;
            newmember.dateofbirth = dtpDOB.Value;
            newmember.joindate    = dtpJoindate.Value;
            newmember.expirydate  = dtpJoindate.Value.AddYears(2);
            newmember.status      = "Active";
            ctx.Members.Add(newmember);
            ctx.SaveChanges();
        }
Exemplo n.º 3
0
        public void ChangeMemberStatus()
        {
            SportsFacilitiesEntities cxt       = new SportsFacilitiesEntities();
            List <Member>            lstmember = new List <Member>();

            lstmember = cxt.Members.Where(x => x.expirydate < DateTime.Today).ToList();
            int c = lstmember.Count;

            foreach (var member in lstmember)
            {
                cxt.Members.First(x => x.memberid == member.memberid).status = "Inactive";
            }
            cxt.SaveChanges();
            List <Member> inlstmember = new List <Member>();

            inlstmember = cxt.Members.Where(x => x.expirydate > DateTime.Today).ToList();
            int count = inlstmember.Count;

            foreach (var member in inlstmember)
            {
                cxt.Members.First(x => x.memberid == member.memberid).status = "Active";
            }

            cxt.SaveChanges();
        }
Exemplo n.º 4
0
 private void ucBooking_Load_1(object sender, EventArgs e)
 {
     ctx = new SportsFacilitiesEntities();
     defaultCmbSports     = "- Select sport -";
     cmbSports.Text       = defaultCmbSports;
     dtpBookingDate.Value = DateTime.Today;
     dtpBookingDatevalue  = dtpBookingDate.Value;
 }
        private void InsertData()
        {
            ctx      = new SportsFacilitiesEntities();
            facility = new Facility();
            facility.facilityname = txtName.Text;
            string price = "";

            if (cmbRates.Text.Length > 6)
            {
                price = cmbRates.Text.Substring(2, 2);
            }
            else
            {
                price = cmbRates.Text.Substring(2, 1);
            }
            int rate = Convert.ToInt32(price);

            if ((ctx.Rates.Where(x => x.ratepertimeslot == rate).Count()) > 0)
            {
                facility.rateid = ctx.Rates.Where(x => x.ratepertimeslot == rate).First().rateid;
            }
            else
            {
                Rate newrate = new Rate();
                newrate.ratepertimeslot = rate;
                ctx.Rates.Add(newrate);
                ctx.SaveChanges();
                facility.rateid = ctx.Rates.Where(x => x.ratepertimeslot == rate).First().rateid;
            }
            try
            {
                ctx.Facilities.Add(facility);
                int noOfCourt = Convert.ToInt32(cmbCourtNo.SelectedItem.ToString());
                for (int i = 0; i < noOfCourt; i++)
                {
                    SubFacility sf = new SubFacility();
                    sf.facilityid = facility.facilityid;
                    if (i == 0)
                    {
                        sf.subfacilityname = "A";
                    }
                    else if (i == 1)
                    {
                        sf.subfacilityname = "B";
                    }
                    else
                    {
                        sf.subfacilityname = "C";
                    }
                    ctx.SubFacilities.Add(sf);
                }
                ctx.SaveChanges();
            }
            catch
            {
                MessageBox.Show("Error Occurred. Please Try Again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            SportsFacilitiesEntities ctx = new SportsFacilitiesEntities();

            // Members Listing
            //DataSet1 ds = new DataSet1();

            //DataSet1TableAdapters.MembersTableAdapter da = new DataSet1TableAdapters.MembersTableAdapter();

            //da.Fill(ds.Members);
            //MemberListing cr = new MemberListing();
            //cr.SetDataSource(ds);

            //crystalReportViewer1.ReportSource = cr;


            // Booking Invoice
            //DataSet2 ds = new DataSet2();

            //DataSet2TableAdapters.bookinginvoicereportTableAdapter da = new DataSet2TableAdapters.bookinginvoicereportTableAdapter();

            //da.Fill(ds.bookinginvoicereport);
            //BookingInvoice cr = new BookingInvoice();
            //cr.SetDataSource(ds);

            //crystalReportViewer1.ReportSource = cr;


            // Membership Form
            //DataSet3 ds = new DataSet3();

            //DataSet3TableAdapters.MembersTableAdapter da = new DataSet3TableAdapters.MembersTableAdapter();

            //da.Fill(ds.Members);
            //MemberForm cr = new MemberForm();
            //cr.SetDataSource(ds);

            //crystalReportViewer1.ReportSource = cr;

            //Revenue Report
            //DataSet4 ds = new DataSet4();

            //DataSet4TableAdapters.revenuereportTableAdapter da = new DataSet4TableAdapters.revenuereportTableAdapter();

            //da.Fill(ds.revenuereport);
            //Revenue cr = new Revenue();
            //cr.SetDataSource(ds);
            ////cr.SetParameterValue("Param_datefrom", 1);
            ////cr.SetParameterValue("Param_dateto", 2);

            //crystalReportViewer1.ReportSource = cr;
        }
 private void btnBook_Click(object sender, EventArgs e)
 {
     try
     {
         Transaction t = new Transaction();
         t.memberid   = Convert.ToInt32(txtMemID.Text);
         t.remark     = txtRemarks.Text;
         t.systemtime = DateTime.Now;
         t.total      = price;
         t.status     = "Confirmed";
         SportsFacilitiesEntities ctx = new SportsFacilitiesEntities();
         ctx.Transactions.Add(t);
         ctx.SaveChanges();
         int id = t.transactionid;
         TransactionDetail td;
         int subfacilityid;
         int timeslotid;
         foreach (BookingDetails bd in ucBooking.getSelectedSlots())
         {
             subfacilityid    = ctx.SubFacilities.First(x => x.facilityid == facilityID && x.subfacilityname == bd.subFacilityBooked).subfacilityid;
             timeslotid       = bd.slotBooked;
             td               = new TransactionDetail();
             td.transactionid = id;
             td.facilityid    = facilityID;
             td.timeslotid    = timeslotid;
             td.date          = dtpDate.Value;
             td.subfacilityid = subfacilityid;
             ctx.TransactionDetails.Add(td);
         }
         ctx.SaveChanges();
         MessageBox.Show("Booking Completed", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
         DialogResult result = MessageBox.Show("Do you want to print the booking invoice?", "Print", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
         if (result == DialogResult.OK)
         {
             rptTransactionid = id;
             frmInvoiceReport frmIR = new frmInvoiceReport();
             frmIR.ShowDialog();
         }
     }
     catch
     {
         MessageBox.Show("You have encountered an error. Please Try Again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     this.Close();
 }
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            ResetAllWarningLabels();
            SportsFacilitiesEntities ctx = new SportsFacilitiesEntities();

            if (txtName.Text == "" || txtICNo.Text == "" || txtMobile.Text == "" || txtEmail.Text == "" || txtAddress.Text == "")
            {
                if (txtName.Text == "")
                {
                    lblWarningName.Visible = true;
                }
                else
                {
                    lblWarningName.Visible = false;
                }

                if (txtICNo.Text == "")
                {
                    lblWarningIC.Visible = true;
                }
                else
                {
                    lblWarningIC.Visible = false;
                }

                if (txtMobile.Text == "")
                {
                    lblWarningMobile.Visible = true;
                }
                else
                {
                    lblWarningMobile.Visible = false;
                }

                if (txtEmail.Text == "")
                {
                    lblWarningEmail.Visible = true;
                }
                else
                {
                    lblWarningEmail.Visible = false;
                }
                if (txtAddress.Text == "")
                {
                    lblWarningAddress.Visible = true;
                }
                else
                {
                    lblWarningAddress.Visible = false;
                }
            }
            else
            {
                if (!CheckEmail(txtEmail.Text))
                {
                    lblWarningEmail.Text    = "Please enter the valid email address";
                    lblWarningEmail.Visible = true;
                }
                else
                {
                    try
                    {
                        InsertData();
                        ResetAllFields();
                        ResetAllWarningLabels();
                        MessageBox.Show("Add Member Successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        DialogResult d = MessageBox.Show("Do you want to print the membership form?", "Print Membership Form", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                        if (d == DialogResult.OK)
                        {
                            ucMembers.memberid = newmember.memberid;
                            frmMemberInfoReport frmMemberInfo = new frmMemberInfoReport();
                            frmMemberInfo.ShowDialog();
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Error Occurred. Please Try Again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
        private void Form2_Load(object sender, EventArgs e)
        {
            SportsFacilitiesEntities ctx = new SportsFacilitiesEntities();

            // Members Listing
            //DataSet1 ds = new DataSet1();

            //DataSet1TableAdapters.MembersTableAdapter da = new DataSet1TableAdapters.MembersTableAdapter();

            //da.Fill(ds.Members);
            //MemberListing cr = new MemberListing();
            //cr.SetDataSource(ds);

            //crystalReportViewer1.ReportSource = cr;


            // Booking Invoice
            //DataSet2 ds = new DataSet2();

            //DataSet2TableAdapters.bookinginvoicereportTableAdapter da = new DataSet2TableAdapters.bookinginvoicereportTableAdapter();

            //da.Fill(ds.bookinginvoicereport);
            //BookingInvoice cr = new BookingInvoice();
            //cr.SetDataSource(ds);

            //crystalReportViewer1.ReportSource = cr;


            // Membership Form
            //DataSet3 ds = new DataSet3();

            //DataSet3TableAdapters.MembersTableAdapter da = new DataSet3TableAdapters.MembersTableAdapter();

            //da.Fill(ds.Members);
            //MemberForm cr = new MemberForm();
            //cr.SetDataSource(ds);

            //crystalReportViewer1.ReportSource = cr;



            //  Monthly Revenue Report
            //DataSet4 ds = new DataSet4();

            //DataSet4TableAdapters.revenuereportTableAdapter da = new DataSet4TableAdapters.revenuereportTableAdapter();

            //da.Fill(ds.revenuereport);
            //MonthlyRevenue cr = new MonthlyRevenue();
            //cr.SetDataSource(ds);

            //crystalReportViewer1.ReportSource = cr;



            //  March Revenue Report
            //DataSet5 ds = new DataSet5();

            //DataSet5TableAdapters.revenuereportTableAdapter da = new DataSet5TableAdapters.revenuereportTableAdapter();

            //da.Fill(ds.revenuereport);
            //MarchRevenue cr = new MarchRevenue();
            //cr.SetDataSource(ds);

            //crystalReportViewer1.ReportSource = cr;


            //Occupancy Report

            //DataSet6 ds = new DataSet6();

            //DataSet6TableAdapters.bookinginvoicereportTableAdapter da = new DataSet6TableAdapters.bookinginvoicereportTableAdapter();

            //da.Fill(ds.bookinginvoicereport);
            //Occupancy cr = new Occupancy();
            //cr.SetDataSource(ds);

            //crystalReportViewer1.ReportSource = cr;



            //Booking Availability Report

            DataSet6 ds = new DataSet6();

            DataSet6TableAdapters.bookinginvoicereportTableAdapter da = new DataSet6TableAdapters.bookinginvoicereportTableAdapter();

            da.Fill(ds.bookinginvoicereport);
            BookingAvailability cr = new BookingAvailability();

            cr.SetDataSource(ds);


            crystalReportViewer1.ReportSource = cr;
        }
        private void FrmSubMembers_Load(object sender, EventArgs e)
        {
            SportsFacilitiesEntities ctx = new SportsFacilitiesEntities();

            dgvMembers.DataSource = ctx.Members.Where(x => x.status == "Active").ToList();
        }
Exemplo n.º 11
0
 private void frmLogin_Load(object sender, EventArgs e)
 {
     ctx = new SportsFacilitiesEntities();
 }