public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (value != null)
     {
         if (editForm == null)
         {
             editForm = new EditForm();
         }
         editForm.DataSource = ((DataSet) value).Copy();
         if (editForm.ShowDialog() == DialogResult.OK)
         {
             value = editForm.DataSource;
         }
     }
     return value;
 }
Exemplo n.º 2
0
        private void RunOnce(ListView listView, EditForm editForm)
        {
            // ProjectName, ScriptName,
            string       strErrors = Execute(editForm.SourceCode);
            StringReader sr        = new StringReader(strErrors);
            int          intNr     = 1;

            while (true)
            {
                string strLine = sr.ReadLine();
                if (strLine == null)
                {
                    break;
                }
                strLine = strLine.Trim();

                if (strLine.StartsWith("TOTAL"))
                {
                    continue;
                }

                string strLineNr   = "";
                string strColumnNr = "";
                string strErrorNr  = "";

                int intImageIndex = -1;
                if (strLine.StartsWith("WARN"))
                {
                    intImageIndex = 1;
                }

                if (strLine.StartsWith("ERR"))
                {
                    intImageIndex = 0;
                }

                int intI = strLine.IndexOf("::");
                if (intI > 0)
                {
                    strLine = strLine.Substring(intI + 2).Trim();
                    intI    = strLine.IndexOf(":");
                    if (intI > 0)
                    {
                        string   strLineColumn = strLine.Substring(0, intI).Replace("(", "").Replace(")", "").Replace(" ", "");
                        string[] LineColumn    = strLineColumn.Split(new char[] { ',' });
                        if (LineColumn.Length > 1)
                        {
                            int intLine   = 0;
                            int intColumn = 0;

                            int.TryParse(LineColumn[0], out intLine);
                            int.TryParse(LineColumn[1], out intColumn);

                            strLineNr   = intLine.ToString();
                            strColumnNr = intColumn.ToString();
                            strErrorNr  = intNr.ToString();
                        }
                        strLine = strLine.Substring(intI + 1).Trim();
                    }
                }

                ListViewItem lvi = new ListViewItem(new string[] {
                    "",                                                     // 0
                    strErrorNr,                                             // 1
                    strLine,                                                // 2
                    editForm.ScriptName,                                    // 3
                    strLineNr,                                              // 4
                    strColumnNr,                                            // 5
                    editForm.ProjectName,                                   // 6
                    editForm.FullPathName,                                  // 7
                    editForm.guid.ToString(),                               // 8
                    editForm.IsScript.ToString()                            // 9
                }, intImageIndex);
                listView.Items.Add(lvi);
                if (strErrorNr != "")
                {
                    intNr++;
                }
            }
        }
Exemplo n.º 3
0
        public static Assembly CompileCSharp(EditForm editForm, string CSharpCode)
        {
            // Code compiler and provider
            CodeDomProvider cc = new CSharpCodeProvider();

            // Compiler parameters
            CompilerParameters cp = new CompilerParameters();

            // Sept 15, 2007 -> 3, 30 oct 2007 -> 4
            if (!Properties.Settings.Default.SkipWarnings)
            {
                cp.WarningLevel = 4;
            }

            // Add common assemblies
            cp.ReferencedAssemblies.Add("System.dll");
            cp.ReferencedAssemblies.Add("System.Windows.Forms.dll");

            // LSLEditor.exe contains all base SecondLife class stuff
            cp.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location);

            // Compiling to memory
            cp.GenerateInMemory = true;

            // Does this work?
            cp.IncludeDebugInformation = true;

            // Wrap strCSharpCode into my namespace
            string strRunTime = "namespace LSLEditor\n{\n";

            strRunTime += CSharpCode;
            strRunTime += "\n}\n";

            int intDefaultLineNumber = FindDefaultLineNumber(strRunTime);

            // Here we go
            CompilerResults cr = cc.CompileAssemblyFromSource(cp, strRunTime);

            // get the listview to store some errors
            ListView ListViewErrors = editForm.parent.SyntaxErrors.ListView;

            // Console.WriteLine(cr.Errors.HasWarnings.ToString());
            // Check for compilation errors...
            if (ListViewErrors != null && (cr.Errors.HasErrors || cr.Errors.HasWarnings))
            {
                int intNr = 1;
                foreach (CompilerError err in cr.Errors)
                {
                    int intLine = err.Line;
                    if (intLine < intDefaultLineNumber)
                    {
                        intLine -= 4;
                    }
                    else
                    {
                        intLine -= 5;
                    }
                    string strError      = OopsFormatter.ApplyFormatting(err.ErrorText);
                    int    intImageIndex = 0;
                    if (err.IsWarning)
                    {
                        intImageIndex = 1;
                    }
                    ListViewItem lvi = new ListViewItem(new string[] {
                        "",                                             // 0
                        intNr.ToString(),                               // 1
                        strError,                                       // 2
                        editForm.ScriptName,                            // 3
                        intLine.ToString(),                             // 4
                        err.Column.ToString(),                          // 5
                        editForm.ProjectName,                           // 6
                        editForm.FullPathName,                          // 7
                        editForm.guid.ToString(),                       // 8
                        editForm.IsScript.ToString()                    // 9
                    }, intImageIndex);
                    ListViewErrors.Items.Add(lvi);
                    intNr++;
                }
                return(null);
            }
            return(cr.CompiledAssembly);
        }
Exemplo n.º 4
0
        protected void GetEditForm(OrderEntity orderEntity)
        {

            forms.ToList().ForEach(
                form =>
                {
                    form.Visibility = Visibility.Collapsed;
                });
            if (orderEntity == null)
            {
                return;
            }
            string key = orderEntity.OrderType.Name;
            EditForm editForm = null;
            if (!forms.Dictionary.ContainsKey(key))
            {
                editForm = new EditForm(orderEntity);
                editForm.RefreshEntityWhenLoad = false;
                editForm.LoadControlComplete += new EventHandler(editForm_LoadControlComplete);
                forms.Add(key, editForm);
                editForm.InitForm();

                //editForm.HorizontalAlignment = HorizontalAlignment.Stretch;
                this.MainGrid.Children.Add(editForm);
            }
            else
            {
                editForm = forms[key];
                editForm.OrderEntity = orderEntity;
                Title = orderEntity.OrderTypeName;
                editForm.InitForm();
                editForm.Visibility = Visibility.Visible;
            }
            CurrentEditForm = editForm;

        }
Exemplo n.º 5
0
    protected override void OnPreRender(EventArgs e)
    {
        HandleFullScreen();

        base.OnPreRender(e);

        if (AllowTypeSwitching && (EditedObject != null))
        {
            if (sharedLayoutId > 0)
            {
                drpLayout.Value = sharedLayoutId;
            }
            else if (EditedObjectType == EditedObjectTypeEnum.Layout)
            {
                drpLayout.Value = EditedObject.Generalized.ObjectID;
            }

            radCustom.Text = GetString("TemplateLayout.Custom");
            radCustom.Attributes.Add("onclick", "window.location = '" + URLHelper.AddParameterToUrl(URLHelper.AddParameterToUrl(RequestContext.CurrentURL, "newshared", "0"), "oldshared", drpLayout.Value.ToString()) + "'");

            radShared.Text = GetString("TemplateLayout.Shared");
            if (drpLayout.UniSelector.HasData)
            {
                radShared.Attributes.Add("onclick", "window.location = '" + URLHelper.AddParameterToUrl(RequestContext.CurrentURL, "newshared", drpLayout.Value + "") + "'");
            }

            // Get the current layout type
            bool radioButtonsEnabled = !SynchronizationHelper.UseCheckinCheckout;
            if (DeviceProfileID > 0)
            {
                // Device profile layout
                PageTemplateDeviceLayoutInfo dli = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(TemplateID, DeviceProfileID);
                if (dli != null)
                {
                    radioButtonsEnabled |= dli.Generalized.IsCheckedOutByUser(MembershipContext.AuthenticatedUser);
                }
            }
            else
            {
                // Page template layout
                radioButtonsEnabled |= PageTemplateInfo.Generalized.IsCheckedOutByUser(MembershipContext.AuthenticatedUser);
            }

            // Disable also radio buttons when the object is not checked out
            radShared.Enabled = radCustom.Enabled = drpLayout.Enabled = radioButtonsEnabled;
        }

        if ((EditedObjectType == EditedObjectTypeEnum.Layout) && (AllowTypeSwitching || DialogMode))
        {
            pnlServer.Visible = false;
            pnlLayout.CategoryTitleResourceString = null;
        }

        SetActionVisiblity();

        RegisterInitScripts(pnlBody.ClientID, editMenuElem.MenuPanel.ClientID, startWithFullScreen);

        if (QueryHelper.GetBoolean("refreshParent", false))
        {
            ScriptHelper.RegisterStartupScript(this, typeof(string), "refreshParent", "window.refreshPageOnClose = true;", true);
        }

        HandleWebpartZonesCountWarning();

        if (DialogMode && QueryHelper.GetBoolean("wopenerrefresh", false) && !ValidationHelper.GetBoolean(hdnWOpenerRefreshed.Value, false))
        {
            RegisterWOpenerRefreshScript();
            hdnWOpenerRefreshed.Value = "1";
        }

        var deviceActions = QueryHelper.GetBoolean("deviceactions", true);

        if (!deviceActions)
        {
            if (createDeviceLayout != null)
            {
                createDeviceLayout.Visible = false;
            }
            if (removeDeviceLayout != null)
            {
                removeDeviceLayout.Visible = false;
            }
        }

        // Try to get page template
        EditForm.EnableByLockState();

        // Enable DDL and disable UIForm for shared layouts
        if (radShared.Checked)
        {
            if (codeElem != null)
            {
                codeElem.Enabled               = false;
                cssEditor.Editor.Enabled       = false;
                codeLayoutElem.Enabled         = false;
                cssLayoutEditor.Editor.Enabled = false;
                deviceCode.Enabled             = false;
                cssDeviceEditor.Editor.Enabled = false;
            }
        }
        else
        {
            drpLayout.Enabled = false;
        }

        // Check whether virtual objects are allowed
        if (!SettingsKeyInfoProvider.VirtualObjectsAllowed)
        {
            ShowWarning(GetString("VirtualPathProvider.NotRunning"), null, null);
        }
    }
 public DataSetEditor()
 {
     editForm = null;
 }
Exemplo n.º 7
0
    /// <summary>
    /// Displays and hides plain CSS code preview.
    /// </summary>
    private void HandleCssCodePreview()
    {
        if (RequestHelper.IsPostBack() && !plainCssOnly)
        {
            // Don't process if the CSS preview control is not visible
            FormEngineUserControl previewControl = EditForm.FieldControls["StylesheetCodePreview"];
            if ((previewControl != null) && !previewControl.Visible)
            {
                return;
            }

            // Get the edited stylesheet
            CssStylesheetInfo cssInfo = EditForm.EditedObject as CssStylesheetInfo;
            if (cssInfo == null)
            {
                return;
            }

            string lang        = ValidationHelper.GetString(cssInfo.StylesheetDynamicLanguage, CssStylesheetInfo.PLAIN_CSS);
            string previewMode = ValidationHelper.GetString(EditForm.GetFieldValue("StylesheetCodePreview"), String.Empty);

            // Display preview
            if (!String.IsNullOrEmpty(previewMode) && previewMode.EqualsCSafe("preview", true) && !lang.EqualsCSafe(CssStylesheetInfo.PLAIN_CSS, true))
            {
                // Get the stylesheet dynamic code
                string code   = ValidationHelper.GetString(EditForm.GetFieldValue("StylesheetDynamicCode"), String.Empty);
                string output = String.Empty;

                // Run preprocessor
                string parserError = CSSStylesheetNewControlExtender.ProcessCss(code, lang, out output, hidCompiledCss);

                if (String.IsNullOrEmpty(parserError))
                {
                    // Set the editor value and disable editing
                    FormEngineUserControl plainCssEditor = EditForm.FieldControls["StylesheetText"];
                    if (plainCssEditor != null)
                    {
                        plainCssEditor.Value = output;
                        codePreviewDisplayed = true;
                    }

                    // Hide dynamic code editor
                    FormEngineUserControl dynamicCodeEditor = EditForm.FieldControls["StylesheetDynamicCode"];
                    if (dynamicCodeEditor != null)
                    {
                        dynamicCodeEditor.CssClass = "Hidden";
                    }
                }
                else
                {
                    // Handle the error that occurred during parsing
                    EditForm.ShowError(parserError);
                    FormEngineUserControl previewField = EditForm.FieldControls["StylesheetCodePreview"];
                    if (previewField != null)
                    {
                        previewField.Value = lang;
                    }
                }

                return;
            }

            // Hide preview
            if (!String.IsNullOrEmpty(previewMode) && !previewMode.EqualsCSafe("preview", true))
            {
                // Ensure the visibility of the field if the preview is not active
                FormEngineUserControl dynamicCodeEditor = EditForm.FieldControls["StylesheetDynamicCode"];
                if (dynamicCodeEditor != null)
                {
                    dynamicCodeEditor.CssClass = "";
                }

                // Enable for editing despite the editor is hidden
                FormEngineUserControl plainCssEditor = EditForm.FieldControls["StylesheetText"];
                if (plainCssEditor != null)
                {
                    plainCssEditor.Enabled = true;
                }
            }
        }
    }
Exemplo n.º 8
0
 /// <summary>
 /// Call this to collapse LSL to LSLI
 /// </summary>
 /// <param name="editform"></param>
 /// <returns>LSLI</returns>
 public string CollapseToLSLIFromEditform(EditForm editform)
 {
     this.editForm = editform;
     return(CollapseToLSLI(editform.SourceCode));
 }
    private void EditForm_OnBeforeValidate(object sender, EventArgs e)
    {
        String errorMsg = String.Empty;

        // Test whether all goal values are higher then the min values
        int visitorsMin  = ValidationHelper.GetInteger(((FormEngineUserControl)EditForm.FieldControls["CampaignGoalVisitorsMin"]).Value, 0);
        int visitorsGoal = ValidationHelper.GetInteger(((FormEngineUserControl)EditForm.FieldControls["CampaignGoalVisitors"]).Value, 0);

        int conversionsMin  = ValidationHelper.GetInteger(((FormEngineUserControl)EditForm.FieldControls["CampaignGoalConversionsMin"]).Value, 0);
        int conversionsGoal = ValidationHelper.GetInteger(((FormEngineUserControl)EditForm.FieldControls["CampaignGoalConversions"]).Value, 0);

        int goalValueMin = ValidationHelper.GetInteger(((FormEngineUserControl)EditForm.FieldControls["CampaignGoalValueMin"]).Value, 0);
        int goalValue    = ValidationHelper.GetInteger(((FormEngineUserControl)EditForm.FieldControls["CampaignGoalValue"]).Value, 0);

        int goalPerVisitorMin = ValidationHelper.GetInteger(((FormEngineUserControl)EditForm.FieldControls["CampaignGoalPerVisitorMin"]).Value, 0);
        int goalPerVisitor    = ValidationHelper.GetInteger(((FormEngineUserControl)EditForm.FieldControls["CampaignGoalPerVisitor"]).Value, 0);

        bool visitorsAsPercent    = ValidationHelper.GetBoolean(((FormEngineUserControl)EditForm.FieldControls["CampaignGoalVisitorsPercent"]).Value, false);
        bool conversionsAsPercent = ValidationHelper.GetBoolean(((FormEngineUserControl)EditForm.FieldControls["CampaignGoalConversionsPercent"]).Value, false);

        if (visitorsMin > visitorsGoal)
        {
            errorMsg = GetString("campaign.error.goal");
        }

        if (conversionsMin > conversionsGoal)
        {
            errorMsg = GetString("campaign.error.goal");
        }

        if (goalValueMin > goalValue)
        {
            errorMsg = GetString("campaign.error.goal");
        }

        if (goalPerVisitorMin > goalPerVisitor)
        {
            errorMsg = GetString("campaign.error.goal");
        }

        // Percent of impressions may not be higher then 100
        if ((conversionsAsPercent) && (conversionsGoal > 100))
        {
            errorMsg = GetString("campaign.error.goalspercent");
        }

        if ((visitorsAsPercent) && (visitorsGoal > 100))
        {
            errorMsg = GetString("campaign.error.goalspercent");
        }

        // Test zero values
        if (visitorsMin < 0)
        {
            errorMsg = GetString("campaign.valuegreaterzero");
        }

        if (visitorsGoal < 0)
        {
            errorMsg = GetString("campaign.valuegreaterzero");
        }

        if (conversionsMin < 0)
        {
            errorMsg = GetString("campaign.valuegreaterzero");
        }

        if (conversionsGoal < 0)
        {
            errorMsg = GetString("campaign.valuegreaterzero");
        }

        if (goalValueMin < 0)
        {
            errorMsg = GetString("campaign.valuegreaterzero");
        }

        if (goalValue < 0)
        {
            errorMsg = GetString("campaign.valuegreaterzero");
        }

        if (goalPerVisitorMin < 0)
        {
            errorMsg = GetString("campaign.valuegreaterzero");
        }

        if (goalPerVisitor < 0)
        {
            errorMsg = GetString("campaign.valuegreaterzero");
        }

        if (errorMsg != String.Empty)
        {
            EditForm.ShowError(errorMsg);
            EditForm.StopProcessing = true;
        }
    }
Exemplo n.º 10
0
 protected void btnOk_Click(object sender, EventArgs ea)
 {
     EditForm.SaveData("");
 }
Exemplo n.º 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            EditForm ef = new EditForm();

            ef.Show();
        }
Exemplo n.º 12
0
        private void arrivalEditToolStripMenuItem_Click(object sender, EventArgs e)                              //edit
        {
            if (radioButtonBasic.Checked && (bool)mainDataGridView.CurrentRow.Cells["Это доход"].Value == false) //расход основы
            {
                EditForm arrivalEdit = new EditForm(@"select date as 'Дата', arrival_or_expense as 'это доход', summa as 'Сумма', description as 'Комментарий'
                                from Cash_flow
                                where  id =" + currentRowMainDataGridView,
                                                    null,//defaults
                                                    new int[] { 0, 2 },
                                                    @"update Cash_flow 
                                        set date = @date,
                                        arrival_or_expense = @arex,
                                        summa = @sum,
                                        description = TRIM (@desc)
                                        where id =" + currentRowMainDataGridView,
                                                    new string[] { "@date", "@arex", "sum", "@desc" },
                                                    new SqlDbType[] { SqlDbType.Date, SqlDbType.Bit, SqlDbType.Money, SqlDbType.VarChar },
                                                    true, currentRowMainDataGridView, CheckSum.Balance, false);
                arrivalEdit.ShowDialog();
            }
            else if (!radioButtonBasic.Checked && (bool)mainDataGridView.CurrentRow.Cells["Это доход"].Value == false)//расход резерва
            {
                EditForm arrivalEdit = new EditForm(@"select date as 'Дата', arrival_or_expense as 'это доход', summa as 'Сумма', description as 'Комментарий'
                                from Cash_flow
                                where  id =" + currentRowMainDataGridView,
                                                    null,//defaults
                                                    new int[] { 0, 2 },
                                                    @"update Cash_flow 
                                        set date = @date,
                                        arrival_or_expense = @arex,
                                        summa = @sum,
                                        description = TRIM (@desc)
                                        where id =" + currentRowMainDataGridView,
                                                    new string[] { "@date", "@arex", "sum", "@desc" },
                                                    new SqlDbType[] { SqlDbType.Date, SqlDbType.Bit, SqlDbType.Money, SqlDbType.VarChar },
                                                    true, currentRowMainDataGridView, CheckSum.Reserve, true);
                arrivalEdit.ShowDialog();
            }
            else if (!radioButtonBasic.Checked && (bool)mainDataGridView.CurrentRow.Cells["Это доход"].Value == true)//доход резерва(расход основы)
            {
                EditForm arrivalEdit = new EditForm(@"select date as 'Дата', arrival_or_expense as 'это доход', summa as 'Сумма', description as 'Комментарий'
                                from Cash_flow
                                where  id =" + currentRowMainDataGridView,
                                                    null,//defaults
                                                    new int[] { 0, 2 },
                                                    @"update Cash_flow 
                                        set date = @date,
                                        arrival_or_expense = @arex,
                                        summa = @sum,
                                        description = TRIM (@desc)
                                        where id =" + currentRowMainDataGridView,
                                                    new string[] { "@date", "@arex", "sum", "@desc" },
                                                    new SqlDbType[] { SqlDbType.Date, SqlDbType.Bit, SqlDbType.Money, SqlDbType.VarChar },
                                                    true, currentRowMainDataGridView, CheckSum.Balance, true);
                arrivalEdit.ShowDialog();
            }
            else //другое
            {
                if (radioButtonBasic.Checked)
                {
                    EditForm arrivalEdit = new EditForm(@"select date as 'Дата', arrival_or_expense as 'это доход', summa as 'Сумма', description as 'Комментарий'
                                from Cash_flow
                                where  id =" + currentRowMainDataGridView,
                                                        null,//defaults
                                                        new int[] { 0, 2 },
                                                        @"update Cash_flow 
                                        set date = @date,
                                        arrival_or_expense = @arex,
                                        summa = @sum,
                                        description = TRIM (@desc)
                                        where id =" + currentRowMainDataGridView,
                                                        new string[] { "@date", "@arex", "sum", "@desc" },
                                                        new SqlDbType[] { SqlDbType.Date, SqlDbType.Bit, SqlDbType.Money, SqlDbType.VarChar },
                                                        true, currentRowMainDataGridView, CheckSum.None, false);
                    arrivalEdit.ShowDialog();
                }
                else
                {
                    EditForm arrivalEdit = new EditForm(@"select date as 'Дата', arrival_or_expense as 'это доход', summa as 'Сумма', description as 'Комментарий'
                                from Cash_flow
                                where  id =" + currentRowMainDataGridView,
                                                        null,//defaults
                                                        new int[] { 0, 2 },
                                                        @"update Cash_flow 
                                        set date = @date,
                                        arrival_or_expense = @arex,
                                        summa = @sum,
                                        description = TRIM (@desc)
                                        where id =" + currentRowMainDataGridView,
                                                        new string[] { "@date", "@arex", "sum", "@desc" },
                                                        new SqlDbType[] { SqlDbType.Date, SqlDbType.Bit, SqlDbType.Money, SqlDbType.VarChar },
                                                        true, currentRowMainDataGridView, CheckSum.None, true);
                    arrivalEdit.ShowDialog();
                }
            }

            UpdateArrivalAndExpenseTab();
        }
Exemplo n.º 13
0
        private void toolStripMenuItemAddExpense_Click(object sender, EventArgs e)// add expense
        {
            EditForm arrivalAdd;

            if (radioButtonBasic.Checked) //расход основы
            {
                arrivalAdd = new EditForm(@"select date as 'Дата', summa as 'Сумма', description as 'Комментарий'
                                from Cash_flow
                                where  id = 0",
                                          new object[] { DateTime.Today, 0, " " }, //defaults
                                          new int[] { 0, 1 },                      //req
                                          @"insert into Cash_flow 
                                (date, arrival_or_expense, summa, description, basic_or_reserve) 
                                values (@date, 0, @sum, TRIM (@desc), 1)",         //insert/edit str
                                          new string[] { "@date", "@sum", "@desc" },
                                          new SqlDbType[] { SqlDbType.Date, SqlDbType.Money, SqlDbType.VarChar },
                                          true, 0, CheckSum.Balance, false);
                arrivalAdd.ShowDialog();
            }
            else //расход резерва
            {
                arrivalAdd = new EditForm(@"select date as 'Дата', summa as 'Сумма', description as 'Комментарий'
                                from Cash_flow
                                where  id = 0",
                                          new object[] { DateTime.Today, 0, " " }, //defaults
                                          new int[] { 0, 1 },                      //req
                                          @"insert into Cash_flow 
                                (date, arrival_or_expense, summa, description, basic_or_reserve) 
                                values (@date, 0, @sum, TRIM (@desc), 0)",         //insert/edit str
                                          new string[] { "@date", "@sum", "@desc" },
                                          new SqlDbType[] { SqlDbType.Date, SqlDbType.Money, SqlDbType.VarChar },
                                          true, 0, CheckSum.Reserve, true);
                arrivalAdd.ShowDialog();

                //создать идентичные записи как доход
                int idForTags = (int)Program.FindMaxId("Cash_Flow");//поиск нового ид
                //создать дт со значениями
                string         s               = @"select date,  summa, description
                    from Cash_flow
                    where id =  " + idForTags;
                SqlDataAdapter dataAdapter     = new SqlDataAdapter(s, SqlC.c);
                DataTable      valuesDataTable = new DataTable();
                dataAdapter.Fill(valuesDataTable);
                //заполнить массив из строки дт
                object[] values = new object[valuesDataTable.Columns.Count];//массив полей записи
                for (int i = 0; i < values.Length; i++)
                {
                    values[i] = valuesDataTable.Rows[0][i];
                }
                //создать идентичные записи как доход
                Program.SqlCommandExecute("insert", @"insert into Cash_flow
                                (date, arrival_or_expense, summa, description, basic_or_reserve)
                                values (@date, 1, @sum, @desc, 1)",
                                          new string[] { "@date", "@sum", "@desc" },
                                          new SqlDbType[] { SqlDbType.Date, SqlDbType.Money, SqlDbType.VarChar },
                                          values);//добавление новой записи дохода
                //добавить теги
                //дт из тегов старой записи
                s           = @"select tag_name as name from Tag_of_flow 
                    where flow_id = " + idForTags;
                dataAdapter = new SqlDataAdapter(s, SqlC.c);
                DataTable tagDataTable = new DataTable();
                dataAdapter.Fill(tagDataTable);
                //поиск ид новой записи
                idForTags = (int)Program.FindMaxId("Cash_Flow");
                //добавление тегов новой записи в базу
                foreach (DataRow dr in tagDataTable.Rows)
                {
                    Program.SqlCommandExecute("insert", @"insert into Tag_of_flow 
                                                    (tag_name, flow_id) 
                                                    values (@name, @flow)",
                                              new string[] { @"name", @"flow" },
                                              new SqlDbType[] { SqlDbType.VarChar, SqlDbType.Int },
                                              new object[] { dr[0], idForTags }); //для дохода
                }
                //делаем строку из тегов
                string tags = Program.StringList(tagDataTable, '|');
                //апдейтим запись новой строкой тегов
                Program.SqlCommandExecute("update", @"update Cash_flow
                                                    set tags = @tags
                                                    where id = " + (idForTags),
                                          new string[] { "@tags" },
                                          new SqlDbType[] { SqlDbType.VarChar },
                                          new object[] { tags });   //для дохода
            }
            UpdateArrivalAndExpenseTab();
        }
    protected override void OnPreRender(EventArgs e)
    {
        HandleFullScreen();

        base.OnPreRender(e);

        if (AllowTypeSwitching && (EditedObject != null))
        {
            if (sharedLayoutId > 0)
            {
                drpLayout.Value = sharedLayoutId;
            }
            else if (EditedObjectType == EditedObjectTypeEnum.Layout)
            {
                drpLayout.Value = EditedObject.Generalized.ObjectID;
            }

            radCustom.Text = GetString("TemplateLayout.Custom");

            var sanitizedCurrentUrl = ScriptHelper.GetString(RequestContext.CurrentURL, encapsulate: false);
            var customLayoutUrl     = URLHelper.AddParameterToUrl(sanitizedCurrentUrl, "newshared", "0");
            customLayoutUrl = URLHelper.AddParameterToUrl(customLayoutUrl, "oldshared", drpLayout.Value.ToString());

            radCustom.Attributes.Add("onclick", "window.location = '" + customLayoutUrl + "'");

            radShared.Text = GetString("TemplateLayout.Shared");
            if (drpLayout.UniSelector.HasData)
            {
                var sharedLayoutUrl = URLHelper.AddParameterToUrl(sanitizedCurrentUrl, "newshared", drpLayout.Value.ToString());
                radShared.Attributes.Add("onclick", "window.location = '" + sharedLayoutUrl + "'");
            }

            // Get the current layout type
            bool radioButtonsEnabled = !SynchronizationHelper.UseCheckinCheckout;

            // Page template layout
            radioButtonsEnabled |= PageTemplateInfo.Generalized.IsCheckedOutByUser(MembershipContext.AuthenticatedUser);

            // Disable also radio buttons when the object is not checked out
            radShared.Enabled = radCustom.Enabled = drpLayout.Enabled = radioButtonsEnabled;
        }

        if ((EditedObjectType == EditedObjectTypeEnum.Layout) && (AllowTypeSwitching || DialogMode))
        {
            pnlServer.Visible = false;
            pnlLayout.CategoryTitleResourceString = null;
        }

        RegisterInitScripts(pnlBody.ClientID, editMenuElem.MenuPanel.ClientID, startWithFullScreen);

        if (QueryHelper.GetBoolean("refreshParent", false))
        {
            ScriptHelper.RegisterStartupScript(this, typeof(string), "refreshParent", "window.refreshPageOnClose = true;", true);
        }

        if (DialogMode && QueryHelper.GetBoolean("wopenerrefresh", false) && !ValidationHelper.GetBoolean(hdnWOpenerRefreshed.Value, false))
        {
            RegisterWOpenerRefreshScript();
            hdnWOpenerRefreshed.Value = "1";
        }

        // Try to get page template
        EditForm.EnableByLockState();

        // Enable DDL and disable UIForm for shared layouts
        if (radShared.Checked)
        {
            DisableEditableFields();
        }
        else
        {
            drpLayout.Enabled = false;
        }

        // Check whether virtual objects are allowed
        if (!SettingsKeyInfoProvider.VirtualObjectsAllowed)
        {
            ShowWarning(GetString("VirtualPathProvider.NotRunning"));
        }
    }
Exemplo n.º 15
0
        private void editBookToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditForm editForm = new EditForm();

            editForm.ShowDialog();
        }
Exemplo n.º 16
0
    /// <summary>
    /// Actions handler.
    /// </summary>
    protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e)
    {
        // Check modify permission
        CheckPermissions("cms.scoring", "modify");

        switch (e.CommandName.ToLower())
        {
        case "save":
            // Save changes in the contact group
            EditForm.SaveData(null);
            break;

        case "recalculate":
            if (EditForm.EditedObject != null)
            {
                ScoreInfo score = (ScoreInfo)EditForm.EditedObject;
                if (score != null)
                {
                    // Set 'Recalculating' status
                    score.ScoreStatus = ScoreStatusEnum.Recalculating;
                    // Ensure scheduled task
                    if (score.ScoreScheduledTaskID == 0)
                    {
                        // Create and initialize new scheduled task
                        task = GetScheduledTask(score);
                        task.TaskInterval    = schedulerInterval.ScheduleInterval;
                        task.TaskNextRunTime = TaskInfoProvider.NO_TIME;
                        task.TaskEnabled     = false;
                        TaskInfoProvider.SetTaskInfo(task);

                        // Update score info
                        score.ScoreScheduledTaskID = task.TaskID;
                    }
                    ScoreInfoProvider.SetScoreInfo(score);

                    // Recalculate the score
                    ScoreEvaluator evaluator = new ScoreEvaluator();
                    evaluator.ScoreID = score.ScoreID;
                    evaluator.Execute(null);

                    EditForm.InfoLabel.Text    = GetString("om.score.recalculationstarted");
                    EditForm.InfoLabel.Visible = true;

                    // Get scheduled task and update last run time
                    if (task == null)
                    {
                        task = TaskInfoProvider.GetTaskInfo(score.ScoreScheduledTaskID);
                    }
                    if (task != null)
                    {
                        task.TaskLastRunTime = DateTime.Now;
                        TaskInfoProvider.SetTaskInfo(task);
                    }

                    // Display basic info about score
                    InitInfoPanel(score);
                }
            }
            break;
        }
    }
Exemplo n.º 17
0
    /// <summary>
    /// Actions handler.
    /// </summary>
    protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e)
    {
        if (ContactGroupHelper.AuthorizedModifyContactGroup(SiteID, true))
        {
            switch (e.CommandName.ToLowerCSafe())
            {
            case "save":
                if (chkDynamic.Checked)
                {
                    // Get scheduled interval string
                    scheduleInterval = schedulerInterval.ScheduleInterval;
                }

                // Save changes in the contact group
                if (EditForm.SaveData(null))
                {
                    mBtnEvaluate.Visible = chkDynamic.Checked;
                }
                break;

            case "evaluate":
                if (EditForm.EditedObject != null)
                {
                    ContactGroupInfo cgi = (ContactGroupInfo)EditForm.EditedObject;
                    if (cgi != null)
                    {
                        // Set 'Rebuilding' status
                        cgi.ContactGroupStatus = ContactGroupStatusEnum.Rebuilding;
                        ContactGroupInfoProvider.SetContactGroupInfo(cgi);

                        // Evaluate the membership of the contact group
                        ContactGroupEvaluator evaluator = new ContactGroupEvaluator();
                        evaluator.ContactGroupID = cgi.ContactGroupID;
                        evaluator.Execute(null);

                        EditForm.InfoLabel.Text    = GetString("om.contactgroup.evaluationstarted");
                        EditForm.InfoLabel.Visible = true;

                        // Get scheduled task and update last run time
                        if (cgi.ContactGroupScheduledTaskID > 0)
                        {
                            task = TaskInfoProvider.GetTaskInfo(cgi.ContactGroupScheduledTaskID);
                            if (task != null)
                            {
                                task.TaskLastRunTime = DateTime.Now;
                                TaskInfoProvider.SetTaskInfo(task);

                                // Initialize interval control
                                schedulerInterval.ScheduleInterval = task.TaskInterval;
                                schedulerInterval.ReloadData();
                            }
                        }

                        // Display basic info about dynamic contact group
                        InitInfoPanel(cgi, false);
                    }
                }
                break;
            }
        }
    }
Exemplo n.º 18
0
 public Messages(EditForm editForm)
 {
     InitializeComponent();
     this.editForm = editForm;
 }
Exemplo n.º 19
0
    /// <summary>
    /// Handles the OnAfterAction event of the ObjectManager control.
    /// </summary>
    protected void ObjectManager_OnAfterAction(object sender, SimpleObjectManagerEventArgs e)
    {
        if ((e.ActionName == ComponentEvents.SAVE) || (e.ActionName == ComponentEvents.CHECKIN))
        {
            if (EditForm.ValidateData())
            {
                // Register refresh script
                string refreshScript = ScriptHelper.GetScript("if ((wopener != null) && (wopener.RefreshPage != null)) {wopener.RefreshPage();}");
                ScriptHelper.RegisterClientScriptBlock(Page, typeof(String), "pageTemplateRefreshScript", refreshScript);

                // Register preview refresh
                RegisterRefreshScript();

                // Close if required
                if (ValidationHelper.GetBoolean(hdnClose.Value, false))
                {
                    ScriptHelper.RegisterStartupScript(Page, typeof(string), "CloseDialogPreviewScript", ScriptHelper.GetScript("CloseDialog();"));
                }
            }

            // Hide warning after save
            MessagesPlaceHolder.WarningText = "";
        }
        else if (e.ActionName == ComponentEvents.UNDO_CHECKOUT)
        {
            if (AllowTypeSwitching)
            {
                var url = RequestContext.CurrentURL;
                url = URLHelper.RemoveParameterFromUrl(url, "newshared");
                url = URLHelper.RemoveParameterFromUrl(url, "oldshared");
                url = URLHelper.AddParameterToUrl(url, "wopenerrefresh", "1");
                Response.Redirect(url);
            }
        }
        else if (e.ActionName == ComponentEvents.CHECKOUT)
        {
            DisplayMessage(true);
        }

        switch (e.ActionName)
        {
        case ComponentEvents.SAVE:
        case ComponentEvents.CHECKOUT:
        case ComponentEvents.CHECKIN:
        case ComponentEvents.UNDO_CHECKOUT:
            if (DialogMode)
            {
                RegisterWOpenerRefreshScript();
            }
            else if (dialog)
            {
                ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "parentWOpenerRefresh", ScriptHelper.GetScript("if (parent && parent.wopener && parent.wopener.refresh) { parent.wopener.refresh(); }"));
            }
            break;
        }

        if (!AllowTypeSwitching && (EditedObjectType == EditedObjectTypeEnum.Layout) && (e.ActionName != ComponentEvents.CHECKOUT) && !DialogMode)
        {
            ScriptHelper.RefreshTabHeader(Page, EditForm.EditedObject.Generalized.ObjectDisplayName);
        }

        // No save for checkout
        if (e.ActionName != ComponentEvents.CHECKOUT)
        {
            ShowChangesSaved();
        }
    }
Exemplo n.º 20
0
    /// <summary>
    /// Detects stylesheet language change and converts CSS code according to the former and the latter language.
    /// </summary>
    /// <param name="originalLanguage">The previous language</param>
    /// <param name="newLanguage">The new language</param>
    private void ChangeStylesheetLanguage(string originalLanguage, string newLanguage)
    {
        // Check whether the stylesheet language has actually changed.
        if (!String.IsNullOrEmpty(newLanguage) && !String.IsNullOrEmpty(originalLanguage) && !originalLanguage.EqualsCSafe(newLanguage, true))
        {
            string code         = String.Empty;
            string output       = String.Empty;
            string errorMessage = String.Empty;

            if (newLanguage.EqualsCSafe(CssStylesheetInfo.PLAIN_CSS, true))
            {
                // Changed from any CSS preprocessor language to plain CSS.
                code = ValidationHelper.GetString(EditForm.GetFieldValue("StylesheetDynamicCode"), String.Empty);
                // Try to parse the code against the original preprocessor language.
                errorMessage = CSSStylesheetNewControlExtender.ProcessCss(code, originalLanguage, out output, hidCompiledCss);
            }
            else if (originalLanguage.EqualsCSafe(CssStylesheetInfo.PLAIN_CSS, true))
            {
                // Changed from Plain CSS to some CSS preprocessor language.
                code = ValidationHelper.GetString(EditForm.GetFieldValue("StylesheetText"), String.Empty);
                // Try to parse the code against the new preprocessor language.
                errorMessage = CSSStylesheetNewControlExtender.ProcessCss(code, newLanguage, out output, hidCompiledCss);
            }
            else
            {
                // Changed from CSS preprocessor language to another one.
                code = ValidationHelper.GetString(EditForm.GetFieldValue("StylesheetDynamicCode"), String.Empty);
                // Try to parse the code against the original preprocessor language.
                errorMessage = CSSStylesheetNewControlExtender.ProcessCss(code, originalLanguage, out output, hidCompiledCss);
            }

            if (String.IsNullOrEmpty(errorMessage))
            {
                // Success -> Set correct values to form controls.
                if (newLanguage.EqualsCSafe(CssStylesheetInfo.PLAIN_CSS, true))
                {
                    // output -> StylesheetText
                    EditForm.FieldControls["StylesheetText"].Value = output;
                }
                else if (originalLanguage.EqualsCSafe(CssStylesheetInfo.PLAIN_CSS, true))
                {
                    // Copy the original code to StylesheetDynamicCode field.
                    EditForm.FieldControls["StylesheetDynamicCode"].Value = code;
                }
                else
                {
                    // Copy the original code to StylesheetDynamicCode field.
                    EditForm.FieldControls["StylesheetDynamicCode"].Value = output;
                }

                // Prevent to additional change processing.
                languageChangeProceeded = true;
            }
            else
            {
                // Failure -> Show error message
                EditForm.AddError(errorMessage);
                // Prevent further processing
                EditForm.StopProcessing = true;
                // Set drop-down list to its former value
                FormEngineUserControl langControl = EditForm.FieldControls["StylesheetDynamicLanguage"];
                if (langControl != null)
                {
                    langControl.Value = originalLanguage;
                    CssStylesheetInfo cssInfo = EditForm.EditedObject as CssStylesheetInfo;
                    if (cssInfo != null)
                    {
                        cssInfo.StylesheetDynamicLanguage = originalLanguage;
                    }
                }
            }
        }
    }
Exemplo n.º 21
0
    /// <summary>
    /// Handles the OnAfterAction event of the ObjectManager control.
    /// </summary>
    protected void ObjectManager_OnAfterAction(object sender, SimpleObjectManagerEventArgs e)
    {
        wpli = EditForm.EditedObject as WebPartLayoutInfo;

        if (wpli != null)
        {
            LayoutCodeName = wpli.WebPartLayoutCodeName;
        }

        if (e.ActionName == ComponentEvents.SAVE)
        {
            if (EditForm.ValidateData())
            {
                if (!isSiteManager)
                {
                    SetCurrentLayout(true);
                }

                if (ValidationHelper.GetBoolean(hdnClose.Value, false))
                {
                    // If window to close, register close script
                    CloseDialog();
                }
                else
                {
                    // Redirect parent for new
                    if (isNew)
                    {
                        if (isSiteManager)
                        {
                            URLHelper.Redirect("WebPart_Edit_Layout_Frameset.aspx?layoutID=" + wpli.WebPartLayoutID + "&webpartID=" + webPartInfo.WebPartID);
                        }
                        else
                        {
                            var codeName    = (wpli != null) ? wpli.WebPartLayoutCodeName : string.Empty;
                            var redirectUrl = ResolveUrl("~/CMSModules/PortalEngine/UI/WebParts/WebPartProperties_layout_frameset.aspx") + URLHelper.UpdateParameterInUrl(URLHelper.Url.Query, "layoutcodename", codeName);
                            ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "RefreshHeader", ScriptHelper.GetScript("parent.location ='" + redirectUrl + "'"));
                        }
                    }
                    else
                    {
                        if (!isSiteManager)
                        {
                            // Reload the parent page after save
                            EnsureParentPageRefresh();
                        }

                        // If all ok show changes saved
                        ShowChangesSaved();
                        RegisterRefreshScript();
                    }
                }
            }

            // Clear warning text
            editMenuElem.MessagesPlaceHolder.WarningText = "";
        }

        if (DialogMode)
        {
            switch (e.ActionName)
            {
            case ComponentEvents.SAVE:
            case ComponentEvents.CHECKOUT:
            case ComponentEvents.UNDO_CHECKOUT:
            case ComponentEvents.CHECKIN:
                ScriptHelper.RegisterStartupScript(Page, typeof(string), "wopenerRefresh", ScriptHelper.GetScript("if (wopener && wopener.refresh) { wopener.refresh(); }"));
                break;
            }
        }

        if (isSiteManager && (e.ActionName != ComponentEvents.CHECKOUT))
        {
            ScriptHelper.RefreshTabHeader(Page, null);
        }
    }
Exemplo n.º 22
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            var username = HttpContext.Session.GetString("_username");
            var usertype = HttpContext.Session.GetString("_usertype");
            var access   = new Access(username, "Student");

            if (access.IsLogin())
            {
                if (access.IsAuthorize(usertype))
                {
                    WeeklyLog = await _context.WeeklyLog
                                .Where(w => w.DateDeleted == null)
                                .Include(w => w.Project)
                                .FirstOrDefaultAsync(w => w.WeeklyLogId == id);

                    if (WeeklyLog == null)
                    {
                        return(RedirectToPage($"/{usertype}/Progress/Index"));
                    }

                    Student = await _context.Student
                              .Where(s => s.DateDeleted == null)
                              .Include(s => s.Batch)
                              .Include(s => s.Project)
                              .FirstOrDefaultAsync(s => s.AssignedId == username);

                    if (WeeklyLog.StudentId != Student.AssignedId)
                    {
                        ErrorMessage = "Access Denied! This is not your weekly log!";
                        return(RedirectToPage($"/{usertype}/Progress/Index"));
                    }

                    if (WeeklyLog.WeeklyLogStatus != "Require Modification")
                    {
                        ErrorMessage = "Modification not required. Action denied";
                        return(RedirectToPage("/Student/Progress/Index"));
                    }

                    Project = await _context.Project
                              .Where(p => p.DateDeleted == null)
                              .FirstOrDefaultAsync(p => p.ProjectId == Student.ProjectId);

                    Supervisor = await _context.Supervisor
                                 .Where(s => s.DateDeleted == null)
                                 .FirstOrDefaultAsync(s => s.AssignedId == Project.SupervisorId);

                    if (Project.CoSupervisorId != null)
                    {
                        CoSupervisor = await _context.Supervisor
                                       .Where(s => s.DateDeleted == null)
                                       .FirstOrDefaultAsync(s => s.AssignedId == Project.CoSupervisorId);
                    }

                    Ef = new EditForm
                    {
                        Date         = WeeklyLog.WeeklyLogDate,
                        WorkDone     = WeeklyLog.WorkDone,
                        WorkToBeDone = WeeklyLog.WorkToBeDone,
                        Problem      = WeeklyLog.Problem,
                        Comment      = WeeklyLog.Comment
                    };

                    return(Page());
                }
                else
                {
                    ErrorMessage = "Access Denied";
                    return(RedirectToPage($"/{usertype}/Index"));
                }
            }
            else
            {
                ErrorMessage = "Login Required";
                return(RedirectToPage("/Account/Login"));
            }
        }
Exemplo n.º 23
0
        protected void EditForm_DataBound(object sender, EventArgs e)
        {
            SearchPanel.Visible = false;

            object obj = null;

            if (this.DatabaseList != null)
            {
                using (RadComboBoxItem item = new RadComboBoxItem(string.Format(CultureInfo.InvariantCulture, Resources.OrganizationsControl_DatabaseList_MasterDatabaseItem_Text, Resources.OrganizationProvider_MasterDatabaseText), string.Empty))
                {
                    this.DatabaseList.Items.Insert(0, item);
                }

                using (RadComboBoxItem item = new RadComboBoxItem(string.Empty, "x"))
                {
                    this.DatabaseList.Items.Insert(0, item);
                }

                obj = DataBinder.Eval(EditForm.DataItem, "DatabaseId");
                if (!Support.IsNullOrDBNull(obj))
                {
                    RadComboBoxItem item1 = this.DatabaseList.FindItemByValue(obj.ToString());
                    if (item1 != null)
                    {
                        this.DatabaseList.SelectedValue = obj.ToString();
                    }
                }
            }

            if (this.ParentOrgsList != null)
            {
                using (RadComboBoxItem item = new RadComboBoxItem(string.Empty, string.Empty))
                {
                    this.ParentOrgsList.Items.Add(item);
                }

                Guid databaseId     = Guid.Empty;
                Guid?organizationId = null;
                if (EditForm.CurrentMode == DetailsViewMode.Insert)
                {
                    databaseId = ((DatabaseList.Items.Count > 2) ? (Guid)Support.ConvertStringToType(DatabaseList.Items[2].Value, typeof(Guid)) : Guid.Empty);
                }
                else
                {
                    databaseId     = (Support.IsNullOrDBNull(obj) ? Guid.Empty : (Guid)obj);
                    organizationId = new Guid?((Guid)EditForm.DataKey[0]);
                }

                this.ParentOrgsList.DataSource = OrganizationProvider.GetOrganizationsByParentOrganizationIdAndDatabaseId(databaseId, organizationId);
                this.ParentOrgsList.DataBind();

                obj = DataBinder.Eval(EditForm.DataItem, "ParentOrganizationId");
                if (Support.IsNullOrDBNull(obj))
                {
                    obj = string.Empty;
                }

                RadComboBoxItem item1 = this.ParentOrgsList.FindItemByValue(obj.ToString());
                if (item1 != null)
                {
                    this.ParentOrgsList.SelectedValue = obj.ToString();
                }
            }

            obj = DataBinder.Eval(EditForm.DataItem, "CreatedTime");
            if (!Support.IsNullOrDBNull(obj))
            {
                Literal lit = (Literal)EditForm.FindControl("CreatedTimeLiteral");
                lit.Text = Support.ToShortDateString((DateTime)obj, m_UserContext.TimeZone);
            }

            obj = DataBinder.Eval(EditForm.DataItem, "ExpirationTime");
            if (!Support.IsNullOrDBNull(obj))
            {
                this.ExpirationTime.SelectedDate = TimeZoneInfo.ConvertTimeFromUtc((DateTime)obj, m_UserContext.TimeZone);
            }

            obj = DataBinder.Eval(EditForm.DataItem, "CanceledTime");
            if (!Support.IsNullOrDBNull(obj))
            {
                this.CanceledTime.SelectedDate = TimeZoneInfo.ConvertTimeFromUtc((DateTime)obj, m_UserContext.TimeZone);
            }
        }
Exemplo n.º 24
0
    /// <summary>
    /// Handles the OnAfterAction event of the ObjectManager control.
    /// </summary>
    protected void ObjectManager_OnAfterAction(object sender, SimpleObjectManagerEventArgs e)
    {
        if ((e.ActionName == ComponentEvents.SAVE) || (e.ActionName == ComponentEvents.CHECKIN))
        {
            if (EditForm.ValidateData())
            {
                LayoutInfo li = EditedObject as LayoutInfo;

                if (radShared.Checked)
                {
                    // Get the current layout type
                    PageTemplateLayoutTypeEnum layoutType = PageTemplateLayoutTypeEnum.PageTemplateLayout;
                    PageTemplateDeviceLayoutInfoProvider.GetLayoutObject(PageTemplateInfo, DeviceProfileInfo, out layoutType);

                    switch (layoutType)
                    {
                    case PageTemplateLayoutTypeEnum.PageTemplateLayout:
                    case PageTemplateLayoutTypeEnum.SharedLayout:
                    {
                        int newLayoutId = ValidationHelper.GetInteger(drpLayout.Value, 0);

                        // We need to save also page template if shared template is used
                        if ((PageTemplateInfo != null) && (PageTemplateInfo.LayoutID != li.LayoutId))
                        {
                            PageTemplateInfo.LayoutID = newLayoutId;
                            PageTemplateInfo.Update();
                        }
                    }
                    break;

                    case PageTemplateLayoutTypeEnum.DeviceSharedLayout:
                    case PageTemplateLayoutTypeEnum.DeviceLayout:
                    {
                        // We need to save also template device layout if shared template is used
                        PageTemplateDeviceLayoutInfo deviceLayout = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(TemplateID, DeviceProfileID);
                        if (deviceLayout != null)
                        {
                            deviceLayout.LayoutID   = ValidationHelper.GetInteger(drpLayout.Value, 0);
                            deviceLayout.LayoutCode = null;
                            deviceLayout.LayoutCSS  = null;
                            deviceLayout.Update();
                        }
                    }
                    break;

                    default:
                        break;
                    }
                }

                // Register refresh script
                string refreshScript = ScriptHelper.GetScript("if ((wopener != null) && (wopener.RefreshPage != null)) {wopener.RefreshPage();}");
                ScriptHelper.RegisterClientScriptBlock(Page, typeof(String), "pageTemplateRefreshScript", refreshScript);

                // Register preview refresh
                RegisterRefreshScript();

                // Close if required
                if (ValidationHelper.GetBoolean(hdnClose.Value, false))
                {
                    ScriptHelper.RegisterStartupScript(Page, typeof(string), "CloseDialogPreviewScript", ScriptHelper.GetScript("CloseDialog();"));
                }

                // Load actual layout info (it was edited during saving by LayoutInfoProvider)
                if (li != null)
                {
                    actualLayoutInfo = LayoutInfoProvider.GetLayoutInfo(li.LayoutId);
                }
            }

            // Hide warning after save
            MessagesPlaceHolder.WarningText = "";
        }
        else if (e.ActionName == ComponentEvents.UNDO_CHECKOUT)
        {
            if (AllowTypeSwitching)
            {
                var url = RequestContext.CurrentURL;
                url = URLHelper.RemoveParameterFromUrl(url, "newshared");
                url = URLHelper.RemoveParameterFromUrl(url, "oldshared");
                url = URLHelper.AddParameterToUrl(url, "wopenerrefresh", "1");
                Response.Redirect(url);
            }
        }
        else if (e.ActionName == ComponentEvents.CHECKOUT)
        {
            DisplayMessage(true);
        }

        switch (e.ActionName)
        {
        case ComponentEvents.SAVE:
        case ComponentEvents.CHECKOUT:
        case ComponentEvents.CHECKIN:
        case ComponentEvents.UNDO_CHECKOUT:
            if (DialogMode)
            {
                RegisterWOpenerRefreshScript();
            }
            else if (dialog)
            {
                ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "parentWOpenerRefresh", ScriptHelper.GetScript("if (parent && parent.wopener && parent.wopener.refresh) { parent.wopener.refresh(); }"));
            }
            break;
        }

        if (!AllowTypeSwitching && (EditedObjectType == EditedObjectTypeEnum.Layout) && (e.ActionName != ComponentEvents.CHECKOUT) && !DialogMode)
        {
            ScriptHelper.RefreshTabHeader(Page, EditForm.EditedObject.Generalized.ObjectDisplayName);
        }

        // No save for checkout
        if (e.ActionName != ComponentEvents.CHECKOUT)
        {
            ShowChangesSaved();
        }
    }
Exemplo n.º 25
0
    /// <summary>
    /// Handles the OnAfterAction event of the ObjectManager control.
    /// </summary>
    protected void ObjectManager_OnAfterAction(object sender, SimpleObjectManagerEventArgs e)
    {
        wpli = EditForm.EditedObject as WebPartLayoutInfo;

        if ((wpli == null) || (wpli.WebPartLayoutID <= 0) || (!e.IsValid))
        {
            // Do not continue if the object has not been created
            return;
        }

        LayoutCodeName = wpli.WebPartLayoutCodeName;

        if (e.ActionName == ComponentEvents.SAVE)
        {
            if (EditForm.ValidateData())
            {
                if (!isSiteManager)
                {
                    SetCurrentLayout(true);
                }

                if (ValidationHelper.GetBoolean(hdnClose.Value, false))
                {
                    // If window to close, register close script
                    CloseDialog();
                }
                else
                {
                    // Redirect parent for new
                    if (isNew)
                    {
                        if (isSiteManager)
                        {
                            URLHelper.Redirect(String.Format("{0}&parentobjectid={1}&objectid={2}&displaytitle={3}",
                                                             UIContextHelper.GetElementUrl("CMS.Design", "Edit.WebPartLayout"), webPartInfo.WebPartID, wpli.WebPartLayoutID, false));
                        }
                        else
                        {
                            var codeName    = (wpli != null) ? wpli.WebPartLayoutCodeName : string.Empty;
                            var redirectUrl = ResolveUrl("~/CMSModules/PortalEngine/UI/WebParts/WebPartProperties_layout_frameset.aspx") + URLHelper.UpdateParameterInUrl(RequestContext.CurrentQueryString, "layoutcodename", codeName);
                            ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "RefreshHeader", ScriptHelper.GetScript("parent.location ='" + redirectUrl + "'"));

                            // Reload the parent page after save
                            EnsureParentPageRefresh();
                        }
                    }
                    else
                    {
                        if (!isSiteManager)
                        {
                            // Reload the parent page after save
                            EnsureParentPageRefresh();
                        }

                        // If all ok show changes saved
                        RegisterRefreshScript();
                    }
                }
            }

            // Clear warning text
            editMenuElem.MessagesPlaceHolder.WarningText = "";
        }

        if (DialogMode)
        {
            switch (e.ActionName)
            {
            case ComponentEvents.SAVE:
            case ComponentEvents.CHECKOUT:
            case ComponentEvents.UNDO_CHECKOUT:
            case ComponentEvents.CHECKIN:
                ScriptHelper.RegisterStartupScript(Page, typeof(string), "wopenerRefresh", ScriptHelper.GetScript("if (wopener && wopener.refresh) { wopener.refresh(); }"));
                break;
            }
        }

        if (isSiteManager && (e.ActionName != ComponentEvents.CHECKOUT) && EditForm.DisplayNameChanged)
        {
            ScriptHelper.RegisterClientScriptBlock(Page, typeof(String), "RefreshBreadcrumbs", ScriptHelper.GetScript("if (parent.refreshBreadcrumbs != null && parent.document.pageLoaded) {parent.refreshBreadcrumbs('" + ResHelper.LocalizeString(EditForm.EditedObject.Generalized.ObjectDisplayName) + "')}"));
        }
    }
Exemplo n.º 26
0
        private void AllButtons_Click(object sender, EventArgs e)
        {
            var button = (Button)sender;

            switch (button.Name)
            {
            case "startButton":
                started = true;
                SetStartVisiblity(true);
                startTimeTextBox.Text = DateTime.Now.ToString().Split(' ')[1];
                startDateTextBox.Text = DateTime.Now.ToString().Split(' ')[0];
                break;

            case "endButton":
                ended = true;
                SetEndVisiblity(true);
                endTimeTextBox.Text = DateTime.Now.ToString().Split(' ')[1];
                endDateTextBox.Text = DateTime.Now.ToString().Split(' ')[0];
                break;

            case "cancelButton":
                ended                 = false;
                started               = false;
                startPanel.Visible    = false;
                endButton.Visible     = false;
                endPanel.Visible      = false;
                confirmButton.Visible = false;
                cancelButton.Visible  = false;
                break;

            case "confirmButton":
                int daysInSeconds;
                try
                {
                    DateTime startDateTime = new DateTime(Convert.ToInt32(startDateTextBox.Text.Split('.')[2]), Convert.ToInt32(startDateTextBox.Text.Split('.')[1]), Convert.ToInt32(startDateTextBox.Text.Split('.')[0]),
                                                          Convert.ToInt32(startTimeTextBox.Text.Split(':')[0]), Convert.ToInt32(startTimeTextBox.Text.Split(':')[1]), Convert.ToInt32(startTimeTextBox.Text.Split(':')[2]));

                    DateTime endDateTime = new DateTime(Convert.ToInt32(endDateTextBox.Text.Split('.')[2]), Convert.ToInt32(endDateTextBox.Text.Split('.')[1]), Convert.ToInt32(endDateTextBox.Text.Split('.')[0]),
                                                        Convert.ToInt32(endTimeTextBox.Text.Split(':')[0]), Convert.ToInt32(endTimeTextBox.Text.Split(':')[1]), Convert.ToInt32(endTimeTextBox.Text.Split(':')[2]));

                    TimeSpan differenseDate = endDateTime - startDateTime;

                    if (differenseDate.Days > 0)
                    {
                        daysInSeconds = differenseDate.Days * 24 * 60 * 60;
                    }
                    else
                    {
                        daysInSeconds = 0;
                    }

                    string[] thisSecondsFileNames = new string[5] {
                        "TotalSeconds", "ThisYearSeconds", "ThisMonthSeconds", "ThisWeekSeconds", "TodaySeconds"
                    };

                    foreach (var fileName in thisSecondsFileNames)
                    {
                        Storage.Save(listBox.SelectedItem.ToString(), fileName, Convert.ToString(Convert.ToInt32(Storage.Load(listBox.SelectedItem.ToString(), fileName)) +
                                                                                                 (differenseDate.Hours * 60 * 60) + (differenseDate.Minutes * 60) + (differenseDate.Seconds) + daysInSeconds));
                    }

                    //totalSeconds += (differenseDate.Hours * 60 * 60) + (differenseDate.Minutes * 60) + (differenseDate.Seconds) + daysInSeconds;
                    //thisYearSeconds += (differenseDate.Hours * 60 * 60) + (differenseDate.Minutes * 60) + (differenseDate.Seconds) + daysInSeconds;
                    //thisMonthSeconds += (differenseDate.Hours * 60 * 60) + (differenseDate.Minutes * 60) + (differenseDate.Seconds) + daysInSeconds;
                    //thisWeekSeconds += (differenseDate.Hours * 60 * 60) + (differenseDate.Minutes * 60) + (differenseDate.Seconds) + daysInSeconds;
                    //todaySeconds += (differenseDate.Hours * 60 * 60) + (differenseDate.Minutes * 60) + (differenseDate.Seconds) + daysInSeconds;

                    int    nowSeconds = (differenseDate.Hours * 60 * 60) + (differenseDate.Minutes * 60) + (differenseDate.Seconds) + daysInSeconds;
                    var    seconds    = TimeSpan.FromSeconds(nowSeconds);
                    string spent      = "";
                    if (seconds.Hours != 0)
                    {
                        spent += $"{seconds.Hours} ч. ";
                    }
                    if (seconds.Minutes != 0)
                    {
                        spent += $"{seconds.Minutes} мин. ";
                    }
                    if (seconds.Seconds != 0)
                    {
                        spent += $"{seconds.Seconds} сек.";
                    }
                    if (spent == "")
                    {
                        spent = "0 сек.";
                    }
                    string saveHistory = historyRichTextBox.Text;
                    historyRichTextBox.Text  = "";
                    historyRichTextBox.Text += $"ОТ {startDateTextBox.Text} {startTimeTextBox.Text}\n" +
                                               $"ДО {endDateTextBox.Text} {endTimeTextBox.Text}\n" +
                                               $"ПОТРАЧЕНО {spent}\n\n";
                    historyRichTextBox.Text += saveHistory;

                    TimeSpentForm timeSpentForm1 = new TimeSpentForm(listBox.SelectedItem.ToString());
                    timeSpentForm1.Close();
                }
                catch
                {
                    ended                 = true;
                    started               = true;
                    startPanel.Visible    = true;
                    endButton.Visible     = true;
                    endPanel.Visible      = true;
                    confirmButton.Visible = true;
                    cancelButton.Visible  = true;
                    break;
                }
                ended                 = false;
                started               = false;
                startPanel.Visible    = false;
                endButton.Visible     = false;
                endPanel.Visible      = false;
                confirmButton.Visible = false;
                cancelButton.Visible  = false;
                break;

            case "addButton":
                AddForm addForm = new AddForm();
                addForm.ShowDialog();
                if (addForm.AddedDirectory != null)
                {
                    ShowItemsInListBox();
                    listBox.SelectedItem = addForm.AddedDirectory;
                }
                break;

            case "deleteButton":
                if (listBox.SelectedItem != null)
                {
                    DialogResult dialogResult = MessageBox.Show($"Delete {listBox.SelectedItem} item?", "Deleting", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        Storage.DeleteDirectory(listBox.SelectedItem.ToString());
                        ShowItemsInListBox();
                        savedDirectorySelection = null;
                        if (listBox.Items.Count > 0)
                        {
                            listBox.SelectedIndex = 0;
                        }
                        else
                        {
                            mainTableLayoutPanel.Visible    = false;
                            historyTableLayoutPanel.Visible = false;
                        }
                    }
                }
                break;

            case "editButton":
                if (listBox.SelectedItem != null)
                {
                    EditForm editForm = new EditForm(listBox.SelectedItem.ToString());
                    editForm.ShowDialog();

                    ShowItemsInListBox();
                    savedDirectorySelection = editForm.NewDirectoryName;
                    listBox.SelectedItem    = editForm.NewDirectoryName;
                }
                break;

            case "showSpentButton":
                TimeSpentForm timeSpentForm = new TimeSpentForm(listBox.SelectedItem.ToString());
                timeSpentForm.ShowDialog();
                timeSpentForm.Close();
                break;
            }
        }
Exemplo n.º 27
0
    /// <summary>
    /// Saves the data
    /// </summary>
    /// <param name="redirect">If true, use server redirect after successful save</param>
    public bool Save(bool redirect)
    {
        string url = "tab_general.aspx?campaignid={%EditedObject.ID%}&saved=1&modaldialog=true&selectorID={?selectorID?}";

        return(EditForm.SaveData(redirect ? url : String.Empty));
    }