コード例 #1
0
        static public void InsertPersonalDetails(PersonalDetail personalDetail)
        {
            using (SqlConnection connection = GetSQLConnection())
            {
                connection.Open();

                SqlCommand cmd = new SqlCommand("dbo.sp_InsertPersonalDetails", connection);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@FirstName", personalDetail.FirstName);
                cmd.Parameters.AddWithValue("@MiddleInitials", personalDetail.MiddleInitials);
                cmd.Parameters.AddWithValue("@LastName", personalDetail.LastName);
                cmd.Parameters.AddWithValue("@Gender", personalDetail.Gender);
                cmd.Parameters.AddWithValue("@DOB", personalDetail.DOB);
                cmd.Parameters.AddWithValue("@PermAddrRow1", personalDetail.PermAddrRow1);
                cmd.Parameters.AddWithValue("@PermAddrRow2", personalDetail.PermAddrRow2);
                cmd.Parameters.AddWithValue("@PermAddrCity", personalDetail.PermAddrCity);
                cmd.Parameters.AddWithValue("@PermAddrZipCode", personalDetail.PermAddrZipCode);
                cmd.Parameters.AddWithValue("@PermAddrState", personalDetail.PermAddrState);
                cmd.Parameters.AddWithValue("@PermAddrCountry", personalDetail.PermAddrCountry);
                cmd.Parameters.AddWithValue("@TempAddrRow1", personalDetail.TempAddrRow1);
                cmd.Parameters.AddWithValue("@TempAddrRow2", personalDetail.TempAddrRow2);
                cmd.Parameters.AddWithValue("@TempAddrCity", personalDetail.TempAddrCity);
                cmd.Parameters.AddWithValue("@TempAddrZipCode", personalDetail.TempAddrZipCode);
                cmd.Parameters.AddWithValue("@TempAddrState", personalDetail.TempAddrState);
                cmd.Parameters.AddWithValue("@TempAddrCountry", personalDetail.TempAddrCountry);

                cmd.ExecuteNonQuery();
            }
        }
コード例 #2
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            PersonalDetail personalDetail = new PersonalDetail();

            personalDetail.FirstName       = "Sherlock";
            personalDetail.MiddleInitials  = 'R';
            personalDetail.LastName        = "Holmes";
            personalDetail.Gender          = "Male";
            personalDetail.DOB             = new DateTime(1854, 12, 25);
            personalDetail.PermAddrRow1    = "221B";
            personalDetail.PermAddrRow2    = "Baker St";
            personalDetail.PermAddrCity    = "London";
            personalDetail.PermAddrState   = 1;
            personalDetail.PermAddrZipCode = "30006";
            personalDetail.PermAddrCountry = 2;
            personalDetail.TempAddrRow1    = "10";
            personalDetail.TempAddrRow2    = "Downing St";
            personalDetail.TempAddrCity    = "London";
            personalDetail.TempAddrState   = 1;
            personalDetail.TempAddrZipCode = "30004";
            personalDetail.TempAddrCountry = 2;

            _controller.InsertPersonalDetail(personalDetail);
        }
コード例 #3
0
 internal void InsertPersonalDetail(PersonalDetail personalDetail)
 {
     DBOperations.InsertPersonalDetails(personalDetail);
 }