コード例 #1
0
 /// <summary>
 /// Delete IFContainer value
 /// </summary>
 private void Delete()
 {
     for (int i = 0; i < dgValues.Rows.Count; i++)
     {
         TemplatedColumn col = (TemplatedColumn)dgValues.Rows[i].Cells.FromKey("Select").Column;
         CheckBox        cb  = (CheckBox)((CellItem)col.CellItems[i]).FindControl("g_sd");
         if (cb.Checked)
         {
             InputFormValue ifValueObj = InputFormValue.GetByKey(Convert.ToInt32(dgValues.Rows[i].Cells.FromKey("InputFormValueId").Text));
             if (!ifValueObj.Delete(HyperCatalog.Shared.SessionState.User.Id))
             {
                 lbError.CssClass = "hc_error";
                 lbError.Text     = InputFormValue.LastError;
                 lbError.Visible  = true;
                 break;
             }
         }
     }
     UpdateDataEdit();
 }
コード例 #2
0
        private void SaveChunk(ChunkStatus status, bool lockTranslations)
        {
            string error = string.Empty;
            string Value = string.Empty;

            if (Request["rd"] != null || !dg.Columns.FromKey("InScope").ServerOnly || uwToolbar.Items.FromKeyButton("ilb").Selected)
            {
                //#ACQ10.0 Starts
                if (Request["rd"] == HyperCatalog.Business.Chunk.BlankText)
                {
                    uwToolbar.Items.FromKeyButton("ilb").Pressed(true);
                    uwToolbar.Items.FromKeyButton("ilb").Selected = true;
                }
                //#ACQ10.0 Ends
                if (uwToolbar.Items.FromKeyButton("ilb").Selected)
                {
                    Value = HyperCatalog.Business.Chunk.BlankValue;
                }
                else if (Request["rd"] != null) // --> radion button (single choice)
                {
                    if (ViewState["Source"].ToString() == "Lookup")
                    {
                        LookupValue lValue = LookupValue.GetByKey(Convert.ToInt32(Request["rd"]));
                        Value = lValue.Text;
                    }
                    else
                    {
                        InputFormValue lValue = InputFormValue.GetByKey(Convert.ToInt32(Request["rd"]));
                        Value = lValue.Text;
                    }
                }
                else // (multi choice)
                {
                    string separator = "; ";
                    bool   success   = true;
                    string curText   = string.Empty;
                    if (dg != null && dg.Rows != null && dg.Rows.Count > 0)
                    {
                        foreach (UltraGridRow r in dg.Rows)
                        {
                            if (Convert.ToBoolean(r.Cells.FromKey("InScope").Value))
                            {
                                //#ACQ10.0 Stats  Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scrollview", "<script>rowIndex = " + e.Row.Index.ToString() + ";</script>");
                                if ((Convert.ToInt32(r.Cells.FromKey("Id").Value) != 0) && (Value.IndexOf(HyperCatalog.Business.Chunk.BlankValue) < 0))
                                {
                                    //#ACQ10.0 Ends
                                    if (ViewState["Source"].ToString() == "Lookup")
                                    {
                                        LookupValue lValue = LookupValue.GetByKey(Convert.ToInt32(r.Cells.FromKey("Id").Value));
                                        curText = lValue.Text;
                                    }
                                    else
                                    {
                                        InputFormValue lValue = InputFormValue.GetByKey(Convert.ToInt32(r.Cells.FromKey("Id").Value));
                                        curText = lValue.Text;
                                    }
                                    if (Value.Length > 0)
                                    {
                                        Value += separator.ToString();
                                    }
                                    Value += curText;
                                }
                                else
                                {
                                    Value = HyperCatalog.Business.Chunk.BlankValue;
                                }
                            }
                        }
                    }
                }
                //ACQ10.0 Starts
                //If the value is empty the user will get a message asking the select a value and no value will be saved into application
                if (Value.Length <= 0)
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('Please, select a value!');</script>");
                    return;
                }
                //ACQ10.0 Ends

                if (chunk != null)
                // Test if user has made a change that allows database update
                {
                    if (Value != chunk.Text || ChunkComment1.Comment != chunk.Comment || status != chunk.Status)
                    {
                        chunk.Text    = Value;
                        chunk.Comment = ChunkComment1.Comment;
                        chunk.Status  = status;
                    }
                }
                else
                {
                    chunk = new HyperCatalog.Business.Chunk(itemId, containerId, culture.Code, Value, ChunkComment1.Comment, status, SessionState.User.Id);
                }
                if (chunk.Save(SessionState.User.Id))
                {
                    //Added this line for QCs# 839 and 1028
                    chunk.ModifyDate = DateTime.UtcNow;
                    //Added this line for QCs# 839 and 1028

                    lbResult.Text     = "<br/>Chunk saved!";
                    lbResult.CssClass = "hc_success";
                    lbResult.Visible  = true;
                    if (chunk.Text == HyperCatalog.Business.Chunk.BlankValue)
                    {
                        chunk.Text = HyperCatalog.Business.Chunk.BlankText;
                    }
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "update", "<script>UpdateGrid('" + HyperCatalog.Business.Chunk.GetStatusFromEnum(chunk.Status) + "', '" + UITools.CleanJSString(chunk.Text) + "');</script>");
                    if (!lockTranslations)
                    {
                        chunk.ForceTranslationsTo(SessionState.User.Id, ChunkStatus.Draft);
                        SessionState.QDEChunk = chunk;
                    }

                    //Added this line for QCs# 839 and 1028
                    ChunkModifier1.Chunk = chunk;
                    //Added this line for QCs# 839 and 1028
                }
                else
                {
                    lbResult.Text     = "<br/>Error: " + HyperCatalog.Business.Chunk.LastError;
                    lbResult.CssClass = "hc_error";
                }
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('Please, select a value!');</script>");
            }
        }