Exemplo n.º 1
0
        private void courseAddButton_Click(object sender, EventArgs e)
        {
            addTeacherObj = new AddTeacherClass();

            addTeacherObj.TeacherId     = teacherIdTextBox.Text;
            addTeacherObj.TeacherName   = teacherNameTextBox.Text;
            addTeacherObj.TeacherDesign = designationTextBox.Text;
            addTeacherObj.DeptName      = dNameComboBox.Text;
            addTeacherObj.Password      = passwordTextBox.Text;

            if ((teacherIdTextBox.Text == "") || (teacherNameTextBox.Text == "") || (designationTextBox.Text == "") || (dNameComboBox.Text == "") || (passwordTextBox.Text == ""))
            {
                MessageBox.Show("Please Fill-Up all field");

                this.Update();
            }
            else
            {
                gateways = new Gateway();

                if (gateways.InserIntoTeacherInfoTable(addTeacherObj) == 1)
                {
                    MessageBox.Show("Information Added Successfully!!!");
                    teacherResetButton_Click(sender, e);
                }
                else
                {
                    MessageBox.Show("Already Added \"" + teacherNameTextBox.Text + "\"");
                }
            }
        }
Exemplo n.º 2
0
        public int InserIntoTeacherInfoTable(AddTeacherClass addTeacherObj)
        {
            string ID = null;

            connection.Open();
            string        queryString = "SELECT Teacher_ID FROM Teacher_Info_Table WHERE Teacher_ID=('" + addTeacherObj.TeacherId + "') ";
            SqlCommand    cmd         = new SqlCommand(queryString, connection);
            SqlDataReader reader      = cmd.ExecuteReader();

            while (reader.Read())
            {
                ID = reader["Teacher_ID"].ToString();
            }
            connection.Close();

            if (ID == addTeacherObj.TeacherId)
            {
                return(0);
            }
            else
            {
                connection.Open();
                string insertString = "INSERT INTO Teacher_Info_Table VALUES('" + addTeacherObj.TeacherId + "', '" + addTeacherObj.TeacherName + "', '" + addTeacherObj.TeacherDesign + "', '" + Call_DeptID(addTeacherObj.DeptName) + "', '" + addTeacherObj.Password + "')";

                SqlCommand command = new SqlCommand(insertString, connection);
                command.ExecuteNonQuery();
                connection.Close();
                return(1);
            }
        }
Exemplo n.º 3
0
        public void UpdateTeacherInfoTable(AddTeacherClass addTeacherOb)
        {
            connection.Open();
            string insertString = "UPDATE  Teacher_Info_Table SET Teacher_Name='" + addTeacherOb.TeacherName + "', Designation='" + addTeacherOb.TeacherDesign + "',Dept_ID='" + Call_DeptID(addTeacherOb.DeptName) + "',Password='******' WHERE Teacher_ID='" + addTeacherOb.TeacherId + "'";

            SqlCommand command = new SqlCommand(insertString, connection);

            command.ExecuteNonQuery();
            connection.Close();
        }
Exemplo n.º 4
0
        private void teacherUpdateButton_Click(object sender, EventArgs e)
        {
            addTeacherObj = new AddTeacherClass();

            addTeacherObj.TeacherId     = teacherIdTextBox.Text;
            addTeacherObj.TeacherName   = teacherNameTextBox.Text;
            addTeacherObj.TeacherDesign = designationTextBox.Text;
            addTeacherObj.DeptName      = dNameComboBox.Text;


            if (teacherIdTextBox.Text == "" || teacherNameTextBox.Text == "" || designationTextBox.Text == "")
            {
                MessageBox.Show("Could not Update!");
            }
            else
            {
                gateways.UpdateTeacherInfoTable(addTeacherObj);
                MessageBox.Show("Information Updated Successfully!");
            }
        }