private void btnSaveCC_Click(object sender, EventArgs e) { string rpta = ""; try { if (string.IsNullOrEmpty(txtCentroCusto.Text)) { txtCentroCusto.BackColor = Color.Red; } else { rpta = DoCadastros.CentroCusto_Cadastro(txtCentroCusto.Text); } if (rpta.Equals("OK")) { txtCentroCusto.Clear(); pCentroCusto.Visible = false; ListCentroCusto(); } else { MessageBox.Show(rpta); } } catch (Exception ex) { rpta = ex.Message + ex.StackTrace; } }
private void btnSalvar_Click(object sender, EventArgs e) { try { string rpta = ""; int Especie = 0; if (string.IsNullOrEmpty(txtCadastro.Text)) { lblError.Visible = true; lblSuc.Visible = false; msgError("Campo não pode estar vazio!"); } else { if (DoCadastros.CentroCusto_Valida(txtCadastro.Text)) { lblSuc.Visible = false; lblError.Visible = true; msgError("Já existe um tipo de Entrada com descrição: " + txtCadastro.Text.Trim().ToUpper()); } else if (IsNew == true) { rpta = DoCadastros.CentroCusto_Cadastro(txtCadastro.Text.Trim().ToUpper()); } else if (IsNew == false) { DoCadastros.CentroCusto_Update(int.Parse(lblID.Text), txtCadastro.Text); } if (rpta.Equals("OK") && IsNew == true) { lblError.Visible = false; msgSuccess("Tipo de Entrada " + txtCadastro.Text.Trim().ToUpper() + ", cadastrado com sucesso!"); } else { msgSuccess("Tipo de Entrada " + txtCadastro.Text.Trim().ToUpper() + ", atualizado com sucesso!"); } } } catch (Exception ex) { msgError(ex.Message + ex.StackTrace); } txtCadastro.Clear(); txtCadastro.Focus(); }
private void btnSalvar_Click(object sender, EventArgs e) { try { string rpta = ""; if (string.IsNullOrEmpty(txtCadastro.Text)) { lblError.Visible = true; lblSuc.Visible = false; msgError("Campo não pode estar vazio!"); } else { if (DoCadastros.CentroCusto_Valida(txtCadastro.Text)) { lblSuc.Visible = false; lblError.Visible = true; msgError("Já existe um Centro de Custo com descrição: " + txtCadastro.Text.Trim().ToUpper()); } else { rpta = DoCadastros.CentroCusto_Cadastro(txtCadastro.Text.Trim().ToUpper()); } if (rpta.Equals("OK")) { lblError.Visible = false; msgSuccess("Centro de Custo " + txtCadastro.Text.Trim().ToUpper() + ", cadastrado com sucesso!"); } } } catch (Exception ex) { msgError(ex.Message + ex.StackTrace); } Lista(); txtCadastro.Clear(); txtCadastro.Focus(); }