private void btnSave4_Click(object sender, EventArgs e)
        {
            Membership m = new Membership();

            m.contribution = member_contribution.Text;
            m.institute = member_institute.Text;
            m.member_id = member_id.Text;
            m.post_name = memebr_post_name.Text;
            m.method = member_method.Text;

            m.setBegin_date(member_begin_date_date.Value.Date);
            m.setRenewal_date(member_renewal_date.Value.Date);
            m.setActive_date_insti(member_active_date_insti_date.Value.Date);
            m.setActive_date_person(member_active_date_person_date.Value.Date);

            if (member_institutional_payment.Checked) { m.institutional_payment = true; }
            else { m.institutional_payment = false; }

            if (member_personal_payment.Checked) { m.personal_payment = true; }
            else { m.personal_payment = false; }

            m.status = member_status.Text;

            bool status = MembershipHandler.addMembership(m);

            if (status)
            {
                MessageBox.Show("Membership details added successfully...!");
                //btnSave4.Enabled = true;
                //btnSave5.Enabled = true;
            }
            else { MessageBox.Show("Failed to add membership details...!"); }
        }
Пример #2
0
        public void updateMembership()
        {
            Membership m = new Membership();

            m.mem_id = this.mem_id;
            m.contribution = this.member_contribution.Text;
            m.institute = this.member_institute.Text;
            m.member_id = this.member_id.Text;
            m.post_name = this.memebr_post_name.Text;
            m.method = this.member_method.Text;

            m.setBegin_date(this.member_begin_date_date.Value.Date);
            m.setRenewal_date(this.member_renewal_date.Value.Date);
            m.setActive_date_insti(this.member_active_date_insti_date.Value.Date);
            m.setActive_date_person(this.member_active_date_person_date.Value.Date);

            if (this.member_institutional_payment.Checked) { m.institutional_payment = true; }
            else { m.institutional_payment = false; }

            if (this.member_personal_payment.Checked) { m.personal_payment = true; }
            else { m.personal_payment = false; }

            bool state = MembershipHandler.updateMembership(m);

            Console.Write(state + "\n");
        }
        public static Membership getMembership()
        {
            //try
            //{

            DBConnector dbcon = new DBConnector();

            if (dbcon.openConnection())
            {

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "SELECT * FROM membership WHERE employee_idemployee=" + Employee.employee_id;
                cmd.Connection = dbcon.connection;

                MySqlDataReader reader = cmd.ExecuteReader();

                Membership mem = null;

                if (reader.Read())
                {
                    mem = new Membership();

                    mem.mem_id = int.Parse(reader["idmembership"].ToString());
                    mem.contribution = reader["contribution"].ToString();
                    mem.institute = reader["institute"].ToString();
                    mem.member_id = reader["member_id"].ToString();
                    mem.method = reader["method"].ToString();
                    mem.post_name = reader["post_name"].ToString();
                    mem.status = reader["status"].ToString();

                    mem.setBegin_date(Convert.ToDateTime(reader["begin_date"]));
                    mem.setRenewal_date(Convert.ToDateTime(reader["renewal_date"]));
                    mem.setActive_date_insti(Convert.ToDateTime(reader["active_date_insti"]));
                    mem.setActive_date_person(Convert.ToDateTime(reader["active_date_person"]));

                    if (reader["institutional_payment"].ToString() == "True") { mem.institutional_payment = true; }
                    else { mem.institutional_payment = false; }

                    if (reader["personal_payment"].ToString() == "True") { mem.personal_payment = true; }
                    else { mem.personal_payment = false; }

                }

                reader.Close();

                dbcon.closeConnection();

                return mem;
            }
            else
            {

                return null;
            }

            //}
            //catch (MySqlException e)
            //{
            //int errorcode = e.Number;
            //return null;
            //}
        }