async void OnClickSucc(object sender, System.EventArgs e) { busyIndicator.IsBusy = true; try { var dspList = await _dbcon.QueryAsync <ScaPagHead>("SELECT * FROM scapaghe WHERE dsp_codice > ? ORDER BY dsp_codice LIMIT 1", _dsp.dsp_codice); if (dspList.Count > 0) { foreach (var dsp in dspList) { _dsp = dsp; await LoadRelAsync(); SetField(); break; } } } catch (Exception ex) { await DisplayAlert("Attenzione!", ex.Message, "OK"); await Navigation.PopAsync(); return; } finally { busyIndicator.IsBusy = false; } }
private async void Edit() { dataGrid.ResetSwipeOffset(); if (swipeIndex == 0 || swipeDsp == null) { return; } ScaPagHead dsp = null; swipeIndex = 0; try { dsp = await dbcon_.GetAsync <ScaPagHead>(swipeDsp.dsp_codice); } catch (Exception ex) { await DisplayAlert("Attenzione!", ex.Message, "OK"); return; } if (dsp == null) { return; } await DisplayAlert("Attenzione", "Guardiamo il dettaglio della distinta", "OK"); //var page = new DocumentiEdit(ref fat, ref nuova); //await Navigation.PushAsync(page); }
async void DataGrid_GridLongPressed(object sender, Syncfusion.SfDataGrid.XForms.GridLongPressedEventArgs e) { var igm = e.RowData as IncassiGridModel; busyIndicator.IsBusy = true; ScaPagHead dsp = null; try { dsp = await dbcon_.GetAsync <ScaPagHead>(igm.dsp_codice); } catch (Exception ex) { busyIndicator.IsBusy = false; await DisplayAlert("Attenzione!", ex.Message, "OK"); return; } if (dsp == null) { busyIndicator.IsBusy = false; return; } await DisplayAlert("Attenzione", "Guardiamo il dettaglio della distinta", "OK"); //var page = new DocumentiEdit(ref fat, ref nuova); //await Navigation.PushAsync(page); busyIndicator.IsBusy = false; }
public IncassiModifica(ref ScaPagHead d) { InitializeComponent(); _dsp = d; _cli = null; _dst = null; _dsrList = null; _first = true; _dbcon = DependencyService.Get <ISQLiteDb>().GetConnection(); }
async void OnModificaClicked(object sender, System.EventArgs e) { ScaPagHead dsp = null; SQLiteAsyncConnection dbcon; dbcon = DependencyService.Get <ISQLiteDb>().GetConnection(); busyIndicator.IsBusy = true; try { var sql = string.Format("SELECT * from scapaghe WHERE ORDER BY dsp_codice DESC LIMIT 1"); var dspList = await dbcon.QueryAsync <ScaPagHead>("SELECT * from scapaghe ORDER BY dsp_codice DESC LIMIT 1"); foreach (var x in dspList) { dsp = x; break; } } catch (Exception ex) { busyIndicator.IsBusy = false; await DisplayAlert("Attenzione!", ex.Message, "OK"); return; } if (dsp == null) { busyIndicator.IsBusy = false; await DisplayAlert("Attenzione!", "Non è stato trovato in archivio alcun incasso", "Ok"); return; } var page = new IncassiModifica(ref dsp); await Navigation.PushAsync(page); busyIndicator.IsBusy = false; }
async void OnSalvaClicked(object sender, System.EventArgs e) { //if (await DisplayAlert("Attenzione", "Vuoi inviare un messaggio alla sede?", "Si", "No")) //{ // var recipients = new List<string>(); // recipients.Add("*****@*****.**"); // recipients.Add("*****@*****.**"); // try // { // var message = new EmailMessage // { // Subject = "Incasso", // To = recipients, // //Cc = ccRecipients, // //Bcc = bccRecipients // }; // message.BodyFormat = EmailBodyFormat.Html; // message.Body = string.Format("<body><h1>Incasso</h1><p>Cliente {0}</p>", m_cli_des.Text); // string str = "<table><tr><td>Data</td><td>Num. Doc.</td><td>Importo Doc</td><td>Importo Scadenza</td><td>Incasso</td></tr>"; // message.Body = message.Body + str + "</table></body>"; // await Email.ComposeAsync(message); // } // catch (FeatureNotSupportedException fbsEx) // { // await DisplayAlert("Attenzione", "Non supportato : " + fbsEx.Message, "OK"); // } // catch (Exception ex) // { // await DisplayAlert("Attenzione", ex.Message, "OK"); // } //} //return; double incasso = 0.0; int num_sca = 0; foreach (var item in dataGrid.View.Records) { var rowData = (IncassiInfo)item.Data; if (!rowData.sca_incasso.TestIfZero(2)) { incasso += rowData.sca_incasso; num_sca++; } } if (num_sca == 0) { await DisplayAlert("Attenzione", "Non è stato inserito alcun importo da incassare!", "OK"); return; } else { bool confirm = await DisplayAlert("Attenzione", "Confermi l'incasso di €" + incasso + " ?", "Si", "No"); if (!confirm) { return; } } // // Leggiamo le impostazioni // var app = (App)Application.Current; LocalImpo lim = null; try { lim = await _dbcon.GetAsync <LocalImpo>(1); } catch { await DisplayAlert("Attenzione!", "Impostazioni locali non trovate!\nRiavviare l'App.", "OK"); return; } if (lim.age == 0) { await DisplayAlert("Attenzione!", "Codice Agente non impostato!\nEffettuare le impostazioni iniziali.", "OK"); return; } // // Inseriamo la testata della distinta di Incasso // var dsp = new ScaPagHead { dsp_relaz = 0, dsp_codice = 0, dsp_clifor = Convert.ToInt32(m_cli_cod.Text), dsp_data = DateTime.Now, dsp_data_sel = null, dsp_mas = 0, dsp_con = 0, dsp_sot = 0, dsp_totale = incasso, dsp_des_con = "", dsp_mezzo = 0, // Cassa dsp_codass = 0, dsp_oldass = 0, dsp_pnota = 0, dsp_dst = string.IsNullOrWhiteSpace(m_dst_cod.Text) ? 0 : Convert.ToInt32(m_dst_cod.Text), dsp_abbuoni = 0.0, dsp_age = lim.age, dsp_sez = 1, dsp_ass = 0, dsp_sez_sca = 0, dsp_nonconf = 0, dsp_timeid = DateTime.Now, dsp_codppc = 0, dsp_parked = 0, dsp_data_ass = null, dsp_user = "", dsp_last_update = DateTime.Now, dsp_immediato = false, dsp_inviato = false }; try { await _dbcon.InsertAsync(dsp); } catch (Exception ex) { await DisplayAlert("Errore", "Impossibile inserire testata : " + ex.Message, "OK"); return; } // // Inseriamo le righe incassate // int idx = 0; foreach (var item in dataGrid.View.Records) { idx++; var rowData = (IncassiInfo)item.Data; if (!rowData.sca_incasso.TestIfZero(2)) { try { var sca = await _dbcon.GetAsync <Scadenze>(rowData.sca_id); var dsr = new ScaPagRow { dsr_id = 0, dsr_relaz = dsp.dsp_relaz, dsr_codice = dsp.dsp_codice, dsr_rel_sca = sca.sca_relaz, dsr_num_sca = sca.sca_num, dsr_data = sca.sca_data, dsr_old_num_doc = "", dsr_d_doc = sca.sca_data_fattura, dsr_tot_doc = sca.sca_tot_fat, dsr_importo = sca.sca_importo, dsr_paginc = rowData.sca_incasso, dsr_idx = idx, dsr_sez = sca.sca_sez, dsr_user = "", dsr_last_update = DateTime.Now, dsr_num_doc = sca.sca_fattura }; try { await _dbcon.InsertAsync(dsr); var resto = sca.sca_importo - rowData.sca_incasso; if (!resto.TestIfZero(2)) { try { sca.sca_importo = rowData.sca_incasso; sca.sca_pagato = 1; sca.sca_cont = 1; await _dbcon.UpdateAsync(sca); sca.sca_id = 0; sca.sca_num = 1 + await _dbcon.ExecuteScalarAsync <int>("SELECT MAX(sca_num) FROM scadenze WHERE sca_relaz = 0"); sca.sca_pagato = 0; sca.sca_cont = 0; sca.sca_importo = resto; sca.sca_locked = 1; await _dbcon.InsertAsync(sca); } catch (Exception ex) { await DisplayAlert("Errore", "Impossibile aggiornare la scadenza : " + ex.Message, "OK"); } } else { try { sca.sca_pagato = 1; sca.sca_cont = 1; await _dbcon.UpdateAsync(sca); } catch (Exception ex) { await DisplayAlert("Errore", "Impossibile aggiornare la scadenza : " + ex.Message, "OK"); } } } catch (Exception ex) { await DisplayAlert("Errore", "Impossibile inserire riga : " + ex.Message, "OK"); } } catch { await DisplayAlert("Attenzione!", "Scadenza non trovata in archivio!", "OK"); } } } m_cli_cod.Text = ""; m_cli_des.Text = ""; m_dst_cod.Text = ""; m_dst_des.Text = ""; dataGrid.ItemsSource = null; m_search_cli.Focus(); }
async void OnClickElimina(object sender, System.EventArgs e) { var test = await DisplayAlert("Attenzione!", "Confermi la cancellazione del documento?", "Si", "No"); if (!test) { return; } // // Cancelliamo le righe // try { await _dbcon.ExecuteAsync("DELETE FROM scapagro WHERE dsr_relaz = ? AND dsr_codice = ?", _dsp.dsp_relaz, _dsp.dsp_codice); await _dbcon.ExecuteAsync("DELETE FROM scapaghe WHERE dsp_relaz = ? AND dsp_codice = ?", _dsp.dsp_relaz, _dsp.dsp_codice); } catch (Exception ex) { await DisplayAlert("Errore!", "Impossibile cancellare : " + ex.Message, "OK"); return; } busyIndicator.IsBusy = true; try { var dspList = await _dbcon.QueryAsync <ScaPagHead>("SELECT * FROM scapaghe WHERE dsp_codice > ? ORDER BY dsp_codice LIMIT 1", _dsp.dsp_codice); if (dspList.Count > 0) { foreach (var dsp in dspList) { _dsp = dsp; await LoadRelAsync(); SetField(); break; } } else { dspList = await _dbcon.QueryAsync <ScaPagHead>("SELECT * FROM scapaghe WHERE dsp_codice < ? ORDER BY dsp_codice DESC LIMIT 1", _dsp.dsp_codice); if (dspList.Count > 0) { foreach (var dsp in dspList) { _dsp = dsp; await LoadRelAsync(); SetField(); break; } } else { await Navigation.PopAsync(); } } } catch (Exception ex) { await DisplayAlert("Attenzione!", ex.Message, "OK"); await Navigation.PopAsync(); return; } finally { busyIndicator.IsBusy = false; } }