Exemple #1
0
        protected void btnSave_Click(Object Sender, EventArgs e)
        {
            int intWM = (intWMFlag == 1 || chkWrite.Checked ? 1 : 0);

            if (intConfig == 0)
            {
                int intOrder = oServiceEditor.GetConfigs(intService, intWM, 0).Tables[0].Rows.Count + 1;
                switch (strCode.ToUpper())
                {
                case "DATE":
                    intConfig = oServiceEditor.AddConfig(intService, intField, intWM, txtQuestion.Text, -1, Int32.Parse(txtMinimum.Text), Int32.Parse(txtMaximum.Text), -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", intOrder, 1);
                    break;

                case "TEXTBOX":
                    intConfig = oServiceEditor.AddConfig(intService, intField, intWM, txtQuestion.Text, Int32.Parse(txtLength.Text), Int32.Parse(txtWidth.Text), -1, -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", intOrder, 1);
                    break;

                case "TEXTAREA":
                    intConfig = oServiceEditor.AddConfig(intService, intField, intWM, txtQuestion.Text, -1, Int32.Parse(txtWidth.Text), Int32.Parse(txtRows.Text), -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", intOrder, 1);
                    break;

                case "USERS":
                case "SERVERS":
                case "MNEMONICS":
                case "APPROVER":
                    intConfig = oServiceEditor.AddConfig(intService, intField, intWM, txtQuestion.Text, -1, Int32.Parse(txtWidth.Text), Int32.Parse(txtRows.Text), -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", intOrder, 1);
                    break;

                case "CHECKBOX":
                    intConfig = oServiceEditor.AddConfig(intService, intField, intWM, txtQuestion.Text, -1, -1, -1, (radCheckYes.Checked ? 1 : 0), -1, -1, txtTip.Text, 0, "", "", "", intOrder, 1);
                    break;

                case "CHECKLIST":
                    intConfig = oServiceEditor.AddConfig(intService, intField, intWM, txtQuestion.Text, 1, -1, -1, -1, (radDirectionH.Checked ? 1 : 0), -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", intOrder, 1);
                    break;

                case "DROPDOWN":
                    intConfig = oServiceEditor.AddConfig(intService, intField, intWM, txtQuestion.Text, -1, Int32.Parse(txtWidth.Text), 0, -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", intOrder, 1);
                    break;

                case "RADIOLIST":
                    intConfig = oServiceEditor.AddConfig(intService, intField, intWM, txtQuestion.Text, 1, -1, -1, -1, (radDirectionH.Checked ? 1 : 0), -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", intOrder, 1);
                    break;

                case "LISTBOX":
                    intConfig = oServiceEditor.AddConfig(intService, intField, intWM, txtQuestion.Text, -1, Int32.Parse(txtWidth.Text), Int32.Parse(txtRows.Text), -1, -1, (radMultipleYes.Checked ? 1 : 0), txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", intOrder, 1);
                    break;

                case "LIST":
                case "SERVERLIST":
                    intConfig = oServiceEditor.AddConfig(intService, intField, intWM, txtQuestion.Text, Int32.Parse(txtLength.Text), Int32.Parse(txtWidth.Text), Int32.Parse(txtRows.Text), -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", intOrder, 1);
                    break;

                case "HYPERLINK":
                    intConfig = oServiceEditor.AddConfig(intService, intField, intWM, txtQuestion.Text, -1, Int32.Parse(txtWidth.Text), -1, -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", intOrder, 1);
                    break;

                case "FILEUPLOAD":
                    intConfig = oServiceEditor.AddConfig(intService, intField, intWM, txtQuestion.Text, -1, Int32.Parse(txtWidth.Text), -1, -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", intOrder, 1);
                    break;

                case "DISCLAIMER":
                    intConfig = oServiceEditor.AddConfig(intService, intField, intWM, txtQuestion.Text, -1, -1, -1, -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, txtURL.Text, txtText.Text, intOrder, 1);
                    break;

                case "LOCATION":
                    intConfig = oServiceEditor.AddConfig(intService, intField, intWM, txtQuestion.Text, -1, Int32.Parse(ddlLocation.SelectedItem.Value), -1, -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", intOrder, 1);
                    break;
                }
            }
            else
            {
                switch (strCode.ToUpper())
                {
                case "DATE":
                    oServiceEditor.UpdateConfig(intConfig, intWM, txtQuestion.Text, -1, Int32.Parse(txtMinimum.Text), Int32.Parse(txtMaximum.Text), -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", 1);
                    break;

                case "TEXTBOX":
                    oServiceEditor.UpdateConfig(intConfig, intWM, txtQuestion.Text, Int32.Parse(txtLength.Text), Int32.Parse(txtWidth.Text), -1, -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", 1);
                    break;

                case "TEXTAREA":
                    oServiceEditor.UpdateConfig(intConfig, intWM, txtQuestion.Text, -1, Int32.Parse(txtWidth.Text), Int32.Parse(txtRows.Text), -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", 1);
                    break;

                case "USERS":
                case "SERVERS":
                case "MNEMONICS":
                case "APPROVER":
                    oServiceEditor.UpdateConfig(intConfig, intWM, txtQuestion.Text, -1, Int32.Parse(txtWidth.Text), Int32.Parse(txtRows.Text), -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", 1);
                    break;

                case "CHECKBOX":
                    oServiceEditor.UpdateConfig(intConfig, intWM, txtQuestion.Text, -1, -1, -1, (radCheckYes.Checked ? 1 : 0), -1, -1, txtTip.Text, 0, "", "", "", 1);
                    break;

                case "CHECKLIST":
                    oServiceEditor.UpdateConfig(intConfig, intWM, txtQuestion.Text, 1, -1, -1, -1, (radDirectionH.Checked ? 1 : 0), -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", 1);
                    break;

                case "DROPDOWN":
                    oServiceEditor.UpdateConfig(intConfig, intWM, txtQuestion.Text, -1, Int32.Parse(txtWidth.Text), 0, -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", 1);
                    break;

                case "RADIOLIST":
                    oServiceEditor.UpdateConfig(intConfig, intWM, txtQuestion.Text, 1, -1, -1, -1, (radDirectionH.Checked ? 1 : 0), -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", 1);
                    break;

                case "LISTBOX":
                    oServiceEditor.UpdateConfig(intConfig, intWM, txtQuestion.Text, -1, Int32.Parse(txtWidth.Text), Int32.Parse(txtRows.Text), -1, -1, (radMultipleYes.Checked ? 1 : 0), txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", 1);
                    break;

                case "LIST":
                case "SERVERLIST":
                    oServiceEditor.UpdateConfig(intConfig, intWM, txtQuestion.Text, Int32.Parse(txtLength.Text), Int32.Parse(txtWidth.Text), Int32.Parse(txtRows.Text), -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", 1);
                    break;

                case "HYPERLINK":
                    oServiceEditor.UpdateConfig(intConfig, intWM, txtQuestion.Text, -1, Int32.Parse(txtWidth.Text), -1, -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", 1);
                    break;

                case "FILEUPLOAD":
                    oServiceEditor.UpdateConfig(intConfig, intWM, txtQuestion.Text, -1, Int32.Parse(txtWidth.Text), -1, -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", 1);
                    break;

                case "DISCLAIMER":
                    oServiceEditor.UpdateConfig(intConfig, intWM, txtQuestion.Text, -1, -1, -1, -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, txtURL.Text, txtText.Text, 1);
                    break;

                case "LOCATION":
                    oServiceEditor.UpdateConfig(intConfig, intWM, txtQuestion.Text, -1, Int32.Parse(ddlLocation.SelectedItem.Value), -1, -1, -1, -1, txtTip.Text, (radRequiredYes.Checked ? 1 : 0), txtRequired.Text, "", "", 1);
                    break;
                }
            }

            //oServiceEditor.DeleteConfigValues(intConfig);
            List <int> lstValues = new List <int>();

            string[] strValues = Request.Form[hdnValues.UniqueID].Split(new char[] { ';' });
            DataSet  dsValues  = oServiceEditor.GetConfigValues(intConfig);

            for (int ii = 0; ii < strValues.Length; ii++)
            {
                if (strValues[ii] != "")
                {
                    // Loop through the values
                    int intValue = 0;
                    foreach (DataRow drValue in dsValues.Tables[0].Rows)
                    {
                        // Try to find matching, existing value
                        if (drValue["value"].ToString() == strValues[ii])
                        {
                            intValue = Int32.Parse(drValue["id"].ToString());
                            break;
                        }
                    }
                    if (intValue > 0)
                    {
                        // If match found, update with new order
                        lstValues.Add(intValue);
                        oServiceEditor.UpdateConfigValue(intValue, ii + 1);
                    }
                    else
                    {
                        // No match, add
                        oServiceEditor.AddConfigValue(intConfig, strValues[ii], ii + 1);
                    }
                }
            }
            // Delete the ones that were not added or selected
            foreach (DataRow drValue in dsValues.Tables[0].Rows)
            {
                int  intValue   = Int32.Parse(drValue["id"].ToString());
                bool boolDelete = true;
                // Try to find matching, existing value
                foreach (int intExists in lstValues)
                {
                    if (intExists == intValue)
                    {
                        boolDelete = false;
                        break;
                    }
                }
                if (boolDelete)
                {
                    oServiceEditor.DeleteConfigValue(intValue);
                }
            }

            /*
             * string strValues = Request.Form[hdnValues.UniqueID];
             * int intDisplay = 0;
             * while (strValues != "")
             * {
             *  intDisplay++;
             *  string strValue = strValues.Substring(0, strValues.IndexOf(";"));
             *  strValues = strValues.Substring(strValues.IndexOf(";") + 1);
             *  oServiceEditor.AddConfigValue(intConfig, strValue, intDisplay);
             * }
             */
            // Check Workload Manager Flag
            if (intWMFlag == 0 && intWM.ToString() != chkWrite.ToolTip.ToString())
            {
                int intDBField_Read = 0;
                Int32.TryParse(oServiceEditor.GetConfig(intConfig, "dbfield"), out intDBField_Read);
                if (intDBField_Read > 0)
                {
                    // A modification was made (either add or remove)
                    if (intWM == 1)
                    {
                        oServiceEditor.AddConfigWorkflowShared(intDBField_Read);
                    }
                    else
                    {
                        oServiceEditor.DeleteConfigWorkflowShared(intDBField_Read);
                    }
                }
            }
            oServiceEditor.AlterTable(intService);
            Response.Redirect(Request.Path + "?save=true");
        }