예제 #1
0
        private void btnAddMe_Click(object sender, EventArgs e)
        {
            frmEditTeacher edit = new frmEditTeacher();

            edit.btnAdd.Text = "&Save"; // set the button to save
            edit.ShowDialog();
        }
예제 #2
0
        private void dgvTeacher_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                //pass value to edit mode
                frmEditTeacher edit = new frmEditTeacher();
                edit.id = this.dgvTeacher.Rows[e.RowIndex].Cells[2].Value.ToString();//for editing criteria

                edit.teacherId       = this.dgvTeacher.Rows[e.RowIndex].Cells[3].Value.ToString();
                edit.fname           = this.dgvTeacher.Rows[e.RowIndex].Cells[4].Value.ToString();
                edit.mname           = this.dgvTeacher.Rows[e.RowIndex].Cells[5].Value.ToString();
                edit.lname           = this.dgvTeacher.Rows[e.RowIndex].Cells[6].Value.ToString();
                edit.adviserOf       = this.dgvTeacher.Rows[e.RowIndex].Cells[7].Value.ToString();
                edit.course          = this.dgvTeacher.Rows[e.RowIndex].Cells[8].Value.ToString();
                edit.specializedSubj = this.dgvTeacher.Rows[e.RowIndex].Cells[9].Value.ToString();

                edit.btnAdd.Text = "&Update";//set button to edit

                Users        user  = new Users();
                List <Users> users = new List <Users>();

                users.Clear();
                user.Teacher_Id = this.dgvTeacher.Rows[e.RowIndex].Cells[3].Value.ToString();
                users           = user.GetByTeacherID();

                //loop through load it to list view
                foreach (var item in users)
                {
                    //MessageBox.Show("S");
                    edit.username = item.UserId;
                    edit.pass     = item.Password;
                    edit.userType = item.UserType;
                }//End LoadSchedule()

                edit.Render();//call edit function
                edit.ShowDialog();// edit form
            }

            if (e.ColumnIndex == 1)
            {
                string message = "Do you want to delete this record?";
                string title   = "GOC_Grading_System";

                MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                DialogResult      result  = MessageBox.Show(message, title, buttons, MessageBoxIcon.Warning);

                if (result == DialogResult.Yes)
                {
                    Teacher teacher = new Teacher();
                    teacher.Id = Convert.ToInt32(dgvTeacher.Rows[e.RowIndex].Cells[2].Value.ToString());//for editing criteria
                    teacher.Delete();

                    MessageBox.Show(dgvTeacher.Rows[e.RowIndex].Cells[3].Value.ToString());
                    TeacherAssignment teacher2 = new TeacherAssignment();
                    teacher2.TeacherId = dgvTeacher.Rows[e.RowIndex].Cells[3].Value.ToString();
                    teacher2.Delete();

                    Load();
                }
                else
                {
                    return;
                }
            }
        }