Ejemplo n.º 1
0
        private void btnAddMember_Click(object sender, EventArgs e)
        {
            frmMembers objfrmMemberToAdd = new frmMembers(ThefrmMain);

             //insert Members

                Member member = new Member();
                member.EnvelopeNo = int.Parse(txtEnvelopeNumber.Text);
                member.LastName = txtLastName.Text;
                member.FirstName = txtFirstName.Text;
                member.Address = txtAddress.Text;
                member.City = txtCity.Text;
                member.Zip = int.Parse(txtZip.Text);
                member.Email = txtEmail.Text;
                membersData.insertMembers(member);
                this.Close();
        }
Ejemplo n.º 2
0
        //------------------------Members----------------------------------
        public void insertMembers(Member member)
        {
            try
            {
                string cmdText = "INSERT INTO dbo.Donor(EnvelopeNumber,LastName,FirstName,Address,City,Zip,email) VALUES(@EnvelopeNumber,@LastName,@FirstName,@Address,@City,@Zip,@email)";
                SqlCommand cmd = new SqlCommand(cmdText, connection);
                cmd.Parameters.AddWithValue("@EnvelopeNumber", member.EnvelopeNo);
                cmd.Parameters.AddWithValue("@LastName", member.LastName);
                cmd.Parameters.AddWithValue("@FirstName", member.FirstName);
                cmd.Parameters.AddWithValue("@Address", member.Address);
                cmd.Parameters.AddWithValue("@City", member.City);
                cmd.Parameters.AddWithValue("@Zip", member.Zip);
                cmd.Parameters.AddWithValue("@email", member.Email);
                connection.Open();
                cmd.ExecuteNonQuery();
            }

            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();

                }
            }
        }