/// <summary> /// Save IFContainer value /// </summary> private void Save() { bool isOk = false; for (int i = 0; i < dgValues.Rows.Count; i++) { if (dgValues.Rows[i].Cells.FromKey("ValueEdit").Value == null) { isOk = false; } else { ////////// string sValue = dgValues.Rows[i].Cells.FromKey("ValueEdit").Value.ToString(); string sComment = (dgValues.Rows[i].Cells.FromKey("CommentEdit").Value == null ? string.Empty : dgValues.Rows[i].Cells.FromKey("CommentEdit").Value.ToString()); string termId = dgValues.Rows[i].Cells.FromKey("TermId").Text; //#ACQ8.20 Starts//// //TemplatedColumn col = (TemplatedColumn)dgValues.Rows[i].Cells.FromKey("IsTranslateRow").Column; //CheckBox cb = (CheckBox)((CellItem)col.CellItems[i]).FindControl("IsTranslateRows"); bool isTranslatable = (bool)dgValues.Rows[i].Cells.FromKey("IsTranslateHeader").Value; //#ACQ8.20 Ends string inputFormValueId = dgValues.Rows[i].Cells.FromKey("InputFormValueId").Text; //InputFormValue IFValue = new InputFormValue(Convert.ToInt64(inputFormValueId), //InputFormContainerId, Convert.ToInt64(termId), //i, sValue, sComment,, SessionState.User.Id, SessionState.User.Id, DateTime.UtcNow, DateTime.UtcNow);//ACQ8.20 Commented InputFormValue IFValue = new InputFormValue(Convert.ToInt64(inputFormValueId), InputFormContainerId, Convert.ToInt64(termId), i, sValue, sComment, isTranslatable, SessionState.User.Id, SessionState.User.Id, DateTime.UtcNow, DateTime.UtcNow);//ACQ8.20 if (!IFValue.Save()) { isOk = false; lbError.CssClass = "hc_error"; lbError.Text = InputFormValue.LastError; lbError.Visible = true; break; } else { isOk = true; } } if (isOk) // Success { // Display message of success lbError.CssClass = "hc_success"; lbError.Text = "Data saved!"; lbError.Visible = true; } } UpdateDataEdit(); }
protected void btnAddRow_Click(object sender, System.Web.UI.ImageClickEventArgs e) { lbError.Visible = false; if (txtValue.Value.Length > 0) { if (ifcObj.Type == InputFormContainerType.MultiChoiceList && txtValue.Value.ToString().IndexOf(';') >= 0) { lbError.CssClass = "hc_error"; lbError.Text = "Value cannot contain the ';' character"; lbError.Visible = true; } else { //#ACQ8.20 Starts //InputFormValue IFValue = new InputFormValue(-1, InputFormContainerId, -1, dgValues.Rows.Count + 1, txtValue.Value, txtComment.Text, SessionState.User.Id, -1, DateTime.UtcNow, null); //QC2691 Check for validation of Terms if it already exists was not there so added TermList Termdetails = Term.GetAll("TermValue = '" + txtValue.Value + "' AND TermTypeCode='C'"); InputFormValue IFValue; if (Termdetails == null || Termdetails.Count == 0) //#2712 //if (Termdetails == null) //#2712 Commented { IFValue = new InputFormValue(-1, InputFormContainerId, -1, dgValues.Rows.Count + 1, txtValue.Value, txtComment.Text, IsTranslateDefaultOption, SessionState.User.Id, -1, DateTime.UtcNow, null); } else { IFValue = new InputFormValue(-1, InputFormContainerId, -1, dgValues.Rows.Count + 1, txtValue.Value, txtComment.Text, Termdetails[0].IsTranslatable, SessionState.User.Id, -1, DateTime.UtcNow, null); } //#ACQ8.20 Ends if (!IFValue.Save()) { lbError.CssClass = "hc_error"; lbError.Text = InputFormValue.LastError; lbError.Visible = true; } else { txtComment.Text = string.Empty; txtValue.Value = string.Empty; UpdateDataEdit(); } } } else { lbError.CssClass = "hc_error"; lbError.Text = "Value cannot be empty"; lbError.Visible = true; } }
/// <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(); }
// Display data protected void UpdateDataEdit() { using (InputFormValueList valuesList = InputFormValue.GetAll("InputFormContainerId = " + InputFormContainerId)) { dgValues.DataSource = valuesList; Utils.InitGridSort(ref dgValues, false); dgValues.DataBind(); Utils.EnableIntelligentSort(ref dgValues, Convert.ToInt32(txtSortColPos.Value)); if (valuesList.Count > 0) { if (SessionState.User.HasCapability(CapabilitiesEnum.MANAGE_CARTOGRAPHY)) { UITools.ShowToolBarButton(uwToolbar, "Delete"); UITools.ShowToolBarSeparator(uwToolbar, "DeleteSep"); } } else { UITools.HideToolBarButton(uwToolbar, "Delete"); UITools.HideToolBarSeparator(uwToolbar, "DeleteSep"); } } }
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>"); } }