Esempio n. 1
0
        protected void rptrPageControls_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            FormGeneratorData data = new FormGeneratorData();
            HiddenField hf = (HiddenField)e.Item.FindControl("hidPageControlID");
            DataTable dtProperties = data.GetPageControlPropertyValuesByPageControl_ID(hf.Value);

            if (dtProperties.Rows.Count > 0)
            {
                if (dtProperties.Rows[0]["ControlList_Name"].ToString() == "Content Block")
                {
                    pnlEditActions.Visible = false;
                    pnlAddEditDropdown.Visible = false;
                    pnlAddEditTextBox.Visible = false;
                    pnlAddEditContentBlock.Visible = true;
                    pnlAddSubmitButton.Visible = false;
                    btnAdd.Visible = true;

                    txtRTE.Text = dtProperties.Rows[0]["SettingValue"].ToString();
                    btnRTECancel.Visible = true;
                    btnUpdateRTE.Visible = true;

                }
                else if (dtProperties.Rows[0]["ControlList_Name"].ToString() == "Submit")
                {
                    pnlEditActions.Visible = false;
                    pnlAddEditDropdown.Visible = false;
                    pnlAddEditTextBox.Visible = false;
                    pnlAddEditContentBlock.Visible = false;
                    pnlAddSubmitButton.Visible = true;
                    btnAdd.Visible = true;

                    txtButtonText.Text = dtProperties.Rows[0]["SettingValue"].ToString();
                }

                hfPageControlSetting_ID.Value = dtProperties.Rows[0]["PageControlSetting_ID"].ToString();
                hfControlListID_ForEdit.Value = dtProperties.Rows[0]["ControlList_ID"].ToString();
                hfPageControlID_ForEdit.Value = dtProperties.Rows[0]["PageControl_ID"].ToString();
            }

            if (e.CommandName.ToString() == "delete")
            {
                data.RemovePageControl(e.CommandArgument.ToString());
                LoadDropdown(ddlControlList, data.GetAvalableControlsByPage_ID(ddlPages.SelectedValue), "name", "controllist_id", "Select Field");

                pnlControlList.Visible = true;
                btnAdd.Visible = true;
                pnlAddEditDropdown.Visible = false;
                pnlAddEditContentBlock.Visible = false;
                pnlAddEditTextBox.Visible = false;
                pnlAddSubmitButton.Visible = false;

                LogMessage("Deleted Field From Form.");
            }
            else // Edit
            {

                pnlControlList.Visible = false;

                DataTable dtControlInfo = data.GetControlInfoByPageControl_ID(hf.Value);
                string controlType = dtControlInfo.Rows[0]["ControlType"].ToString();

                if (controlType == "TextBox" || controlType == "Multi-line")
                {
                    pnlEditActions.Visible = false;
                    pnlAddEditDropdown.Visible = false;
                    pnlAddEditTextBox.Visible = true;
                    pnlAddEditContentBlock.Visible = false;
                    btnAdd.Visible = true;

                    hfControlListID_ForEdit.Value = dtControlInfo.Rows[0]["ControlList_ID"].ToString();
                    hfPageControlID_ForEdit.Value = hf.Value;
                }
                else if (controlType == "DropDownList")
                {
                    pnlEditActions.Visible = false;
                    pnlAddEditDropdown.Visible = true;
                    pnlAddEditTextBox.Visible = false;
                    pnlAddEditContentBlock.Visible = false;
                    btnAdd.Visible = false;
                    hfPageControlID_DD_ForEdit.Value = hf.Value;

                    DataTable dtOptions = data.GetControlOptionsByPageControl_ID(hf.Value);
                    string defaultValue = data.GetDefaultOptionByPageControl_ID(hf.Value);

                    txtDefaultOption.Text = defaultValue;
                    rptrOptions.DataSource = dtOptions;
                    rptrOptions.DataBind();
                }
                else if (controlType == "Submit")
                {
                    pnlEditActions.Visible = true;
                    pnlAddSubmitButton.Visible = true;
                    pnlControlList.Visible = false;

                    btnUpdateButtonText.Visible = true;

                    hfPageControlID_Action_ForEdit.Value = hf.Value;
                    hfPageControlID_ForEdit.Value = hf.Value;

                    DataTable dtActionTypes = data.GetControlActionTypes();
                    DataTable dtActions = data.GetControlActionsByPageControl_ID(hf.Value);
                    DataTable dtAprimoInfo = data.GetAprimoInfoByPage_ID(ddlPages.SelectedValue);

                    if (dtAprimoInfo != null)
                    {
                        txtAprimoSubject.Text = dtAprimoInfo.Rows[0]["Subject"].ToString();
                        txtAprimoID.Text = dtAprimoInfo.Rows[0]["Aprimo_ID"].ToString();
                    }

                    LoadDropdown(ddlActions, dtActionTypes, "Name", "ControlActionType_ID", "Select Action");

                    rptrActions.DataSource = dtActions;
                    rptrActions.DataBind();

                    if (ddlPages.SelectedIndex != 0)
                    {
                        if (data.DoesPagehaveECASControlAction(ddlPages.SelectedValue))
                        {
                            string url = "";

                            if (ddlPages.SelectedIndex != 0)
                                url = data.GetReturnURLByPage_ID(ddlPages.SelectedValue);

                            tbxReturnURL.Text = url;

                            pnlReturnURL.Visible = true;
                        }
                    }

                }

            }

            ReloadControlList();
        }