Esempio n. 1
0
        public void Save()
        {
            List <uc_Field> c = flowLayoutPanel1.Controls.OfType <uc_Field>().Cast <uc_Field>().ToList();

            foreach (uc_Field field in c)
            {
                SynapseLabel lbl = _lblBag.GetLabel(field.FieldName);
                lbl.TEXT = field.FieldValue.ToString();
                lbl.save();
            }
        }
Esempio n. 2
0
        public override void initForm(SynapseCore.Security.Tools.SecureAndTranslateMode Mode)
        {
            base.initForm(Mode);

            switch (_action)
            {
            case "NEW":
                this.Text = this.Text + " - " + SynapseForm.GetLabel("global.Create");

                _category.ID           = 0;
                _category.LABEL        = new LabelBag();
                _category.LABEL.Labels = new List <SynapseLabel>();

                foreach (SynapseLanguage lang in languages)
                {
                    SynapseLabel newlabel = new SynapseLabel();

                    newlabel.LABELID  = 0;
                    newlabel.LANGUAGE = lang.CODE;
                    newlabel.TEXT     = "";
                    _category.LABEL.Labels.Add(newlabel);
                }
                break;

            case "EDIT":
                this.Text = this.Text + " - " + SynapseForm.GetLabel("global.Edit");
                _category = Category.LoadByID(_categoryID);

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

                            newlabel.LABELID  = _category.LABEL.GetLabelID();
                            newlabel.LANGUAGE = lang.CODE;
                            newlabel.TEXT     = "";
                            newlabel.save();
                            _category.LABEL.Labels.Add(newlabel);
                        }
                    }
                }
                break;
            }
            bag.FieldName = GetLabel("frmCategory.lblBag");
            bag.LblBag    = _category.LABEL;
            bag.Visible   = true;
            bag.Dock      = DockStyle.Fill;
            flowLayoutPanel1.Controls.Add(bag);
        }
Esempio n. 3
0
        public override void initForm(SynapseCore.Security.Tools.SecureAndTranslateMode Mode)
        {
            base.initForm(Mode);

            ckOwner.Text = SynapseForm.GetLabel("frmGroup.ckOwner");

            fillModule();

            switch (_action)
            {
            case "NEW":
                this.Text = this.Text + " - " + SynapseForm.GetLabel("Label.Create");

                _profile.ID = 0;

                cbModule.SelectedIndex = -1;
                txTechnicalName.Text   = "";
                txLevel.Text           = "";
                ckOwner.Checked        = false;

                _profile.Description        = new LabelBag();
                _profile.Description.Labels = new List <SynapseLabel>();
                foreach (SynapseLanguage lang in languages)
                {
                    SynapseLabel newDescription = new SynapseLabel();
                    newDescription.LABELID  = 0;
                    newDescription.LANGUAGE = lang.CODE;
                    newDescription.TEXT     = "";
                    _profile.Description.Labels.Add(newDescription);
                }
                break;

            case "EDIT":
                this.Text = this.Text + " - " + SynapseForm.GetLabel("Label.Edit");

                if (_profile.FK_ModuleID != null)
                {
                    cbModule.SelectedValue = _profile.FK_ModuleID;
                }
                else
                {
                    cbModule.SelectedIndex = -1;
                }
                txTechnicalName.Text = _profile.TECHNICALNAME;
                txLevel.Text         = _profile.LEVEL.ToString();
                ckOwner.Checked      = _profile.IS_OWNER;

                if (_profile.Description.Labels.Count < languages.Count)
                {
                    foreach (SynapseLanguage lang in languages)
                    {
                        if (_profile.Description.GetLabel(lang.CODE) == null)
                        {
                            SynapseLabel newlabel = new SynapseLabel();
                            newlabel.LABELID  = _profile.Description.GetLabelID();
                            newlabel.LANGUAGE = lang.CODE;
                            newlabel.TEXT     = "";
                            newlabel.save();
                            _profile.Description.Labels.Add(newlabel);
                        }
                    }
                }
                break;
            }
            bagDescription.FieldName = GetLabel("frmGroup.gbDescription");
            bagDescription.LblBag    = _profile.Description;
            bagDescription.Visible   = true;
            bagDescription.Dock      = DockStyle.Fill;
            flowLayoutPanel1.Controls.Add(bagDescription);
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
0
        public override void initForm(SynapseCore.Security.Tools.SecureAndTranslateMode Mode)
        {
            base.initForm(Mode);

            switch (_action)
            {
            case "NEW":
                this.Text = this.Text + " - " + SynapseForm.GetLabel("Label.Create");

                _module.ID = 0;

                txPath.Text           = "";
                txTechnicalName.Text  = "";
                txVersion.Text        = "";
                txVersionDate.Text    = "";
                txCategory.Text       = "";
                txDevSources.Text     = "";
                txProdSources.Text    = "";
                ckActive.Checked      = true;
                ckRequestable.Checked = false;

                _module.FriendlyName        = new LabelBag();
                _module.FriendlyName.Labels = new List <SynapseLabel>();
                _module.Description         = new LabelBag();
                _module.Description.Labels  = new List <SynapseLabel>();
                foreach (SynapseLanguage lang in languages)
                {
                    SynapseLabel newFriendlyName = new SynapseLabel();
                    newFriendlyName.LABELID  = 0;
                    newFriendlyName.LANGUAGE = lang.CODE;
                    newFriendlyName.TEXT     = "";
                    _module.FriendlyName.Labels.Add(newFriendlyName);

                    SynapseLabel newDescription = new SynapseLabel();
                    newDescription.LABELID  = 0;
                    newDescription.LANGUAGE = lang.CODE;
                    newDescription.TEXT     = "";
                    _module.Description.Labels.Add(newDescription);
                }
                break;

            case "EDIT":
                this.Text = this.Text + " - " + SynapseForm.GetLabel("Label.Edit");
                _module   = SynapseModule.LoadByID(_moduleID);

                txPath.Text           = _module.PATH;
                txTechnicalName.Text  = _module.TECHNICALNAME;
                txVersion.Text        = _module.VERSION;
                txVersionDate.Text    = _module.VERSIONDATE;
                txCategory.Text       = _module.MODULECATEGORY;
                txDevSources.Text     = _module.DEVSOURCE;
                txProdSources.Text    = _module.PRODSOURCE;
                ckActive.Checked      = _module.IS_ACTIVE;
                ckRequestable.Checked = _module.IS_REQUESTABLE;

                if (_module.FriendlyName.Labels.Count < languages.Count)
                {
                    foreach (SynapseLanguage lang in languages)
                    {
                        if (_module.FriendlyName.GetLabel(lang.CODE) == null)
                        {
                            SynapseLabel newlabel = new SynapseLabel();
                            newlabel.LABELID  = _module.FriendlyName.GetLabelID();
                            newlabel.LANGUAGE = lang.CODE;
                            newlabel.TEXT     = "";
                            newlabel.save();
                            _module.FriendlyName.Labels.Add(newlabel);
                        }
                    }
                }
                if (_module.Description.Labels.Count < languages.Count)
                {
                    foreach (SynapseLanguage lang in languages)
                    {
                        if (_module.Description.GetLabel(lang.CODE) == null)
                        {
                            SynapseLabel newlabel = new SynapseLabel();
                            newlabel.LABELID  = _module.Description.GetLabelID();
                            newlabel.LANGUAGE = lang.CODE;
                            newlabel.TEXT     = "";
                            newlabel.save();
                            _module.Description.Labels.Add(newlabel);
                        }
                    }
                }
                break;
            }
            bagName.FieldName = GetLabel("frmModule.gbFiendlyName");
            bagName.LblBag    = _module.FriendlyName;
            bagName.Visible   = true;
            bagName.Dock      = DockStyle.Fill;
            flowLayoutPanel1.Controls.Add(bagName);

            bagDescription.FieldName = GetLabel("frmModule.gbDescription");
            bagDescription.LblBag    = _module.Description;
            bagDescription.Visible   = true;
            bagDescription.Dock      = DockStyle.Fill;
            flowLayoutPanel1.Controls.Add(bagDescription);
        }
Esempio n. 6
0
        private void tsbCopy_Click(object sender, EventArgs e)
        {
            SynapseCore.Database.DBFunction.StartTransaction();

            Definition reportDef = Definition.LoadByID(((Definition)olvReport.SelectedObject).ID);
            Definition reportNew = new Definition();

            try
            {
                reportNew.ID            = 0;
                reportNew.QRY_JOIN      = reportDef.QRY_JOIN;
                reportNew.QRY_CONDITION = reportDef.QRY_CONDITION;
                reportNew.QRY_GROUP     = reportDef.QRY_GROUP;
                reportNew.FK_MODULE     = reportDef.FK_MODULE;
                reportNew.FK_INTERFACE  = reportDef.FK_INTERFACE;
                reportNew.FK_CATEGORY   = reportDef.FK_CATEGORY;
                reportNew.FK_TYPE       = reportDef.FK_TYPE;
                reportNew.ADDCATEGORY   = reportDef.ADDCATEGORY;
                reportNew.AVAILABLE     = false;

                Int64 reportNew_lblID = SynapseLabel.GetNextID();
                foreach (SynapseLanguage lang in SynapseLanguage.LoadFromQuery("SELECT * FROM SYNAPSE_LANGUAGE ORDER BY CODE"))
                {
                    SynapseLabel newlabel = new SynapseLabel();

                    newlabel.LABELID  = reportNew_lblID;
                    newlabel.LANGUAGE = lang.CODE;
                    newlabel.TEXT     = SynapseLabel.Load("WHERE LANGUAGE='" + lang.CODE + "' AND LABELID=" + reportDef.LABELID).FirstOrDefault().TEXT + " (*)";
                    newlabel.save();
                }
                reportNew.LABELID = reportNew_lblID;

                reportNew.save();

                foreach (Tables tbl in Tables.Load("WHERE FK_REPORT=" + reportDef.ID))
                {
                    Tables tblNew = new Tables();
                    tblNew.ID        = 0;
                    tblNew.TABLENAME = tbl.TABLENAME;
                    tblNew.TYPE      = tbl.TYPE;
                    tblNew.FK_REPORT = reportNew.ID;

                    tblNew.save();
                }

                foreach (Field fld in Field.Load("WHERE FK_REPORT=" + reportDef.ID))
                {
                    Field fldNew = new Field();
                    fldNew.ID        = 0;
                    fldNew.FIELDNAME = fld.FIELDNAME;
                    fldNew.FORMAT    = fld.FORMAT;
                    fldNew.POSITION  = fld.POSITION;
                    fldNew.WIDTH     = fld.WIDTH;
                    fldNew.FK_REPORT = reportNew.ID;

                    Int64 fldNew_lblID = SynapseLabel.GetNextID();
                    foreach (SynapseLanguage lang in SynapseLanguage.LoadFromQuery("SELECT * FROM SYNAPSE_LANGUAGE ORDER BY CODE"))
                    {
                        SynapseLabel newlabel = new SynapseLabel();

                        newlabel.LABELID  = fldNew_lblID;
                        newlabel.LANGUAGE = lang.CODE;
                        newlabel.TEXT     = SynapseLabel.Load("WHERE LANGUAGE='" + lang.CODE + "' AND LABELID=" + fld.ALIASID).FirstOrDefault().TEXT;
                        newlabel.save();
                    }
                    fldNew.ALIASID = fldNew_lblID;

                    fldNew.save();
                }

                foreach (Filter flt in Filter.Load("WHERE FK_REPORT=" + reportDef.ID))
                {
                    Filter fltNew = new Filter();
                    fltNew.ID                 = 0;
                    fltNew.NAME               = flt.NAME;
                    fltNew.TYPE               = flt.TYPE;
                    fltNew.POSITION           = flt.POSITION;
                    fltNew.CTRL_TABLE         = flt.CTRL_TABLE;
                    fltNew.CTRL_FIELD         = flt.CTRL_FIELD;
                    fltNew.CTRL_CUSTOM        = flt.CTRL_CUSTOM;
                    fltNew.DATA_TABLE         = flt.DATA_TABLE;
                    fltNew.DATA_VALUE         = flt.DATA_VALUE;
                    fltNew.DATA_DISPLAY       = flt.DATA_DISPLAY;
                    fltNew.DATA_QUERY         = flt.DATA_QUERY;
                    fltNew.WIDTH              = flt.WIDTH;
                    fltNew.ADD_TO_REPORTTITLE = flt.ADD_TO_REPORTTITLE;
                    fltNew.IS_LINKED          = false;
                    fltNew.LINKED_FILTERID    = 0;
                    fltNew.LINKED_FIELD       = "";
                    fltNew.CTRL_TYPE          = flt.CTRL_TYPE;
                    fltNew.FK_REPORT          = reportNew.ID;

                    Int64 fltNew_lblID = SynapseLabel.GetNextID();
                    foreach (SynapseLanguage lang in SynapseLanguage.LoadFromQuery("SELECT * FROM SYNAPSE_LANGUAGE ORDER BY CODE"))
                    {
                        SynapseLabel newlabel = new SynapseLabel();

                        newlabel.LABELID  = fltNew_lblID;
                        newlabel.LANGUAGE = lang.CODE;
                        newlabel.TEXT     = SynapseLabel.Load("WHERE LANGUAGE='" + lang.CODE + "' AND LABELID=" + flt.LABELID).FirstOrDefault().TEXT;
                        newlabel.save();
                    }
                    fltNew.LABELID = fltNew_lblID;

                    fltNew.save();
                }

                SynapseCore.Database.DBFunction.CommitTransaction();

                listReport();
            }
            catch (Exception ex)
            {
                SynapseCore.Database.DBFunction.RollbackTransaction();
                GlobalFunctions.showMessage("ERR", "Err.9999", ex.Message);
            }
        }