Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //declaring studentid to 0

                //if requested string is not null then
                if (Request.QueryString != null)
                {
                    //get the studentid
                    studentid = Convert.ToInt32(Request.QueryString["StudentID"]);
                    //instantiate datacommunication
                }
            if(!IsPostBack)
            {
                    DataCommunication dcom = new DataCommunication();
                    stn = dcom.GetStudentDetailsByStudentID(studentid);
                    if (stn != null)
                    {
                        //populate the textboxes with objects in studententity framework
                        tbStudentName.Text = stn.StudentName;
                        ddlTeacherID.Text = stn.TeacherID;
                        ddlGrade.Text = stn.Grade;
                        tbAddress.Text = stn.Address;
                        tbCity.Text = stn.City;
                        tbZipCode.Text = stn.ZipCode;
                        ddlState.Text = stn.State;
                        tbTotalMarks.Text = stn.TotalMarks.ToString();

                    }
                }
        }
Пример #2
0
 protected void btnUpdateStudent_Click(object sender, EventArgs e)
 {
     //int returncode = 0;
     if (stn==null)
     {
         stn = new Student();
     }
     //when we click edit button then the studententities should be updated with new informations
     stn.StudentID = studentid;
     stn.StudentName = tbStudentName.Text;
     stn.TeacherID = ddlTeacherID.Text;
     stn.Grade = ddlGrade.Text;
     stn.Address = tbAddress.Text;
     stn.City = tbCity.Text;
     stn.ZipCode = tbZipCode.Text;
     stn.State = ddlState.Text;
     stn.TotalMarks =Convert.ToInt16( tbTotalMarks.Text);
     DataCommunication dcom = new DataCommunication();
     if (dcom.UpdatesStudentDetails(stn) == 1)
     {
         lblResult.Text = "Update student data successfull....";
     }
     else
     {
         lblResult.Text = "Failed";
     }
 }
Пример #3
0
        // method made for click for add student
        protected void Button1_Click(object sender, EventArgs e)
        {
            //create object for DataCommunication so that we can use AddStudent method
            DataCommunication dbcom = new DataCommunication();
            //calling the method using all the parameter from the text boxes and converiting to int where needed
            int response = dbcom.AddStudent(tbStudentName.Text,
                                            Convert.ToInt32(ddlTeacherID.Text),
                                            ddlGrade.Text,
                                            tbAddress.Text,
                                            tbCity.Text,
                                            Convert.ToInt32(tbZipCode.Text),
                                            ddlState.Text,
                                            Convert.ToInt32(tbTotalMarks.Text)
                                            );

            //response is the return from the AddStudent method which is iresult in this case
            if (response == 0)
            {
                lblResult.Text = "Registration failed........ please try again.";
            }
            else
            {
                lblResult.Text = string.Format("Registration successfull........ and Student ID:{0}.", response);
            }
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //in UI we get the data and bind the data
            //create the datacommunication object
            dc = new DataCommunication();
            //get the tool we used in design view and get datasource and call GetAllStudent Method
            GridView1.DataSource = dc.GetAllStudent();
            //adding the Gridview1_RowDeleting() with delegate GridViewDeleteEventHandler calling Gridview1_RowDeleting method
            GridView1.RowDeleting += new GridViewDeleteEventHandler(Gridview1_RowDeleting);
            GridView1.RowEditing+=GridView1_RowEditing;

            //Then we need to bind the data
            GridView1.DataBind();
        }