public CFCalcWindow() { InitializeComponent(); dag = new DataAccessGateway(); cfcalc = new CFcalculator.CFcalculator(); btnInserisci.IsEnabled = false; cl = new Cliente(); }
private void loadClientData(int id) { clienteModificato = dag.cercaCliente(id); txtboxCognome.Text = clienteModificato.Cognome; txtboxNome.Text = clienteModificato.Nome; if (clienteModificato.IsFemmina) radioButtonF.IsChecked = true; else radioButtonM.IsChecked = true; txtboxTel.Text = clienteModificato.Telefoni; txtboxMail.Text = clienteModificato.Email; txtboxNoteCliente.Text = clienteModificato.Descr; txtboxAddr.Text = clienteModificato.Indirizzo; if (clienteModificato.DataNascita != DateTime.MinValue) datePickerNascita.SelectedDate = clienteModificato.DataNascita; if (clienteModificato.ComuneNascita != null) { txtboxComuneNascita.Text = clienteModificato.ComuneNascita.Nome + " (" + clienteModificato.ComuneNascita.Provincia + ")"; } if (clienteModificato.StatoNascita != null) txtboxStatoNascita.Text = clienteModificato.StatoNascita.Nome; if (clienteModificato.StatoCittadinanza != null) txtboxCittadinanza.Text = clienteModificato.StatoCittadinanza.Nome; if (clienteModificato.ComuneResidenza != null) { txtboxComuneResid.Text = clienteModificato.ComuneResidenza.Nome + " (" + clienteModificato.ComuneResidenza.Provincia + ")"; } if (clienteModificato.StatoResidenza != null) txtboxStatoResid.Text = clienteModificato.StatoResidenza.Nome; txtboxNumDoc.Text = clienteModificato.NumDoc; if (clienteModificato.DataRilascioDoc != DateTime.MinValue) datePickerRilascioDoc.SelectedDate = clienteModificato.DataRilascioDoc; if (clienteModificato.ComuneRilascioDoc != null) { txtboxComuneRilascioDoc.Text = clienteModificato.ComuneRilascioDoc.Nome + " (" + clienteModificato.ComuneRilascioDoc.Provincia + ")"; } if (clienteModificato.StatoRilascioDoc != null) txtboxStatoRilascioDoc.Text = clienteModificato.StatoRilascioDoc.Nome; if (clienteModificato.TipoDoc != null) { var tipodocToSelect = (from t in tipidoc where t.Id == clienteModificato.TipoDoc.Id select t).FirstOrDefault(); cbxTipoDoc.SelectedItem = tipodocToSelect; } if (clienteModificato.ProvenIstat != null) txtboxProvIstat.Text = clienteModificato.ProvenIstat.Regione == "" ? clienteModificato.ProvenIstat.Stato : clienteModificato.ProvenIstat.Regione; loadSoggiorniCliente(id); }
private void btnArchivioClienti_Click(object sender, RoutedEventArgs e) { sucw = new SelezionaUnClienteWindow(); sucw.ShowDialog(); if (sucw.DialogResult.HasValue && sucw.DialogResult.Value) { txtboxCliente.Text = sucw.clienteSelezionato.Cognome; this.cliente = sucw.clienteSelezionato; } }
public AddClienteWindow() { InitializeComponent(); nuovoCliente = new Cliente(); dag = new DataAccessGateway(); tipidoc = dag.getAllTipiDoc(); cbxTipoDoc.DataContext = tipidoc; idStatoItalia = dag.getStatoByNome(nomeStatoItalia); }
private void btnSelectCliente_Click(object sender, RoutedEventArgs e) { //caso 0 risultati if (dataGridClienti.Items.Count == 0) { MessageBox.Show("E' necessario avere almeno un risultato per selezionare un cliente", "Nessun risultato di ricerca", MessageBoxButton.OK, MessageBoxImage.Error); return; } //caso nessuna riga selezionata if (dataGridClienti.SelectedItems.Count == 0) { MessageBox.Show("E' necessario selezionare un cliente dalla griglia", "Nessuna selezione", MessageBoxButton.OK, MessageBoxImage.Error); return; } //prelevo tutti i dati del cliente selezionato clienteSelezionato = dag.cercaCliente(((Cliente)dataGridClienti.SelectedItems[0]).Id); this.DialogResult = true; }
private void loadClientData(int idcliente) { cl = dag.cercaCliente(idcliente); txtboxCognome.Text = cl.Cognome; txtboxNome.Text = cl.Nome; if (cl.IsFemmina) radioButtonF.IsChecked = true; else radioButtonM.IsChecked = true; if (cl.DataNascita != null && cl.DataNascita!= DateTime.MinValue) datePickerNascita.SelectedDate = cl.DataNascita; else datePickerNascita.SelectedDate = null; if (cl.ComuneNascita != null) { txtboxComuneNascita.Text = cl.ComuneNascita.Nome +" (" + cl.ComuneNascita.Provincia + ")"; } }
private void btnResetCliente_Click(object sender, RoutedEventArgs e) { txtboxCliente.Text = ""; this.cliente = null; }
private void verificaPremi(Cliente cl) { //verifica se ci sono notifiche da fare per questo cliente: tipo ogni X soggiorni un premio var sogs = dag.cercaSoggiorniCliente(idSelectedClient); if (sogs.Count > 0) { int soggiorniCliente = sogs.Count + 1; if (soggiorniCliente == Properties.Settings.Default.CadenzaPremioSoggiorni) { //suono premio soggiorno /*var mp = new MediaPlayer(); mp.Open(new Uri("arpa.mp3", UriKind.Relative)); mp.Play();*/ var sp = new SoundPlayer("arpa.wav"); sp.Play(); loadNotifyIcon(cl.Cognome); } } }
private void btnArchivioClienti_Click(object sender, RoutedEventArgs e) { sucw = new SelezionaUnClienteWindow(); sucw.ShowDialog(); if (sucw.DialogResult.HasValue && sucw.DialogResult.Value) { cl = sucw.clienteSelezionato; txtboxCognome.Text = cl.Cognome; txtboxNome.Text = cl.Nome; if (cl.IsFemmina) radioButtonF.IsChecked = true; else radioButtonM.IsChecked = true; if (cl.DataNascita != null && cl.DataNascita != DateTime.MinValue) datePickerNascita.SelectedDate = cl.DataNascita; else datePickerNascita.SelectedDate = null; if (cl.ComuneNascita != null) { txtboxComuneNascita.Text = cl.ComuneNascita.Nome + " (" + cl.ComuneNascita.Provincia + ")"; } } }
internal Cliente cercaClienteNomeCognome(int idcliente) { var cta = new ClienteTableAdapter(); var cdt = cta.GetNomeCognomeById(idcliente); var c = new Cliente { Id = idcliente, Cognome = cdt[0].Cognome, Nome = cdt[0].Nome }; return c; }
internal void inserisciCliente(Cliente c) { var cta = new ClienteTableAdapter(); cta.Insert(c.Nome, c.Cognome, c.IsFemmina, c.Indirizzo, c.ComuneResidenza == null ? null : (int?)c.ComuneResidenza.Id, c.StatoResidenza == null ? null : (int?)c.StatoResidenza.Id, c.Telefoni, c.Descr, c.Email, c.DataNascita == DateTime.MinValue ? null : (DateTime?)c.DataNascita, c.ComuneNascita == null ? null : (int?)c.ComuneNascita.Id, c.StatoNascita == null ? null : (int?)c.StatoNascita.Id, c.StatoCittadinanza == null ? null : (int?)c.StatoCittadinanza.Id, c.TipoDoc == null ? null : (int?)c.TipoDoc.Id, c.NumDoc, c.DataRilascioDoc == DateTime.MinValue ? null : (DateTime?)c.DataRilascioDoc, c.ComuneRilascioDoc == null ? null : (int?)c.ComuneRilascioDoc.Id, c.StatoRilascioDoc == null ? null : (int?)c.StatoRilascioDoc.Id, c.ProvenIstat == null ? null : (int?)c.ProvenIstat.Id); }
internal List<Soggiorno> cercaSoggiorni(DateTime arrivo, DateTime partenza, Cliente cliente) { OleDbConnection conn = new OleDbConnection(Properties.Settings.Default.SoggiorniDbConnectionString); string queryString; if(cliente!=null) queryString = "SELECT * FROM QuerySoggiorniBetweenDataByCliente"; else queryString = "SELECT * FROM QuerySoggiorniBetweenData"; OleDbCommand cmd = new OleDbCommand(queryString, conn); cmd.Parameters.Add("Arrivo", OleDbType.Date).Value = arrivo; cmd.Parameters.Add("Partenza", OleDbType.Date).Value = partenza; if(cliente != null) cmd.Parameters.Add("IdCliente", OleDbType.Integer).Value = cliente.Id; conn.Open(); OleDbDataReader reader = cmd.ExecuteReader(); var slist = new List<Soggiorno>(); while (reader.Read()) { //Soggiorno.ID, Soggiorno.Arrivo, Soggiorno.Partenza, Soggiorno.TotaleSoggiorno, Cliente.Cognome, Camera.Numero, //Soggiorno.IsCheckedIn, Soggiorno.IsCheckedOut slist.Add(new Soggiorno { Id = int.Parse(reader[0].ToString()), Arrivo = DateTime.Parse(reader[1].ToString()), Partenza = DateTime.Parse(reader[2].ToString()), TotaleSoggiorno = (reader[3].ToString() == "") ? 0 : decimal.Parse(reader[3].ToString()), Cliente = new Cliente{ Cognome = reader[4].ToString()}, Camera = new Camera { Numero = int.Parse(reader[5].ToString()) }, IsCheckedIn = bool.Parse(reader[6].ToString()), IsCheckedOut = bool.Parse(reader[7].ToString()) }); } reader.Close(); conn.Close(); return slist; }
internal void aggiornaCliente(Cliente cl) { var cta = new ClienteTableAdapter(); cta.UpdateById( cl.Nome, cl.Cognome, cl.IsFemmina, cl.Indirizzo, cl.ComuneResidenza == null ? null : (int?)cl.ComuneResidenza.Id, cl.StatoResidenza == null ? null : (int?)cl.StatoResidenza.Id, cl.Telefoni, cl.Descr, cl.Email, cl.DataNascita == DateTime.MinValue ? null : (DateTime?)cl.DataNascita, cl.ComuneNascita== null ? null : (int?)cl.ComuneNascita.Id, cl.StatoNascita == null ? null : (int?)cl.StatoNascita.Id, cl.StatoCittadinanza == null ? null : (int?)cl.StatoCittadinanza.Id, cl.TipoDoc == null ? null : (int?)cl.TipoDoc.Id, cl.NumDoc, cl.DataRilascioDoc == DateTime.MinValue ? null : (DateTime?)cl.DataRilascioDoc, cl.ComuneRilascioDoc == null ? null : (int?)cl.ComuneRilascioDoc.Id, cl.StatoRilascioDoc == null ? null : (int?)cl.StatoRilascioDoc.Id, cl.ProvenIstat == null ? null : (int?)cl.ProvenIstat.Id, cl.Id ); }
internal Cliente cercaCliente(int idcliente) { var cta = new ClienteTableAdapter(); var cdt = cta.GetDataById(idcliente); var cl = cdt[0]; var foundcliente = new Cliente { //ID, Nome, Cognome, IsFemmina, Indirizzo, ComuneResid, StatoResid, Telefoni, Descrizione, //Email, DataNascita, ComuneNascita, StatoNascita, StatoCittadinanza, TipoDocumento, NumDocumento, //DataRilascioDoc, ComuneRilascioDoc, StatoRilascioDoc, ProvenienzaIstat Id = cl.ID, Nome = cl.IsNomeNull() ? "" : cl.Nome, Cognome = cl.Cognome, IsFemmina = cl.IsFemmina, Indirizzo = cl.IsIndirizzoNull() ? "" : cl.Indirizzo, ComuneResidenza = cl.IsComuneResidNull() ? null : new Comune { Id = cl.ComuneResid }, StatoResidenza = cl.IsStatoResidNull() ? null : new Stato { Id = cl.StatoResid }, Telefoni = cl.IsTelefoniNull() ? "" : cl.Telefoni, Descr = cl.IsDescrizioneNull() ? "" : cl.Descrizione, Email = cl.IsEmailNull() ? "" : cl.Email, DataNascita = cl.IsDataNascitaNull() ? DateTime.MinValue : cl.DataNascita, ComuneNascita = cl.IsComuneNascitaNull() ? null : new Comune { Id = cl.ComuneNascita }, StatoNascita = cl.IsStatoNascitaNull() ? null : new Stato { Id = cl.StatoNascita }, StatoCittadinanza = cl.IsStatoCittadinanzaNull() ? null : new Stato { Id = cl.StatoCittadinanza }, TipoDoc = cl.IsTipoDocumentoNull() ? null : new TipoDocumento { Id = cl.TipoDocumento }, NumDoc = cl.IsNumDocumentoNull() ? "" : cl.NumDocumento, DataRilascioDoc = cl.IsDataRilascioDocNull() ? DateTime.MinValue : cl.DataRilascioDoc, ComuneRilascioDoc = cl.IsComuneRilascioDocNull() ? null : new Comune { Id = cl.ComuneRilascioDoc }, StatoRilascioDoc = cl.IsStatoRilascioDocNull() ? null : new Stato { Id = cl.StatoRilascioDoc }, ProvenIstat = cl.IsProvenienzaIstatNull() ? null : new ProvenienzaIstat { Id = cl.ProvenienzaIstat } }; //raccolgo dati comuni (se presenti) var comta = new ComuneTableAdapter(); SoggiorniDbDataSet.ComuneDataTable comdt; if (foundcliente.ComuneNascita != null) { comdt = comta.GetDataById(foundcliente.ComuneNascita.Id); foundcliente.ComuneNascita.Nome = comdt[0].Nome; foundcliente.ComuneNascita.Provincia = comdt[0].Provincia; } if (foundcliente.ComuneResidenza != null) { comdt = comta.GetDataById(foundcliente.ComuneResidenza.Id); foundcliente.ComuneResidenza.Nome = comdt[0].Nome; foundcliente.ComuneResidenza.Provincia = comdt[0].Provincia; } if (foundcliente.ComuneRilascioDoc != null) { comdt = comta.GetDataById(foundcliente.ComuneRilascioDoc.Id); foundcliente.ComuneRilascioDoc.Nome = comdt[0].Nome; foundcliente.ComuneRilascioDoc.Provincia = comdt[0].Provincia; } //raccolgo dati stati (se presenti) var stata = new StatoTableAdapter(); SoggiorniDbDataSet.StatoDataTable stadt; if (foundcliente.StatoNascita != null) { stadt = stata.GetDataById(foundcliente.StatoNascita.Id); foundcliente.StatoNascita.Nome = stadt[0].Nome; } if (foundcliente.StatoResidenza != null) { stadt = stata.GetDataById(foundcliente.StatoResidenza.Id); foundcliente.StatoResidenza.Nome = stadt[0].Nome; } if (foundcliente.StatoRilascioDoc != null) { stadt = stata.GetDataById(foundcliente.StatoRilascioDoc.Id); foundcliente.StatoRilascioDoc.Nome = stadt[0].Nome; } if (foundcliente.StatoCittadinanza != null) { stadt = stata.GetDataById(foundcliente.StatoCittadinanza.Id); foundcliente.StatoCittadinanza.Nome = stadt[0].Nome; } //raccolgo dati provenienza istat if (foundcliente.ProvenIstat != null) { var prota = new ProvenienzaIstatTableAdapter(); var prodt = prota.GetDataById(foundcliente.ProvenIstat.Id); foundcliente.ProvenIstat.Regione = prodt[0].Regione; foundcliente.ProvenIstat.Stato = prodt[0].Stato; } //raccolgo dati tipo documento if (foundcliente.TipoDoc != null) { var tdocta = new TipoDocumentoTableAdapter(); var tdocdt = tdocta.GetDataById(foundcliente.TipoDoc.Id); foundcliente.TipoDoc.Descrizione = tdocdt[0].Descrizione; } return foundcliente; }
internal List<Cliente> cercaClientiByCognome(string prefix) { OleDbConnection conn = new OleDbConnection(Properties.Settings.Default.SoggiorniDbConnectionString); string queryString = "SELECT * FROM QueryClienteByCognome"; OleDbCommand cmd = new OleDbCommand(queryString, conn); cmd.Parameters.Add("Prefisso", OleDbType.Char, 255).Value = prefix+"%"; conn.Open(); OleDbDataReader reader = cmd.ExecuteReader(); var clist = new List<Cliente>(); while (reader.Read()) { //ID, Cognome, Nome, Telefoni var cliente = new Cliente { Id = int.Parse(reader[0].ToString()), Cognome = reader[1].ToString(), Nome = reader[2].ToString(), Telefoni = reader[3].ToString(), }; clist.Add(cliente); } reader.Close(); conn.Close(); return clist; }
private bool isSchedinaClienteCompleta(Cliente cliente) { if (cliente.Nome == "") return false; if (cliente.Cognome == "") return false; if (cliente.DataNascita == DateTime.MinValue) return false; if (cliente.StatoNascita == null) return false; else { if ((cliente.StatoNascita.Id == idStatoItalia) && (cliente.ComuneNascita == null)) return false; } if (cliente.StatoCittadinanza == null) return false; if (cliente.StatoResidenza == null) return false; else { if ((cliente.StatoResidenza.Id == idStatoItalia) && (cliente.ComuneResidenza == null)) return false; } if (cliente.Indirizzo == "") return false; if (cliente.TipoDoc == null) return false; if (cliente.NumDoc == "") return false; if (cliente.StatoRilascioDoc == null) return false; else { if ((cliente.StatoRilascioDoc.Id == idStatoItalia) && (cliente.ComuneRilascioDoc == null)) return false; } //la provenienza non sarebbe obbligatoria ma la rendo tale per facilitare la compilazione //del file presenze ISTAT if (cliente.ProvenIstat == null) return false; return true; }