Example #1
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int SelectedSurveysCount = listView_AllSurveys.SelectedItems.Count;

            MaterialMessageBox.MessageBoxResult result = MaterialMessageBox.MessageBoxResult.None;
            string TextMessage = "Sunteti sigur ca vrei sa stergeti chestionarele selectate?";

            MaterialMessageBox.MessageBoxIcon IconMessage = MaterialMessageBox.MessageBoxIcon.Warning;

            //Check if any Question from Surveys are contained into Attitudes
            long QuestionsCount = 0;

            using (AttitudeController attitudeController = new AttitudeController())
                using (QuestionController questionController = new QuestionController())
                {
                    foreach (ListViewItem selectedItem in listView_AllSurveys.SelectedItems)
                    {
                        long            SurveyID  = Convert.ToInt64(selectedItem.Tag);
                        List <Question> Questions = questionController.GetQuestionsForSurvey(SurveyID);

                        foreach (Question question in Questions)
                        {
                            if (attitudeController.Contains(question.QuestionID))
                            {
                                ++QuestionsCount;
                            }
                        }
                    }
                }

            if (QuestionsCount > 0)
            {
                IconMessage  = MaterialMessageBox.MessageBoxIcon.Error;
                TextMessage += Environment.NewLine + QuestionsCount + " (de) intrebari sunt continute in cateva Definitii de Atitudini(daca selectati DA acestea vor fi sterse din Definitii).";
            }

            if (SelectedSurveysCount > 0)
            {
                result = MaterialMessageBox.Show(TextMessage, "Easy Survey - Delete Surveys", MaterialMessageBox.MessageBoxButtons.YesNo, IconMessage);
            }

            if (result == MaterialMessageBox.MessageBoxResult.Yes)
            {
                using (SurveyController surveyController = new SurveyController())
                    foreach (ListViewItem selectedItem in listView_AllSurveys.SelectedItems)
                    {
                        long SurveyID = Convert.ToInt64(selectedItem.Tag);

                        Surveys.Remove(Surveys.Find(i => i.SurveyID == SurveyID));
                        surveyController.Delete(SurveyID);
                        listView_AllSurveys.Items.Remove(selectedItem);
                    }
            }
        }
Example #2
0
        private void toolStripMenuItem_DeleteQuestions_Click(object sender, EventArgs e)
        {
            int SelectedQuestionsCount = listView_EditSurveyQuestions.SelectedItems.Count;

            MaterialMessageBox.MessageBoxResult result = MaterialMessageBox.MessageBoxResult.None;
            string TextMessage = "Sunteti sigur ca vrei sa stergeti intrebarile selectate?";

            MaterialMessageBox.MessageBoxIcon IconMessage = MaterialMessageBox.MessageBoxIcon.Warning;

            long QuestionCount = 0;

            using (AttitudeController attitudeController = new AttitudeController())
                foreach (ListViewItem selectedItem in listView_EditSurveyQuestions.SelectedItems)
                {
                    long QuestionID = Convert.ToInt64(selectedItem.Tag);

                    if (attitudeController.Contains(QuestionID))
                    {
                        QuestionCount++;
                    }
                }

            if (QuestionCount > 0)
            {
                TextMessage += Environment.NewLine + QuestionCount + " (de) intrebari sunt continute in Definitii de Atitudini(daca selectati DA acestea vor fi sterse din Definitii)";
                IconMessage  = MaterialMessageBox.MessageBoxIcon.Error;
            }

            if (SelectedQuestionsCount > 0)
            {
                result = MaterialMessageBox.Show(TextMessage, "Easy Survey - Delete Questions", MaterialMessageBox.MessageBoxButtons.YesNo, IconMessage);
            }

            if (result == MaterialMessageBox.MessageBoxResult.Yes)
            {
                using (QuestionController questionController = new QuestionController())
                    foreach (ListViewItem selectedItem in listView_EditSurveyQuestions.SelectedItems)
                    {
                        long QuestionID = Convert.ToInt64(selectedItem.Tag);
                        long SurveyID   = Convert.ToInt64(txt_EditSurveyDetailsName.Tag);

                        questionController.Delete(QuestionID, SurveyID);
                        listView_EditSurveyQuestions.Items.Remove(selectedItem);
                    }
            }
        }
Example #3
0
        public MsgBox(string text, string caption, MaterialMessageBox.MessageBoxButtons buttons, MaterialMessageBox.MessageBoxIcon icon)
        {
            InitializeComponent();

            __materialSkinManager = MaterialSkinManager.Instance;
            __materialSkinManager.AddFormToManage(this);
            __materialSkinManager.Theme       = MaterialSkinManager.Themes.LIGHT;
            __materialSkinManager.ColorScheme = new ColorScheme(Primary.Blue800, Primary.Blue900, Primary.Blue500, Accent.LightBlue200, TextShade.WHITE);

            btn_No.AutoSize     = false;
            btn_OK.AutoSize     = false;
            btn_Yes.AutoSize    = false;
            btn_Cancel.AutoSize = false;

            btn_No.Size     = new Size(127, 36);
            btn_OK.Size     = new Size(127, 36);
            btn_Yes.Size    = new Size(127, 36);
            btn_Cancel.Size = new Size(127, 36);

            base.Text     = caption;
            lbl_text.Text = text;

            switch (buttons)
            {
            case MaterialMessageBox.MessageBoxButtons.OK:
                btn_OK.Visible = true; btn_OK.Enabled = true;

                btn_OK.Location = new Point(base.Size.Width / 2 - btn_OK.Size.Width / 2, btn_OK.Location.Y);

                btn_Yes.Visible    = false; btn_Yes.Enabled = false;
                btn_No.Visible     = false; btn_No.Enabled = false;
                btn_Cancel.Visible = false; btn_Cancel.Enabled = false;
                break;

            case MaterialMessageBox.MessageBoxButtons.YesNo:
                btn_Yes.Visible = true; btn_Yes.Enabled = true;
                btn_No.Visible  = true; btn_No.Enabled = true;

                btn_OK.Visible     = false; btn_OK.Enabled = false;
                btn_Cancel.Enabled = false; btn_Cancel.Visible = false;

                break;

            case MaterialMessageBox.MessageBoxButtons.YesNoCancel:
                btn_Yes.Visible    = true; btn_Yes.Enabled = true;
                btn_Cancel.Enabled = true; btn_Cancel.Visible = true;
                btn_No.Visible     = true; btn_No.Enabled = true;
                break;

            default: break;
            }

            switch (icon)
            {
            case MaterialMessageBox.MessageBoxIcon.Error:
                pic_Icon.Image = Properties.Resources.icon_error_64x64;
                SystemSounds.Hand.Play();
                break;

            case MaterialMessageBox.MessageBoxIcon.Information:
                pic_Icon.Image = Properties.Resources.icon_information_64x64;
                SystemSounds.Asterisk.Play();
                break;

            case MaterialMessageBox.MessageBoxIcon.None:
                pic_Icon.Dispose();
                lbl_text.Location = new Point(12, 74);
                lbl_text.Size     = new Size(399, 131);
                break;

            case MaterialMessageBox.MessageBoxIcon.Question:
                pic_Icon.Image = Properties.Resources.icon_question_64x64;
                SystemSounds.Question.Play();
                break;

            case MaterialMessageBox.MessageBoxIcon.Warning:
                pic_Icon.Image = Properties.Resources.icon_warning_64x64;
                SystemSounds.Exclamation.Play();
                break;

            default: break;
            }
        }