示例#1
0
        private void btnConfrontaAnagrafiche_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtAnagrafica.Text) || string.IsNullOrEmpty(txtAnagraficaDestinazione.Text))
            {
                txtMessaggio.Text = "Inserire il codice anagrafica o il codice anagrafica destinazione";
                return;
            }
            BCServices bc = new BCServices();

            bc.CreaConnessione();
            Articoli articolo             = bc.EstraiArticolo(txtAnagrafica.Text);
            Articoli articoloDestinazione = bc.EstraiArticolo(txtAnagraficaDestinazione.Text);

            if (articolo == null)
            {
                txtMessaggio.Text = "Articolo non trovato " + txtAnagrafica.Text;
                return;
            }
            if (articoloDestinazione == null)
            {
                txtMessaggio.Text = "Articolo non trovato " + txtAnagraficaDestinazione.Text;
                return;
            }
            Type type = articolo.GetType();

            PropertyInfo[] props = type.GetProperties();

            StringBuilder sb = new StringBuilder();

            foreach (PropertyInfo pi in props.OrderBy(X => X.Name))
            {
                object valore1 = pi.GetValue(articolo);
                object valore2 = pi.GetValue(articoloDestinazione);
                bool   uguali  = false;
                if (valore1.ToString() == valore2.ToString())
                {
                    uguali = true;
                }

                string messaggio = string.Format("{0}  {1}  {2} - {3}", uguali ? "SI" : "NO", pi.Name, valore1.ToString(), valore2.ToString());
                sb.AppendLine(messaggio);
            }
            txtMessaggio.Text = sb.ToString();
        }
示例#2
0
 private void btnEstraiAnagrafica_Click(object sender, EventArgs e)
 {
     txtMessaggio.Text = string.Empty;
     try
     {
         if (string.IsNullOrEmpty(txtAnagrafica.Text))
         {
             txtMessaggio.Text = "Inserire il codice anagrafica";
             return;
         }
         BCServices bc = new BCServices();
         bc.CreaConnessione();
         Articoli articolo = bc.EstraiArticolo(txtAnagrafica.Text);
         txtDescrizioneArticolo.Text = articolo.Description;
         txtMessaggio.Text           = string.Format("{0} {1} {2}", articolo.No, articolo.Description, articolo.Description_2);
     }
     catch (Exception ex)
     {
         txtMessaggio.Text = estraiErrore(ex);
     }
 }