public void LoadForm()
        {
            ServicesController sc       = new ServicesController();
            List <Service>     services = sc.ShowAll();

            servicesDataGridView.Rows.Clear();
            servicesDataGridView.Columns.Clear();
            servicesDataGridView.Refresh();
            //setup
            //columns
            servicesDataGridView.Columns.Add("serviceId", "ID");
            servicesDataGridView.Columns.Add("name", "Service Name");
            servicesDataGridView.Columns.Add("day", "Service Day");

            servicesDataGridView.Columns["serviceId"].Visible = false;
            //rows
            if (services.Count > 0)
            {
                foreach (Service service in services)
                {
                    servicesDataGridView.Rows.Add(
                        service.id,
                        service.name,
                        service.DayFullName()
                        );
                }
            }
            else
            {
                MessageBox.Show("No servicse are currently registered in the system. Please add a service!", "No Service Found!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Esempio n. 2
0
        private void GivingFrm_Load(object sender, EventArgs e)
        {
            servicesCmbBx.SelectedIndexChanged -= new System.EventHandler(this.ServicesCmbBx_SelectedIndexChanged);
            ServicesController sc = new ServicesController();

            services = sc.ShowAll();
            if (services.Count > 0)
            {
                UpdateDateTimePicker(services[0]);
                Dictionary <Service, string> serviceLibrary = new Dictionary <Service, string>();
                foreach (Service service in services)
                {
                    serviceLibrary.Add(service, service.name);
                }
                servicesCmbBx.DataSource            = new BindingSource(serviceLibrary, null);
                servicesCmbBx.DisplayMember         = "Value";
                servicesCmbBx.ValueMember           = "Key";
                servicesCmbBx.SelectedIndexChanged += new System.EventHandler(this.ServicesCmbBx_SelectedIndexChanged);

                //servicesCmbBx.SelectedIndex = 0;
            }
            else
            {
                MessageBox.Show("No service registered. Please Create a service type first!.",
                                "Service Unavailable", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.Close();
            }

            LoadGivings();
        }
Esempio n. 3
0
        public void LoadForm()
        {   //loads UI for Update or Add
            this.Text           = IsUpdate ? "Edit Offering" : "Add Offering";
            this.submitBtn.Text = IsUpdate ? "Submit" : "Create";
            this.AcceptButton   = submitBtn;

            //loads memebers
            MembersController mc      = new MembersController();
            List <Member>     members = mc.ShowAll();

            if (members.Count > 0)
            {
                List <KeyValuePair <int, string> > membersLibrary = new List <KeyValuePair <int, string> >();
                foreach (Member member in members)
                {
                    membersLibrary.Add(new KeyValuePair <int, string>(member.id, member.firstName + " " + member.lastName));
                }
                membersCmbBx.DataSource    = membersLibrary.ToList <KeyValuePair <int, string> >();//new BindingSource(membersLibrary, null);
                membersCmbBx.DisplayMember = "Value";
                membersCmbBx.ValueMember   = "Key";
                if (IsUpdate)
                {
                    membersCmbBx.SelectedValue = currentGiving.member.id;
                }
                else
                {
                    membersCmbBx.SelectedIndex = 0;
                }
            }

            //loads services

            ServicesController sc       = new ServicesController();
            List <Service>     services = sc.ShowAll();

            if (services.Count > 0)
            {
                List <KeyValuePair <int, string> > servicesLibrary = new List <KeyValuePair <int, string> >();
                foreach (Service service in services)
                {
                    servicesLibrary.Add(new KeyValuePair <int, string>(service.id, service.name));
                }
                serviceCmbBox.DataSource    = servicesLibrary.ToList <KeyValuePair <int, string> >();//new BindingSource(membersLibrary, null);
                serviceCmbBox.DisplayMember = "Value";
                serviceCmbBox.ValueMember   = "Key";
                if (IsUpdate)
                {
                    serviceCmbBox.SelectedValue = currentGiving.service.id;
                }
                else
                {
                    serviceCmbBox.SelectedValue = addedService.id;
                }
            }

            //load date
            givingDateDateTimePicker.Value = IsUpdate ? currentGiving.givingDate : addedDate;
        }
Esempio n. 4
0
        public void Update(string name, int day)
        {
            ServicesController sc = new ServicesController();

            Service service = sc.Update(this.id,
                                        new Param("name", name),
                                        new Param("day", day)
                                        );

            this.name = service.name;
            this.day  = service.day;
        }
Esempio n. 5
0
        public Service(string name, int day)
        {
            ServicesController sc = new ServicesController();

            sc.Add(
                new Param("name", name),
                new Param("day", day)
                );
            Service s = sc.GetLastAdded();

            this.id   = s.id;
            this.name = s.name;
            this.day  = s.day;
        }
        private void EditServiceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (servicesDataGridView.Rows.Count == 0)
            {
                return;
            }

            Service s = new ServicesController().Show((int)servicesDataGridView.SelectedRows[0].Cells["serviceId"].Value);

            AddUpdateServiceFrm addFrm = new AddUpdateServiceFrm(true, s);

            addFrm.FormClosing += new FormClosingEventHandler(this.ServicesUpdated);

            addFrm.ShowDialog();
        }
Esempio n. 7
0
        public Giving(DataRow r)
        {
            try
            {
                MembersController  mc   = new MembersController();
                ServicesController sc   = new ServicesController();
                SessionsController sesC = new SessionsController();
                this.id         = Convert.ToInt32(r["givingId"]);
                this.member     = mc.Show(Convert.ToInt32(r["memberId"]));
                this.givingDate = Convert.ToDateTime(r["givingDate"]);
                this.entryDate  = Convert.ToDateTime(r["entryDate"]);
                this.service    = sc.Show(Convert.ToInt32(r["serviceId"]));

                this.session = sesC.Show(Convert.ToInt32(r["sessionId"]));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 8
0
        public void Delete()
        {
            ServicesController sc = new ServicesController();

            sc.Delete(this.id);
        }