Exemple #1
0
        /// <summary>
        /// Remove the selected element in the list.
        /// </summary>
        private void Btn_Admin_Delete_Click(object sender, EventArgs e)
        {
            if (List_Admin_Items.SelectedIndex != MyronWebUAT.admin_notSelected)
            {
                int indexToRemove = List_Admin_Items.SelectedIndex;

                if (Cmb_Admin_ContentType.SelectedIndex == MyronWebUAT.admin_contenttype_dataRows)
                {
                }
                else if (Cmb_Admin_ContentType.SelectedIndex == MyronWebUAT.admin_contenttype_standardTranslations)
                {
                    controller.standardTranslations.RemoveAt(indexToRemove);
                }
                else if (Cmb_Admin_ContentType.SelectedIndex == MyronWebUAT.admin_contenttype_valuedFixedTranslations)
                {
                    controller.fixedTranslations.RemoveAt(indexToRemove);
                }
                else if (Cmb_Admin_ContentType.SelectedIndex == MyronWebUAT.admin_contenttype_valuedConditionedTranslations)
                {
                    controller.conditionedTranslations.RemoveAt(indexToRemove);
                }
                else if (Cmb_Admin_ContentType.SelectedIndex == MyronWebUAT.admin_contenttype_templates)
                {
                    controller.templates.RemoveAt(indexToRemove);
                }

                controller.SaveWebUATJsonData();
                FillAdminList(Cmb_Admin_ContentType.SelectedIndex);
                ToggleEditorGroups(MyronWebUAT.admin_notSelected);
                //Clicking cancel restore all the buttons to the normal status
                Btn_Admin_Cancel.PerformClick();
            }
        }
Exemple #2
0
        /// <summary>
        /// This method enables the admin buttons (New, Edit, Save). For this to be effective, the default tab when the app
        /// opens must be Measurements.
        /// </summary>
        private void TabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            Btn_Admin_Cancel.PerformClick();

            //If the Tab is changed to other that is not admin, set the edition mode to none to prevent undesired changes if save is clicked later
            if (TabControl.SelectedIndex != MyronWebUAT.tab_admin)
            {
                admin_EditionMode = MyronWebUAT.admin_editmode_none;
            }
        }
Exemple #3
0
        /// <summary>
        /// Called when Save button in Admin is called. It will internally evaluate if it's gonna save a new translation or an edition.
        /// </summary>
        private void Btn_Admin_Save_Click(object sender, EventArgs e)
        {
            bool saveToFile = false;

            if (admin_EditionMode == MyronWebUAT.admin_editmode_new)
            {
                if (Cmb_Admin_ContentType.SelectedIndex == MyronWebUAT.admin_contenttype_dataRows && ValidateDataRow())
                {
                    currentDataRow.description = Text_DataRow_Description.Text;
                    controller.dataRows.Add(currentDataRow);
                    //The newDataRow variable is cleaned after save on ToggleEditorGroups call
                    saveToFile = true;
                }
                else if (Cmb_Admin_ContentType.SelectedIndex == MyronWebUAT.admin_contenttype_standardTranslations && ValidateStandardTranslations())
                {
                    Translation stdTranslation = new Translation(Text_TextOnly_EngMY.Text, Text_TextOnly_EngCAAZ.Text, Text_TextOnly_FRCA.Text);
                    controller.standardTranslations.Add(stdTranslation);
                    saveToFile = true;
                }
                else if (Cmb_Admin_ContentType.SelectedIndex == MyronWebUAT.admin_contenttype_valuedFixedTranslations && ValidateFixedTranslations())
                {
                    ValuedFixedTranslation fixedTranslation = new ValuedFixedTranslation(Text_Fixed_MY.Text, Text_Fixed_CAAZ.Text,
                                                                                         Text_Fixed_CAFR.Text, Cmb_Fixed_ValueType.SelectedIndex, Text_Fixed_ValueDescription.Text, Chck_Fixed_CanUseVariable.Checked, Text_Fixed_Variable.Text);
                    controller.fixedTranslations.Add(fixedTranslation);
                    saveToFile = true;
                }
                else if (Cmb_Admin_ContentType.SelectedIndex == MyronWebUAT.admin_contenttype_valuedConditionedTranslations && ValidateConditionedTranslations())
                {
                    ValuedConditionedTranslation conditionedTranslation = new ValuedConditionedTranslation(Text_Cdtl_MY.Text, Text_Cdtl_CAAZ.Text, Text_Cdtl_CAFR.Text,
                                                                                                           Text_Cdtl_ValueDescriptor.Text, Chck_Cdtl_UsesVariable.Checked, Text_Cdtl_Variable.Text, Cmb_Cdtl_ConditionType.SelectedIndex,
                                                                                                           Text_Cdtl_ElseMY.Text, Text_Cdtl_ElseCAAZ.Text, Text_Cdtl_ElseFRCA.Text);
                    controller.conditionedTranslations.Add(conditionedTranslation);
                    saveToFile = true;
                }
                else if (Cmb_Admin_ContentType.SelectedIndex == MyronWebUAT.admin_contenttype_templates && ValidateTemplate())
                {
                    currentTemplate.templateName = Text_Temp_Description.Text;
                    controller.templates.Add(currentTemplate);
                    //The currentTemplate variable is cleaned after save on ToggleEditorGroups call
                    saveToFile = true;
                }
            }
            else if (admin_EditionMode == MyronWebUAT.admin_editmode_edit)
            {
                if (Cmb_Admin_ContentType.SelectedIndex == MyronWebUAT.admin_contenttype_dataRows && ValidateDataRow())
                {
                    controller.dataRows[List_Admin_Items.SelectedIndex] = currentDataRow;
                    saveToFile = true;
                }
                else if (Cmb_Admin_ContentType.SelectedIndex == MyronWebUAT.admin_contenttype_standardTranslations && ValidateStandardTranslations())
                {
                    controller.standardTranslations[List_Admin_Items.SelectedIndex].FillTranslation(Text_TextOnly_EngMY.Text, Text_TextOnly_EngCAAZ.Text, Text_TextOnly_FRCA.Text);
                    saveToFile = true;
                }
                else if (Cmb_Admin_ContentType.SelectedIndex == MyronWebUAT.admin_contenttype_valuedFixedTranslations && ValidateFixedTranslations())
                {
                    controller.fixedTranslations[List_Admin_Items.SelectedIndex].FillValuedFixedTranslation(Text_Fixed_MY.Text, Text_Fixed_CAAZ.Text,
                                                                                                            Text_Fixed_CAFR.Text, Cmb_Fixed_ValueType.SelectedIndex, Text_Fixed_ValueDescription.Text, Chck_Fixed_CanUseVariable.Checked, Text_Fixed_Variable.Text);
                    saveToFile = true;
                }
                else if (Cmb_Admin_ContentType.SelectedIndex == MyronWebUAT.admin_contenttype_valuedConditionedTranslations && ValidateConditionedTranslations())
                {
                    controller.conditionedTranslations[List_Admin_Items.SelectedIndex].FillValuedConditionedTranslation(Text_Cdtl_MY.Text, Text_Cdtl_CAAZ.Text, Text_Cdtl_CAFR.Text,
                                                                                                                        Text_Cdtl_ValueDescriptor.Text, Chck_Cdtl_UsesVariable.Checked, Text_Cdtl_Variable.Text, Cmb_Cdtl_ConditionType.SelectedIndex,
                                                                                                                        Text_Cdtl_ElseMY.Text, Text_Cdtl_ElseCAAZ.Text, Text_Cdtl_ElseFRCA.Text);
                    saveToFile = true;
                }
                else if (Cmb_Admin_ContentType.SelectedIndex == MyronWebUAT.admin_contenttype_templates && ValidateTemplate())
                {
                    currentTemplate.templateName = Text_Temp_Description.Text;
                    controller.templates[List_Admin_Items.SelectedIndex] = currentTemplate;
                    saveToFile = true;
                }
            }

            if (saveToFile)
            {
                controller.SaveWebUATJsonData();
                FillAdminList(Cmb_Admin_ContentType.SelectedIndex);
                ToggleEditorGroups(MyronWebUAT.admin_notSelected);
                //Clicking cancel restore all the buttons to the normal status
                Btn_Admin_Cancel.PerformClick();
            }
        }