예제 #1
0
        private void SynapseTracability_Load(object sender, EventArgs e)
        {
            if (!this.DesignMode)
            {
                _AssemblyName = Assembly.GetEntryAssembly().GetName().Name;

                logEntryTableName = "LOGENTRY_" + _AssemblyName;
                logValueTableName = "LOGVALUE_" + _AssemblyName;

                if (_UseBuiltinFilters)
                {
                    IList <LogEntry> _objects = LogEntry.LoadFromQuery("SELECT DISTINCT OBJECT_NAME FROM " + logEntryTableName);
                    cbObject.Items.Add(new logObject("", ""));
                    foreach (LogEntry _le in _objects)
                    {
                        cbObject.Items.Add((new logObject(SynapseForm.GetLabel(((SynapseModule)SynapseForm.FormUser.Modules.Where(m => m.ID == SynapseForm.FormUser.CurrentModuleID).FirstOrDefault()).TECHNICALNAME + "_" + _le.OBJECT_NAME), _le.OBJECT_NAME)));
                    }

                    resetFilters();
                }
            }
        }
예제 #2
0
        public void RedrawControls()
        {
            this.Items.Clear();
            if (!_HideFilter)
            {
                filter.Image = Properties.Resources.FilterAdd;
                this.Items.Add(filter);

                ToolStripButton clearfilter = new ToolStripButton();
                clearfilter.Click       += new EventHandler(clearfilter_Click);
                clearfilter.Image        = Properties.Resources.FilterDelete;
                clearfilter.Text         = SynapseForm.GetLabel("SynapseListFilter.Clear");
                clearfilter.DisplayStyle = ToolStripItemDisplayStyle.Image;
                this.Items.Add(clearfilter);

                ToolStripSeparator sb1 = new ToolStripSeparator();
                sb1.Margin = new Padding(5, 0, 5, 0);
                this.Items.Add(sb1);
            }

            if (!_HideSearch)
            {
                ToolStripLabel icon = new ToolStripLabel();
                icon.Image       = Properties.Resources.search2;
                icon.Margin      = new System.Windows.Forms.Padding(0, 1, 0, 2);
                icon.ToolTipText = SynapseForm.GetLabel("SynapseListFilter.Search");

                txt_filter.TextChanged += new EventHandler(txt_filter_TextChanged);
                txt_filter.KeyUp       += new KeyEventHandler(txt_filter_KeyUp);
                txt_filter.BorderStyle  = BorderStyle.FixedSingle;
                this.Items.Add(icon);
                this.Items.Add(txt_filter);
                if (!FilterOnTheFly)
                {
                    ToolStripButton btn_OK = new ToolStripButton();
                    btn_OK.DisplayStyle = ToolStripItemDisplayStyle.Image;
                    btn_OK.Text         = SynapseForm.GetLabel("SynapseListFilter.Filter");
                    btn_OK.Click       += new EventHandler(btn_OK_Click);
                    this.Items.Add(btn_OK);
                }
            }
            if (!_HideExport)
            {
                ToolStripSeparator sb2 = new ToolStripSeparator();
                sb2.Margin = new Padding(5, 0, 5, 0);
                this.Items.Add(sb2);

                ToolStripButton Excel = new ToolStripButton();
                Excel.Click       += new EventHandler(Excel_Click);
                Excel.Image        = Properties.Resources.excel;
                Excel.DisplayStyle = ToolStripItemDisplayStyle.Image;
                Excel.Text         = SynapseForm.GetLabel("SynapseListFilter.Excel");
                this.Items.Add(Excel);
            }
            if (!_HidePrint)
            {
                ToolStripSeparator sb3 = new ToolStripSeparator();
                sb3.Margin = new Padding(5, 0, 5, 0);
                this.Items.Add(sb3);

                ToolStripButton Preview = new ToolStripButton();
                Preview.Image        = Properties.Resources.preview;
                Preview.Click       += new EventHandler(Preview_Click);
                Preview.Text         = SynapseForm.GetLabel("SynapseListFilter.Preview");
                Preview.DisplayStyle = ToolStripItemDisplayStyle.Image;
                this.Items.Add(Preview);

                ToolStripButton Print = new ToolStripButton();
                Print.Image        = Properties.Resources.Print_Grid_32;
                Print.Click       += new EventHandler(Print_Click);
                Print.Text         = SynapseForm.GetLabel("SynapseListFilter.Print");
                Print.DisplayStyle = ToolStripItemDisplayStyle.Image;
                this.Items.Add(Print);
            }
            if (!_HideSaveConfig)
            {
                ToolStripSeparator sb4 = new ToolStripSeparator();
                sb4.Margin = new Padding(5, 0, 5, 0);
                this.Items.Add(sb4);

                ToolStripButton tsb_saveconfig = new ToolStripButton();
                tsb_saveconfig.Image        = Properties.Resources.ViewSave;
                tsb_saveconfig.Click       += new EventHandler(tsb_saveconfig_Click);
                tsb_saveconfig.Text         = SynapseForm.GetLabel("SynapseListFilter.SaveConfig");
                tsb_saveconfig.DisplayStyle = ToolStripItemDisplayStyle.Image;
                this.Items.Add(tsb_saveconfig);

                ToolStripButton tsb_restoreconfig = new ToolStripButton();
                tsb_restoreconfig.Image        = Properties.Resources.ViewRestore;
                tsb_restoreconfig.Click       += new EventHandler(tsb_restoreconfig_Click);
                tsb_restoreconfig.Text         = SynapseForm.GetLabel("SynapseListFilter.RestoreConfig");
                tsb_restoreconfig.DisplayStyle = ToolStripItemDisplayStyle.Image;
                this.Items.Add(tsb_restoreconfig);
            }
            if (!HideFilter)
            {
                ToolStripSeparator sb5 = new ToolStripSeparator();
                sb5.Margin = new Padding(5, 0, 5, 0);
                this.Items.Add(sb5);
                if (_List != null)
                {
                    FormatFilterMenu(_List, filter);
                    _List.AfterSorting += new EventHandler <AfterSortingEventArgs>(_List_AfterSorting);
                    foreach (OLVColumn col in _List.AllColumns)
                    {
                        CheckBox chk = new CheckBox();
                        chk.Text            = col.Text;
                        chk.BackColor       = Color.Transparent;
                        chk.Checked         = col.Searchable;
                        chk.Tag             = col;
                        chk.CheckedChanged += new EventHandler(chk_CheckedChanged);
                        if (col.Searchable)
                        {
                            ToolStripControlHost host = new ToolStripControlHost(chk);
                            this.Items.Add(host);
                        }
                    }
                }
            }
        }
예제 #3
0
        public frm_SynapseObjectEdit(object SynapseObject)
        {
            InitializeComponent();
            _SynapseObject = SynapseObject;
            bags           = new Hashtable();
            languages      = SynapseLanguage.Load();
            IList <PropertyInfo> properties      = SynapseObject.GetType().GetProperties();
            IList <FieldInfo>    fields          = SynapseObject.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
            List <Control>       labelBagControl = new List <Control>();

            foreach (FieldInfo fi in fields)
            {
                if (fi.Name == "_IDproperty")
                {
                    _IDproperty = fi.GetValue(SynapseObject).ToString();
                }
                if (fi.Name == "_EcludeForSave")
                {
                    _EcludeForSave = fi.GetValue(SynapseObject).ToString();
                }
                if (fi.Name == "_tableName")
                {
                    _tableName = fi.GetValue(SynapseObject).ToString().Trim(new char[] { '[', ']' });
                }
            }
            foreach (PropertyInfo pi in from x in properties where x.PropertyType.ToString() == "SynapseCore.Database.LabelBag" select x)
            {
                uc_LabelBag bag   = new uc_LabelBag();
                object      value = pi.GetValue(SynapseObject, null);
                LabelBag    lbl   = (LabelBag)value;
                Int64       lblid = lbl.GetLabelID();
                if (lblid == 0)
                {
                    lblid = SynapseLabel.GetNextID();
                }

                LabelId[] ids = (LabelId[])pi.GetCustomAttributes(typeof(LabelId), true);
                foreach (LabelId id in ids)
                {
                    PropertyInfo field = SynapseObject.GetType().GetProperty(id.IDField);
                    field.SetValue(SynapseObject, lblid, null);
                    bags.Add(id.IDField, id);
                }

                if (lbl.Labels.Count < languages.Count)
                {
                    foreach (SynapseLanguage lang in languages)
                    {
                        if (lbl.GetLabel(lang.CODE) == null)
                        {
                            SynapseLabel newlabel = new SynapseLabel();

                            newlabel.LABELID = lblid;

                            newlabel.LANGUAGE = lang.CODE;
                            newlabel.TEXT     = "";
                            newlabel.save();
                            lbl.Labels.Add(newlabel);
                        }
                    }
                    _NewLabels = true;
                }

                bag.FieldName = pi.Name;
                bag.LblBag    = lbl;
                labelBagControl.Add(bag);
                //flowLayoutPanel1.Controls.Add(bag);
            }

            foreach (PropertyInfo pi in from x in properties where x.PropertyType.ToString() != "SynapseCore.Database.LabelBag" select x)
            {
                if (!bags.ContainsKey(pi.Name))
                {
                    EntityFieldType FieldType = ((EntityFieldType[])pi.GetCustomAttributes(typeof(EntityFieldType), true)).SingleOrDefault();

                    uc_Field field;
                    if (FieldType != null)
                    {
                        field = new uc_Field(FieldType);
                    }
                    else
                    {
                        field = new uc_Field();
                    }
                    field.FieldName   = pi.Name;
                    field.DisplayName = SynapseForm.GetLabel(_tableName.ToUpperInvariant() + "." + pi.Name.ToUpperInvariant());
                    object value = pi.GetValue(SynapseObject, null);
                    if (value != null)
                    {
                        field.FieldValue = value;
                    }
                    if (pi.Name == _IDproperty)
                    {
                        field.Enabled = false;
                    }
                    flowLayoutPanel1.Controls.Add(field);
                }
            }
            flowLayoutPanel1.Controls.AddRange(labelBagControl.ToArray());
            if (_NewLabels)
            {
                SynapseObject.GetType().InvokeMember("save", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public, null, SynapseObject, null);
            }
        }
예제 #4
0
        public SynapseTracability()
        {
            InitializeComponent();

            gbTracability.Left  = 0;
            gbTracability.Width = this.Width;

            if (_UseBuiltinFilters)
            {
                gbFilter.Visible = true;

                gbTracability.Top    = gbFilter.Height + 7;
                gbTracability.Height = this.Height - (gbFilter.Height + 7);
            }
            else
            {
                gbFilter.Visible = false;

                gbTracability.Top    = 0;
                gbTracability.Height = this.Height;
            }

            gbFilter.Dock        = DockStyle.Top;
            gbTracability.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);

            gbFilter.Text           = _LabelOfFilters;
            lbDateFrom.Text         = _LabelOfDateFrom;
            lbDateTo.Text           = _LabelOfDateTo;
            lbFreeText.Text         = _LabelOfFreeText;
            lbObject.Text           = _LabelOfObjectName;
            lbValue.Text            = _LabelOfObjectValue;
            btApply.Text            = _LabelOfApplyButton;
            btReset.Text            = _LabelOfResetButton;
            gbTracability.Text      = _LabelOfTraceList;
            treeLog.Columns[0].Text = _LabelOfObjectName;
            treeLog.Columns[1].Text = _LabelOfObjectValue;
            treeLog.Columns[2].Text = _LabelOfAction;
            treeLog.Columns[3].Text = _LabelOfWho;
            treeLog.Columns[4].Text = _LabelOfWhen;
            treeLog.Columns[5].Text = _LabelOfOldValue;
            treeLog.Columns[6].Text = _LabelOfNewValue;
            tsbExpand.Text          = _LabelOfExpand;
            tsbCollapse.Text        = _LabelOfCollapse;
            tsbPrint.Text           = _LabelOfPrint;

            treeLog.EmptyListMsg = "";

            #region Aspect Getters
            colAction.AspectToStringConverter = delegate(object x)
            {
                if (x is string && !x.ToString().Contains("is not a parameter-less method, property or field"))
                {
                    switch ((String)x)
                    {
                    case "INSERT":
                        return(SynapseForm.GetLabel("global.Create"));

                    case "MODIFY":
                        return(SynapseForm.GetLabel("global.Edit"));

                    case "DELETE":
                        return(SynapseForm.GetLabel("global.Delete"));

                    default:
                        return((String)x);
                    }
                }
                else
                {
                    return(string.Empty);
                }
            };

            colWho.AspectToStringConverter = delegate(object x)
            {
                if (x is string && !x.ToString().Contains("is not a parameter-less method, property or field"))
                {
                    return(x.ToString());
                }
                else
                {
                    return(string.Empty);
                }
            };

            colWhen.AspectToStringConverter = delegate(object x)
            {
                if (x is string && !x.ToString().Contains("is not a parameter-less method, property or field"))
                {
                    if (x is DateTime)
                    {
                        return(((DateTime)x).ToString("dd/MM/yyyy HH:mm:ss"));
                    }
                    else
                    {
                        return(string.Empty);
                    }
                }
                else
                if (x is DateTime)
                {
                    return(((DateTime)x).ToString("dd/MM/yyyy HH:mm:ss"));
                }
                else
                {
                    return(string.Empty);
                }
            };

            colObjectName.ImageGetter = delegate(object x)
            {
                if (x is LogEntry)
                {
                    LogEntry _logEntry = (LogEntry)x;
                    switch (_logEntry.ACTION_CODE)
                    {
                    case "INSERT":
                        return("new");

                    case "MODIFY":
                        return("edit");

                    case "DELETE":
                        return("delete");
                    }
                    return("");
                }

                return("");
            };

            colObjectName.AspectToStringConverter = delegate(object x)
            {
                if (x is string && !x.ToString().Contains("is not a parameter-less method, property or field"))
                {
                    return(SynapseForm.GetLabel(((SynapseModule)SynapseForm.FormUser.Modules.Where(m => m.ID == SynapseForm.FormUser.CurrentModuleID).FirstOrDefault()).TECHNICALNAME + "_" + x.ToString()));
                }
                else
                {
                    return(string.Empty);
                }
            };

            colObjectValue.AspectToStringConverter = delegate(object x)
            {
                if (x is string && !x.ToString().Contains("is not a parameter-less method, property or field"))
                {
                    return(x.ToString());
                }
                else
                {
                    return(string.Empty);
                }
            };


            colOld.AspectToStringConverter = delegate(object x)
            {
                if (x is string && !x.ToString().Contains("is not a parameter-less method, property or field"))
                {
                    return(x.ToString());
                }
                else
                {
                    return(string.Empty);
                }
            };

            colNew.AspectToStringConverter = delegate(object x)
            {
                if (x is string && !x.ToString().Contains("is not a parameter-less method, property or field"))
                {
                    return(x.ToString());
                }
                else
                {
                    return(string.Empty);
                }
            };

            treeLog.CanExpandGetter = delegate(object x)
            {
                if (x is LogEntry)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            };

            treeLog.ChildrenGetter = delegate(object x)
            {
                LogEntry         _logEntry = (LogEntry)x;
                IList <LogValue> _logValue = LogValue.LoadFromQuery("SELECT * FROM " + logValueTableName + " WHERE " + logValueTableName + ".FK_LOGENTRY=" + _logEntry.ID + " ORDER BY ID");

                return(_logValue);
            };
            #endregion
        }