Ejemplo n.º 1
0
        public member1 Getmember(int memberId)
        {
            MemberBroker mb  = new MemberBroker();
            member1      mem = mb.GetMember(memberId);

            return(mem);
        }
Ejemplo n.º 2
0
        public member1 GetMember(int MemberId)
        {
            SqlParameter pMemberId = new SqlParameter("@MemberId", SqlDbType.Int);

            cmSelbyPK.Parameters.Add(pMemberId);
            pMemberId.Value = MemberId;

            member1 mem = new member1();

            cn.Open();
            SqlDataReader dr = cmSelbyPK.ExecuteReader();

            if (dr.Read())
            {
                mem.MemberId    = Convert.ToInt32(dr["MemberId"]);
                mem.MemberName  = (dr["MemberName"]).ToString();
                mem.Address1    = (dr["Address1"]).ToString();
                mem.Phone       = (dr["Phone"]).ToString();
                mem.DateOfBirth = (dr["DateOfBirth"].ToString());
                mem.Gender      = (dr["Gender"]).ToString();
            }
            else
            {
            }
            cn.Close();
            return(mem);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            memberController mc = new memberController();

            if (this.textBox1.Text == Convert.ToString(mc.GetAllmember().Count() + 1))
            {
                member1 newmember = new member1();
                newmember.MemberId   = Convert.ToInt32(this.textBox1.Text);
                newmember.MemberName = this.textBox2.Text;
                string G = "";
                if (this.radioButton1.Checked)
                {
                    G = "M";
                }
                else
                {
                    G = "F";
                }
                newmember.Gender      = G;
                newmember.DateOfBirth = this.dateTimePicker1.Value.Date.ToString();
                newmember.Address1    = this.textBox3.Text;
                newmember.Phone       = this.textBox4.Text;

                mc.Addmember(newmember);

                MessageBox.Show("saved");
                button1_Click(null, null);
            }
            else
            {
                member1 a = mc.Getmember(Convert.ToInt32(this.textBox1.Text));

                a.MemberName = this.textBox2.Text;
                string G = "";
                if (this.radioButton1.Checked)
                {
                    G = "M";
                }
                else
                {
                    G = "F";
                }
                a.Gender      = G;
                a.DateOfBirth = this.dateTimePicker1.Value.Date.ToString();
                a.Address1    = this.textBox3.Text;
                a.Phone       = this.textBox4.Text;

                mc.ModifymemberInfo(a);

                MessageBox.Show("update successfully");
                button1_Click(null, null);
            }
        }
Ejemplo n.º 4
0
        public void insert(member1 mem)
        {
            SqlParameter pMemberId    = new SqlParameter("@MemberId", SqlDbType.Int);
            SqlParameter pMemberName  = new SqlParameter("@MemberName", SqlDbType.VarChar, 50);
            SqlParameter pAddress1    = new SqlParameter("@Address1", SqlDbType.VarChar, 100);
            SqlParameter pPhone       = new SqlParameter("@Phone", SqlDbType.VarChar, 50);
            SqlParameter pDateOfBirth = new SqlParameter("@DateOfBirth", SqlDbType.VarChar, 100);
            SqlParameter pGender      = new SqlParameter("@Gender", SqlDbType.VarChar, 1);

            cmInsert.Parameters.AddRange(new SqlParameter[] { pMemberId, pMemberName, pAddress1, pPhone, pDateOfBirth, pGender });
            pMemberId.Value    = mem.MemberId;
            pMemberName.Value  = mem.MemberName;
            pAddress1.Value    = mem.Address1;
            pPhone.Value       = mem.Phone;
            pDateOfBirth.Value = mem.DateOfBirth;
            pGender.Value      = mem.Gender;

            cn.Open();
            cmInsert.ExecuteNonQuery();
            cn.Close();
        }
Ejemplo n.º 5
0
        public List <member1> GetAllMember()
        {
            cn.Open();
            SqlDataReader  dr      = cmSelAll.ExecuteReader();
            List <member1> memlist = new List <member1>();

            while (dr.Read())
            {
                member1 mem = new member1();
                mem.MemberId    = Convert.ToInt32(dr["MemberId"]);
                mem.MemberName  = (dr["MemberName"]).ToString();
                mem.Address1    = (dr["Address1"]).ToString();
                mem.Phone       = (dr["Phone"]).ToString();
                mem.DateOfBirth = (dr["DateOfBirth"].ToString());
                mem.Gender      = (dr["Gender"]).ToString();

                memlist.Add(mem);
            }
            cn.Close();
            return(memlist);
        }
Ejemplo n.º 6
0
        public void Addmember(member1 mem)
        {
            MemberBroker mb = new MemberBroker();

            mb.insert(mem);
        }
Ejemplo n.º 7
0
        public void ModifymemberInfo(member1 mem)
        {
            MemberBroker mb = new MemberBroker();

            mb.update(mem);
        }