Exemple #1
0
 public logged(utente u)
 {
     this.loggato              = u;
     this.tipi_spesa           = tipo_spesa.al.load_tipi_spesa(u);
     this.eventi               = evento.al.eventi(u);
     this.cats_spesa_for_combo = cat_spesa.al.load_cat_spesa(u, true);
 }
Exemple #2
0
        public void login(elements.utente u)
        {
            try {
                set_status("CARICAMENTO DATI UTENTE...");

                logged.login(u);
                foreach (base_view f in base_view.viste.Where(x => x.tipo != base_view.type_view.login))
                {
                    f.init_controls();
                }

                // first_form
                try {
                    if (cfg.exist_app_key("first_form"))
                    {
                        base_view.viste_nomi v = (base_view.viste_nomi)Enum.Parse(typeof(base_view.viste_nomi), cfg.key("first_form"));
                        if (get_view(v).admin_view&& !logged.utente().is_admin)
                        {
                            set_status_err($"Non sei autorizzato alla vista {v}!");
                            show_view(base_view.viste_nomi.home); return;
                        }
                        this.show_view(v);
                    }
                    else
                    {
                        this.show_view(base_view.viste_nomi.home);
                    }
                } catch { this.show_view(base_view.viste_nomi.home); }

                lbl_title.BackColor = pic_main.BackColor = Color.WhiteSmoke;
                lbl_title.ForeColor = logged.utente().is_admin ? Color.Tomato : Color.DodgerBlue;
                set_status();
            } catch (Exception ex) { set_status_err(ex); }
        }
Exemple #3
0
 public scontrino(utente u, DataRow r) : base(u, fld.get_int(r["id_scontrino"]))
 {
     this.cosa   = fld.get_str(r["cosa"]); _qta = fld.get_int_null(r["qta"]);
     this.data   = fld.get_date(r["dt_scontrino"]); this.importo = fld.get_dec(r["importo"]);
     this.tipo   = fld.get_int(r["id_tipo_spesa"]) > 0 ? new tipo_spesa(u, r) : null;
     this.evento = fld.get_int(r["id_evento"]) > 0 ? new evento(u, r) : null;
     this.doppio = fld.get_bool(r["doppio"]);
 }
Exemple #4
0
 public tipo_spesa(utente u, DataRow r) : base(u, fld.get_int_null(r["id_tipo_spesa"]))
 {
   this.title = fld.get_str(r["title_tipo_spesa"]);
   this.note = fld.get_str(r["note_tipo_spesa"]);
   if(r.Table.Columns.Contains("cc_scontrini")) this.cc_scontrini = fld.get_int(r["cc_scontrini"], 0);
   if(r.Table.Columns.Contains("last_scontrino")) this.last_scontrino = fld.get_date_null(r["last_scontrino"]);
   this.cat_spesa = r.Table.Columns.Contains("id_cat_spesa") ? new cat_spesa(u, r) : null;
 }
Exemple #5
0
   public static utente_filtri from_dr(utente u, DataRow dr)
   {
       return(dr == null ? null
 : new utente_filtri(u, fld.get_int(dr["id_utente_filtro"]), fld.get_str(dr["title_filtro"]), fld.get_str(dr["tp_filtro"]))
       {
           top_rows = fld.get_int_null(dr["top_rows"]), last_days = fld.get_int_null(dr["last_days"]), order_ins = fld.get_bool(dr["order_ins"])
       });
   }
Exemple #6
0
   public static List <evento> eventi(utente u)
   {
       return(dal.dt_sql($@"select e.id_evento, e.title_evento, e.note as note_evento, e.dt_da, e.dt_a
   , te.id_tipo_evento, te.title_tipo_evento, te.note as note_tipo_evento
 from eventi e with(nolock)
 join tipi_eventi te with(nolock) on te.id_tipo_evento = e.id_tipo_evento
 where e.id_utente = {u.id} order by dt_da desc")
              .Rows.Cast <DataRow>().Select(r => new evento(u, r)).ToList());
   }
Exemple #7
0
   public static List <cat_spesa> load_cat_spesa(utente u, bool for_combo = false)
   {
       return(dal.dt_sql($@"select id_cat_spesa, title_cat_spesa
  from cats_spesa with(nolock)
  where id_utente = {u.id}
 {(for_combo ? $"union select null as id_cat_spesa, '' as title_cat_spesa" : "")}
 order by 2")
              .Rows.Cast <DataRow>().Select(r => new cat_spesa(u, r)).ToList());
   }
Exemple #8
0
            public static cat_spesa ins_cat_spesa(utente u, string title)
            {
                int id = dal.exec($@"insert into cats_spesa (title_cat_spesa, id_utente)
          values({fld.str_qry(title)}, {u.id})", true);

                return(new cat_spesa(u)
                {
                    id = id, title = title
                });
            }
Exemple #9
0
        public void login(elements.utente u)
        {
            try {
                set_status("CARICAMENTO DATI UTENTE...");

                logged.login(u);

                this.show_view(typeof(vw_home));

                lbl_title.BackColor = pic_main.BackColor = Color.WhiteSmoke;
                lbl_title.ForeColor = logged.utente().is_admin ? Color.Tomato : Color.DodgerBlue;

                set_status();
            } catch (Exception ex) { set_status_err(ex); }
        }
Exemple #10
0
  public static List <scontrino> load_scontrini(utente u, utente_filtri vs = null, tipo_spesa tp = null, bool last_ins = false)
  {
      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, ts.title_tipo_spesa, ts.note as note_tipo_spesa
  , e.id_evento, e.title_evento, e.dt_da, e.dt_a, e.note as note_evento
  , te.id_tipo_evento, te.title_tipo_evento, te.note as note_tipo_evento
  , (select top 1 1 from scontrini 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 scontrini s with(nolock)
 join tipi_spesa ts with(nolock) on ts.id_tipo_spesa = s.id_tipo_spesa
 left join eventi e with(nolock) on e.id_evento = s.id_evento
 left join tipi_eventi te with(nolock) on te.id_tipo_evento = e.id_tipo_evento
 where s.id_utente = {u.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.order_ins ? "s.dt_ins desc" : "s.dt_scontrino desc") : "s.dt_ins desc")}").Rows.Cast <DataRow>().Select(r => new scontrino(u, r)).ToList());
  }
Exemple #11
0
      public static List<tipo_spesa> load_tipi_spesa(utente u, int? id_cat = null, bool for_combo = false, string order_by = "cc_scontrini desc")
      {
        return dal.dt_sql($@"select t.*
         from (
	        select ts.id_tipo_spesa, ts.title_tipo_spesa, ts.note as note_tipo_spesa, s.last_scontrino, s.cc_scontrini, 1 as ordine
            , cs.id_cat_spesa, cs.title_cat_spesa
	         from tipi_spesa ts with(nolock)
           left join cats_spesa cs with(nolock) on cs.id_cat_spesa = ts.id_cat_spesa
	         left join (
	          select id_tipo_spesa, max(dt_ins) as last_scontrino, count(*) as cc_scontrini
	          from scontrini with(nolock) where id_utente = {u.id} group by id_tipo_spesa
	         ) as s on s.id_tipo_spesa = ts.id_tipo_spesa
	         where ts.id_utente = {u.id}
          {(for_combo ? $@"union select null as tipo_spesa, 'Tutti' as title_tipo_spesa, null as note
              , null as last_scontrino, null as cc_scontrini, 0 as ordine, null as id_cat_spesa, null as title_cat_spesa" : "")}
        ) t where 1 = 1 {(id_cat.HasValue ? $" and id_cat_spesa = {id_cat.Value}" : "")}
        order by t.ordine {(order_by != "" ? $", {string.Join(",", order_by.Split(new char[] { ',' }).Select(x => $"t.{x}"))}" : "")}")
        .Rows.Cast<DataRow>().Select(r => new tipo_spesa(u, r)).ToList();
      }
Exemple #12
0
 public static void active(utente u)
 {
     mwl.dal.exec($@"update utenti set dt_activate = getdate(), active_key = null where id_utente = {u.id}");
 }
Exemple #13
0
 public tipo_evento(utente u, DataRow r) : base(u, fld.get_int(r["id_tipo_evento"]))
 {
     this.title = fld.get_str(r["title_tipo_evento"]); this.note = fld.get_str(r["note_tipo_evento"]);
 }
Exemple #14
0
 public tipo_evento(utente u, int id, string title, string note)
     : base(u, id)
 {
     this.title = title; this.note = note;
 }
Exemple #15
0
 public static void change_tipo(utente u, int id_spesa, int to_id_spesa)
 {
     dal.exec($@"update scontrini set id_tipo_spesa = {to_id_spesa} where id_utente = {u.id} and id_tipo_spesa = {id_spesa}");
 }
Exemple #16
0
 public evento(utente u, DataRow r) : base(u, fld.get_int(r["id_evento"]))
 {
     this.title = fld.get_str(r["title_evento"]); this.note = fld.get_str(r["note_evento"]);
     this.da    = fld.get_date(r["dt_da"]); this.a = fld.get_date(r["dt_a"]);
     this.tipo  = new tipo_evento(u, r);
 }
Exemple #17
0
 public utente_filtri(utente u, int id, string title, string tp_filtro)
 {
     this.id = id; this.utente = u; this.title = title;
 }
Exemple #18
0
 public static bool there_tipo_spesa(utente u, string title, int? exclude_id = null)
 {
   return dal.first_int($@"select top 1 1 from tipi_spesa 
     where id_utente = {u.id} and title_tipo_spesa = {fld.str_qry(title)} 
       {(exclude_id.HasValue ? $" and id_tipo_spesa <> {exclude_id}" : "")}") > 0;
 }
Exemple #19
0
 public base_element(utente u)
 {
     this.utente = u;
 }
Exemple #20
0
 public tipo_spesa(utente u) : base(u) { }
Exemple #21
0
 public static void login(utente u)
 {
     _logged = new logged(u);
 }
Exemple #22
0
 public cat_spesa(utente u) : base(u)
 {
 }
Exemple #23
0
 public scontrino(utente u) : base(u)
 {
 }
Exemple #24
0
 public cat_spesa(utente u, DataRow r) : base(u, fld.get_int_null(r["id_cat_spesa"]))
 {
     this.title = fld.get_str(r["title_cat_spesa"]);
 }
Exemple #25
0
 public evento(utente u, int id, string title, DateTime da, DateTime a, string note, tipo_evento tipo = null)
     : base(u, id)
 {
     this.title = title; this.da = da; this.a = a; this.note = note; this.tipo = tipo;
 }
Exemple #26
0
 public base_element(utente u, int?id)
 {
     this.utente = u; this.id = id;
 }
Exemple #27
0
    public static List <utente_filtri> load(utente u, string tp_filtro)
    {
        return(dal.dt_sql($@"select vs.id_utente_filtro, vs.title_filtro, vs.tp_filtro, vs.top_rows, vs.last_days, vs.order_ins
 from utente_filtri vs with(nolock) where vs.id_utente = {u.id} and vs.tp_filtro = {fld.str_qry(tp_filtro)}
 order by vs.ordine").Rows.Cast <DataRow>().Select(r => from_dr(u, r)).ToList());
    }
Exemple #28
0
 public static scontrino last_ins_scontrino(utente u)
 {
     List <scontrino> l = load_scontrini(u, last_ins: true); return(l.Count > 0 ? l[0] : null);
 }