Exemple #1
0
        private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
        {
            // The undo / redo stack collections are not "Observable", so we
            // need to manually refresh the UI when they change.
            var root = UndoService.Current[this];

            root.UndoStackChanged += new EventHandler(OnUndoStackChanged);
            root.RedoStackChanged += new EventHandler(OnRedoStackChanged);
            FirstNameTextbox.Focus();
        }
Exemple #2
0
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            if (UpdateButton.Text == "UPDATE INFORMATION")
            {
                UpdateButton.Text     = "SAVE ALL";
                UpdateButton.Size     = new Size(95, 30);
                UpdateButton.Location = new Point(901, 445);
                ResetButton.Visible   = true;

                EnableControls();
                FirstNameTextbox.Focus();
            }

            else if (UpdateButton.Text == "SAVE ALL")
            {
                //EXCEPTION 2
                try
                {
                    opacityform        = new OpacityForm();
                    cryptography       = new Cryptography();
                    darkeropacityform  = new DarkerOpacityForm();
                    notificationwindow = new NotificationWindow();

                    if (FirstNameTextbox.Text.Trim().Length < 1 || MiddleNameTextbox.Text.Trim().Length < 1 || LastNameTextbox.Text.Trim().Length < 1 ||
                        BirthDateTextbox.Text.Trim().Length < 1 || GenderTextbox.Text.Length < 1 || BloodTypeTextbox.Text.Trim().Length < 1 ||
                        PresentAddressTextbox.Text.Trim().Length < 1 || ReligionTextbox.Text.Trim().Length < 1 || EmailAddressTextbox.Text.Trim().Length < 1 ||
                        MobileNumberTextbox.Text.Trim().Length < 1)
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "PLEASE PROVIDE THE REQUIRED\nINFORMATIONS BEING ASK !";

                        darkeropacityform.Show();
                        notificationwindow.ShowDialog();
                        darkeropacityform.Hide();
                    }

                    else if (!EmailAddressTextbox.Text.Trim().Contains("@") || !EmailAddressTextbox.Text.Trim().Contains(".com"))
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "PLEASE PROVIDE A VALID EMAIL ADDRESS !";

                        darkeropacityform.Show();
                        notificationwindow.ShowDialog();
                        darkeropacityform.Hide();
                    }

                    else if (MobileNumberTextbox.Text.Trim().Length < 11 || MobileNumberTextbox.Text.Trim().Length > 11)
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "PHONE NUMBER MUST BE 11-DIGITS LONG !";

                        darkeropacityform.Show();
                        notificationwindow.ShowDialog();
                        darkeropacityform.Hide();
                    }

                    else if (isNumber(MobileNumberTextbox.Text.Trim()) == false)
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "PHONE NUMBER CONTAIN AN INVALID\nCHARACTERS !";

                        darkeropacityform.Show();
                        notificationwindow.ShowDialog();
                        darkeropacityform.Hide();
                    }

                    else
                    {
                        //INNER EXCEPTION 2
                        try
                        {
                            string alterquery = "UPDATE [Tbl.Teachers] SET [FIRST NAME] = @fname, [MIDDLE NAME] = @mname, [LAST NAME] = @lname," +
                                                "GENDER = @gender, [BIRTH DATE] = @bdate, [PRESENT ADDRESS] = @paddress, RELIGION = @religion, [BLOOD TYPE] = @btype," +
                                                "[EMAIL ADDRESS] = @eaddress, [MOBILE NUMBER] = @mnumber WHERE [USER ID] = '" + UserID + "'";
                            sqlcommand = new SqlCommand(alterquery, sqlconnection);

                            sqlcommand.Parameters.AddWithValue("@fname", FirstNameTextbox.Text.Trim());
                            sqlcommand.Parameters.AddWithValue("@mname", MiddleNameTextbox.Text.Trim());
                            sqlcommand.Parameters.AddWithValue("@lname", LastNameTextbox.Text.Trim());
                            sqlcommand.Parameters.AddWithValue("@gender", GenderTextbox.Text.Trim());

                            sqlcommand.Parameters.AddWithValue("@bdate", BirthDateTextbox.Text.Trim());
                            sqlcommand.Parameters.AddWithValue("@paddress", PresentAddressTextbox.Text.Trim());
                            sqlcommand.Parameters.AddWithValue("@religion", ReligionTextbox.Text.Trim());

                            sqlcommand.Parameters.AddWithValue("@btype", BloodTypeTextbox.Text.Trim());
                            sqlcommand.Parameters.AddWithValue("@eaddress", EmailAddressTextbox.Text.Trim());
                            sqlcommand.Parameters.AddWithValue("@mnumber", MobileNumberTextbox.Text.Trim());
                            sqlcommand.ExecuteNonQuery();

                            notificationwindow.CaptionText    = "MESSAGE CONTENT";
                            notificationwindow.MsgImage.Image = Properties.Resources.check;
                            notificationwindow.MessageText    = "SUCCESSFULLY UPDATED !";

                            darkeropacityform.Show();
                            notificationwindow.ShowDialog();
                            darkeropacityform.Hide();

                            UpdateButton.Text     = "UPDATE INFORMATION";
                            UpdateButton.Size     = new Size(170, 30);
                            UpdateButton.Location = new Point(826, 445);

                            ResetButton.Visible = false;
                            DisableControls();
                        }

                        catch (Exception exception)
                        {
                            opacityform.Show();
                            MessageBox.Show(exception.Message.ToString(), "Account Information Form Inner Exception 2",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);

                            opacityform.Hide();
                        }
                    }
                }

                catch (Exception exception)
                {
                    opacityform.Show();
                    MessageBox.Show(exception.Message.ToString(), "Account Information Form Exception 2",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);

                    opacityform.Hide();
                }
            }
        }