async void OnAddClicked(object sender, System.EventArgs e) { var app = (App)Application.Current; LocalImpo lim = null; // // Leggiamo le impostazioni // try { lim = await dbcon_.GetAsync <LocalImpo>(1); } catch { await DisplayAlert("Attenzione!", "Impostazioni locali non trovate!\nRiavviare l'App.", "OK"); return; } if (lim.dep == 0) { await DisplayAlert("Attenzione!", "Deposito non impostato!\nEffettuare le impostazioni iniziali.", "OK"); return; } try { var rig = new FatRow(); rig.rig_tipo = _parent.doc.fat_tipo; rig.rig_n_doc = _parent.doc.fat_n_doc; rig.rig_dep = lim.dep; if (app.facile_db_impo != null) { rig.rig_iva_inclusa = app.facile_db_impo.dit_iva_inc; } rig.rig_coef_mol = 1; rig.rig_coef_mol2 = 1; var page = new DocumentRow(this, ref rig, -1, _parent.doc.fat_editable); await Navigation.PushModalAsync(page); } catch (Exception ex) { await DisplayAlert("Attenzione", "Errore : " + ex.Message, "OK"); } }
public DocumentRow(DocumentiBody par, ref FatRow rig, int index = -1, bool editable = true) { par_ = par; rig_ = rig; change_ = false; first_ = true; index_ = index; editable_ = editable; InitializeComponent(); //var culture = new CultureInfo("en-US"); //m_quantita.Culture = culture; //m_prezzo.Culture = culture; //m_sco1.Culture = culture; //m_sco2.Culture = culture; //m_sco3.Culture = culture; //m_totale.Culture = culture; // // Rimuoviamo le righe per i lotti se non gestiti // if (!((App)Application.Current).facile_db_impo.dit_usa_lotti) { int x = 0; foreach (var row in m_grid.RowDefinitions) { if (x == 9 || x == 10) { row.Height = 0; } x++; } } NavigationPage.SetHasNavigationBar(this, false); dbcon_ = DependencyService.Get <ISQLiteDb>().GetConnection(); m_image.Source = null; if (Device.RuntimePlatform == Device.iOS) { Padding = new Thickness(0, 30, 0, 0); } if (Device.Idiom == TargetIdiom.Tablet) { if (((App)Application.Current).facile_db_impo.dit_usa_lotti) { m_image_box.HeightRequest = 350; } else { m_image_box.HeightRequest = 500; } } if (index_ == -1) { m_elimina.IsEnabled = false; m_elimina.IsVisible = false; } if (!editable_) { m_art.IsEnabled = false; m_search.IsEnabled = false; m_salva.IsEnabled = false; m_elimina.IsEnabled = false; m_salva.IsVisible = false; m_elimina.IsVisible = false; m_quantita.IsEnabled = false; m_prezzo.IsEnabled = false; m_sco1.IsEnabled = false; m_sco2.IsEnabled = false; m_sco3.IsEnabled = false; m_sostituzione.IsEnabled = false; m_qta_down.IsEnabled = false; m_qta_up.IsEnabled = false; m_prezzo_down.IsEnabled = false; m_prezzo_up.IsEnabled = false; m_sco1_down.IsEnabled = false; m_sco1_up.IsEnabled = false; m_sco2_down.IsEnabled = false; m_sco2_up.IsEnabled = false; m_sco3_down.IsEnabled = false; m_sco3_up.IsEnabled = false; m_search_lotto.IsEnabled = false; } if (Device.RuntimePlatform == Device.Android) { m_esci.IsEnabled = false; m_esci.IsVisible = false; } m_quantita.Culture = new CultureInfo("it-IT"); m_prezzo.Culture = new CultureInfo("it-IT"); m_sco1.Culture = new CultureInfo("it-IT"); m_sco2.Culture = new CultureInfo("it-IT"); m_sco3.Culture = new CultureInfo("it-IT"); m_totale.Culture = new CultureInfo("it-IT"); SetField(); }
public async static Task <double> RecalcAsync(this FatRow rig) { if (rig.rig_tara_recalc == true || !rig.rig_tara_altre.TestIfZero(3) || !rig.rig_tara_imballo.TestIfZero(3)) { rig.rig_tara = rig.rig_tara_altre + rig.rig_colli * rig.rig_tara_imballo; } double sco1 = Math.Round((rig.rig_prezzo) * (rig.rig_sconto1 / 100.0), (int)DecPlaces.MAX_DECIMAL_PLACES, MidpointRounding.AwayFromZero); double sco2 = Math.Round(((rig.rig_prezzo - sco1) * (rig.rig_sconto2 / 100.0)), (int)DecPlaces.MAX_DECIMAL_PLACES, MidpointRounding.AwayFromZero); double sco3 = Math.Round(((rig.rig_prezzo - sco1 - sco2) * (rig.rig_sconto3 / 100.0)), (int)DecPlaces.MAX_DECIMAL_PLACES, MidpointRounding.AwayFromZero); double sco4 = Math.Round(((rig.rig_prezzo - sco1 - sco2 - sco3) * (rig.rig_sconto4 / 100.0)), (int)DecPlaces.MAX_DECIMAL_PLACES, MidpointRounding.AwayFromZero); double sco5 = Math.Round(((rig.rig_prezzo - sco1 - sco2 - sco3 - sco4) * (rig.rig_sconto5 / 100.0)), (int)DecPlaces.MAX_DECIMAL_PLACES, MidpointRounding.AwayFromZero); double sco6 = Math.Round(((rig.rig_prezzo - sco1 - sco2 - sco3 - sco4 - sco5) * (rig.rig_sconto6 / 100.0)), (int)DecPlaces.MAX_DECIMAL_PLACES, MidpointRounding.AwayFromZero); double sco7 = Math.Round(((rig.rig_prezzo - sco1 - sco2 - sco3 - sco4 - sco5 - sco6) * (rig.rig_sconto7 / 100.0)), (int)DecPlaces.MAX_DECIMAL_PLACES, MidpointRounding.AwayFromZero); rig.rig_tot_peso = rig.rig_qta * rig.rig_coef_mol * rig.rig_coef_mol2 * rig.rig_peso; rig.rig_tot_sconto = (rig.rig_qta - rig.rig_tara) * rig.rig_coef_mol * rig.rig_coef_mol2 * (sco1 + sco2 + sco3 + sco4 + sco5 + sco6 + sco7); rig.rig_tot_sconto += rig.rig_scovalore; rig.rig_tot_sconto += rig.rig_scomerce * rig.rig_coef_mol * rig.rig_coef_mol2 * (sco1 + sco2 + sco3 + sco4 + sco5 + sco6 + sco7); rig.rig_tot_sconto = Math.Round(rig.rig_tot_sconto, (int)DecPlaces.TOT_DECIMAL_PLACES, MidpointRounding.AwayFromZero); double totale = Math.Round(rig.rig_prezzo - sco1 - sco2 - sco3 - sco4 - sco5 - sco6 - sco7, (int)DecPlaces.MAX_DECIMAL_PLACES, MidpointRounding.AwayFromZero); rig.rig_importo = Math.Round((rig.rig_qta - rig.rig_tara - rig.rig_scomerce) * rig.rig_coef_mol * rig.rig_coef_mol2 * (totale + rig.rig_spese) - rig.rig_scovalore, (int)DecPlaces.TOT_DECIMAL_PLACES, MidpointRounding.AwayFromZero); // // Codice Aggiunto per il calcolo dello sconto iva esclusa 24/03/2009 // rig.rig_sco_iva_esc = 0; rig.rig_importo_impo = rig.rig_importo; if (rig.rig_iva_inclusa != 0 && rig.rig_iva != 0) { try { SQLiteAsyncConnection dbcon = DependencyService.Get <ISQLiteDb>().GetConnection(); var iva = await dbcon.GetAsync <Codiva>(rig.rig_iva); rig.rig_importo_impo = Math.Round(rig.rig_importo_impo / (1 + (iva.iva_aliq / 100.0)), (int)DecPlaces.TOT_DECIMAL_PLACES, MidpointRounding.AwayFromZero); } catch { throw new RsaException(RsaException.NotFoundMsg, RsaException.NotFoundErr); } } totale = Math.Round((rig.rig_qta - rig.rig_tara - rig.rig_scomerce) * rig.rig_coef_mol * rig.rig_coef_mol2 * (rig.rig_prezzo + rig.rig_spese) - rig.rig_scovalore, (int)DecPlaces.TOT_DECIMAL_PLACES, MidpointRounding.AwayFromZero); if (totale.TestIfZero(4) != true) { rig.rig_sco_iva_esc = (float)(100 - (rig.rig_importo_impo / totale) * 100); } // Fine Codice Aggiunto // Torniamo il prezzo unitario if (rig.rig_qta.TestIfZero(3) != true) { return(Math.Round(rig.rig_importo / rig.rig_qta, (int)DecPlaces.TOT_DECIMAL_PLACES, MidpointRounding.AwayFromZero)); } else { return(totale); } }