Пример #1
0
        private void scontrini_KeyDown(object sender, KeyEventArgs e)
        {
            try {
                DataGridView dgv = (DataGridView)sender;
                scontrino    s   = dgv.CurrentCell != null ? (scontrino)dgv.Rows[dgv.CurrentCell.RowIndex].DataBoundItem : null;

                if (e.Alt && e.KeyCode == Keys.A)
                {
                    add_scontrino();
                }
                else if (e.Control && e.KeyCode == Keys.C)
                {
                    if (dgv.CurrentCell.IsInEditMode)
                    {
                        dgv.EndEdit();
                    }
                    remove_scontrino(dgv.CurrentCell.RowIndex);
                }
                else if (e.KeyCode == Keys.Delete)
                {
                    if (!dgv.CurrentCell.IsInEditMode)
                    {
                        dgv.CurrentCell.Value = null;
                        s.save();
                    }
                }
            } catch (Exception ex) { main.set_status_err(ex); }
        }
Пример #2
0
        protected void ok(bool remain = false)
        {
            try {
                if (cmb_tipo.SelectedValue == null)
                {
                    cmb_tipo.Focus(); throw new Exception("Scegli un tipo di scontrino!");
                }
                if (txt_prezzo.Text == "")
                {
                    txt_prezzo.Focus(); throw new Exception("Manca il prezzo!");
                }

                scontrino s = this.new_scontrino ? new scontrino(logged.utente()) : this.scontrino;
                s.id_tipo = (int)cmb_tipo.SelectedValue;
                s.qta     = txt_qta.Text != "" ? Convert.ToInt32(txt_qta.Text) : (int?)null;
                s.prezzo  = fld.money_to_dec(txt_prezzo.Text);
                s.cosa    = txt_cosa.Text;
                s.data    = dt_il.Value;

                if (s.is_doppio())
                {
                    if (!this.main.popup_yn("Scontrino doppio", $"Scontrino Doppio! Vuoi {(this.new_scontrino ? "aggiungerlo" : "aggiornarlo")} lo stesso?!?!"))
                    {
                        return;
                    }
                }

                s.save();

                // view scontrini
                if (this.web_scontrini != null)
                {
                    if (this.new_scontrino)
                    {
                        this.web_scontrini.add_scontrino(s);
                    }
                    else
                    {
                        this.web_scontrini.update_scontrino(s);
                    }
                }

                if (!remain)
                {
                    this.main.back_view();
                }
                else
                {
                    txt_prezzo.Text  = "";
                    txt_qta.Text     = "";
                    txt_importo.Text = "";
                    txt_cosa.Text    = "";
                    cmb_tipo.Focus();
                }
            } catch (Exception ex) { this.main.set_status_err(ex); }
        }
Пример #3
0
 private void scontrini_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     try {
         if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
         {
             DataGridView dgv = (DataGridView)sender;
             scontrino    s   = (scontrino)dgv.Rows[e.RowIndex].DataBoundItem;
             s.save();
             if (dgv.Columns[e.ColumnIndex].Name == "id_tipo")
             {
                 invalidate_tipi_spesa();
             }
             reload_doppio(s.data);
             if (_pre_data.HasValue && s.data.HasValue && _pre_data.Value != s.data.Value)
             {
                 reload_doppio(_pre_data);
             }
             dgv.Refresh();
         }
     } catch (Exception ex) { }
 }