예제 #1
0
        /// <summary>
        ///
        /// </summary>
        private void insertRecord()
        {
            //結果表示用
            //string result = string.Empty;

            using (StudentDataContext student = new StudentDataContext())
            {
                var studentId   = String.Format("{0:D6}", int.Parse(TextBox1.Text));
                var height      = Math.Round(double.Parse(TextBox2.Text), 2, MidpointRounding.AwayFromZero);
                var weight      = Math.Round(double.Parse(TextBox3.Text), 2, MidpointRounding.AwayFromZero);
                var idealWeight = (height - 100) * 0.9;
                var year        = short.Parse(DropDownList1.Text);

                STUDENT_HEALTH health = new STUDENT_HEALTH
                {
                    StudentId   = studentId,
                    Height      = (decimal)height,
                    Weight      = (decimal)weight,
                    IdealWeight = (decimal)idealWeight,
                    Year        = year
                };
                student.STUDENT_HEALTH.InsertOnSubmit(health);

                try
                {
                    student.SubmitChanges();
                    DropDownList1.Text = "2015";
                    TextBox1.Text      = "";
                    TextBox2.Text      = "";
                    TextBox3.Text      = "";
                    Label7.Text        = "登録に成功しました。";
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e);
                    Label7.Text = "登録に失敗しました。";
                }
            }
        }
예제 #2
0
 partial void DeleteSTUDENT_HEALTH(STUDENT_HEALTH instance);
예제 #3
0
 partial void UpdateSTUDENT_HEALTH(STUDENT_HEALTH instance);
예제 #4
0
 partial void InsertSTUDENT_HEALTH(STUDENT_HEALTH instance);
예제 #5
0
        /// <summary>
        /// 
        /// </summary>
        private void insertRecord()
        {
            //結果表示用
            //string result = string.Empty;

            using (StudentDataContext student = new StudentDataContext())
            {
                var studentId = String.Format("{0:D6}", int.Parse(TextBox1.Text));
                var height = Math.Round(double.Parse(TextBox2.Text), 2, MidpointRounding.AwayFromZero);
                var weight = Math.Round(double.Parse(TextBox3.Text), 2, MidpointRounding.AwayFromZero);
                var idealWeight = (height - 100) * 0.9;
                var year = short.Parse(DropDownList1.Text);

                STUDENT_HEALTH health = new STUDENT_HEALTH
               {
                   StudentId = studentId,
                   Height = (decimal)height,
                   Weight = (decimal)weight,
                   IdealWeight = (decimal)idealWeight,
                   Year = year
               };
                student.STUDENT_HEALTH.InsertOnSubmit(health);

                try
                {
                    student.SubmitChanges();
                    DropDownList1.Text = "2015";
                    TextBox1.Text = "";
                    TextBox2.Text = "";
                    TextBox3.Text = "";
                    Label7.Text = "登録に成功しました。";
                }
                catch(Exception e)
                {
                    Debug.WriteLine(e);
                    Label7.Text = "登録に失敗しました。";
                }
            }
        }
예제 #6
0
 partial void DeleteSTUDENT_HEALTH(STUDENT_HEALTH instance);
예제 #7
0
 partial void UpdateSTUDENT_HEALTH(STUDENT_HEALTH instance);
예제 #8
0
 partial void InsertSTUDENT_HEALTH(STUDENT_HEALTH instance);