Exemple #1
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            switch (InputParameters["Action"].ToString().ToLower())
            {
            case "addnew":
                // In inserimento creo uno storage vuoto
                //(DocumentArchive)e.Argument = new DocumentArchive();
                attribute = new BiblosDs.Document.AdminCentral.ServiceReferenceAdministration.Attribute();
                break;

            case "modify":
                // Se sto modificando carico i dati da modificare
                attribute = Client.GetAttribute((Guid)InputParameters["ID"]);
                break;
            }

            attributeMode = Client.GetAttributeModes();

            archive = Client.GetArchive((Guid)InputParameters["IdArchive"]);
        }
Exemple #2
0
        /// <summary>
        /// Sincronizza i valori dei campi del Controllo con i valori della classe dell'oggetto del DB
        /// In caso di passaggio dati verso il database ( false ) restituisce false se i campi obbligatori non sono valorizzati
        /// </summary>
        /// <param name="storage">classe oggetto del db</param>
        /// <param name="fromStorage">true o false per la direzione del sincronismo dati</param>
        /// <returns>bool</returns>
        private bool SyncroMemoryDB(BiblosDs.Document.AdminCentral.ServiceReferenceAdministration.Attribute attribute, Boolean fromStorage)
        {
            Boolean campiRequiredPopolati = false;

            if (fromStorage)
            {
                // Popolo i controlli dai valori ottenuti dalla classe dell'oggetto DB
                txtName.Text = attribute.Name;
                if (!string.IsNullOrEmpty(attribute.AttributeType))
                {
                    comboBoxType.SelectedItem = attribute.AttributeType.Substring(attribute.AttributeType.LastIndexOf('.') + 1);
                }
                if (attribute.Mode != null)
                {
                    comboBoxMode.SelectedValue = attribute.Mode.IdMode;
                }
                ckRequired.Checked   = attribute.IsRequired;
                ckPrinaryKey.Checked = attribute.KeyOrder.HasValue && attribute.KeyOrder.Value > 0;
                txtKeyFilter.Text    = attribute.KeyFilter;
                txtKeyFormat.Text    = attribute.KeyFormat;
                if (attribute.KeyOrder != null)
                {
                    txtKeyOrder.Value = (short)attribute.KeyOrder;
                }
                txtValidation.Text    = attribute.Validation;
                txtFormat.Text        = attribute.Format;
                ckMainDate.Checked    = attribute.IsMainDate != null ? (bool)attribute.IsMainDate : false;
                ckAutoInc.Checked     = attribute.IsAutoInc != null ? (bool)attribute.IsAutoInc : false;
                ckUnique.Checked      = attribute.IsUnique != null ? (bool)attribute.IsUnique : false;
                txtMaxLenght.Value    = attribute.MaxLenght.HasValue ? attribute.MaxLenght.Value : 0;
                txtDefaultValue.Text  = attribute.DefaultValue;
                txtDescription.Text   = (string.IsNullOrWhiteSpace(attribute.Description)) ? attribute.Name : attribute.Description;
                ckIsSectional.Checked = attribute.IsSectional.GetValueOrDefault();
                attributeGroup        = attribute.AttributeGroup;
                lsAttributeGroup      = Client.GetAttributeGroup(archive.IdArchive);
                lsAttributeGroup.Select(x => x.Description).ToList().ForEach(
                    x => cbAttributeGroup.Items.Add(x.ToString())
                    );
                cbAttributeGroup.Text = attributeGroup != null ? attributeGroup.Description : string.Empty;

                ckRequiredForPreservation.Checked = attribute.IsRequiredForPreservation.GetValueOrDefault();
                ckVisibleForUser.Checked          = attribute.IsVisibleForUser.GetValueOrDefault();
                campiRequiredPopolati             = true;
            }
            else
            {
                // Qui controllo che i campi obbligatori siano valorizzati
                if (!RequiredFieldsArePopulated(true))
                {
                    return(false);
                }
                //if (String.IsNullOrEmpty(txtName.Text) || comboBoxType.SelectedItem == null || comboBoxMode.SelectedItem==null || cbAttributeGroup.SelectedItem==null)
                //{
                //    campiRequiredPopolati = false;
                //}
                //else
                //{
                // Popolo la classe dell'oggetto DB col valore dei controlli
                attribute.Name           = txtName.Text.Trim();
                attribute.Archive        = archive;
                attribute.AttributeType  = "System." + comboBoxType.SelectedItem.ToString();
                attribute.Format         = txtFormat.Text;
                attribute.IsMainDate     = ckMainDate.Checked;
                attribute.IsRequired     = ckRequired.Checked;
                attribute.KeyFilter      = txtKeyFilter.Text;
                attribute.KeyFormat      = txtKeyFormat.Text;
                attribute.KeyOrder       = (short)txtKeyOrder.Value;
                attribute.Mode           = (AttributeMode)comboBoxMode.SelectedItem;
                attribute.Validation     = txtValidation.Text;
                attribute.IsUnique       = ckUnique.Checked;
                attribute.AttributeGroup = attributeGroup;
                attribute.IsVisible      = ckVisible.Checked;
                attribute.DefaultValue   = txtDefaultValue.Text;
                attribute.Description    = (string.IsNullOrWhiteSpace(txtDescription.Text)) ? attribute.Name : txtDescription.Text.Trim();
                attribute.IsSectional    = ckIsSectional.Checked;
                if (txtMaxLenght.Visible)
                {
                    attribute.MaxLenght = (int)txtMaxLenght.Value;
                }

                attribute.IsRequiredForPreservation = ckRequiredForPreservation.Checked;
                attribute.IsVisibleForUser          = ckVisibleForUser.Checked;
                campiRequiredPopolati = true;
                //}
            }

            return(campiRequiredPopolati);
        }