public void CarregarDadosGrid() { try { BLL.Pedido ped = new BLL.Pedido(); dataGridView1.DataSource = ped.Listar(textBox1.Text.Trim().ToUpper(), 1).Tables[0]; textBox1.Focus(); if (dataGridView1.Rows.Count == 0) { btnEditar.Enabled = false; btnConsultar.Enabled = false; btnDesativar.Enabled = false; btnAtivar.Enabled = false; btnExcluir.Enabled = false; } else { btnEditar.Enabled = true; btnConsultar.Enabled = true; btnDesativar.Enabled = true; btnAtivar.Enabled = true; btnExcluir.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); //throw; } }
private void FinalizarPedido(object o, EventArgs e) { try { BLL.Pedido ped = new BLL.Pedido(); ped.CodigoCliente = Codigo; ped.CodigoFuncionario = CodigoVendedor; ped.DataPedido = DateTime.Today; ped.DataEntrega = DateTime.Today.AddDays(10); foreach (DataGridViewRow row in dataGridView1.Rows.Cast <DataGridViewRow>() .Where(t => !string.IsNullOrEmpty(t.Cells["ValorTot"].Value?.ToString()))) { ValorTotalPedido += Convert.ToDecimal(row.Cells["ValorTot"].Value); } ped.ValorTotalPedido = Convert.ToDecimal(ValorTotalPedido); ped.CodigoDestinatario = CodigoDestinatario; ped.IncluirComParametro(); RegistrarLogSaida(); AtualizarEstoque(); SalvarPagamentoVenda(); BuscarDestinatario(); MessageBox.Show("Pedido finalizado com sucesso"); GerarPDF3(o, e); Close(); } catch (Exception ex) { throw ex; } }
private void SalvarPagamentoVenda() { try { BLL.Pedido ped = new BLL.Pedido(); int CodigoUltimoPedido = ped.RetornarPedido(); if (checkBox1.Checked) { TCC_Inf2Dm.ClasseParaManipularBancoDeDados c = new TCC_Inf2Dm.ClasseParaManipularBancoDeDados(); string comando; SqlParameter[] listaComParametros = { new SqlParameter("@CodigoPedido", SqlDbType.Int) { Value = CodigoUltimoPedido }, new SqlParameter("@CodigoFormaPgto", SqlDbType.Int) { Value = Convert.ToInt32(comboBox1.SelectedValue) }, new SqlParameter("@Valor", SqlDbType.Decimal) { Value = totalVenda / 2 } }; comando = "INSERT INTO tbPgto_Pedido(CodigoPedido,CodigoFormaPgto,ValorForma) Values (@CodigoPedido,@CodigoFormaPgto,@Valor)"; c.ExecutarComandoParametro(comando, listaComParametros); SqlParameter[] listaComParametros2 = { new SqlParameter("@CodigoPedido", SqlDbType.Int) { Value = CodigoUltimoPedido }, new SqlParameter("@CodigoFormaPgto2", SqlDbType.Int) { Value = Convert.ToInt32(comboBox2.SelectedValue) }, new SqlParameter("@Valor", SqlDbType.Decimal) { Value = totalVenda / 2 } }; comando = "INSERT INTO tbPgto_Pedido(CodigoPedido,CodigoFormaPgto,ValorForma) Values (@CodigoVenda,@CodigoFormaPgto2,@Valor)"; c.ExecutarComandoParametro(comando, listaComParametros2); } else { TCC_Inf2Dm.ClasseParaManipularBancoDeDados c = new TCC_Inf2Dm.ClasseParaManipularBancoDeDados(); string comando; SqlParameter[] listaComParametros = { new SqlParameter("@CodigoPedido", SqlDbType.Int) { Value = CodigoUltimoPedido }, new SqlParameter("@CodigoFormaPgto", SqlDbType.Int) { Value = Convert.ToInt32(comboBox1.SelectedValue) }, new SqlParameter("@Valor", SqlDbType.Decimal) { Value = totalVenda } }; comando = "INSERT INTO tbPgto_Pedido(CodigoPedido,CodigoFormaPgto,ValorForma) Values (@CodigoPedido,@CodigoFormaPgto,@Valor)"; c.ExecutarComandoParametro(comando, listaComParametros); } } catch (Exception ex) { MessageBox.Show(ex.Message); throw ex; } }