Esempio n. 1
0
        private void tsbSave_Click(object sender, EventArgs e)
        {
            GlobalFunctions.resetError();

            if (checkFields())
            {
                SynapseCore.Database.DBFunction.StartTransaction();
                try
                {
                    foreach (uc_LabelBag bag in flowLayoutPanel1.Controls)
                    {
                        if (bag.LblBag.Labels[0].LABELID == 0)
                        {
                            lblid = SynapseLabel.GetNextID();
                            for (Int32 x = 0; x < bag.LblBag.Labels.Count; x++)
                            {
                                bag.LblBag.Labels[x].LABELID = lblid;
                            }
                            bag.Save();
                        }
                        else
                        {
                            lblid = bag.LblBag.Labels[0].LABELID;
                            bag.Save();
                        }
                    }

                    _category.ID = _categoryID;
                    switch (GlobalVariables.selectedOrigin.ORIGIN)
                    {
                    case Origin.Module:
                        _category.FK_MODULE    = GlobalVariables.selectedOrigin.MODULEID;
                        _category.FK_INTERFACE = 0;
                        break;

                    case Origin.Interface:
                        _category.FK_MODULE    = 0;
                        _category.FK_INTERFACE = GlobalVariables.selectedOrigin.INTERFACEID;
                        break;
                    }

                    _category.LABELID = lblid;
                    _category.save();

                    SynapseCore.Database.DBFunction.CommitTransaction();

                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                }
                catch (Exception ex)
                {
                    SynapseCore.Database.DBFunction.RollbackTransaction();
                    GlobalFunctions.showMessage("ERR", "Err.9999", ex.Message);
                }
            }
            else
            {
                GlobalFunctions.showError();
            }
        }
Esempio n. 2
0
        private void CopyProperties(object dest, object src)
        {
            Type srctype = src.GetType();

            foreach (PropertyInfo pi in dest.GetType().GetProperties())
            {
                if (pi.CanWrite)
                {
                    if (pi.PropertyType.ToString() != "SynapseCore.Database.LabelBag")
                    {
                        pi.SetValue(dest, srctype.GetProperty(pi.Name).GetValue(src, null), null);
                    }
                    else
                    {
                        if (chk_save.Checked)
                        {
                            //--------------------------------------------
                            Int64     labelID     = 0;
                            string    DefaultText = null;
                            LabelId[] ids         = (LabelId[])pi.GetCustomAttributes(typeof(LabelId), true);
                            foreach (LabelId id in ids)
                            {
                                PropertyInfo field = src.GetType().GetProperty(id.IDField);
                                labelID = (Int64)field.GetValue(src, null);
                                if (id.DefaultField != null)
                                {
                                    PropertyInfo defaultfield = src.GetType().GetProperty(id.DefaultField);
                                    DefaultText = (string)defaultfield.GetValue(src, null);
                                }
                            }

                            ACCLabelBag srclb = new ACCLabelBag();
                            srclb.load(labelID, DefaultText);
                            //--------------------------------------------
                            LabelBag destlb = new LabelBag();
                            destlb.Labels = new List <SynapseLabel>();
                            //CopyProperties(destlb, srclb);
                            foreach (ACCSynapseLabel a_lbl in srclb.Labels)
                            {
                                SynapseLabel p_lbl = new SynapseLabel();
                                CopyProperties(p_lbl, a_lbl);

                                destlb.Labels.Add(p_lbl);
                            }
                            Int64 nextid = SynapseLabel.GetNextID();
                            foreach (LabelId id in ids)
                            {
                                dest.GetType().GetProperty(id.IDField).SetValue(dest, nextid, null);
                            }
                            foreach (SynapseLabel lbl in destlb.Labels)
                            {
                                lbl.LABELID = nextid;
                            }
                            CreateLinkEntry(srclb, labelID, nextid);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        private void tsbSave_Click(object sender, EventArgs e)
        {
            if (checkFields())
            {
                SynapseCore.Database.DBFunction.StartTransaction();
                try
                {
                    _profile.FK_ModuleID   = (Int64)cbModule.SelectedValue;
                    _profile.TECHNICALNAME = txTechnicalName.Text;
                    _profile.LEVEL         = Int64.Parse("0" + txLevel.Text);
                    _profile.IS_OWNER      = ckOwner.Checked;

                    Int64 lblid = 0;
                    if (bagDescription.LblBag.Labels[0].LABELID == 0)
                    {
                        lblid = SynapseLabel.GetNextID();
                        for (Int32 x = 0; x < bagDescription.LblBag.Labels.Count; x++)
                        {
                            bagDescription.LblBag.Labels[x].LABELID = lblid;
                        }
                        bagDescription.Save();
                    }
                    else
                    {
                        lblid = bagDescription.LblBag.Labels[0].LABELID;
                        bagDescription.Save();
                    }
                    _profile.FK_LABELID = lblid;
                    _profile.save();

                    SynapseCore.Database.DBFunction.CommitTransaction();

                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                }
                catch (Exception ex)
                {
                    SynapseCore.Database.DBFunction.RollbackTransaction();
                    MessageBox.Show("Data not saved in Database:" + ex.Message, "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 4
0
        private void tsbSave_Click(object sender, EventArgs e)
        {
            GlobalFunctions.resetError();

            if (checkFields())
            {
                SynapseCore.Database.DBFunction.StartTransaction();
                try
                {
                    foreach (uc_LabelBag bag in flowLayoutPanel1.Controls)
                    {
                        if (bag.LblBag.Labels[0].LABELID == 0)
                        {
                            Int64 lblID = SynapseLabel.GetNextID();
                            for (Int32 x = 0; x < bag.LblBag.Labels.Count; x++)
                            {
                                bag.LblBag.Labels[x].LABELID = lblID;
                            }
                            bag.Save();
                        }
                        else
                        {
                            bag.Save();
                        }
                    }

                    SynapseCore.Database.DBFunction.CommitTransaction();

                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                catch (Exception ex)
                {
                    SynapseCore.Database.DBFunction.RollbackTransaction();
                    GlobalFunctions.showMessage("ERR", "Err.9999", ex.Message);
                }
            }
            else
            {
                GlobalFunctions.showError();
            }
        }
Esempio n. 5
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. 6
0
        private void tsbSave_Click(object sender, EventArgs e)
        {
            if (checkFields())
            {
                SynapseCore.Database.DBFunction.StartTransaction();
                try
                {
                    _module.ID             = _moduleID;
                    _module.PATH           = txPath.Text;
                    _module.TECHNICALNAME  = txTechnicalName.Text;
                    _module.VERSION        = txVersion.Text;
                    _module.VERSIONDATE    = txVersionDate.Text;
                    _module.MODULECATEGORY = txCategory.Text;
                    _module.DEVSOURCE      = txDevSources.Text;
                    _module.PRODSOURCE     = txProdSources.Text;
                    _module.IS_ACTIVE      = ckActive.Checked;
                    _module.IS_REQUESTABLE = ckRequestable.Checked;

                    if (bagName.LblBag.Labels[0].LABELID == 0)
                    {
                        lblid = SynapseLabel.GetNextID();
                        for (Int32 x = 0; x < bagName.LblBag.Labels.Count; x++)
                        {
                            bagName.LblBag.Labels[x].LABELID = lblid;
                        }
                        bagName.Save();
                    }
                    else
                    {
                        lblid = bagName.LblBag.Labels[0].LABELID;
                        bagName.Save();
                    }
                    _module.LABELID = lblid;

                    if (bagDescription.LblBag.Labels[0].LABELID == 0)
                    {
                        lblid = SynapseLabel.GetNextID();
                        for (Int32 x = 0; x < bagDescription.LblBag.Labels.Count; x++)
                        {
                            bagDescription.LblBag.Labels[x].LABELID = lblid;
                        }
                        bagDescription.Save();
                    }
                    else
                    {
                        lblid = bagDescription.LblBag.Labels[0].LABELID;
                        bagDescription.Save();
                    }
                    _module.DESCLABELID = lblid;
                    _module.save();

                    SynapseCore.Database.DBFunction.CommitTransaction();

                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                }
                catch (Exception ex)
                {
                    SynapseCore.Database.DBFunction.RollbackTransaction();
                    MessageBox.Show("Data not saved in Database:" + ex.Message, "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 7
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);
            }
        }