private void button3_Click(object sender, EventArgs e) { try { string qtdCancelada = dgvPedido.CurrentRow.Cells[3].Value.ToString(); txtCancelado.Text = qtdCancelada; string codPro = dgvPedido.CurrentRow.Cells[0].Value.ToString(); txtCodBarra2.Text = codPro; dgvPedido.Rows.Remove(dgvPedido.CurrentRow); decimal total = 0; int i = 0; for (i = 0; i < dgvPedido.Rows.Count; i++) { total = total + Convert.ToDecimal(dgvPedido.Rows[i].Cells["Total"].Value); } txtVtotal.Text = "R$" + (total).ToString(); ProdutoTableAdapter taProduto = new ProdutoTableAdapter(); DataTable dt; dt = taProduto.PesquisaCodBarra(Convert.ToInt64(txtCodBarra2.Text)); txtQuantestoq.Text = dt.Rows[0]["Quantidade_Produto"].ToString(); int voltestoq = Convert.ToInt32(txtQuantestoq.Text) + Convert.ToInt32(txtCancelado.Text); taProduto.RetornarEstoque(voltestoq, Convert.ToInt64(txtCodBarra2.Text)); CultureInfo ci = new CultureInfo("pt-BR"); decimal valorTotal = 0; foreach (DataGridViewRow col in dgvPedido.Rows) { valorTotal = valorTotal + Convert.ToDecimal(col.Cells[4].Value); } //decimal valorall = Convert.ToDecimal(txtValorall.Text); txtValorfin2.Text = valorTotal.ToString(); txtValorall.Text = valorTotal.ToString("C2", ci); txtTotalFin.Text = valorTotal.ToString("C2", ci); ItemPedidoTableAdapter taitem = new ItemPedidoTableAdapter(); taitem.DeleteQuery(int.Parse(txtNumPedido.Text)); txtCodigoB.Focus(); txtQuantComp.Text = ""; txtPreco.Text = ""; txtDesc.Text = ""; txtCodigoB.Text = ""; txtQuantidadeEstoq.Text = ""; txtVtotal.Text = ""; } catch { MessageBox.Show("Favor selecionar uma linha para ser cancelada."); } }
private void frmConsultaPedido_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'lealDataSet.Produto' table. You can move, or remove it, as needed. //this.produtoTableAdapter.Fill(this.lealDataSet.Produto); // TODO: This line of code loads data into the 'lealDataSet1.ItemPedido' table. You can move, or remove it, as needed. this.itemPedidoTableAdapter.Fill(this.lealDataSet1.ItemPedido); // TODO: This line of code loads data into the 'lealDataSet.ItemPedido' table. You can move, or remove it, as needed. this.itemPedidoTableAdapter.Fill(this.lealDataSet.ItemPedido); if (!this.Propriedade.Equals("")) { txtCodPed.Text = this.Propriedade; } try { //this.itemPedidoTableAdapter.FillBy2(this.lealDataSet.ItemPedido, Convert.ToInt32(txtCodPed.Text)); ItemPedidoTableAdapter taItemPedido = new ItemPedidoTableAdapter(); DataTable dtlista; dtlista = taItemPedido.ConsultaPedido(Convert.ToInt32(txtCodPed.Text)); dataGridView1.DataSource = dtlista; } catch { } }
private void btnInserir_Click(object sender, EventArgs e) { try { int estoque = int.Parse(txtQuantidadeEstoq.Text); if (txtQuantComp.Value <= estoque) { string marca = txtMarca.Text; //decimal precounit = Convert.ToDecimal(txtPrecounid.Text); ////preco = preco.Replace("R$", "#######,##"); CultureInfo ci = new CultureInfo("pt-BR"); //txtPreco.Text= precounit.ToString("C2", ci); //decimal total = Convert.ToDecimal(txtVtotal.Text); //txtVtotal.Text = total.ToString("C2", ci); //total = total.Replace("R$ ", "#######,##"); if (txtMarca.Text != "") { txtDesc.Text = txtDesc.Text + ", " + txtMarca.Text; } else if (txtMarca.Text == "") { txtDesc.Text = txtMarca.Text; } if (txtQuantComp.Value != 0) { decimal totalvenda = 0; string pag = ""; PedidoTableAdapter taPedido = new PedidoTableAdapter(); taPedido.Insert(Convert.ToInt32(txtCodCli.Text), dateTimePicker1.Value, totalvenda, pag, 0); ItemPedidoTableAdapter taItemPedido = new ItemPedidoTableAdapter(); string quantidadeprod = txtQuantComp.Value.ToString(); taItemPedido.Insert(Convert.ToInt32(txtNumPedido.Text), int.Parse(quantidadeprod), int.Parse(txtCodPro.Text)); dgvPedido.Rows.Add(txtCodigoB.Text, txtDesc.Text, txtPrecounid.Text, txtQuantComp.Value.ToString(), txtTotal.Text); { //decimal total2 = 0; //int i = 0; //for (i = 0; i < dgvPedido.Rows.Count; i++) //{ // total2 = total2 + Convert.ToDecimal(dgvPedido.Rows[i].Cells["Total"].Value); //} //txtVtotal.Text = total2.ToString("C2", ci); string novoEstoque = (Convert.ToDecimal(txtQuantidadeEstoq.Text) - Convert.ToDecimal(txtQuantComp.Text)).ToString(); ProdutoTableAdapter taProduto = new ProdutoTableAdapter(); taProduto.UpdateEstoque(int.Parse(novoEstoque), Convert.ToInt64(txtCodigoB.Text)); } decimal valorTotal = 0; foreach (DataGridViewRow col in dgvPedido.Rows) { valorTotal = valorTotal + Convert.ToDecimal(col.Cells[4].Value); } //decimal valorall = Convert.ToDecimal(txtValorall.Text); txtValorfin2.Text = valorTotal.ToString(); txtValorall.Text = valorTotal.ToString("C2", ci); txtTotalFin.Text = valorTotal.ToString("C2", ci); //txtTotalFin.Text = valorTotal.ToString("C2", ci); txtCodigoB.Focus(); txtQuantComp.Text = ""; txtPreco.Text = ""; txtDesc.Text = ""; txtCodigoB.Text = ""; txtQuantidadeEstoq.Text = ""; txtVtotal.Text = ""; } else { MessageBox.Show("Adicione um quantidade!"); } } else { MessageBox.Show("A quantidade ultrapassa o estoque."); } } catch (Exception ex) { MessageBox.Show(ex.Message); //MessageBox.Show("Favor completar os espaços em branco."); } }
private void frmCaixaCli_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'lealDataSet.ItemPedido' table. You can move, or remove it, as needed. this.itemPedidoTableAdapter.Fill(this.lealDataSet.ItemPedido); // TODO: This line of code loads data into the 'lealDataSet.ItemPedido' table. You can move, or remove it, as needed. this.itemPedidoTableAdapter.Fill(this.lealDataSet.ItemPedido); if (!this.Propriedade.Equals("")) { txtNumPedido.Text = this.Propriedade; } if (!this.codcli.Equals("")) { txtCodClie.Text = this.codcli; } try { ItemPedidoTableAdapter taItemPedido = new ItemPedidoTableAdapter(); DataTable dtlista; dtlista = taItemPedido.ConsultaPedido(Convert.ToInt32(txtNumPedido.Text)); dataGridView1.DataSource = dtlista; ClienteTableAdapter taCli = new ClienteTableAdapter(); dtlista = taCli.Pesquisa_Cliente(int.Parse(txtCodClie.Text)); if (dtlista.Rows.Count == 0) { MessageBox.Show("Pedido Não Encontrado!"); this.Close(); } else { txtNome.Text = dtlista.Rows[0]["Nome_Cliente"].ToString(); txtSobrenome.Text = dtlista.Rows[0]["Sobrenome_Cliente"].ToString(); txtNomeCli.Text = txtNome.Text + " " + txtSobrenome.Text; } PedidoTableAdapter taPedido = new PedidoTableAdapter(); dtlista = taPedido.Pesquisa_Pedido(int.Parse(txtNumPedido.Text)); if (dtlista.Rows.Count == 0) { MessageBox.Show("Pedido Não Encontrado"); this.Close(); } else { txtValorfin2.Text = dtlista.Rows[0]["SubTotal_Pedido"].ToString(); txtdebi.Text = dtlista.Rows[0]["Debito_Pedido"].ToString(); } if (txtdebi.Text == "0") { decimal valor = Convert.ToDecimal(txtValorfin2.Text); CultureInfo ci = new CultureInfo("pt-BR"); txtValorall.Text = valor.ToString("C2", ci); txtTotalFin.Text = valor.ToString("C2", ci); } else if (txtdebi.Text != "0") { decimal valor = Convert.ToDecimal(txtValorfin2.Text); decimal debi = Convert.ToDecimal(txtdebi.Text); CultureInfo ci = new CultureInfo("pt-BR"); txtValorall.Text = valor.ToString("C2", ci); txtTotalFin.Text = debi.ToString("C2", ci); } } catch { } }