Applicazione Tester di EPHWS_Allianz
Esempio
C#
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using EPHESO.Utility; namespace testEPHWS_Allianz { public partial class Form1 : Form { public static string ws_user = ""; public static string ws_pwd = ""; public static string ws_url = ""; public static WSCALC.KeyValueStruct[] pCategoriePrevidenziali; bool Attivato = false; public Form1() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { try { //istanziamento ed autentificazione al servizio web WSCALC.Calcola CALCOLO = new WSCALC.Calcola(); CALCOLO.Url = txtUrl.Text; CALCOLO.EnableDecompression = true; CALCOLO.AuthHeaderValue = new WSCALC.AuthHeader(); CALCOLO.AuthHeaderValue.user = txtUser.Text; CALCOLO.AuthHeaderValue.pass = txtPwd.Text; ws_user = txtUser.Text; ws_pwd = txtPwd.Text; ws_url = txtUrl.Text; //Recupero dati pCategoriePrevidenziali = CALCOLO.FunzioneAusiliaria_CategoriePrevidenziali(); txtAnnoVal.Text = (DateTime.Now.Year + 1).ToString("0"); cboProfessione.Items.Clear(); foreach (WSCALC.KeyValueStruct it in Form1.pCategoriePrevidenziali) this.cboProfessione.Items.Add(new ComboElement(it.Text, it.ID)); cboProfessione.SelectedIndex = cboProfessione.Items.Count - 1; Attivato = true; } catch (Exception ex) { MessageBox.Show("Controllare l'URL e le credenziali, servizio non disponibile"); } } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { if (!Attivato) return; //istanziamento ed autentificazione al servizio web WSCALC.Calcola CALCOLO = new WSCALC.Calcola(); CALCOLO.Url = ws_url; CALCOLO.EnableDecompression = true; CALCOLO.AuthHeaderValue = new WSCALC.AuthHeader(); CALCOLO.AuthHeaderValue.user = ws_user; CALCOLO.AuthHeaderValue.pass = ws_pwd; WSCALC.Analisi ana = new WSCALC.Analisi(); ana.RisultatiNetti = chkRisultatiNetti.Checked; ana.Persona = new WSCALC.Soggetto(); try { ana.CausaLavoro = chkCausa.Checked; ana.Persona.Nascita = EString.CDATE(txtDataNascita.Text); ana.Persona.SessoMaschio = chkMaschio.Checked; ana.Persona.CodiceCategoriaPrevidenziale = ((ComboElement)cboProfessione.Items[cboProfessione.SelectedIndex]).codice; ana.Persona.DataInizioAttivita = EString.CDATE(txtDataInizioLavoro.Text); ana.Persona.UltimoReddito = EString.DBL(txtReddito.Text); ana.Persona.RedditoNetto = chkRedditoNetto.Checked; ana.AnnoValutazione = EString.INT(txtAnnoVal.Text); int tc = 0; if (chkConiuge.Checked) ++tc; if (chkF1.Checked) ++tc; if (chkF2.Checked) ++tc; if (chkF3.Checked) ++tc; if (tc > 0) { ana.NucleoFamigliare = new WSCALC.Famigliare[tc]; tc = 0; if (chkConiuge.Checked) { ana.NucleoFamigliare[tc] = new WSCALC.Famigliare(); ana.NucleoFamigliare[tc].DataDiNascita = EString.CDATE(txtNascitaCon.Text); if (rbConiuge.Checked) ana.NucleoFamigliare[tc].Relazione = WSCALC.RelazioneFamigliare.coniuge; else if (rbUnione.Checked) ana.NucleoFamigliare[tc].Relazione = WSCALC.RelazioneFamigliare.UnioneDiFatto; else ana.NucleoFamigliare[tc].Relazione = WSCALC.RelazioneFamigliare.convivente; ana.NucleoFamigliare[tc].ID = "CON"; ++tc; } if (chkF1.Checked) { ana.NucleoFamigliare[tc] = new WSCALC.Famigliare(); ana.NucleoFamigliare[tc].DataDiNascita = EString.CDATE(txtNascitaF1.Text); ana.NucleoFamigliare[tc].Relazione = WSCALC.RelazioneFamigliare.figlio; ana.NucleoFamigliare[tc].ID = "F1"; ++tc; } if (chkF2.Checked) { ana.NucleoFamigliare[tc] = new WSCALC.Famigliare(); ana.NucleoFamigliare[tc].DataDiNascita = EString.CDATE(txtNascitaF2.Text); ana.NucleoFamigliare[tc].Relazione = WSCALC.RelazioneFamigliare.figlio; ana.NucleoFamigliare[tc].ID = "F2"; ++tc; } if (chkF3.Checked) { ana.NucleoFamigliare[tc] = new WSCALC.Famigliare(); ana.NucleoFamigliare[tc].DataDiNascita = EString.CDATE(txtNascitaF3.Text); ana.NucleoFamigliare[tc].Relazione = WSCALC.RelazioneFamigliare.figlio; ana.NucleoFamigliare[tc].ID = "F3"; ++tc; } } WSCALC.AnalisiRisultati result = CALCOLO.CalcolaPensioni(ana); new EPHESO.Utility.WinControls.TreeViewClassReflection().DisplayTV(tvResult, result, "Risultato"); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } private void button3_Click(object sender, EventArgs e) { if (!Attivato) return; //istanziamento ed autentificazione al servizio web WSCALC.Calcola CALCOLO = new WSCALC.Calcola(); CALCOLO.Url = ws_url; CALCOLO.EnableDecompression = true; CALCOLO.AuthHeaderValue = new WSCALC.AuthHeader(); CALCOLO.AuthHeaderValue.user = ws_user; CALCOLO.AuthHeaderValue.pass = ws_pwd; WSCALC.AnalisiInv ana = new WSCALC.AnalisiInv(); ana.RisultatiNetti = chkRisultatiNetti.Checked; ana.Persona = new WSCALC.Soggetto(); try { ana.CausaLavoro = chkCausa.Checked; ana.Persona.Nascita = EString.CDATE(txtDataNascita.Text); ana.Persona.SessoMaschio = chkMaschio.Checked; ana.Persona.CodiceCategoriaPrevidenziale = ((ComboElement)cboProfessione.Items[cboProfessione.SelectedIndex]).codice; ana.Persona.DataInizioAttivita = EString.CDATE(txtDataInizioLavoro.Text); ana.Persona.UltimoReddito = EString.DBL(txtReddito.Text); ana.Persona.RedditoNetto = chkRedditoNetto.Checked; ana.AnnoValutazione = EString.INT(txtAnnoVal.Text); ana.PercentualeInvalidita = EString.DBL(txtPercInv.Text); double result = CALCOLO.PensioneInvalidita(ana); txtPensioneOut.Text = EString.NUM2STR(result, 2); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } } public class ComboElement { public string descrizione = ""; public string codice = ""; public ComboElement(string d, string c) { descrizione = d; codice = c; } public override string ToString() { return descrizione; } } }