protected void Page_Load(object sender, EventArgs e)
        {
            test_date = DateTime.Now.ToString("dd.MM.yyy");
            DateTime dt = DateTime.Now;

            test_time = dt.ToShortTimeString();

            Label19.Text     = "Welcome" + "  " + Login_page.getChildNameFromDatabase();
            lblUsername.Text = "  " + totalPonits.ToString();
            lbltime.Text     = "Time :" + "  " + test_time;
            lbldate.Text     = "Date :" + "  " + test_date;
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text == "5")
            {
                txt6.Text = ".10";
            }
            else

            {
                txt6.Text      = "0";
                txt6.ForeColor = System.Drawing.Color.Red;
            }
            if (TextBox2.Text == "14")
            {
                txt7.Text = ".10";
            }
            else

            {
                txt7.Text      = "0";
                txt7.ForeColor = System.Drawing.Color.Red;
            }

            if (TextBox3.Text == "9")
            {
                txt8.Text = ".10";
            }
            else

            {
                txt8.Text      = "0";
                txt8.ForeColor = System.Drawing.Color.Red;
            }
            if (TextBox4.Text == "11")
            {
                txt9.Text = ".10";
            }
            else

            {
                txt9.Text      = "0";
                txt9.ForeColor = System.Drawing.Color.Red;
            }
            if (TextBox5.Text == "7")
            {
                txt10.Text = ".10";
            }
            else

            {
                txt10.Text      = "0";
                txt10.ForeColor = System.Drawing.Color.Red;
            }

            point6  = Convert.ToDouble(txt6.Text);
            point7  = Convert.ToDouble(txt7.Text);
            point8  = Convert.ToDouble(txt8.Text);
            point9  = Convert.ToDouble(txt9.Text);
            point10 = Convert.ToDouble(txt10.Text);

            totalResult2 = point6 + point7 + point8 + point9 + point10;

            total2.Text = totalResult2.ToString();


            totalPonits      = Convert.ToDouble(total1.Text) + Convert.ToDouble(total2.Text);
            lblUsername.Text = "  " + totalPonits.ToString();
            PointsColor();

            try
            {
                child_id     = int.Parse(Login_page.child_username);
                total_points = totalPonits.ToString("P", CultureInfo.InvariantCulture);
                parent_id    = GetParentIDFromChildTable();
                child_Name   = Login_page.getChildNameFromDatabase();
                Parent_Name  = GetParentNameFromPointsTable();


                SqlConnection conn = new SqlConnection(@"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\Users\tumi\source\repos\LearnOnlineSystem\LearnOnlineSystem\App_Data\Learn_Online_System.mdf; Integrated Security = True");

                conn.Open();

                SqlCommand cmd = new SqlCommand("INSERT into points (child_id,child_Name,test_date,test_time,total_points,parent_id,Parent_Name)values (@child_id,@child_Name,@test_date,@test_time,@total_points,@parent_id,@Parent_Name)");

                cmd.Parameters.AddWithValue("@child_id", child_id);
                cmd.Parameters.AddWithValue("@child_Name", child_Name);
                cmd.Parameters.AddWithValue("@test_date", test_date);
                cmd.Parameters.AddWithValue("@test_time", test_time);
                cmd.Parameters.AddWithValue("@total_points", total_points);
                cmd.Parameters.AddWithValue("@parent_id", parent_id);
                cmd.Parameters.AddWithValue("@Parent_Name", Parent_Name);



                cmd.Connection = conn;
                cmd.ExecuteNonQuery();

                conn.Close();

                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + " Test is Completed Thank you " + Login_page.getChildNameFromDatabase() + "'); ", true);


                TextBox1.Enabled = false;
                TextBox2.Enabled = false;
                TextBox3.Enabled = false;
                TextBox4.Enabled = false;
                TextBox5.Enabled = false;
            }
            catch (FormatException)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Alert1", "alert('" + "Please Key in all details " + "'); ", true); //alert shown.
            }
        }
Exemple #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Child_Name.Text  = Login_page.getChildNameFromDatabase();
     Parent_Name.Text = AssignParentNameIntoChildProfile();
     Image1.ImageUrl  = SetImageProfile();
 }