protected void btn_editar_Click(object sender, EventArgs e) { ArrayList erros = new ArrayList(); try { lista_credito.Visible = false; Credito_Operações crd_banco = new Credito_Operações(); txtAlerta.Text = ""; if (lista_status.SelectedIndex != 0 || lista_mecanica.SelectedIndex != 0) { if ((Int32.Parse(hf_mecanica.Value) != Int32.Parse(lista_mecanica.SelectedValue.ToString()) || decimal.Parse(hf_valor.Value) != decimal.Parse(valor_compra.Text)) || Int32.Parse(hf_status.Value) != Int32.Parse(lista_status.SelectedValue)) { if (decimal.Parse(valor_compra.Text.Replace(".", ",")) > 0) { ModeloCredito crd = new ModeloCredito(); crd.id_mecanica = Int32.Parse(lista_mecanica.SelectedValue.ToString()); crd.valor_compra = decimal.Parse(valor_compra.Text); crd.id_status = Int32.Parse(lista_status.SelectedValue.ToString()); crd.id_usuario = Credito_Operações.RetornaID(Int32.Parse(hf_credito.Value)); crd.id_credito = Int32.Parse(hf_credito.Value); crd.data_credito = DateTime.Parse(data_credito.Text); if (crd_banco.LimpaCriacao(Int32.Parse(hf_credito.Value), decimal.Parse(hf_valor.Value), Int32.Parse(hf_mecanica.Value)) && crd_banco.UpdateCredito(crd)) { erros.Add("Edição realizada!"); LimpaTudo(); } else { erros.Add("Problemas na Edição do Crédito"); LimpaTudo(); } } else { erros.Add("Valor da compra inválido!\n"); LimpaTudo(); } } else { erros.Add("Esses valores já estão no banco\n"); } } else { erros.Add("Selecione Mecânica e Status"); } } catch (Exception ex) { erros.Add(ex.Message); } finally { if (erros.Count > 0) { ModalAlerta.Visible = true; for (int i = 0; i < erros.Count; i++) { txtAlerta.Text = txtAlerta.Text += erros[i]; } } } }