private void CreateButton_Click(object sender, RoutedEventArgs e)
        {
            AnnouncementData.calculateErrors();

            if (organiserCombobox.SelectedIndex <= -1)
            {
                MessageBox.Show("Please select the department which is passing this information.");
            }
            else if (AnnouncementData.noDepartmentSelected)
            {
                MessageBox.Show("Please select at least one department which this announcement/notification has to be shown to.");
            }
            else
            {
                SqlCommand cmd = SQLServerConnection.initializeSqlCommand("insert into Announcement (event_heading, event_desc, org_branch, elig_branch, date_created) values (@heading, @desc, @org, @elig, @date)");
                cmd.Parameters.AddWithValue("@heading", AnnouncementData.announcementTitle);
                cmd.Parameters.AddWithValue("@desc", AnnouncementData.announcementDetails);
                cmd.Parameters.AddWithValue("@org", organiserCombobox.SelectedIndex);
                cmd.Parameters.AddWithValue("@elig", AnnouncementData.eligibleBranches());

                DateTime myDateTime       = DateTime.Now;
                string   sqlFormattedDate = myDateTime.ToString("yyyy-MM-dd HH:mm:ss.fff");

                cmd.Parameters.AddWithValue("@date", sqlFormattedDate);

                cmd.ExecuteNonQuery();

                cmd.Parameters.Clear();
                SQLServerConnection.closeConnection();

                AnnouncementWindow aw = new AnnouncementWindow(true);
                aw.Show();
                this.Close();
            }
        }
Exemplo n.º 2
0
        private void switchButton_Click(object sender, RoutedEventArgs e)
        {
            AnnouncementWindow a1 = new AnnouncementWindow(true);

            a1.Show();
            this.Close();
        }
Exemplo n.º 3
0
        private void loginButton_Click(object sender, RoutedEventArgs e)
        {
            loginButton.Background = (Brush)(new BrushConverter().ConvertFrom("#FF82B3C9"));
            exceptionLabel.Content = "";

            if (!(isTeacher || isStudent))
            {
                MessageBox.Show(" Please Select Student Or Teacher.", "Select User Type");
            }
            else
            {   //SQL Command template.
                //SqlCommand cmd = SQLServerConnection.initializeSqlCommand("");
                //body
                //SQLServerConnection.closeConnection();

                SqlCommand cmd = SQLServerConnection.initializeSqlCommand("select count(*) from LoginTable where usn=@usn and pwd=@pwd and usertype=@usertype");

                char usertype         = ' ';
                bool studentOrTeacher = false;

                if (isTeacher)
                {
                    usertype         = 't';
                    studentOrTeacher = true;
                }
                if (isStudent)
                {
                    usertype         = 's';
                    studentOrTeacher = false;
                }


                cmd.Parameters.AddWithValue("@usn", userIdValue.Text);
                cmd.Parameters.AddWithValue("@pwd", passwordValue.Password);
                cmd.Parameters.AddWithValue("@usertype", usertype);

                int count = Convert.ToInt32(cmd.ExecuteScalar());

                if (count > 0)
                {
                    AnnouncementWindow announcement = new AnnouncementWindow(studentOrTeacher);
                    announcement.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Username or password is incorrect.");
                    userIdValue.Text       = "";
                    passwordValue.Password = "";
                }

                cmd.Parameters.Clear();
                SQLServerConnection.closeConnection();
            }

            /*if(isTeacher&&isStudent)
             *  exceptionLabel.Content = "**Student/Teacher Button NOT Selected**";*/
        }
Exemplo n.º 4
0
        private void prevButton_Click(object sender, RoutedEventArgs e)
        {
            AnnouncementData.wasPreviousButtonClicked = true;
            AnnouncementData.wasNextButtonClicked     = false;
            AnnouncementWindow aw = new AnnouncementWindow(true);

            aw.Show();
            this.Close();
        }