コード例 #1
0
        private void BtnSearch_Click(object sender, EventArgs e)
        {
            bool bCheck = false;

            for (int i = 0; i < StudentGrid.RowCount; i++)
            {
                if (StudentGrid.Rows[i].Cells[1].Value.ToString() == txtFindName.Text.Trim())
                {
                    StudentGrid.ClearSelection();
                    StudentGrid.Rows[i].Selected = true;
                    bCheck = true;

                    lblStudentID.Text   = StudentGrid.Rows[i].Cells[0].Value.ToString();
                    lblStudentName.Text = StudentGrid.Rows[i].Cells[1].Value.ToString();

                    LoadSchoolData();
                    LoadMockData();
                }
            }

            if (!bCheck)
            {
                MaterialMessageBox.Show("존재하지 않는 학생입니다.", "삭제확인", MessageBoxButtons.OK);
            }

            txtFindName.Text = "";
        }
コード例 #2
0
        protected void StudentGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            GridViewRow   row              = (GridViewRow)(((Control)e.CommandSource).NamingContainer);
            int           RowIndex         = row.RowIndex;
            SqlConnection objSqlConnection = new SqlConnection(
                WebConfigurationManager.ConnectionStrings["StudentDataBaseConnection"].ConnectionString);

            if (e.CommandName == "delete")
            {
                var        command       = String.Format("DELETE FROM Student WHERE StudentId = {0}", StudentGrid.DataKeys[RowIndex].Value);
                SqlCommand objSqlCommand = new SqlCommand(command, objSqlConnection);
                objSqlConnection.Open();

                objSqlCommand.ExecuteNonQuery();

                objSqlConnection.Close();

                e.Handled = true;
                StudentGrid.DataSource = ShowListOfStudents();
                StudentGrid.DataBind();
            }

            else if (e.CommandName == "schedule")
            {
                Session["StudentId"]   = StudentGrid.DataKeys[RowIndex].Value;
                Session["StudentName"] = StudentGrid.DataKeys[RowIndex].Value;
                Response.Redirect(@"\Admin\AddSchedule.aspx");
            }
        }
コード例 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         StudentGrid.DataSource = ShowListOfStudents();
         StudentGrid.DataBind();
     }
 }
コード例 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         StudentNameLabel.Text  = Session["StudentName"]?.ToString();
         StudentGrid.DataSource = GetStudentInfo();
         StudentGrid.DataBind();
     }
 }
コード例 #5
0
        protected void AddBtn_Click(object sender, EventArgs e)
        {
            List <string> listOfSubjects = new List <string>();

            foreach (ListItem listItem in ListBoxSubjects.Items)
            {
                if (listItem.Selected)
                {
                    listOfSubjects.Add(listItem.Value);
                }
            }
            InsertSubjects(listOfSubjects);
            StudentGrid.DataSource = GetStudentInfo();
            StudentGrid.DataBind();
        }
コード例 #6
0
        protected void AddBtn_Click(object sender, EventArgs e)
        {
            var studentId = Convert.ToInt32(Session["StudentId"]);

            List <string> listOfSubjects = new List <string>();

            foreach (ListItem listItem in ListBoxSubjects.Items)
            {
                if (listItem.Selected)
                {
                    listOfSubjects.Add(listItem.Value);
                }
            }
            studentService.InsertListOfSubjects(listOfSubjects, studentId);
            StudentGrid.DataSource = GetStudentInfo();
            StudentGrid.DataBind();
        }
コード例 #7
0
        protected void StudentGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            GridViewRow row      = (GridViewRow)(((Control)e.CommandSource).NamingContainer);
            int         RowIndex = row.RowIndex;

            if (e.CommandName == "delete")
            {
                var StudentId = StudentGrid.DataKeys[RowIndex].Value;
                studentService.DeleteStudent(StudentId);
                e.Handled = true;
                StudentGrid.DataSource = ShowListOfStudents();
                StudentGrid.DataBind();
            }

            else if (e.CommandName == "schedule")
            {
                Session["StudentId"]   = StudentGrid.DataKeys[RowIndex].Values[0];
                Session["StudentName"] = StudentGrid.DataKeys[RowIndex].Values[1];
                Response.Redirect(@"\Admin\AddSchedule.aspx");
            }
        }
コード例 #8
0
        protected void Submit_Score(object sender, EventArgs e)
        {
            var    courseId    = Convert.ToInt32(Session["CourseId"]);
            var    studentId   = Convert.ToInt32(Session["StudentId"]);
            string attendence  = Attendence.Text;
            string Quiz        = quiz.Text;
            string homeWork    = HomeWork.Text;
            string research    = Reasearch.Text;
            string labPractice = LabPractice.Text;
            string finalExam   = FinalExam.Text;

            studentService.SubmitScore(courseId, studentId, attendence, Quiz, homeWork, research, labPractice, finalExam);
            StudentGrid.DataSource = GetStudentInfo();
            StudentGrid.DataBind();
            SubjectLbl.Visible = false;
            scorediv.Visible   = false;
            Attendence.Text    = "0";
            quiz.Text          = "0";
            HomeWork.Text      = "0";
            Reasearch.Text     = "0";
            LabPractice.Text   = "0";
            FinalExam.Text     = "0";
        }
コード例 #9
0
        protected void StudentsGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            SqlConnection myconnect = new SqlConnection(WebConfigurationManager.ConnectionStrings["smsconnection"].ConnectionString);
            string        id        = StudentsGrid.DataKeys[e.RowIndex].Values["StudentId"].ToString();

            myconnect.Open();
            try
            {
                SqlCommand mycommand = new SqlCommand("getstudent", myconnect);
                mycommand.Parameters.AddWithValue("@StudentId", id);
                mycommand.CommandType = System.Data.CommandType.StoredProcedure;
                SqlDataReader myreader = mycommand.ExecuteReader();
                StudentGrid.DataSource = myreader;
                StudentGrid.DataBind();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                myconnect.Close();
            }
        }