protected void btnAdicionarServico_Click(object sender, EventArgs e) { try { Servico servico = new Servico(); servico.TipoServico = TipoServicoDB.Select(Convert.ToInt64(ddlSubTipoServico.SelectedValue)); if (Session["ObjEst"] != null) { servico.Estabelecimento = (Estabelecimento)Session["ObjEst"]; } servico.Nome = txbNomeServico.Text; servico.Preco = Convert.ToDouble(txbValorServico.Text); if (ServicoDB.Insert(servico) == 0) { Session["ObjEst"] = EstabelecimentoDB.Select(servico.Estabelecimento.Codigo); txbValorServico.Text = ""; txbNomeServico.Text = ""; Response.Redirect("/editar/meusservicos?n=d"); } else { Response.Redirect("/editar/meusservicos?n=D"); } } catch (Exception exc) { } }
protected void btnAddTipoServico_Click(object sender, EventArgs e) { if (txbAddTipoServico.Text == "") { Response.Redirect("/admin/servicos?n=X"); return; } TipoServico tipoServico = new TipoServico(); TipoServico tipoServicoPai = new TipoServico(); tipoServicoPai = TipoServicoDB.Select(Convert.ToInt32(ddlServico.SelectedValue)); tipoServico.Descricao = txbAddTipoServico.Text; tipoServico.TipoPai = tipoServicoPai; long codigo; if (TipoServicoDB.NomeIsValid(tipoServico.Descricao) == true) { if ((codigo = TipoServicoDB.Insert(tipoServico)) != -2) { tipoServico.Codigo = codigo; txbAddServico.Text = ""; bindDdlServicoContent(); Response.Redirect("/admin/servicos?n=j"); } else { Response.Redirect("/admin/servicos?n=J"); return; } } else { Response.Redirect("/admin/servicos?n=X"); return; } }