-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
75 lines (63 loc) · 2.17 KB
/
Form1.cs
File metadata and controls
75 lines (63 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SoftwareMercado
{
public partial class frmPrincipal : Form
{
double valorTotal;
public frmPrincipal()
{
InitializeComponent();
// Estilizando a listView
lsvInfoProduto.View = View.Details;
lsvInfoProduto.FullRowSelect = true;
lsvInfoProduto.GridLines = true;
// Criando as colunas (Estilização)
lsvInfoProduto.Columns.Add("Nome Produto", 200, HorizontalAlignment.Left);
lsvInfoProduto.Columns.Add("Quantidade", 100, HorizontalAlignment.Left);
lsvInfoProduto.Columns.Add("Preço", 100, HorizontalAlignment.Left);
}
private void btnInserir_Click(object sender, EventArgs e)
{
string nome = inpProduto.Text;
int quantidade = int.Parse(inpQuantidade.Text);
double valor = double.Parse(inpValor.Text);
double valor_venda = (quantidade * valor);
valorTotal = valorTotal + (quantidade * valor);
lblTotal.Text = $"{valorTotal.ToString("C")}";
// Criando um Item e adicionando ele no primeiro campo
ListViewItem lvi = new ListViewItem(nome);
lsvInfoProduto.Items.Add(lvi);
// Criando os subitems e os adicionando
lvi.SubItems.Add($"{quantidade}");
lvi.SubItems.Add($"{valor_venda.ToString("C")}");
}
private void btnFechar_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnLimpar_Click(object sender, EventArgs e)
{
clear();
}
private void clear()
{
lsvInfoProduto.Items.Clear();
valorTotal = 0;
inpProduto.Text = "";
inpQuantidade.Text = "";
inpValor.Text = "";
lblTotal.Text = "R$ 00,00";
}
private void grbTotal_Enter(object sender, EventArgs e)
{
}
}
}