Exemple #1
0
        public bool DeletACourseFromDB(CourseO aCoursesInformation)
        {
            SqlConnection connection = DatabaseConnection.openAnanotherSqlConnection();
            string query = "DELETE  CoursesInformation WHERE CId ='" + aCoursesInformation.Id + "'"; 
            SqlCommand command = new SqlCommand(query, connection);
            int rowsAffected = command.ExecuteNonQuery();
            if (rowsAffected == 1)
            {
                command.Dispose();
                return true;
            }
            else
            {
                command.Dispose();
                return false;
            }

        }
Exemple #2
0
        //public bool UpdateNewStudentToDB(Student aStudent)
        //{
        //    SqlConnection connection = DatabaseConnection.openAnSqlConnection();
        //    string query = "Update Student SET Name ='" + aStudent.Name + "',Age = " + aStudent.Age + ",Faculty ='" + aStudent.Faculty + "', ParmanentAdress = '" + aStudent.ParmanentAdress + "', PresentAdress ='" + aStudent.PresentAdress + "', Gender ='" + aStudent.Gender
        //    + "',ContactNo = '" + aStudent.ContactNo + "',BloodGroup = '" + aStudent.Bloodgroup + "' Where  Id ='" + aStudent.Id + "' ";
        //    SqlCommand command = new SqlCommand(query, connection);
        //    int rowsAffected = command.ExecuteNonQuery();
        //    if (rowsAffected == 1)
        //    {
        //        command.Dispose();
        //        return true;
        //    }
        //    else
        //    {
        //        command.Dispose();
        //        return false;
        //    }

        //}
        //public bool DeleteAStudentFromDB(Student aStudent)
        //{
        //    SqlConnection connection = DatabaseConnection.openAnSqlConnection();
        //    string query = "DELETE FROM Student WHERE Id ='" + aStudent.Id + "'";
        //    SqlCommand command = new SqlCommand(query, connection);
        //    int rowsAffected = command.ExecuteNonQuery();
        //    if (rowsAffected == 1)
        //    {
        //        command.Dispose();
        //        return true;
        //    }
        //    else
        //    {
        //        command.Dispose();
        //        return false;
        //    }

        //}
        public bool UpdateNewCourseToDB(CourseO aCoursesInformation)
        {
            SqlConnection connection = DatabaseConnection.openAnanotherSqlConnection();
            string query = "Update CoursesInformation SET CourseName ='" + aCoursesInformation.Name + "',  CourseCredit = '" + aCoursesInformation.Credit + "', Semister ='" + aCoursesInformation.Semister + "',Teacher = '" + aCoursesInformation.Teacher + "', CourseFee = " + aCoursesInformation.CourseFee + " where CID='"+aCoursesInformation .Id+"' ";
            SqlCommand command = new SqlCommand(query, connection);
            int rowsAffected = command.ExecuteNonQuery();
            if (rowsAffected == 1)
            {
                command.Dispose();
                return true;
            }
            else
            {
                command.Dispose();
                return false;
            }

        }
Exemple #3
0
   //     private object aCoursesUI;

        public bool SaveNewCourseToDB(CourseO  aCoursesInformation)
        {
            SqlConnection connection = DatabaseConnection.openAnanotherSqlConnection();
            string query = "INSERT INTO CoursesInformation VALUES('" + aCoursesInformation.Name+ "','" + aCoursesInformation.Id + "','" + aCoursesInformation.Credit + "','" + aCoursesInformation.Semister + "','" + aCoursesInformation.Teacher + "'," + aCoursesInformation.CourseFee+")";
            SqlCommand command = new SqlCommand(query, connection);
            int rowsAffected = command.ExecuteNonQuery();
            if (rowsAffected == 1)
            {
                command.Dispose();
                return true;
            }
            else
            {
                command.Dispose();
                return false;
            }

        }
        //private void backbutton1_Click(object sender, EventArgs e)
        //{
        //    Courses CoursesUI = new Courses();
        //    CoursesUI.Show();
        //    this.Hide();
        //}

        private void confirmbutton1_Click(object sender, EventArgs e)
        {
            DAL.DAO.CourseO aCourseInfo = new DAL.DAO.CourseO();
            aCourseInfo.Name = coursenametextBox.Text;
            aCourseInfo.Id   = courseidtextBox.Text;

            aCourseInfo.Credit = 0;
            double.TryParse(CredittextBox.Text, out aCourseInfo.Credit);



            aCourseInfo.Semister  = semistertextBox.Text;
            aCourseInfo.Teacher   = teachertextBox.Text;
            aCourseInfo.CourseFee = coursefeetextBox.Text;

            CourseBL CourseBLOBJ = new CourseBL();
            bool     result      = CourseBLOBJ.ValidateNewCourseandSendToDA(aCourseInfo);

            if (result)
            {
                MessageBox.Show("A NEW COURSE ADDED");
                //this.populateDataGriedview();
                this.PopulateDatagridview();
                Updatebutton.Enabled      = true;
                deletcoursebutton.Enabled = true;
                CANCELbutton1.Enabled     = true;


                confirmbutton1.Enabled = true;

                coursenametextBox.Text = " ";
                courseidtextBox.Text   = " ";
                CredittextBox.Text     = " ";
                semistertextBox.Text   = " ";
                teachertextBox.Text    = " ";
                coursefeetextBox.Text  = " ";
            }
            else
            {
                MessageBox.Show("RESULT: " + CourseBLOBJ.Message);
            }
        }
        private void deletcoursebutton_Click(object sender, EventArgs e)
        {
            DAL.DAO.CourseO aCourseInfo = new DAL.DAO.CourseO();
            aCourseInfo.Name   = coursenametextBox.Text;
            aCourseInfo.Id     = courseidtextBox.Text;
            aCourseInfo.Credit = 0;

            double.TryParse(CredittextBox.Text, out aCourseInfo.Credit);

            aCourseInfo.Semister  = semistertextBox.Text;
            aCourseInfo.Teacher   = teachertextBox.Text;
            aCourseInfo.CourseFee = coursefeetextBox.Text;

            CourseBL CourseBLOBJ = new CourseBL();
            bool     result      = CourseBLOBJ.DeletACourseBL(aCourseInfo);

            if (result)
            {
                MessageBox.Show("The Course is Delete FromDB...!!!");
                this.PopulateDatagridview();
                Updatebutton.Enabled      = true;
                deletcoursebutton.Enabled = true;
                CANCELbutton1.Enabled     = true;
                confirmbutton1.Enabled    = true;

                coursenametextBox.Text = " ";
                courseidtextBox.Text   = " ";
                CredittextBox.Text     = " ";
                semistertextBox.Text   = " ";
                teachertextBox.Text    = " ";
                coursefeetextBox.Text  = " ";
            }
            else
            {
                MessageBox.Show("RESULT: " + CourseBLOBJ.Message);
            }
        }