Ejemplo n.º 1
0
        public override void Exec(CommandData cmdData)
        {
            AttributeVariableDialogInfo dialogInfo = new AttributeVariableDialogInfo();
            dialogInfo.Filter = TypedObjectKind.Attribute;
            dialogInfo.MultiSelection = true;

            IList<object> selectedObjects = GenexusUIServices.SelectAttributeVariable.SelectAttributeVariable(dialogInfo);
            if (selectedObjects != null && selectedObjects.Count != 0)
            {
                foreach (Gx.Attribute selectedAtt in selectedObjects)
                {
                    PatternInstanceElement filterAttElement = BaseElement.Children.AddNewElement(InstanceChildren.FilterAttributes.FilterAttribute);
                    filterAttElement.Attributes[InstanceAttributes.FilterAttribute.Name] = selectedAtt.Name;
                    filterAttElement.Attributes[InstanceAttributes.FilterAttribute.Description] = selectedAtt.Title;
                    //filterAttElement.Attributes[InstanceAttributes.FilterAttribute.Attribute] = selectedAtt;
                    if (selectedAtt.GetPropertyValue<int>(Properties.ATT.ControlType) == Properties.ATT.ControlType_Values.ComboBox)
                        filterAttElement.Attributes[InstanceAttributes.FilterAttribute.AllValue] = true;
                }

                if (StandardMessageBox.Confirm(Messages.ConfirmAddFilterCondition))
                {
                    PatternInstanceElement conditionsElement = BaseElement.Parent.Children[InstanceChildren.Filter.Conditions];
                    foreach (Gx.Attribute selectedAtt in selectedObjects)
                    {
                        PatternInstanceElement conditionElement = conditionsElement.Children.AddNewElement(InstanceChildren.Conditions.Condition);
                        string attCondition = CreateCondition(selectedAtt, BaseElement);
                        conditionElement.Attributes[InstanceAttributes.Condition.Value] = attCondition;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Item it = (Item)comboVar.SelectedItem;

            if (it != null)
            {
                Variable v3 = it.Var;
                if (v3 != null)
                {
                    AttributeVariableDialogInfo info = new AttributeVariableDialogInfo();
                    info.Filter         = TypedObjectKind.Attribute | TypedObjectKind.Domain;
                    info.DialogTitle    = "Select domain/Attribute";
                    info.MultiSelection = false;
                    IList <object> selectedAtts = GenexusUIServices.SelectAttributeVariable.SelectAttributeVariable(info);
                    if (selectedAtts.Count > 0)
                    {
                        Domain dom = null;
                        try
                        {
                            dom = (Domain)selectedAtts[0];
                        }
                        catch (Exception ee)
                        {
                            Console.WriteLine("{0} Exception caught.", ee);
                            dom = null;
                        };

                        if (dom != null)
                        {
                            if (v3.Type != dom.Type)
                            {
                                MessageBox.Show("Different types !! " + v3.Type.ToString() + " " + dom.TypeDescriptor.Name);
                            }
                            v3.DomainBasedOn = dom;
                            v3.KBObject.Save();
                            comboVar.Items.Remove(it);
                            cantVariables.Text = comboVar.Items.Count.ToString() + " not based variables";
                            source.Text        = "";
                            if (comboVar.Items.Count == 0)
                            {
                                this.Close();
                                return;
                            }
                            else
                            {
                                comboVar.SelectedIndex = 0;
                            }
                            comboVar.SelectedIndex = 0;
                        }
                        else
                        {
                            Artech.Genexus.Common.Objects.Attribute att = (Artech.Genexus.Common.Objects.Attribute)selectedAtts[0];
                            if (att != null)
                            {
                                if (v3.Type != att.Type)
                                {
                                    MessageBox.Show("Different types!!" + v3.Type.ToString() + " " + att.TypeDescriptor.Name);
                                }
                                v3.AttributeBasedOn = att;
                                v3.KBObject.Save();
                                comboVar.Items.Remove(it);
                                cantVariables.Text = comboVar.Items.Count.ToString() + " not based variables";
                                source.Text        = "";
                                if (comboVar.Items.Count == 0)
                                {
                                    this.Close();
                                    return;
                                }
                                else
                                {
                                    comboVar.SelectedIndex = 0;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                //Debe seleccionar una variable
            }
        }