Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Pessoal, este erro ta me arrebentando no meio...
Tenho uma tabela onde criei na maioria campos tipo Money, e no Page_Load eu defino um valor padrao para os textbox... O codigo funciona, mas quando cliclo no botao INSERIR ele gera o erro "Input string was not in a correct format".
Segue abaixo o codigo que implementei no Page_Load:
protected void Page_Load(object sender, EventArgs e)
{
//ACESSA OBJETOS NO FORMVIEW E CRIA VARIAVEIS
TextBox DATA_CADASTRO = (TextBox)FormView1.FindControl("TextBox3");
TextBox PRECO_CUSTO = (TextBox)FormView1.FindControl("TextBox6");
TextBox PERCENTUAL_LUCRO = (TextBox)FormView1.FindControl("TextBox7");
TextBox VALOR_LUCRO = (TextBox)FormView1.FindControl("TextBox8");
TextBox PRECO_VENDA = (TextBox)FormView1.FindControl("TextBox9");
TextBox ESTOQUE_MINIMO = (TextBox)FormView1.FindControl("TextBox14");
TextBox ESTOQUE_MAXIMO = (TextBox)FormView1.FindControl("TextBox15");
if (!IsPostBack)
{
DATA_CADASTRO.Text = Convert.ToString(DateTime.Now);
PRECO_CUSTO.Text = "0,00";
PERCENTUAL_LUCRO.Text = "0,00";
VALOR_LUCRO.Text = "0,00";
PRECO_VENDA.Text = "0,00";
ESTOQUE_MINIMO.Text = "0,00";
ESTOQUE_MAXIMO.Text = "0,00";
}
Decimal DPRECO_CUSTO;
Decimal DPERCENTUAL_LUCRO;
Decimal DVALOR_LUCRO;
Decimal DPRECO_VENDA;
if (PRECO_CUSTO.Text != "")
{
//CALCULO DO VALOR DO LUCRO
DPRECO_CUSTO = Decimal.Parse(PRECO_CUSTO.Text);
DPERCENTUAL_LUCRO = Decimal.Parse(PERCENTUAL_LUCRO.Text);
DVALOR_LUCRO = (DPRECO_CUSTO / 100) * DPERCENTUAL_LUCRO;
VALOR_LUCRO.Text = Convert.ToString(DVALOR_LUCRO);
//CALCULO DO PREÇO DE VENDA
DPRECO_VENDA = DPRECO_CUSTO + DVALOR_LUCRO;
PRECO_VENDA.Text = Convert.ToString(DPRECO_VENDA);
}
}Carregando comentários...