private void BtnExcluir_Click(object sender, EventArgs e) { if (MessageBox.Show("Se confirmar, será impossível recuperar o registro. Deseja excluir a rota? ", ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { CRota.CRotaClient oProxy = new CRota.CRotaClient(); CRota.ROTA oRota = new CRota.ROTA(); oRota.ROCodigo = int.Parse(TxtROCodigo.Text); oProxy.Excluir(oRota); BtnCancela_Click(sender, e); } }
private void btnSalvar_Click(object sender, EventArgs e) { if (validador1.isValid()) { if (ChkROBloqueada.Checked) { if (TxtROMotivoBloqueio.Text.Trim() == "") { MessageBox.Show("Preencha o motivo do bloqueio.", ProductName, MessageBoxButtons.OK); TxtROMotivoBloqueio.Focus(); return; } } else { TxtROMotivoBloqueio.Text = ""; } CRota.CRotaClient oProxy = new CRota.CRotaClient(); CRota.ROTA oRota = new CRota.ROTA(); oRota.RONome = TxtRONome.Text; oRota.RODescricao = TxtRODescricao.Text; oRota.ROBloqueada = ChkROBloqueada.Checked; oRota.ROMotivoBloqueio = TxtROMotivoBloqueio.Text; //oRota.ro if (Novo) { TxtROCodigo.Text = oProxy.Incluir(oRota).ToString(); } else { oRota.ROCodigo = int.Parse(TxtROCodigo.Text); oProxy.Alterar(oRota); } validador1.HabilitaControles(false); BtnNovo.Enabled = true; BtnCancela.Enabled = true; btnSalvar.Enabled = false; BtnExcluir.Enabled = true; BtnAlterar.Enabled = true; BtnSalvarPontoRota.Enabled = true; GrdItens.DataSource = oProxy.PontosRota(int.Parse(TxtROCodigo.Text)); } }