public Tb_Comanda getComandaByID(int IdComanda) { Tb_Comanda resultado = new Tb_Comanda(); StringBuilder sql = new StringBuilder(); try { sql.AppendFormat( "Select * from Tb_Comanda " + "where id = {0}", IdComanda); resultado = new RepositoryComanda().Get(sql.ToString()).FirstOrDefault(); } catch (Exception ex) { MessageBox.Show("Erro ao Consultar Comanda:" + ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(resultado); }
public List <Tb_Comanda> getListaComandasAtivas() { List <Tb_Comanda> resultado = new List <Tb_Comanda>(); StringBuilder sql = new StringBuilder(); try { sql.AppendFormat( "Select * from Tb_Comanda " + "where Ativo = 1"); resultado = new RepositoryComanda().Get(sql.ToString()); } catch (Exception ex) { MessageBox.Show("Erro ao Consultar comandas ativas:" + ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(resultado); }
public Resultado Insert(Tb_Comanda comanda) { Resultado resultado = new Resultado(); StringBuilder sql = new StringBuilder(); int var = comanda.Ativo == false ? 0 : 1; try { sql.AppendFormat("INSERT INTO TB_COMANDA " + "VALUES({0},{1})", comanda.Numero, var ); resultado = new RepositoryComanda().Insert(sql.ToString()); } catch (Exception ex) { MessageBox.Show("Erro ao Consultar o estoque:" + ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(resultado); }
public Resultado Update(Tb_Comanda comanda) { Resultado resultado = new Resultado(); StringBuilder sql = new StringBuilder(); if (comanda.DataAbertura <= DateTime.Now.AddYears(-50)) { comanda.DataAbertura = DateTime.Now; } try { sql.AppendFormat("Update Tb_Comanda Set Ativo = {1},DataAbertura = '{2}' " + "Where numero = {0}", comanda.Numero, comanda.Ativo == false ? 0 : 1, comanda.DataAbertura.ToString("yyyy/MM/dd HH:mm")); resultado = new RepositoryComanda().Update(sql.ToString()); } catch (Exception ex) { MessageBox.Show("Erro ao Consultar o estoque:" + ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(resultado); }