Esempio n. 1
0
        private void Btn_DataRow_Add_Click(object sender, EventArgs e)
        {
            if (dataRowNewPart == MyronWebUAT.dataType_customText && Text_DataRow_CustomText.Text != "")
            {
                Translation customText = new Translation(MyronWebUAT.dataType_customText, Text_DataRow_CustomText.Text, Text_DataRow_CustomText.Text, Text_DataRow_CustomText.Text);
                //Save the new customText in the controller
                controller.customTextTranslations.Add(customText);
                //New Custom text created and added to the datarow
                currentDataRow.dataRowParts.Add(customText.translationID);
                //Update the list
                List_DataRow_Parts.Items.Add(customText.eng_MY);
                List_DataRow_Parts.Refresh();
                RefreshFinalDataRowTextBox();
                HideDataRowCustomTextField();
            }
            else if (dataRowNewPart == MyronWebUAT.dataType_stdTranslation && Cmb_DataRow_Translations.SelectedIndex != MyronWebUAT.admin_notSelected)
            {
                Translation stdTranslation = controller.standardTranslations[Cmb_DataRow_Translations.SelectedIndex];
                //Std translation added to the datarow
                currentDataRow.dataRowParts.Add(stdTranslation.translationID);
                //Update the list
                List_DataRow_Parts.Items.Add(stdTranslation.eng_MY);
                List_DataRow_Parts.Refresh();
                RefreshFinalDataRowTextBox();
                //Make the Cmb visilble and its label
                Cmb_DataRow_Translations.Visible      = false;
                Lbl_DataRow_SelectTranslation.Visible = false;
                Cmb_DataRow_Translations.Items.Clear();
            }
            else if (dataRowNewPart == MyronWebUAT.dataType_fixedTranslation && Cmb_DataRow_Translations.SelectedIndex != MyronWebUAT.admin_notSelected)
            {
                ValuedFixedTranslation fixedTranslation = controller.fixedTranslations[Cmb_DataRow_Translations.SelectedIndex];
                //Fixed translation added to the datarow
                currentDataRow.dataRowParts.Add(fixedTranslation.translationID);
                //Update the list with the description
                List_DataRow_Parts.Items.Add(fixedTranslation.valueDescription);
                List_DataRow_Parts.Refresh();
                RefreshFinalDataRowTextBox();
                //Make the Cmb visilble and its label
                Cmb_DataRow_Translations.Visible      = false;
                Lbl_DataRow_SelectTranslation.Visible = false;
                Cmb_DataRow_Translations.Items.Clear();
            }
            else if (dataRowNewPart == MyronWebUAT.dataType_conditionedTranslation && Cmb_DataRow_Translations.SelectedIndex != MyronWebUAT.admin_notSelected)
            {
                ValuedConditionedTranslation conditionedTranslation = controller.conditionedTranslations[Cmb_DataRow_Translations.SelectedIndex];
                //Conditioned translation added to the datarow
                currentDataRow.dataRowParts.Add(conditionedTranslation.translationID);
                //Update the list with the description
                List_DataRow_Parts.Items.Add(conditionedTranslation.valueDescription);
                List_DataRow_Parts.Refresh();
                RefreshFinalDataRowTextBox();
                //Make the Cmb visilble and its label
                Cmb_DataRow_Translations.Visible      = false;
                Lbl_DataRow_SelectTranslation.Visible = false;
                Cmb_DataRow_Translations.Items.Clear();
            }

            Text_DataRow_CustomText.Text = "";
            Btn_DataRow_Cancel.PerformClick();
        }
Esempio n. 2
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();
            }
        }