public void AlterarStatus(PedidoLer p, string status) { try { using (SqlConnection conexao = new SqlConnection()) { conexao.ConnectionString = strConexao; conexao.Open(); using (SqlCommand comando = new SqlCommand()) { string strSql = "update dbo.Pedido set status=@status where id=@id"; comando.CommandText = strSql; comando.Connection = conexao; comando.Parameters.AddWithValue("@status", status); comando.Parameters.AddWithValue("@id", p.Id); comando.ExecuteNonQuery(); } } MessageBox.Show("Status Alterado com Sucesso"); } catch (Exception ex) { throw ex; } }
public void preencherInfo(Cliente c, PedidoLer pLer) { rtxtCliente.Text = c.Nome + "\t" + c.Telefone; rTxtBoxPedidos.Text = pLer.Descricao + "\n Total: " + pLer.Total; cbstatus.Text = pLer.Status; peLer = pLer; cli = c; }
private void button3_Click(object sender, EventArgs e) { string data = DateTime.Now.ToString("M/d/yyyy"); PedidoLer pLer = pDAO.ConsultarPedido(c, data); VerPedido vP = new VerPedido(); vP.preencherInfo(c, pLer); vP.ShowDialog(); }
public PedidoLer ConsultarPedido(Cliente c, string data) { try { List <PedidoLer> lstPler = new List <PedidoLer>(); PedidoLer pLer = new PedidoLer(); using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = strConexao; conn.Open(); using (SqlCommand comando = new SqlCommand()) { string query = "Select id,status, descricao, data, cli_nome, cli_tel, total from dbo.Pedido where data=@data and cli_tel=@cli_tel"; comando.CommandText = query; comando.Connection = conn; comando.Parameters.AddWithValue("@data", data); comando.Parameters.AddWithValue("@cli_tel", c.Telefone); SqlDataReader read = comando.ExecuteReader(); while (read.Read()) { pLer.Id = Convert.ToInt32(read["id"]); pLer.Descricao = read["descricao"].ToString(); pLer.Total = float.Parse(read["total"].ToString()); pLer.Status = read["status"].ToString(); } } } return(pLer); } catch (Exception ex) { throw ex; } }