frmCaixa.cs :
using System;
using System.Windows.Forms;
namespace Caixa
{
public partial class frmCaixa : Form
{
string[] codProd = new string[6];
string[] nomeProd = new string[6];
decimal[] valorProd = new decimal[6];
decimal somaTotal;
public frmCaixa()
{
InitializeComponent();
}
private void label2_Click(object sender, EventArgs e)
{
}
private void pictureBox2_Click(object sender, EventArgs e)
{
}
private void frmCaixa_Load(object sender, EventArgs e)
{
loadProducts();
somaTotal = 0;
}
private void loadProducts()
{
codProd[1] = "12345";
codProd[2] = "12346";
codProd[3] = "12347";
codProd[4] = "12348";
codProd[5] = "12349";
nomeProd[1] = "Grifon";
nomeProd[2] = "BMW";
nomeProd[3] = "Cogumelo Doido";
nomeProd[4] = "Player Music";
nomeProd[5] = "RSS";
valorProd[1] = 2000.00M;
valorProd[2] = 350.99M;
valorProd[3] = 2.50M;
valorProd[4] = 50.99M;
valorProd[5] = 25.25M;
}
private void txtCod_textchanged(object sender, EventArgs e)
{
if(txtcod.Text.Length == 5)
{
int ind = 0;
for(int cp = 1; cp < 6; cp++)
{
if(txtcod.Text == codProd[cp])
{
ind = cp;
}
}
if(ind > 0)
{
listProd.Items.Add(string.Format("#{0} - {1} - {2:c}", codProd[ind], nomeProd[ind], valorProd[ind]));
picProd.ImageLocation = "C:/Users/Lucas/Documents/Visual Studio 2015/Projects/Caixa/Caixa/images" + codProd[ind] + ".jpg";
somaTotal += valorProd[ind];
txtTotal.Text = Convert.ToString("R$" + somaTotal);
txtcod.Text = "";
txtcod.Focus();
}
else
{
MessageBox.Show("Produto não encontrado.");
}
}
}
}
}frmCaixa.cs[Design]:

Nenhum comentário:
Postar um comentário