static TxMoneySrc getCreateTxMoneySrc(A0DbContext db, out string acntDir, string acntId, string filename) { var ad = acntDir = PreSet.GetAcntFolder((acntId ?? "AcntUnknown").Replace(PreSet.AcntIdTAg, "").Trim()); var txMoneySrcs = db.TxMoneySrcs.FirstOrDefault(r => string.Compare(ad, r.Fla, true) == 0); if (txMoneySrcs == null) { txMoneySrcs = db.TxMoneySrcs.Add(new TxMoneySrc { CreatedAt = _batchTimeNow, Fla = acntDir, Name = acntDir, Notes = $"Auto created from '{filename}'" }); db.SaveChanges(); new System.Speech.Synthesis.SpeechSynthesizer().Speak($"New account {acntDir} created from the file {filename}."); } if (txMoneySrcs == null) { //todo: new System.Speech.Synthesis.SpeechSynthesizer().SpeakAsync($"Unable to establich source account. Exiting"); if (Debugger.IsAttached) { Debugger.Break(); } else { throw new NullReferenceException($"Unable to establich source account. Exiting"); } } return(txMoneySrcs); }
public PreSet Buscar(int id) { try { PreSet retorno = null; DBSession session = new DBSession(); Query quey = session.CreateQuery("SELECT * FROM PreSet WHERE PreSet_id = @id"); quey.SetParameter("id", id); IDataReader reader = quey.ExecuteQuery(); if (reader.Read()) { retorno = new PreSet(Convert.ToInt32(reader["PreSet_id"]), new Painel(Convert.ToInt32(reader["painel"])), Convert.ToDateTime(reader["data"]), Convert.ToBoolean(reader["ativo"]), Convert.ToString(reader["titulo"])); } reader.Close(); session.Close(); return(retorno); } catch (Exception error) { throw error; } }
public void Excluir(PreSet variavel) { try { DBSession session = new DBSession(); Query query = session.CreateQuery("DELETE FROM PreSet WHERE preset_id = @preset_id; DELETE FROM PreSet_acionador WHERE preset_id = @preset_id; DELETE FROM PreSet_subtarefa WHERE preset_subtarefa_id IN (SELECT preset_tarefa_id FROM diagweb.preset_tarefa WHERE preset_id = @preset_id); DELETE FROM PreSet_tarefa WHERE preset_id = @preset_id"); query.SetParameter("preset_id", variavel.preset_id); query.ExecuteUpdate(); session.Close(); } catch (Exception erro) { throw erro; } }
public void Salvar(PreSet variavel) { try { DBSession session = new DBSession(); Query query = session.CreateQuery("INSERT INTO PreSet (data, painel, ativo, titulo) VALUES (@data, @painel, @ativo, @titulo) "); query.SetParameter("data", variavel.data) .SetParameter("painel", variavel.painel.codigo) .SetParameter("ativo", variavel.ativo) .SetParameter("titulo", variavel.titulo); query.ExecuteUpdate(); session.Close(); } catch (Exception erro) { throw erro; } }
public void Alterar(PreSet variavel) { try { DBSession session = new DBSession(); Query query = session.CreateQuery("UPDATE PreSet SET data = @data, painel = @painel, ativo = @ativo, titulo = @titulo WHERE preset_id = @preset_id"); query.SetParameter("data", variavel.data) .SetParameter("painel", variavel.painel.codigo) .SetParameter("ativo", variavel.ativo) .SetParameter("titulo", variavel.titulo) .SetParameter("preset_id", variavel.preset_id); query.ExecuteUpdate(); session.Close(); } catch (Exception erro) { throw erro; } }
public int Salvar(PreSet preset, string tabela, bool inclusao, bool alteracao, string alteracao_campo, string alteracao_campo_valor) { try { DBSession session = new DBSession(); Query query = session.CreateQuery("INSERT INTO PreSet_acionador (preset_id, tabela, inclusao, alteracao, alteracao_campo, alteracao_campo_valor) VALUES (@preset_id, @tabela, @inclusao, @alteracao, @alteracao_campo, @alteracao_campo_valor) "); query.SetParameter("preset_id", preset.preset_id) .SetParameter("tabela", tabela) .SetParameter("inclusao", inclusao) .SetParameter("alteracao", alteracao) .SetParameter("alteracao_campo", alteracao_campo) .SetParameter("alteracao_campo_valor", alteracao_campo_valor); query.ExecuteUpdate(); session.Close(); int retorno = 0; session = new DBSession(); query = session.CreateQuery("SELECT PreSet_acionador_id FROM PreSet_acionador WHERE preset_id = @preset_id AND tabela = @tabela AND inclusao = @inclusao AND alteracao = @alteracao AND alteracao_campo = @alteracao_campo AND alteracao_campo_valor = @alteracao_campo_valor ORDER BY PreSet_acionador_id DESC"); query.SetParameter("preset_id", preset.preset_id) .SetParameter("tabela", tabela) .SetParameter("inclusao", inclusao) .SetParameter("alteracao", alteracao) .SetParameter("alteracao_campo", alteracao_campo) .SetParameter("alteracao_campo_valor", alteracao_campo_valor); IDataReader reader = query.ExecuteQuery(); if (reader.Read()) { retorno = Convert.ToInt32(reader["PreSet_acionador_id"]); } reader.Close(); session.Close(); return(retorno); } catch (Exception erro) { throw erro; } }
public int Salvar(PreSet preset, Grupo_tarefas grupo_tarefas, string texto, int prazo) { try { DBSession session = new DBSession(); Query query = session.CreateQuery("INSERT INTO PreSet_tarefa (preset_id, grupo_tarefas_id, texto, prazo) VALUES (@preset_id, @grupo_tarefas_id, @texto, @prazo) "); query.SetParameter("preset_id", preset.preset_id) .SetParameter("grupo_tarefas_id", grupo_tarefas.grupo_tarefas_id) .SetParameter("texto", texto) .SetParameter("prazo", prazo); query.ExecuteUpdate(); session.Close(); int retorno = 0; session = new DBSession(); query = session.CreateQuery("SELECT PreSet_tarefa_id FROM PreSet_tarefa WHERE preset_id = @preset_id AND grupo_tarefas_id = @grupo_tarefas_id AND texto = @texto AND prazo = @prazo ORDER BY PreSet_tarefa_id DESC"); query.SetParameter("preset_id", preset.preset_id) .SetParameter("grupo_tarefas_id", grupo_tarefas.grupo_tarefas_id) .SetParameter("texto", texto) .SetParameter("prazo", prazo); IDataReader reader = query.ExecuteQuery(); if (reader.Read()) { retorno = Convert.ToInt32(reader["PreSet_tarefa_id"]); } reader.Close(); session.Close(); return(retorno); } catch (Exception erro) { throw erro; } }