private void PreencherLabels() { VendasDTO venda = new VendasDTO(); venda = GeralRN.GetSellingByCode2((string)SessionRN.getInstance().get(Constantes.COD_VENDA)); lbl_pedido.Text = venda.codigo; lbl_date.Text = venda.dataEmissao.ToString("dd/MM/yyyy"); lbl_pagamento.Text = GeralRN.GetPaymentName(venda.tipoPagamento); }
private void btn_ok_Click(object sender, EventArgs e) { VendasDTO venda = new VendasDTO(); VendaProdutoDTO vendaProduto = new VendaProdutoDTO(); int contador = 0; venda.tipoPagamento = chklist.SelectedIndex; venda.total = total; if(GeralRN.InsertSelling(venda)) { while (contador < this.dtgrid_venda.Rows.Count) { vendaProduto.codigo_venda = this.lbl_pedido.Text; vendaProduto.codigo_produto = this.dtgrid_venda.Rows[contador].Cells["code"].Value.ToString(); vendaProduto.quantidade_ites = Convert.ToInt32(this.dtgrid_venda.Rows[contador].Cells["quatde"].Value); vendaProduto.total = Convert.ToDouble(this.dtgrid_venda.Rows[contador].Cells["totall"].Value.ToString().Replace("R$ ", "")); GeralRN.InsertingProductInSelling(vendaProduto); GeralRN.UpdatingProductQuantify(vendaProduto.codigo_produto, vendaProduto.quantidade_ites); contador++; } if(GeralRN.GeneratePdf(this.lbl_pedido.Text, this.chklist.SelectedIndex)) { RecreateSelling(); } } }
public static bool InsertSelling(VendasDTO venda) { try { return VendaDAO.InsertSelling(venda); } catch(Exception e) { throw e; } }
private void btn_finalizar_Click(object sender, EventArgs e) { double valor = 0; VendasDTO venda = new VendasDTO(); VendaProdutoDTO vendaProduto = new VendaProdutoDTO(); int contador = 0; venda.tipoPagamento = cbx_forma.SelectedIndex; Adicionar_Valor troco = new Adicionar_Valor(); DialogResult dr = troco.ShowDialog(this); if(dr.Equals(DialogResult.Cancel)) { if(troco.Clicked().Equals("clicked")) { if (!(string.IsNullOrWhiteSpace(troco.GetText()))) { valor = Convert.ToDouble(troco.GetText()); if (descont > 0) { venda.total = total * descont; SessionRN.getInstance().add(Constantes.TROCO, (Math.Abs(venda.total - valor)).ToString()); if (GeralRN.InsertSelling(venda)) { while (contador < this.dt_produtos.Rows.Count) { vendaProduto.codigo_venda = this.lbl_codigo_venda.Text; vendaProduto.codigo_produto = this.dt_produtos.Rows[contador].Cells["CODIGO"].Value.ToString(); vendaProduto.quantidade_ites = Convert.ToInt32(this.dt_produtos.Rows[contador].Cells["QUANT"].Value); vendaProduto.total = Convert.ToDouble(this.dt_produtos.Rows[contador].Cells["TOTALL"].Value.ToString()); GeralRN.InsertingProductInSelling(vendaProduto); GeralRN.UpdatingProductQuantify(vendaProduto.codigo_produto, vendaProduto.quantidade_ites); contador++; } if (GeralRN.GeneratePdf(this.lbl_codigo_venda.Text, this.cbx_forma.SelectedIndex)) { } } } else { venda.total = total; if (GeralRN.InsertSelling(venda)) { while (contador < this.dt_produtos.Rows.Count) { vendaProduto.codigo_venda = this.lbl_codigo_venda.Text; vendaProduto.codigo_produto = this.dt_produtos.Rows[contador].Cells["ITEM"].Value.ToString(); vendaProduto.quantidade_ites = Convert.ToInt32(this.dt_produtos.Rows[contador].Cells["QUANT"].Value); vendaProduto.total = Convert.ToDouble(this.dt_produtos.Rows[contador].Cells["TOTALL"].Value.ToString()); GeralRN.InsertingProductInSelling(vendaProduto); GeralRN.UpdatingProductQuantify(vendaProduto.codigo_produto, vendaProduto.quantidade_ites); contador++; } if (GeralRN.GeneratePdf(this.lbl_codigo_venda.Text, this.cbx_forma.SelectedIndex)) { RecreateSelling(); } } } } else { } } else { if (descont > 0) { venda.total = total * descont; if (GeralRN.InsertSelling(venda)) { while (contador < this.dt_produtos.Rows.Count) { vendaProduto.codigo_venda = this.lbl_codigo_venda.Text; vendaProduto.codigo_produto = this.dt_produtos.Rows[contador].Cells["CODIGO"].Value.ToString(); vendaProduto.quantidade_ites = Convert.ToInt32(this.dt_produtos.Rows[contador].Cells["QUANT"].Value); vendaProduto.total = Convert.ToDouble(this.dt_produtos.Rows[contador].Cells["TOTALL"].Value.ToString()); GeralRN.InsertingProductInSelling(vendaProduto); GeralRN.UpdatingProductQuantify(vendaProduto.codigo_produto, vendaProduto.quantidade_ites); contador++; } if (GeralRN.GeneratePdf(this.lbl_codigo_venda.Text, this.cbx_forma.SelectedIndex)) { RecreateSelling(); } } } else { venda.total = total; if (GeralRN.InsertSelling(venda)) { while (contador < this.dt_produtos.Rows.Count) { vendaProduto.codigo_venda = this.lbl_codigo_venda.Text; vendaProduto.codigo_produto = this.dt_produtos.Rows[contador].Cells["ITEM"].Value.ToString(); vendaProduto.quantidade_ites = Convert.ToInt32(this.dt_produtos.Rows[contador].Cells["QUANT"].Value); vendaProduto.total = Convert.ToDouble(this.dt_produtos.Rows[contador].Cells["TOTALL"].Value.ToString()); GeralRN.InsertingProductInSelling(vendaProduto); GeralRN.UpdatingProductQuantify(vendaProduto.codigo_produto, vendaProduto.quantidade_ites); contador++; } if (GeralRN.GeneratePdf(this.lbl_codigo_venda.Text, this.cbx_forma.SelectedIndex)) { RecreateSelling(); } } } } } }
public static bool InsertSelling(VendasDTO venda) { StringBuilder SQL = new StringBuilder(); SQL.Append(@"INSERT INTO Vendas (codigo,dataEmissao, valorTotal, pagamento_id) VALUES (NEXT VALUE FOR dbo.Sequence_Vendas,CONVERT (date,GETDATE()), @VALORTOTAL, @PAGAMENTO_ID)"); try { using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Mendes_Varejo"].ConnectionString)) { connection.Open(); SqlCommand command = new SqlCommand(SQL.ToString(), connection); command.Parameters.AddWithValue("@VALORTOTAL", venda.total); command.Parameters.AddWithValue("@PAGAMENTO_ID", venda.tipoPagamento); command.ExecuteNonQuery(); command.Dispose(); } return true; } catch (Exception e) { throw e; } }
public static VendasDTO GetSellingByCode2(string codigo) { VendasDTO venda = new VendasDTO(); StringBuilder SQL = new StringBuilder(); SQL.Append(@" SELECT codigo, dataEmissao, pagamento_id, valorTotal FROM Vendas "); SQL.Append(@" WHERE codigo = @CODIGO"); try { using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Mendes_varejo"].ConnectionString)) { connection.Open(); SqlCommand command = new SqlCommand(SQL.ToString(), connection); command.Parameters.AddWithValue("@CODIGO", codigo); using (SqlDataReader dr = command.ExecuteReader()) { while (dr.Read()) { venda.codigo = dr["codigo"].ToString(); venda.dataEmissao = Convert.ToDateTime(dr["dataEmissao"]); venda.tipoPagamento = Convert.ToInt32(dr["pagamento_id"]); venda.total = Convert.ToDouble(dr["valorTotal"]); } } } return venda; } catch (Exception e) { throw e; } }