Example #1
0
 public static string teacher_edit(string tname, string sex, string room, string tel, string email, string title,
     string education, string course, string research, string article, string demand, string institute)
 {
     teacher tea = new teacher();
     tea.tno = tno;
     tea.tname = tname;
     tea.sex = sex;
     tea.room = room;
     tea.tel = tel;
     tea.email = email;
     tea.title = title;
     tea.education = education;
     tea.course = course;
     tea.research = research;
     tea.article = article;
     tea.demand = demand;
     tea.institute = institute;
     tea_Manage teaManage = new tea_Manage();
     return string.Format(teaManage.tea_Update(tea));
 }
 partial void Insertteacher(teacher instance);
Example #3
0
        static void Main(string[] args)
        {
            // 5.Run the same code in Program.cs from Module 5 to create instances of your classes so that you can setup a single course that is part of a program and a degree path. Be sure to include at least one Teacher and an array of Students.
            student student1 = new student();
            student1.Firstname = "Tony";
            student1.Lastname = "Stark";
            student1.Dateofbirth = "1st Jan 1969";
            student1.Grades.Push(90);
            student1.Grades.Push(100);
            student1.Grades.Push(90);
            student1.Grades.Push(75);
            student1.Grades.Push(60);

            student student2 = new student();
            student2.Firstname = "Steve";
            student2.Lastname = "Rodgers";
            student2.Dateofbirth = "1st Feb 1920";
            student2.Grades.Push(90);
            student2.Grades.Push(100);
            student2.Grades.Push(90);
            student2.Grades.Push(75);
            student2.Grades.Push(60);

            student student3 = new student();
            student3.Firstname = "Bruce";
            student3.Lastname = "Banner";
            student3.Dateofbirth = "1st April 1975";
            student3.Grades.Push(90);
            student3.Grades.Push(100);
            student3.Grades.Push(90);
            student3.Grades.Push(75);
            student3.Grades.Push(60);

            //2.Instantiate a Course object called Programming with C#.
            course ProgrammingCourses = new course();
            ProgrammingCourses.CourseTitle = "Programming with C#";
            ProgrammingCourses.CourseLength = 3;
            ProgrammingCourses.CourseCredits = 90;

            //3.Add your three students to this Course object
            ProgrammingCourses.students.Add(student1);
            ProgrammingCourses.students.Add(student2);
            ProgrammingCourses.students.Add(student3);

            //4.Instantiate at least one Teacher object.
            teacher teacher1 = new teacher();
            teacher1.Firstname = "Stan";
            teacher1.Lastname = "Winston";
            teacher1.Dateofbirth = "1st Dec 1919";

            //5.Add that Teacher object to your Course object
            ProgrammingCourses.teachers[0] = teacher1;

            //6.Instantiate a Degree object, such as Bachelor.
            degree degree1 = new degree();
            degree1.DegreeName = "Bachelor";

            //7.Add your Course object to the Degree object.
            degree1.degreecourse = ProgrammingCourses;

            //8.Instantiate a UProgram object called Information Technology.
            uprogram uprogram1 = new uprogram();
            uprogram1.Programtitle = "Information Technology";

            //9.Add the Degree object to the UProgram object.
            uprogram1.Programdegree = degree1;

            //10.Using Console.WriteLine statements, output
            //Console.WriteLine("The {0} program contains the {1} degree", uprogram1.Programtitle, degree1.DegreeName);
            //Console.WriteLine("The {0} degree contains the course {1}", degree1.DegreeName, ProgrammingCourses.CourseTitle);
            //Console.WriteLine("The {0} course contains {1} students(s)", ProgrammingCourses.CourseTitle, ProgrammingCourses.CourseTitle);

            ProgrammingCourses.ListStudents();
        }
    public bool isTeacherUpdated( string fname, string mid, string lname, DateTime dob, string position, int u_ID )
    {
        if (!teacherExists( fname, mid, lname, dob )) {
            try {

                teacher oldTeacher = getTeacher( fname, mid, lname, dob );
                teacher newTeacher = new teacher() {

                    firstName = fname,
                    middleName = mid,
                    lastName = lname,
                    DOB = dob,
                    position = position,
                    user__ID = u_ID
                };

                int id = oldTeacher.teacher_ID;
                oldTeacher = newTeacher;
                oldTeacher.teacher_ID = id;

                MOE_DB.SubmitChanges();

                return true;

            }
            catch (Exception ex) {
                return false;
            }//try catch
        }//if
        return false;
    }
        public ActionResult EditTeacher(teacher t, int id)
        {
            if ((string)Session["user"] != null)
            {
                teacher teacher = new teacher();
                bool    Status  = false;
                string  message = "";

                teacher teachertoupdate = data.teacher.Where(x => x.id == id).FirstOrDefault();
                //Debug.WriteLine(superadmintoupdate);
                //Debug.WriteLine(id);
                //Debug.WriteLine(s.superadminid);
                //Debug.WriteLine(s.superadminname);
                //Debug.WriteLine(s.superadminpassword);
                //Debug.WriteLine(s.superadminconfirmpassword);
                //superadmintoupdate.id = s.id;
                teachertoupdate.teacherid              = t.teacherid;
                teachertoupdate.teachername            = t.teachername;
                teachertoupdate.teacherpassword        = Crypto.Hash(t.teacherpassword);
                teachertoupdate.teacherconfirmpassword = Crypto.Hash(t.teacherconfirmpassword);


                try
                {
                    //data.SaveChanges();
                    if (ModelState.IsValid)
                    {
                        var nameExistsSuper = NameExistsTeacher(teachertoupdate.teachername);
                        if (nameExistsSuper)
                        {
                            ModelState.AddModelError("NameExistTeacher", " Teacher name already exists");
                            return(View(teacher));
                        }

                        data.SaveChanges();
                        message = " Teacher Account  with ID = " + teachertoupdate.teacherid + " has been edited.";
                        Status  = true;
                    }
                    else
                    {
                        message = "Invalid Request";
                    }
                    ViewBag.Message = message;
                    ViewBag.Status  = Status;
                    return(View(teacher));
                }
                catch (DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                        eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                            ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    throw;
                }

                //return RedirectToAction("ListTeacher");
            }
            return(RedirectToAction("Login", "User"));
        }
Example #6
0
    public static bool Update(teacher oldteacher,
                              teacher newteacher)
    {
        SqlConnection connection = SchoolData.GetConnection();
        string        updateStatement
            = "UPDATE "
              + "     [teacher] "
              + "SET "
              + "     [ClassId] = @NewClassId "
              + "    ,[FullName] = @NewFullName "
              + "    ,[DateOfJoin] = @NewDateOfJoin "
              + "    ,[HomeAddress] = @NewHomeAddress "
              + "    ,[PhoneNumber] = @NewPhoneNumber "
              + "WHERE "
              + "     [TeacherId] = @OldTeacherId "
              + " AND ((@OldClassId IS NULL AND [ClassId] IS NULL) OR [ClassId] = @OldClassId) "
              + " AND ((@OldFullName IS NULL AND [FullName] IS NULL) OR [FullName] = @OldFullName) "
              + " AND ((@OldDateOfJoin IS NULL AND [DateOfJoin] IS NULL) OR [DateOfJoin] = @OldDateOfJoin) "
              + " AND ((@OldHomeAddress IS NULL AND [HomeAddress] IS NULL) OR [HomeAddress] = @OldHomeAddress) "
              + " AND ((@OldPhoneNumber IS NULL AND [PhoneNumber] IS NULL) OR [PhoneNumber] = @OldPhoneNumber) "
              + "";
        SqlCommand updateCommand = new SqlCommand(updateStatement, connection);

        updateCommand.CommandType = CommandType.Text;
        if (newteacher.ClassId.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewClassId", newteacher.ClassId);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewClassId", DBNull.Value);
        }
        if (newteacher.FullName != null)
        {
            updateCommand.Parameters.AddWithValue("@NewFullName", newteacher.FullName);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewFullName", DBNull.Value);
        }
        if (newteacher.DateOfJoin.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewDateOfJoin", newteacher.DateOfJoin);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewDateOfJoin", DBNull.Value);
        }
        if (newteacher.HomeAddress != null)
        {
            updateCommand.Parameters.AddWithValue("@NewHomeAddress", newteacher.HomeAddress);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewHomeAddress", DBNull.Value);
        }
        if (newteacher.PhoneNumber != null)
        {
            updateCommand.Parameters.AddWithValue("@NewPhoneNumber", newteacher.PhoneNumber);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewPhoneNumber", DBNull.Value);
        }
        updateCommand.Parameters.AddWithValue("@OldTeacherId", oldteacher.TeacherId);
        if (oldteacher.ClassId.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@OldClassId", oldteacher.ClassId);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldClassId", DBNull.Value);
        }
        if (oldteacher.FullName != null)
        {
            updateCommand.Parameters.AddWithValue("@OldFullName", oldteacher.FullName);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldFullName", DBNull.Value);
        }
        if (oldteacher.DateOfJoin.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@OldDateOfJoin", oldteacher.DateOfJoin);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldDateOfJoin", DBNull.Value);
        }
        if (oldteacher.HomeAddress != null)
        {
            updateCommand.Parameters.AddWithValue("@OldHomeAddress", oldteacher.HomeAddress);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldHomeAddress", DBNull.Value);
        }
        if (oldteacher.PhoneNumber != null)
        {
            updateCommand.Parameters.AddWithValue("@OldPhoneNumber", oldteacher.PhoneNumber);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@OldPhoneNumber", DBNull.Value);
        }
        try
        {
            connection.Open();
            int count = updateCommand.ExecuteNonQuery();
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            throw ex;
        }
        finally
        {
            connection.Close();
        }
    }
    public bool isTeacherAdded( string fname, string mid, string lname, DateTime dob, string position, int u_ID )
    {
        if (!teacherExists( fname, mid, lname, dob )) {
            try {
                teacher newTeacher = new teacher() {

                    firstName = fname,
                    middleName = mid,
                    lastName = lname,
                    DOB = dob,
                    position = position,
                    user__ID = u_ID
                };

                MOE_DB.teachers.InsertOnSubmit( newTeacher );
                MOE_DB.SubmitChanges();

                return true;

            }
            catch (Exception ex) {
                return false;
            }//try catch
        }//if
        return false;
    }
Example #8
0
        public static void FillHeaderNom(LIVEX.UserControls.TableTeacherGroup ttg, LIVEX.UserControls.NominaMaestros nom)
        {
            livexEntities         context = new livexEntities();
            List <teacher_skills> lstTs   = new List <teacher_skills>();
            teacher t = new teacher();

            string[] ciclo = ttg.cmbCiclo.Text.Split(' ');
            string   middleDay;

            int idTeacher = Int32.Parse(ttg.cmbTeacherNames.SelectedValue.ToString());

            lstTs = context.teacher_skills.Where(x => x.teacherID == idTeacher).ToList();
            t     = context.teacher.FirstOrDefault(x => x.idteacher == idTeacher);

            DateTime firstDay = DateTime.Parse(ciclo[4]);
            DateTime lastDay  = DateTime.Parse(ciclo[6]);

            middleDay          = firstDay.AddDays(12).ToShortDateString();
            nom.txtTName.Text  = ttg.cmbTeacherNames.Text;
            nom.txtCiclo.Text  = ciclo[0] + " " + ciclo[1] + " " + ciclo[2];
            nom.txtFechas.Text = ciclo[4] + " AL\n " + middleDay;
            nom.txtYear.Text   = DateTime.Parse(ciclo[4]).Year.ToString();
            nom.txtAlta.Text   = t.start_date;
            if (ciclo[2] == "A")
            {
                nom.txtNoSemanas.Text = "SEMANA 1 y 2";
            }
            else
            {
                nom.txtNoSemanas.Text = "SEMANA 3 y 4";
            }
            nom.txtFechaInicio.Text = "INICIA \n" + firstDay.ToShortDateString();
            nom.txtFechaFin.Text    = "TERMINA \n" + lastDay.ToShortDateString();
            nom.txtFechaDep.Text    = "PARA DEPOSITO " + lastDay.AddDays(2).ToLongDateString().ToUpper();


            foreach (teacher_skills ts in lstTs)
            {
                switch (ts.skillID)
                {
                case 1:
                    nom.txtTOEFL.Foreground = Brushes.Green;
                    break;

                case 2:
                    nom.txtExp.Foreground = Brushes.Green;
                    break;

                case 3:
                    nom.txtTra.Foreground = Brushes.Green;
                    break;

                case 4:
                    nom.txtLic.Foreground = Brushes.Green;
                    break;
                }
            }

            nom.txtSalario_Base.Text = t.salary_base.ToString();
            nom.txtSignName.Text     = ttg.cmbTeacherNames.Text.ToUpper() + " " + t.teacher_lastname.ToUpper();
            nom.txtTeacherName.Text  = "TEACHER: " + ttg.cmbTeacherNames.Text.ToUpper() + " " + t.teacher_lastname.ToUpper();

            AddGroups(idTeacher, nom, ciclo);
        }
Example #9
0
 public string tea_Update(teacher tea)
 {
     SqlConnection myConn = GetConnection();
     myConn.Open();
     string sqlStr = "update teacherInfo set tname=@tname,sex=@sex,room=@room,tel=@tel,email=@email,title=@title,";
     sqlStr = sqlStr + "education=@education,course=@course,research=@research,article=@article,demand=@demand,";
     sqlStr = sqlStr + "institute=@institute where tno=@tno";
     SqlCommand myCmd = new SqlCommand(sqlStr, myConn);
     myCmd.Parameters.AddWithValue("@tno", tea.tno);
     myCmd.Parameters.AddWithValue("@tname", tea.tname);
     myCmd.Parameters.AddWithValue("@sex", tea.sex);
     myCmd.Parameters.AddWithValue("@room", tea.room);
     myCmd.Parameters.AddWithValue("@tel", tea.tel);
     myCmd.Parameters.AddWithValue("@email", tea.email);
     myCmd.Parameters.AddWithValue("@title", tea.title);
     myCmd.Parameters.AddWithValue("@education", tea.education);
     myCmd.Parameters.AddWithValue("@course", tea.course);
     myCmd.Parameters.AddWithValue("@research", tea.research);
     myCmd.Parameters.AddWithValue("@article", tea.article);
     myCmd.Parameters.AddWithValue("@demand", tea.demand);
     myCmd.Parameters.AddWithValue("@institute", tea.institute);
     int i = myCmd.ExecuteNonQuery();
     myConn.Close();
     if (i > 0)
         return "修改信息成功";
     else
         return "修改信息失败";
 }
 //更新数据
 public int Update(teacher t)
 {
     return(tdal.Update(t));
 }
Example #11
0
        public static int SaveGroup(LIVEX.UserControls.NewGroup newGroup)
        {
            livexEntities context = new livexEntities();
            grupo         g       = new grupo();
            //grupo_categoria gc = new grupo_categoria();
            //ciclo c = new ciclo();

            string catname = newGroup.cmbCategoria.SelectionBoxItem.ToString();
            //int maxg = context.grupo.Count();
            //int maxc = context.ciclo.Count();
            //int maxgc = 0;
            string   clasificacion = "";
            string   nivel, dias = "", idioma = "";
            ComboBox cmb = new ComboBox();

            //maxgc = context.grupo_categoria.Count();

            if (newGroup.cmbTipo.Visibility == Visibility.Visible)
            {
                cmb = newGroup.cmbTipo;
            }
            else
            {
                cmb = newGroup.cmbTipo2;
            }

            if (cmb.Text == "A" || cmb.Text == "B")
            {
                clasificacion = "semi-Intensivo";
            }
            else
            {
                clasificacion = "Intensivo";
            }

            foreach (ListBoxItem i in newGroup.lstDias.SelectedItems)
            {
                dias = dias + " " + i.Content;
            }

            if (newGroup.chkingles.IsChecked == true)
            {
                idioma = "Inglés";
            }
            else
            {
                idioma = "Francés";
            }


            if (newGroup.cmbNivel4.Visibility == Visibility.Visible)
            {
                nivel = newGroup.cmbNivel4.SelectionBoxItem.ToString();
            }
            else
            {
                nivel = newGroup.cmbNivel12.SelectionBoxItem.ToString();
            }

            //c.Fecha_inicio = newGroup.dtpFechaInicio.Text;
            //c.Fecha_fin = newGroup.dtpFechaFin.Text;
            //c.ciclo_nombre = newGroup.cmbCiclo.SelectionBoxItem.ToString();

            //context.ciclo.Add(c);
            //context.SaveChanges();

            categoria catid = context.categoria.FirstOrDefault(x => x.categoria_nombre == catname && x.clasificacion == clasificacion);


            //gc.grupo_ID = maxg + 1;
            //gc.categoria_ID = catid.idcategoria;
            //gc.nivel = Int32.Parse(nivel);
            //gc.tipo = cmb.SelectionBoxItem.ToString();

            //context.grupo_categoria.Add(gc);
            //context.SaveChanges();

            g.nombre_nivel   = catname + " " + nivel + " " + cmb.SelectionBoxItem.ToString();
            g.Horario_inicio = newGroup.cmbHrInicio.SelectionBoxItem.ToString();
            g.Horario_fin    = newGroup.cmbHrFin.SelectionBoxItem.ToString();
            g.Dias           = dias;
            g.MaestroID      = Int32.Parse(newGroup.cmbTeacher.SelectedValue.ToString());
            teacher t = context.teacher.FirstOrDefault(x => x.idteacher == g.MaestroID);

            g.teacher = t;
            g.Idioma  = idioma;
            if (newGroup.cmbCicloEscolar.SelectedValue != null)
            {
                g.CicloID = Int32.Parse(newGroup.cmbCicloEscolar.SelectedValue.ToString());
                if (newGroup.dtpFechaInicioEscolar.Text != "")
                {
                    g.year = Convert.ToDateTime(newGroup.dtpFechaInicioEscolar.Text).Year;
                }
            }
            if (newGroup.cmbCiclo.SelectedValue != null)
            {
                g.CicloID = Int32.Parse(newGroup.cmbCiclo.SelectedValue.ToString());


                if (newGroup.dtpFechaInicio.Text != "" && newGroup.dtpFechaFin.Text != "")
                {
                    ciclo c = new ciclo();
                    c.ciclo_num    = (int)g.CicloID;
                    c.Fecha_inicio = newGroup.dtpFechaInicio.Text;
                    c.Fecha_fin    = newGroup.dtpFechaFin.Text;
                    c.ciclo_side   = "C";
                    c.ciclocol     = "C" + " " + g.nombre_nivel;
                    c.year         = Convert.ToDateTime(newGroup.dtpFechaInicio.Text).Year;
                    //context.ciclo.Add(c);
                    g.ciclo = c;
                    g.year  = Convert.ToDateTime(newGroup.dtpFechaInicio.Text).Year;
                }
            }
            //g.CategoriaID = maxgc + 1;
            //g.CicloID = maxc + 1;
            g.numero_alumnos  = Int32.Parse(newGroup.txtCantAlumnos.Text);
            g.grupo_categoria = new grupo_categoria();
            g.grupo_categoria.categoria_ID = catid.idcategoria;
            g.grupo_categoria.nivel        = Int32.Parse(nivel);
            g.grupo_categoria.tipo         = cmb.SelectionBoxItem.ToString();

            context.grupo.Add(g);
            //context.SaveChanges();



            return(context.SaveChanges());
        }
 //插入数据
 public int Add(teacher t)
 {
     return(tdal.Add(t));
 }
        public ActionResult DeleteTeacher(int id)
        {
            teacher t = data.teacher.Where(a => a.id == id).FirstOrDefault();

            return(View(t));
        }
Example #14
0
    public static bool Delete(teacher clsteacher)
    {
        SqlConnection connection = SchoolData.GetConnection();
        string        deleteStatement
            = "DELETE FROM "
              + "     [teacher] "
              + "WHERE "
              + "     [TeacherId] = @OldTeacherId "
              + " AND ((@OldClassId IS NULL AND [ClassId] IS NULL) OR [ClassId] = @OldClassId) "
              + " AND ((@OldFullName IS NULL AND [FullName] IS NULL) OR [FullName] = @OldFullName) "
              + " AND ((@OldDateOfJoin IS NULL AND [DateOfJoin] IS NULL) OR [DateOfJoin] = @OldDateOfJoin) "
              + " AND ((@OldHomeAddress IS NULL AND [HomeAddress] IS NULL) OR [HomeAddress] = @OldHomeAddress) "
              + " AND ((@OldPhoneNumber IS NULL AND [PhoneNumber] IS NULL) OR [PhoneNumber] = @OldPhoneNumber) "
              + "";
        SqlCommand deleteCommand = new SqlCommand(deleteStatement, connection);

        deleteCommand.CommandType = CommandType.Text;
        deleteCommand.Parameters.AddWithValue("@OldTeacherId", clsteacher.TeacherId);
        if (clsteacher.ClassId.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldClassId", clsteacher.ClassId);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldClassId", DBNull.Value);
        }
        if (clsteacher.FullName != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldFullName", clsteacher.FullName);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldFullName", DBNull.Value);
        }
        if (clsteacher.DateOfJoin.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldDateOfJoin", clsteacher.DateOfJoin);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldDateOfJoin", DBNull.Value);
        }
        if (clsteacher.HomeAddress != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldHomeAddress", clsteacher.HomeAddress);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldHomeAddress", DBNull.Value);
        }
        if (clsteacher.PhoneNumber != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldPhoneNumber", clsteacher.PhoneNumber);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldPhoneNumber", DBNull.Value);
        }
        try
        {
            connection.Open();
            int count = deleteCommand.ExecuteNonQuery();
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            throw ex;
        }
        finally
        {
            connection.Close();
        }
    }
 partial void Updateteacher(teacher instance);
 public ActionResult UploadFile(HttpPostedFileBase file, uploadnote uploadnote, @class classid, section section, teacher teacher)
 {
     if ((string)Session["user"] != null)
     {
         smsEntities data = new smsEntities();
         try
         {
             if (file.ContentLength > 0)
             {
                 string FileName = Path.GetFileName(file.FileName);
                 string path     = Path.Combine(Server.MapPath("~/UploadedFiles"), FileName);
                 file.SaveAs(path);
             }
             ViewBag.Message = "File Uploaded Successfully!!";
             return(View());
         }
         catch
         {
             ViewBag.Message = "File upload failed!!";
             return(View());
         }
     }
     return(RedirectToAction("Login", "User"));
 }
 partial void Deleteteacher(teacher instance);
Example #18
0
    public static bool Add(teacher clsteacher)
    {
        SqlConnection connection = SchoolData.GetConnection();
        string        insertStatement
            = "INSERT "
              + "     [teacher] "
              + "     ( "
              + "     [ClassId] "
              + "    ,[FullName] "
              + "    ,[DateOfJoin] "
              + "    ,[HomeAddress] "
              + "    ,[PhoneNumber] "
              + "     ) "
              + "VALUES "
              + "     ( "
              + "     @ClassId "
              + "    ,@FullName "
              + "    ,@DateOfJoin "
              + "    ,@HomeAddress "
              + "    ,@PhoneNumber "
              + "     ) "
              + "";
        SqlCommand insertCommand = new SqlCommand(insertStatement, connection);

        insertCommand.CommandType = CommandType.Text;
        if (clsteacher.ClassId.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@ClassId", clsteacher.ClassId);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@ClassId", DBNull.Value);
        }
        if (clsteacher.FullName != null)
        {
            insertCommand.Parameters.AddWithValue("@FullName", clsteacher.FullName);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@FullName", DBNull.Value);
        }
        if (clsteacher.DateOfJoin.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@DateOfJoin", clsteacher.DateOfJoin);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@DateOfJoin", DBNull.Value);
        }
        if (clsteacher.HomeAddress != null)
        {
            insertCommand.Parameters.AddWithValue("@HomeAddress", clsteacher.HomeAddress);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@HomeAddress", DBNull.Value);
        }
        if (clsteacher.PhoneNumber != null)
        {
            insertCommand.Parameters.AddWithValue("@PhoneNumber", clsteacher.PhoneNumber);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@PhoneNumber", DBNull.Value);
        }
        try
        {
            connection.Open();
            int count = insertCommand.ExecuteNonQuery();
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            throw ex;
        }
        finally
        {
            connection.Close();
        }
    }