Example #1
0
        protected void EntityList_IndexChanged(object sender, EventArgs e)
        {
            VisibleButtonSaveTemplate(false);
            if (Frame.UserTypeList.SelectedValue == "" && Frame.UserList.SelectedValue == "")
            {
                Frame.EntityList.SelectedIndex = 0;
                SetCss(Frame.EntityList, "default_border");
                SetCss(Frame.UserList, "default_border");
                SetCss(Frame.UserTypeList, "default_border");
                return;
            }

            if (Frame.EntityList.SelectedValue == "" && Frame.UserList.SelectedValue == "")
            {
                UserTypeList_IndexChanged(null, EventArgs.Empty);
                SetCss(Frame.EntityList, "default_border");
                SetCss(Frame.UserList, "default_border");
                return;
            }

            if (Frame.EntityList.SelectedValue == "")
            {
                UserList_IndexChanged(null, EventArgs.Empty);
                SetCss(Frame.EntityList, "default_border");
                return;
            }

            MView.ActiveViewIndex = 1;

            PredicateBuilder1.create.Checked = PredicateBuilder1.delete.Checked = PredicateBuilder1.read.Checked = PredicateBuilder1.update.Checked = false;
            PredicateBuilder1.comment.Text   = "";

            PredicateBuilder1.EntityID = Frame.EntityList.SelectedValue;
            PredicateBuilder1.template = GetTemplate();
            PredicateBuilder1.DataBind();

            SetCss(Frame.EntityList, "green_border");
        }
Example #2
0
        private void SaveEntityFilter(string id, string nameTableFilter,
                                      string nameTableFilterAttr, string nameCol, string nameTableIPermission)
        {
            var delete = new StringBuilder();
            var insert = new StringBuilder();

            #region Delete and insert [Z_EUFilter], [Z_EUFilterAttribute], [Z_EUTFilter], [Z_EUTFilterAttribute]
            var d = " DELETE {0} WHERE {1} = {2} AND [entity] = '{3}' ";

            delete.Append(string.Format(d, nameTableFilterAttr, nameCol, id, PredicateBuilder1.template.Entity.SystemName));
            delete.Append(string.Format(d, nameTableFilter, nameCol, id, PredicateBuilder1.template.Entity.SystemName));

            insert.Append(string.Format("INSERT INTO {0} ({1}, [entity], [read], [create], [update], [delete], [comment]) VALUES ({2}, '{3}', '{4}', '{5}', '{6}', '{7}','{8}')",
                                        nameTableFilter,
                                        nameCol,
                                        id,
                                        PredicateBuilder1.template.Entity.SystemName,
                                        PredicateBuilder1.read.Checked,
                                        PredicateBuilder1.create.Checked,
                                        PredicateBuilder1.update.Checked,
                                        PredicateBuilder1.delete.Checked,
                                        PredicateBuilder1.comment.Text));

            foreach (Teleform.Reporting.TemplateField field in PredicateBuilder1.template.Fields)
            {
                insert.Append(string.Format(" INSERT INTO {0} ({1}, [entity], [attr], [filterPredicate], [predicateInfo]) VALUES ({2}, '{3}', '{4}', '{5}', '{6}') ",
                                            nameTableFilterAttr,
                                            nameCol,
                                            id,
                                            PredicateBuilder1.template.Entity.SystemName,
                                            field.Attribute.FPath,
                                            field.Predicate == null ? string.Empty : field.Predicate.Replace("'", "''"),
                                            field.PredicateInfo.Replace("'", "''")));
            }

            var fullQuery = GetTransactionString(delete.ToString(), insert.ToString());
            QueryToDB(fullQuery);

            #endregion

            #region
            insert.Clear();
            delete.Clear();

            var dataView = PredicateBuilder1.GetDataView();

            if (dataView.Count == 0) //|| dataView[[0]["ojbID"] == null)
            {
                return;
            }

            var objIDs = new StringBuilder();
            objIDs.Append(string.Concat("( ", dataView[0]["objID"].ToString()));

            for (int i = 1; i < dataView.Count; i++)
            {
                objIDs.Append(string.Concat(",", dataView[i]["objID"].ToString()));
            }
            objIDs.Append(")");

            insert.Append(string.Format(
                              "INSERT INTO {0} ([instanceID],[entity],{1}, [read],[create],[update],[delete]) SELECT [objID],'{2}',{3},'{4}','{5}','{6}','{7}' FROM [{2}] WHERE [objID] IN {8}",
                              nameTableIPermission,
                              nameCol,
                              PredicateBuilder1.template.Entity.SystemName,
                              id,
                              PredicateBuilder1.read.Checked,
                              PredicateBuilder1.create.Checked,
                              PredicateBuilder1.update.Checked,
                              PredicateBuilder1.delete.Checked,
                              objIDs.ToString()
                              ));
            delete.Append(string.Format(d, nameTableIPermission, nameCol, id, PredicateBuilder1.template.Entity.SystemName));

            fullQuery = GetTransactionString(delete.ToString(), insert.ToString());
            QueryToDB(fullQuery);

            #endregion
        }