protected void dg_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e)
    {
        cv.ApplyFilter("Id", Convert.ToInt32(e.Row.DataKey), HyperCatalog.Business.CollectionView.FilterOperand.Equals);

        TemplatedColumn col      = (TemplatedColumn)e.Row.Cells.FromKey("nDelay").Column;
        CellItem        cellItem = (CellItem)col.CellItems[e.Row.Index];
        DropDownList    ddDelay  = (DropDownList)cellItem.FindControl("ddDelay");

        for (int i = 0; i < delays.Length; i++)
        {
            ddDelay.Items.Add(new ListItem(delays[i], i.ToString()));
        }

        HyperCatalog.Business.UserNotification obj = cv.Count == 1 ? (HyperCatalog.Business.UserNotification)cv[0] : null;
        col      = (TemplatedColumn)e.Row.Cells.FromKey("Select").Column;
        cellItem = (CellItem)col.CellItems[e.Row.Index];
        CheckBox cb = (CheckBox)cellItem.FindControl("g_sd");

        cb.Checked = obj != null;
        bool allowInAdv = (bool)e.Row.Cells.FromKey("AllowNotificationInAdvance").Value;

        if (allowInAdv)
        {
            //the user has checked this notification
            ddDelay.SelectedIndex = obj != null?Convert.ToInt32(obj.Delay) : 0;
        }
        else
        {
            ddDelay.Items.Clear();
            ddDelay.Items.Add(new ListItem("Instant", "-1"));
        }
        //allow offset editing only if AllowNotificationInAdvance
        ddDelay.Enabled = allowInAdv;
        cv.RemoveFilter();
    }
    protected void dg_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e)
    {
        try
        {
            cv.ApplyFilter("Id", Convert.ToInt32(e.Row.DataKey), HyperCatalog.Business.CollectionView.FilterOperand.Equals);

            TemplatedColumn col      = (TemplatedColumn)e.Row.Cells.FromKey("Delay").Column;
            CellItem        cellItem = (CellItem)col.CellItems[e.Row.Index];
            DropDownList    ddDelay  = (DropDownList)cellItem.FindControl("ddDelay");
            for (int i = 0; i < delays.Length; i++)
            {
                ddDelay.Items.Add(new ListItem(delays[i], i.ToString()));
            }

            HyperCatalog.Business.UserNotification obj = cv.Count == 1 ? (HyperCatalog.Business.UserNotification)cv[0] : null;
            col      = (TemplatedColumn)e.Row.Cells.FromKey("Select").Column;
            cellItem = (CellItem)col.CellItems[e.Row.Index];
            CheckBox cb = (CheckBox)cellItem.FindControl("g_sd");
            cb.Checked = obj != null;

            bool allowNotif = (bool)e.Row.Cells.FromKey("AllowNotificationInAdvance").Value;
            bool allowInAdv = (allowNotif && SessionState.User.HasCapability(CapabilitiesEnum.MANAGE_USERS));
            if (allowNotif)
            {
                ddDelay.SelectedIndex = obj != null?Convert.ToInt32(obj.Delay) : 0;
            }
            else
            {
                ddDelay.Items.Clear();
                ddDelay.Items.Add(new ListItem("Instant", "-1"));
            }
            ddDelay.Enabled = allowInAdv;
        }
        catch (Exception exc)
        {
            e.Row.Cells.FromKey("Delay").Text = exc.ToString();
        }
        finally
        {
            cv.RemoveFilter();
        }
    }
Example #3
0
    protected void dg_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e)
    {
        //ifcl.ApplyFilter("ContainerId", Convert.ToInt32(e.Row.Cells.FromKey("Id").Text), CollectionView.FilterOperand.Equals);
        e.Row.Cells.FromKey("ContainerName").Text = "[" + e.Row.Cells.FromKey("Tag").Text + "] - " + e.Row.Cells.FromKey("ContainerName").Text;
        TemplatedColumn col      = (TemplatedColumn)e.Row.Cells.FromKey("ifcType").Column;
        CellItem        cellItem = (CellItem)col.CellItems[e.Row.Index];
        DropDownList    ddType   = (DropDownList)cellItem.FindControl("ddType");

        if (e.Row.Cells.FromKey("LookupId") != null && e.Row.Cells.FromKey("LookupId").Text == "-1")
        {
            foreach (string t in Enum.GetNames(typeof(InputFormContainerType)))
            {
                ddType.Items.Add(new ListItem(t, t));
            }
        }
        else
        {
            string defaultValue = Enum.GetName(typeof(InputFormContainerType), InputFormContainerType.Normal);
            ddType.Items.Add(new ListItem(defaultValue, defaultValue));
            ddType.Enabled = false;
        }
        if (txtFilter.Text.Trim() != string.Empty)
        {
            Infragistics.WebUI.UltraWebGrid.UltraGridRow r = e.Row;
            UITools.HiglightGridRowFilter(ref r, txtFilter.Text, true);
        }
        //if (ifcl.Count != 0)
        //{
        //  InputFormContainer obj = ((InputFormContainer)ifcl[0]);
        //  col = (TemplatedColumn)e.Row.Cells.FromKey("Select").Column;
        //  cellItem = (CellItem)col.CellItems[e.Row.Index];
        //  CheckBox cb = (CheckBox)cellItem.FindControl("g_sd");
        //  cb.Checked = true;
        //  cb.Enabled = false;
        //  col = (TemplatedColumn)e.Row.Cells.FromKey("Mandatory").Column;
        //  cellItem = (CellItem)col.CellItems[e.Row.Index];
        //  cb = (CheckBox)cellItem.FindControl("g_m");
        //  cb.Checked = obj.Mandatory;
        //  cb.Enabled = false;
        //  ddType.SelectedValue = obj.Type.ToString();
        //  e.Row.Cells.FromKey("Comment").Text = obj.Comment.ToString();
        //  e.Row.Cells.FromKey("Comment").AllowEditing = AllowEditing.No;
        //  ddType.Enabled = false;
        //}
        //else
        //{
        ddType.SelectedValue = InputFormContainerType.Normal.ToString();
        //}
        //ifcl.RemoveFilter();
    }
        protected void uwgModules_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e)
        {
            // Build dataset containing all pane names
            DataSet   ds = new DataSet();
            DataTable dt = ds.Tables.Add("PaneList");

            dt.Columns.Add("Value", Type.GetType("System.Int32"));
            dt.Columns.Add("Text", Type.GetType("System.String"));
            dt.Rows.Add(new object[] { 0, "LeftPane" });
            dt.Rows.Add(new object[] { 1, "ContentPane" });
            dt.Rows.Add(new object[] { 2, "RightPane" });

            // Get properties for this row
            int     moduleDefId  = (Int16)e.Row.Cells.FromKey(CST_FIELD_WEBPARTID).Value;
            DataRow drProperties = Configuration.GetModuleProperties(moduleDefId);

            // Find pane list in current row
            TemplatedColumn currentTempColPane  = (TemplatedColumn)e.Row.Cells.FromKey(CST_FIELD_PANENAME).Column;
            CellItem        currentCellItemPane = (CellItem)currentTempColPane.CellItems[e.Row.Index];
            DropDownList    currentDDL          = (DropDownList)currentCellItemPane.FindControl("ddlPaneList");

            // Find module order in current row
            TemplatedColumn currentTempColOrder  = (TemplatedColumn)e.Row.Cells.FromKey(CST_FIELD_SORT).Column;
            CellItem        currentCellItemOrder = (CellItem)currentTempColOrder.CellItems[e.Row.Index];
            WebNumericEdit  currentWNE           = (WebNumericEdit)currentCellItemOrder.FindControl("wneModuleOrder");

            // Update data in pane list
            currentDDL.DataSource     = ds;
            currentDDL.DataTextField  = "Text";
            currentDDL.DataValueField = "Value";
            currentDDL.DataBind();
            int selectedPane = 0;

            if (drProperties != null)
            {
                selectedPane = (Int16)drProperties[CST_FIELD_PANEID];
            }
            currentDDL.SelectedIndex = selectedPane;           // select pane name

            // Update data in edit for module order
            currentWNE.Value = 0;
            if (drProperties != null)
            {
                currentWNE.Value = drProperties[CST_FIELD_SORT].ToString() != string.Empty? Convert.ToInt32(drProperties[CST_FIELD_SORT].ToString()): 0;
            }

            // free memory
            ds.Dispose();
        }
    void UpdateDataView()
    {
        lbError.Visible = false;

        using (Database dbObj = Utils.GetMainDB())
        {
            using (DataSet ds = dbObj.RunSPReturnDataSet("_User_GetCulturesSorted", "cultures", new SqlParameter("@UserId", userId)))
            {
                dbObj.CloseConnection();
                if (dbObj.LastError.Length == 0)
                {
                    if (ds != null)
                    {
                        dg.DataSource = ds.Tables[0];
                        Utils.InitGridSort(ref dg, false);
                        dg.DataBind();
                        dg.DisplayLayout.AllowSortingDefault = AllowSorting.No;
                        ds.Dispose();

                        if (!SessionState.User.HasCapability(CapabilitiesEnum.MANAGE_USERS) || SessionState.User.IsReadOnly)
                        {
                            TemplatedColumn colHeader      = (TemplatedColumn)dg.Columns.FromKey("Select");
                            HeaderItem      cellItemHeader = colHeader.HeaderItem;
                            CheckBox        cbHeader       = (CheckBox)cellItemHeader.FindControl("g_ca");
                            cbHeader.Enabled = false;

                            foreach (UltraGridRow r in dg.Rows)
                            {
                                TemplatedColumn col      = (TemplatedColumn)r.Cells.FromKey("Select").Column;
                                CellItem        cellItem = (CellItem)col.CellItems[r.Index];
                                CheckBox        cb       = (CheckBox)cellItem.FindControl("g_sd");
                                cb.Enabled = false;
                            }
                        }
                    }
                }
                else
                {
                    lbError.CssClass = "hc_error";
                    lbError.Text     = dbObj.LastError;
                    lbError.Visible  = true;
                }
            }
        }
    }
    private void Save()
    {
        if (SessionState.User == null)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "clientScript", "<script>back();</script>");
        }

        if (dg.Rows.Count > 0)
        {
            bool success = true;
            success = SessionState.User.Notifications.RemoveAll();
            TemplatedColumn col = (TemplatedColumn)dg.Rows[0].Cells.FromKey("Select").Column;

            foreach (CellItem cell in col.CellItems)
            {
                TemplatedColumn colDelay      = (TemplatedColumn)cell.Cell.Row.Cells.FromKey("nDelay").Column;
                CellItem        cellItemDelay = (CellItem)colDelay.CellItems[cell.Cell.Row.Index];
                CheckBox        cb            = (CheckBox)cell.FindControl("g_sd");
                DropDownList    ddDelay       = (DropDownList)cellItemDelay.FindControl("ddDelay");
                if (cb.Checked)
                {
                    success = success && SessionState.User.Notifications.Add(Convert.ToInt32(cell.Cell.Row.DataKey), ddDelay.Enabled?Convert.ToInt32(ddDelay.SelectedValue): 0);
                }
            }

            SessionState.User.ClearNotifications();
            BindLists();
            if (success)
            {
                lbError.Text     = "Data saved!";
                lbError.CssClass = "hc_success";
                lbError.Visible  = true;
            }
            else
            {
                lbError.Text     = "Error, update failed" + HyperCatalog.Business.UserNotification.LastError;
                lbError.CssClass = "hc_error";
                lbError.Visible  = true;
            }
        }
    }
Example #7
0
    /// <summary>
    /// Delete multiple containers on the grid
    /// </summary>
    private void Delete()
    {
        lbError.Visible = false;
        bool success = true;

        if (dg != null && dg.Rows != null && dg.Rows.Count > 0)
        {
            TemplatedColumn col = (TemplatedColumn)dg.Rows[0].Cells.FromKey("Select").Column;
            if (col != null)
            {
                for (int i = 0; i < col.CellItems.Count; i++)
                {
                    CellItem cellItem = (CellItem)col.CellItems[i];
                    Infragistics.WebUI.UltraWebGrid.UltraGridRow r = cellItem.Cell.Row;
                    CheckBox cb = (CheckBox)cellItem.FindControl("g_sd");
                    if (cb != null)
                    {
                        if (cb.Checked)
                        {
                            HyperCatalog.Business.InputFormContainer ifCObj = HyperCatalog.Business.InputFormContainer.GetByKey(Convert.ToInt32(r.Cells.FromKey("InputFormContainerId").Value));
                            success = ifCObj.Delete(HyperCatalog.Shared.SessionState.User.Id);
                            if (!success)
                            {
                                UpdateDataView();
                                lbError.CssClass = "hc_error";
                                lbError.Text     = HyperCatalog.Business.InputFormContainer.LastError;
                                lbError.Visible  = true;

                                break;
                            }
                        }
                    }
                }
            }
        }
        if (success)
        {
            UpdateDataView();
        }
    }
    private void BindLists()
    {
        SessionState.EditedUser.ClearNotifications();
        cv            = new HyperCatalog.Business.CollectionView(SessionState.EditedUser.Notifications);
        dg.DataSource = SessionState.EditedUser.Role.Notifications;
        dg.DataBind();
        Utils.InitGridSort(ref dg, false);

        if (!SessionState.User.HasCapability(CapabilitiesEnum.MANAGE_USERS) || SessionState.User.IsReadOnly)
        {
            TemplatedColumn colHeader      = (TemplatedColumn)dg.Columns.FromKey("Select");
            HeaderItem      cellItemHeader = colHeader.HeaderItem;
            CheckBox        cbHeader       = (CheckBox)cellItemHeader.FindControl("g_ca");
            cbHeader.Enabled = false;

            foreach (UltraGridRow r in dg.Rows)
            {
                TemplatedColumn col      = (TemplatedColumn)r.Cells.FromKey("Select").Column;
                CellItem        cellItem = (CellItem)col.CellItems[r.Index];
                CheckBox        cb       = (CheckBox)cellItem.FindControl("g_sd");
                cb.Enabled = false;
            }
        }
    }
Example #9
0
    private void Save()
    {
        lbError.Visible = false;
        Trace.Warn("Save");
        if (dg != null && dg.Rows != null && dg.Rows.Count > 0)
        {
            Trace.Warn("Entering loop");
            TemplatedColumn col     = (TemplatedColumn)dg.Rows[0].Cells.FromKey("Select").Column;
            TemplatedColumn colMand = (TemplatedColumn)dg.Rows[0].Cells.FromKey("Mandatory").Column;
            TemplatedColumn colType = (TemplatedColumn)dg.Rows[0].Cells.FromKey("ifcType").Column;

            if (col != null)
            {
                for (int i = 0; i < col.CellItems.Count; i++)
                {
                    try
                    {
                        CellItem cellItem = (CellItem)col.CellItems[i];
                        Infragistics.WebUI.UltraWebGrid.UltraGridRow r = cellItem.Cell.Row;
                        CheckBox cb = (CheckBox)cellItem.FindControl("g_sd");
                        cellItem = (CellItem)colMand.CellItems[i];
                        CheckBox chkMandatory = (CheckBox)cellItem.FindControl("g_m");
                        cellItem = (CellItem)colType.CellItems[i];
                        DropDownList ddType = (DropDownList)cellItem.FindControl("ddType");

                        if (cb != null)
                        {
                            Trace.Warn("Testing for " + dg.Rows[i].Cells.FromKey("Tag").Text + "=>" + cb.Checked.ToString());
                            if (cb.Checked && cb.Enabled)
                            {
                                using (InputFormContainer ifc = new InputFormContainer(-1, Convert.ToInt32(dg.Rows[i].Cells.FromKey("Id").Text),
                                                                                       inputFormId, ddlGroups.Text,
                                                                                       0,
                                                                                       dg.Rows[i].Cells.FromKey("Tag").Text,
                                                                                       dg.Rows[i].Cells.FromKey("ContainerName").Text,
                                                                                       (bool)dg.Rows[i].Cells.FromKey("isReg").Value,
                                                                                       dg.Rows[i].Cells.FromKey("Comment").Value != null ? dg.Rows[i].Cells.FromKey("Comment").Value.ToString() : string.Empty,
                                                                                       chkMandatory.Checked,
                                                                                       (InputFormContainerType)Enum.Parse(typeof(InputFormContainerType), ddType.SelectedValue, false),
                                                                                       SessionState.User.Id,
                                                                                       DateTime.UtcNow, -1, null))
                                {
                                    Trace.Warn("  -> Saving for " + dg.Rows[i].Cells.FromKey("Tag").Text);
                                    if (!ifc.Save())
                                    {
                                        // Error
                                        lbError.CssClass = "hc_error";
                                        lbError.Text    += ifc.ContainerName + " -> " + InputFormContainer.LastError + "<br/>" + Environment.NewLine;
                                        lbError.Visible  = true;
                                        Trace.Warn("  -> Error " + ifc.ContainerName + " -> " + InputFormContainer.LastError);
                                    }
                                    Trace.Warn("  -> Success ");
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Trace.Warn("UNEXPECTED Error " + ex.ToString());
                    }
                }
                //ifcl.Dispose();
                //Cache.Remove("ifcl");
                UpdateDataView();
                if (!lbError.Visible)
                {
                    lbError.CssClass = "hc_success";
                    lbError.Text     = "Data saved!";
                    lbError.Visible  = true;
                }
            }
        }
    }