async void OnDstCodUnfocused(object sender, Xamarin.Forms.FocusEventArgs e) { GetField(); _dst = null; if (_parent.doc.fat_inte != 0) { if (_parent.doc.fat_dest != 0) { try { _dst = await _dbcon.GetAsync <Destinazioni>(_parent.doc.fat_dest); if (_dst.dst_cli_for != _cli.cli_codice || _dst.dst_rel != 0) { _dst = null; } } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } } } if (_dst == null) { _parent.doc.fat_dest = 0; } SetField(); }
async void OnDestinazioneTapped(object sender, System.EventArgs e) { // // Verifichiamo che ci destinazioni per il cliente // var recTotal_ = 0; if (_cli != null) { string sql = "SELECT COUNT(*) FROM destina1 WHERE dst_rel = 0 AND dst_cli_for = " + _cli.cli_codice; recTotal_ = await _dbcon.ExecuteScalarAsync <int>(sql); } if (recTotal_ == 0) { await DisplayAlert("Attenzione!", "Non ci sono destinazioni per il Cliente selezionato", "OK"); return; } var page = new DestinazioniSearch(_cli != null ? _cli.cli_codice : 0); page.DstList.ItemDoubleTapped += (source, args) => { _dst = (Destinazioni)args.ItemData; SetField(); Navigation.PopAsync(); }; await Navigation.PushAsync(page); }
async void OnCliCodUnfocused(object sender, Xamarin.Forms.FocusEventArgs e) { GetField(); _cli = null; _dst = null; if (_parent.doc.fat_inte != 0) { try { _cli = await _dbcon.GetAsync <Clienti>(_parent.doc.fat_inte); if (_parent.doc.fat_tipo_ven == (short)DocTipoVen.VEN_TRASFERT) { _parent.doc.fat_listino = _cli.cli_listino_tra; } else { _parent.doc.fat_listino = _cli.cli_listino; } _parent.doc.fat_pag = _cli.cli_pag; if (_parent.doc.fat_tipo != (short)DocTipo.TIPO_FAT && _parent.doc.fat_tipo != (short)DocTipo.TIPO_ORD && _parent.doc.fat_tipo != (short)DocTipo.TIPO_PRE && _parent.doc.fat_tipo != (short)DocTipo.TIPO_BUO) { _parent.doc.fat_rag = _cli.cli_ragg; } _parent.doc.fat_spese = _cli.cli_spese; _parent.doc.fat_bolli = _cli.cli_bolli; _parent.doc.fat_iva_cli = _cli.cli_iva; _parent.doc.fat_ban = _cli.cli_ban; } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } if (_parent.doc.fat_dest != 0) { try { _dst = await _dbcon.GetAsync <Destinazioni>(_parent.doc.fat_dest); if (_dst.dst_cli_for != _cli.cli_codice || _dst.dst_rel != 0) { _dst = null; } } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } } } if (_cli == null) { _parent.doc.fat_inte = 0; } if (_dst == null) { _parent.doc.fat_dest = 0; } SetField(); }
protected async Task LoadRel() { _cli = null; _dst = null; if (_parent.doc.fat_inte != 0) { try { _cli = await _dbcon.GetAsync <Clienti>(_parent.doc.fat_inte); } catch (System.Exception) { await DisplayAlert("Attenzione", "Cliente non trovato", "OK"); } if (_parent.doc.fat_dest != 0) { try { _dst = await _dbcon.GetAsync <Destinazioni>(_parent.doc.fat_dest); } catch (System.Exception) { await DisplayAlert("Attenzione", "Destinazione non trovata", "OK"); } } } }
async void OnClientiClicked(object sender, System.EventArgs e) { var page = new ClientiSearch(); page.CliList.ItemDoubleTapped += async(source, args) => { var cli = (Clienti)args.ItemData; m_cli_cod.Text = cli.cli_codice.ToString(); m_cli_des.Text = cli.cli_desc; await Navigation.PopAsync(); if ((_cli == null) || (_cli.cli_codice != cli.cli_codice)) { m_dst_cod.Text = ""; m_dst_des.Text = ""; _cli = cli; _dst = null; dataGrid.IsBusy = true; string sql = String.Format("SELECT sca_id, sca_data, sca_importo, (sca_importo * 0) AS sca_incasso, sca_fattura, sca_tot_fat, sca_desc, sca_locked FROM scadenze WHERE sca_relaz = 0 AND sca_pagato = 0 AND sca_cli_for = {0} ORDER BY sca_data, sca_num", cli.cli_codice); var scaList = await _dbcon.QueryAsync <IncassiInfo>(sql); var scaCollection = new ObservableCollection <IncassiInfo>(scaList); dataGrid.ItemsSource = scaCollection; dataGrid.IsBusy = false; } _cli_changed = false; _dst_changed = false; }; await Navigation.PushAsync(page); }
protected async Task LoadRelAsync() { _cli = null; _dst = null; if (_dsp.dsp_clifor != 0) { try { _cli = await _dbcon.GetAsync <Clienti>(_dsp.dsp_clifor); } catch (System.Exception) { await DisplayAlert("Attenzione", "Cliente non trovato", "OK"); } if (_dsp.dsp_dst != 0) { try { _dst = await _dbcon.GetAsync <Destinazioni>(_dsp.dsp_dst); } catch (System.Exception) { await DisplayAlert("Attenzione", "Destinazione non trovata", "OK"); } } _dsrList = await _dbcon.QueryAsync <ScaPagRow>("SELECT * FROM scapagro WHERE dsr_relaz = ? AND dsr_codice = ?", _dsp.dsp_relaz, _dsp.dsp_codice); } }
public Incassi(Clienti cli, Destinazioni dst) { _dbcon = DependencyService.Get <ISQLiteDb>().GetConnection(); _cli = cli; _dst = dst; _on_edit = false; InitializeComponent(); if (Device.Idiom != TargetIdiom.Phone) { m_cli_cod.WidthRequest = 110; m_dst_cod.WidthRequest = 110; } m_cli_cod.Text = _cli != null?_cli.cli_codice.ToString() : ""; m_cli_des.Text = _cli != null ? _cli.cli_desc : ""; m_dst_cod.Text = _dst != null?_dst.dst_codice.ToString() : ""; m_dst_des.Text = _dst != null ? _dst.dst_desc : ""; GridTableSummaryRow summaryRow1 = new GridTableSummaryRow(); summaryRow1.Title = "Totale da Incassare {Totale} - Incasso : {Incasso}"; summaryRow1.ShowSummaryInRow = true; summaryRow1.Position = Position.Bottom; summaryRow1.SummaryColumns.Add(new GridSummaryColumn() { Name = "Totale", MappingName = "sca_importo", Format = "{Sum:c}", SummaryType = SummaryType.DoubleAggregate }); summaryRow1.SummaryColumns.Add(new GridSummaryColumn() { Name = "Incasso", MappingName = "sca_incasso", Format = "{Sum:c}", SummaryType = SummaryType.DoubleAggregate }); dataGrid.TableSummaryRows.Add(summaryRow1); dataGrid.LiveDataUpdateMode = LiveDataUpdateMode.AllowSummaryUpdate; /* * dataGrid.AllowEditing = true; * GridNumericColumn column = new GridNumericColumn(); * column.MappingName = "Incasso"; * column.AllowEditing = true; * dataGrid.EditTapAction = TapAction.OnTap; */ _cli_changed = false; _dst_changed = false; }
async void OnDestinazioniUnfocused(object sender, Xamarin.Forms.FocusEventArgs e) { if (!_dst_changed) { return; } try { if (_cli != null) { _dst = await _dbcon.GetAsync <Destinazioni>(Convert.ToInt32(m_dst_cod.Text)); if (_dst.dst_cli_for != _cli.cli_codice || _dst.dst_rel != 0) { _dst = null; } } else { _dst = null; } } catch (Exception ex) { _dst = null; Debug.WriteLine(ex.Message); } m_cli_cod.Text = _cli != null?_cli.cli_codice.ToString() : ""; m_cli_des.Text = _cli != null ? _cli.cli_desc : ""; m_dst_cod.Text = _dst != null?_dst.dst_codice.ToString() : ""; m_dst_des.Text = _dst != null ? _dst.dst_desc : ""; var scaList = new List <IncassiInfo>(); dataGrid.IsBusy = true; if (_cli != null) { string sql = ""; if (_dst == null) { sql = String.Format("SELECT sca_id, sca_data, sca_importo, (sca_importo * 0) AS sca_incasso, sca_fattura, sca_tot_fat, sca_desc, sca_locked FROM scadenze WHERE sca_relaz = 0 AND sca_pagato = 0 AND sca_cli_for = {0} ORDER BY sca_data, sca_num", _cli.cli_codice); } else { sql = String.Format("SELECT sca_id, sca_data, sca_importo, (sca_importo * 0) AS sca_incasso, sca_fattura, sca_tot_fat, sca_desc, sca_locked FROM scadenze WHERE sca_relaz = 0 AND sca_pagato = 0 AND sca_cli_for = {0} AND sca_dst = {1} ORDER BY sca_data, sca_num", _cli.cli_codice, _dst.dst_codice); } scaList = await _dbcon.QueryAsync <IncassiInfo>(sql); } var scaCollection = new ObservableCollection <IncassiInfo>(scaList); dataGrid.ItemsSource = scaCollection; dataGrid.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 OnDestinazioniClicked(object sender, System.EventArgs e) { if ((_cli == null) || (_cli.cli_codice == 0)) { return; } var recTotal_ = 0; string sql = "SELECT COUNT(*) FROM destina1 WHERE dst_rel = 0 AND dst_cli_for = " + _cli.cli_codice; recTotal_ = await _dbcon.ExecuteScalarAsync <int>(sql); if (recTotal_ == 0) { await DisplayAlert("Attenzione!", "Non ci sono destinazioni per il Cliente selezionato", "OK"); return; } var page = new DestinazioniSearch(_cli != null ? _cli.cli_codice : 0); page.DstList.ItemDoubleTapped += async(source, args) => { var dst = (Destinazioni)args.ItemData; m_dst_cod.Text = dst.dst_codice.ToString(); m_dst_des.Text = dst.dst_desc; await Navigation.PopAsync(); if ((_dst == null) || (_dst.dst_codice != dst.dst_codice)) { _dst = dst; dataGrid.IsBusy = true; sql = String.Format("SELECT sca_id, sca_data, sca_importo, (sca_importo * 0) AS sca_incasso, sca_fattura, sca_tot_fat, sca_desc, sca_locked FROM scadenze WHERE sca_relaz = 0 AND sca_pagato = 0 AND sca_cli_for = {0} AND sca_dst = {1} ORDER BY sca_data, sca_num", _cli.cli_codice, _dst.dst_codice); var scaList = await _dbcon.QueryAsync <IncassiInfo>(sql); var scaCollection = new ObservableCollection <IncassiInfo>(scaList); dataGrid.ItemsSource = scaCollection; dataGrid.IsBusy = false; } _cli_changed = false; _dst_changed = false; }; await Navigation.PushAsync(page); }
void OnClienteTapped(object sender, System.EventArgs e) { var page = new ClientiSearch(); page.CliList.ItemDoubleTapped += (source, args) => { _cli = (Clienti)args.ItemData; if (_parent.doc.fat_tipo_ven == (short)DocTipoVen.VEN_TRASFERT) { _parent.doc.fat_listino = _cli.cli_listino_tra; } else { _parent.doc.fat_listino = _cli.cli_listino; } _parent.doc.fat_pag = _cli.cli_pag; if (_parent.doc.fat_tipo != (short)DocTipo.TIPO_FAT && _parent.doc.fat_tipo != (short)DocTipo.TIPO_ORD && _parent.doc.fat_tipo != (short)DocTipo.TIPO_PRE && _parent.doc.fat_tipo != (short)DocTipo.TIPO_BUO) { _parent.doc.fat_rag = _cli.cli_ragg; } _parent.doc.fat_spese = _cli.cli_spese; _parent.doc.fat_bolli = _cli.cli_bolli; _parent.doc.fat_iva_cli = _cli.cli_iva; _parent.doc.fat_ban = _cli.cli_ban; if (_dst != null) { if (_dst.dst_cli_for != _cli.cli_codice) { _dst = null; _parent.doc.fat_dest = 0; } } SetField(); Navigation.PopAsync(); }; Navigation.PushAsync(page); }
public async Task <int> PrintDocHeaderAsync(Fatture doc, int row, bool stprice) { Destinazioni dst = null; Agenti age = null; var cli = await dbcon_.GetAsync <Clienti>(doc.fat_inte); if (doc.fat_dest != 0) { dst = await dbcon_.GetAsync <Destinazioni>(doc.fat_dest); } if (doc.fat_age != 0) { age = await dbcon_.GetAsync <Agenti>(doc.fat_age); } int col = 0; int last_hor = 0; string logo = ""; IFolder rootFolder = FileSystem.Current.LocalStorage; string path = rootFolder.Path + "/images/" + "logo.prn"; IFile file = await rootFolder.CreateFileAsync(path, CreationCollisionOption.OpenIfExists); if (file != null) { logo = await file.ReadAllTextAsync(); } string str = "^XA" + // Inizializziamo la stampa "^PW800" + // Settiamo la Larghezza "^MN" + // Settiamo la stampa in continuos mode "^POI" + "^LH0,0"; // Settiamo la posizione Iniziale // Settiamo la lunghezza iniziale del modulo str = str + $"^LL{_mod_len}"; if (logo != "") { str = str + logo; } col = 0; row = 30 * 8; // Scriviamo il Tipo di Documento string num = ""; switch (doc.fat_tipo) { case (int)DocTipo.TIPO_BOL: num = "B O L L A"; break; case (int)DocTipo.TIPO_DDT: num = "DOCUMENTO GENERALE DI TRASPORTO"; break; case (int)DocTipo.TIPO_BUO: num = "B U O N O D I C O N S E G N A"; break; case (int)DocTipo.TIPO_ORD: num = "O R D I N E"; break; default: num = "FATTURA/NOTA CONSEGNA TENTATA VENDITA D.P.R.472/96 art.1 comma 3"; break; } str = str + $"^FO{col},{row}" + "^A0,N,23,23" + $"^FB784,1,0,R,0^FD{num}^FS"; // Disegniamo il box col = 0; row += 3 * 8; last_hor = row; str = str + $"^FO{col},{row}" + "^GB800,388,2^FS"; row += 1 * 8; col = 3; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDNum. Doc.^FS"; col = 16 * 8; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDData^FS"; col = 32 * 8; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDCod.Cli.^FS"; col = 42 * 8; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDCod.Age.^FS"; col = 52 * 8; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDTarga^FS"; col = 73 * 8; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDTelefono^FS"; // Tracciamo le linee Verticali col = 15 * 8; str = str + $"^FO{col},{last_hor}" + $"^GB1,{7 * 8},2^FS"; col = 31 * 8; str = str + $"^FO{col},{last_hor}" + $"^GB1,{7 * 8},2^FS"; col = 41 * 8; str = str + $"^FO{col},{last_hor}" + $"^GB1,{7 * 8},2^FS"; col = 51 * 8; str = str + $"^FO{col},{last_hor}" + $"^GB1,{7 * 8},2^FS"; col = 71 * 8; str = str + $"^FO{col},{last_hor}" + $"^GB1,{7 * 8},2^FS"; row += 3 * 8; col = 1; num = string.Format("{0:#,#}/{1}", RsaUtils.GetShowedNumDoc(doc.fat_n_doc), RsaUtils.GetRegistroFromStoredNumDoc(doc.fat_n_doc)); str = str + $"^FO{col},{row}" + "^A0,N,23,23" + $"^FB{14 * 8},1,0,R,0^FD{num}^FS"; col = 16 * 8; str = str + $"^FO{col},{row}" + "^A0,N,23,23" + $"^FB{14 * 8},1,0,C,0^FD{doc.fat_d_doc:dd/MM/yyy}^FS"; col = 32 * 8; num = string.Format("{0:#}", doc.fat_inte); str = str + $"^FO{col},{row}" + "^A0,N,25,25" + $"^FB{8 * 8},1,0,R,0^FD{num}^FS"; col = 42 * 8; num = string.Format("{0:#}", doc.fat_age); str = str + $"^FO{col},{row}" + "^A0,N,25,25" + $"^FB{8 * 8},1,0,R,0^FD{num}^FS"; col = 52 * 8; if (age != null) { str = str + $"^FO{col},{row}" + "^A0,N,25,25" + $"^FB{18 * 8},1,0,L,0^FD{age.age_targa.Trim()}^FS"; } col = 73 * 8; if (age != null) { str = str + $"^FO{col},{row}" + "^A0,N,25,25" + $"^FD{age.age_targa.Trim()}^FS"; } // Tracciamo la linea orizzontale col = 0; row += 3 * 8; last_hor = row; str = str + $"^FO{col},{row}" + $"^GB800,1,2^FS"; // Intestazione Cliente row += 1 * 8; col = 1 * 8; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDCliente / Cessionario^FS"; col = 80 * 8; str = str + $"^FO{col},{row}" + "^A0,N,23,23" + $"^FB{18 * 8},1,0,R,0^FD{_codcli}^FS"; row += 4 * 8; col = 1 * 8; str = str + $"^FO{col},{row}" + "^A0,N,23,23" + $"^FD{cli.cli_rag_soc1.Trim()}^FS"; row += 3 * 8; str = str + $"^FO{col},{row}" + "^A0,N,23,23" + $"^FD{cli.cli_rag_soc2.Trim()}^FS"; row += 3 * 8; str = str + $"^FO{col},{row}" + "^A0,N,23,23" + $"^FD{cli.cli_indirizzo.Trim()}^FS"; row += 3 * 8; num = string.Format("{0} {1} {2}", cli.cli_cap, cli.cli_citta, cli.cli_prov); str = str + $"^FO{col},{row}" + "^A0,N,23,23" + $"^FD{num.Trim()}^FS"; row += 3 * 8; num = ""; if (!string.IsNullOrWhiteSpace(cli.cli_piva)) { num = $"P.IVA {cli.cli_piva}"; } num = num + " "; if (!string.IsNullOrWhiteSpace(cli.cli_codfis)) { num = num + $"Cod. Fiscale {cli.cli_codfis}"; } str = str + $"^FO{col},{row}" + "^A0,N,23,23" + $"^FD{num.Trim()}^FS"; // Tracciamo la linea orizzontale col = 0; row += 3 * 8; last_hor = row; str = str + $"^FO{col},{row}" + $"^GB800,1,2^FS"; // Intestazione Destinazione row += 1 * 8; col = 1 * 8; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDDestinatario e Luogo di Consegna (se diverso dal cessionario) ^FS"; col = 80 * 8; str = str + $"^FO{col},{row}" + "^A0,N,23,23" + $"^FB{18 * 8},1,0,R,0^FD{_coddst}^FS"; col = 1 * 8; row += 4 * 8; if (dst != null) { str = str + $"^FO{col},{row}" + "^A0,N,25,25" + $"^FD{dst.dst_rag_soc1.Trim()}^FS"; } row += 3 * 8; if (dst != null) { str = str + $"^FO{col},{row}" + "^A0,N,25,25" + $"^FD{dst.dst_rag_soc2.Trim()}^FS"; } row += 3 * 8; if (dst != null) { str = str + $"^FO{col},{row}" + "^A0,N,25,25" + $"^FD{dst.dst_indirizzo.Trim()}^FS"; } row += 3 * 8; if (dst != null) { num = string.Format("{0} {1} {2}", dst.dst_cap, dst.dst_citta, dst.dst_prov); str = str + $"^FO{col},{row}" + "^A0,N,25,25" + $"^FD{num.Trim()}^FS"; } // Tracciamo la linea orizzontale col = 0; row += 3 * 8; last_hor = row; str = str + $"^FO{col},{row}" + $"^GB800,1,2^FS"; col = 1 * 8; row += 1 * 8; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDCodice^FS"; col = 15 * 8; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDDescrizione^FS"; if (stprice) { col = 30 * 8; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDU.M.^FS"; col = 43 * 8; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDQuantita'^FS"; col = 58 * 8; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDPrezzo^FS"; col = 70 * 8; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDSconti^FS"; col = 83 * 8; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDTotale^FS"; col = 92 * 8; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDCod.Iva^FS"; } else { col = 77 * 8; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDU.M.^FS"; col = 92 * 8; str = str + $"^FO{col},{row}" + "^A0,N,19,19" + "^FDQuantita'^FS"; } //str = str + "^XZ"; var t = new UTF8Encoding().GetBytes(str); _con.Write(t); PostPrintCheckStatus(); row += 3; return(82 * 8); }