Example #1
0
 public static void save(tipo_spesa s)
 {
   if(!s.id.HasValue)
     s.id = dal.exec($@"insert into tipo_spesa (title, note, id_utente, id_cat_spesa)
       values ({fld.str_qry(s.title)}, {fld.str_qry(s.note)}, {s.utente.id}, {(s.id_cat_spesa.HasValue ? s.id_cat_spesa.Value.ToString() : "null")})", true);
   else
     dal.exec($@"update tipo_spesa set title = {fld.str_qry(s.title)}, note = {fld.str_qry(s.note)}
         , id_cat_spesa = {(s.id_cat_spesa.HasValue ? s.id_cat_spesa.Value.ToString() : "null")}        
       where id_tipo_spesa = {s.id}");
 }
Example #2
0
 public static tipo_spesa from_dr(utente u, DataRow r, string prfx_flds = "", string prfx_flds_cat_spesa = "")
 {
   tipo_spesa res = new tipo_spesa(u, fld.get_int_null(r[$"{prfx_flds}id_tipo_spesa"]));
   res.title = fld.get_str(r[$"{prfx_flds}title"]);
   res.note = fld.get_str(r[$"{prfx_flds}note"]);
   if(r.Table.Columns.Contains($"{prfx_flds}cc_scontrini")) res.cc_scontrini = fld.get_int(r[$"{prfx_flds}cc_scontrini"], 0);
   if(r.Table.Columns.Contains($"{prfx_flds}last_scontrino")) res.last_scontrino = fld.get_date_null(r[$"{prfx_flds}last_scontrino"]);
   res.cat_spesa = r.Table.Columns.Contains($"{prfx_flds_cat_spesa}id_cat_spesa") ?
     new cat_spesa(u, fld.get_int_null(r[$"{prfx_flds_cat_spesa}id_cat_spesa"]), fld.get_str(r[$"{prfx_flds_cat_spesa}title"])) : null;
   return res;
 }
Example #3
0
  public static List <scontrino> scontrini(utente u, view_filter vs = null, tipo_spesa tp = null, bool last_ins = false, int?id = null)
  {
      return(dal.dt_sql($@"select {(last_ins ? "top 1" : "")} {(vs != null && vs.top_rows.HasValue ? $"top {vs.top_rows}" : "")} 
 s.id_scontrino, s.cosa, s.qta, s.dt_scontrino, s.importo
  , ts.id_tipo_spesa as ts_id_tipo_spesa, ts.title as ts_title, ts.note as ts_note
  , e.id_evento as ev_id_evento, e.title as ev_title, e.dt_da as ev_dt_da, e.dt_a as ev_dt_a, e.note as ev_note
  , te.id_tipo_evento as te_id_tipo_evento, te.title as te_title, te.note as te_note
  , (select top 1 1 from scontrino with(nolock) where id_scontrino <> s.id_scontrino and dt_scontrino = s.dt_scontrino
      and id_tipo_spesa = s.id_tipo_spesa and importo = s.importo and id_utente = s.id_utente) as doppio
 from scontrino s with(nolock)
 join tipo_spesa ts with(nolock) on ts.id_tipo_spesa = s.id_tipo_spesa
 left join evento e with(nolock) on e.id_evento = s.id_evento
 left join tipo_evento te with(nolock) on te.id_tipo_evento = e.id_tipo_evento
 where s.id_utente = {u.id} {(id.HasValue ? $" and s.id_scontrino = {id}" : "")} 
  {(vs != null && vs.last_days.HasValue ? $" and datediff(day, dt_scontrino, getdate()) <= {vs.last_days}" : "")}
  {(tp != null && tp.id.HasValue ? $" and ts.id_tipo_spesa = {tp.id}" : "")}
 order by {(!last_ins ? (vs != null && vs.has_order_by ? vs.get_order_by("s") : "s.dt_scontrino desc") : "s.dt_ins desc")}")
             .Rows.Cast <DataRow>().Select(r => dl.from_dr(u, r, "ts_", "", "ev_", "te_")).ToList());
  }