protected void btnSalvar_Click(object sender, EventArgs e) { BancoDeDadosPadraoDataContext contexto = new BancoDeDadosPadraoDataContext(); FILIAL filial = null; if (_idFilial == -1) { filial = new FILIAL(); contexto.FILIALs.InsertOnSubmit(filial); } else { filial = (from f in contexto.FILIALs where f.ID == _idFilial select f) .FirstOrDefault(); } filial.NOMEFANTASIA = txtNomeFantasia.Text; filial.RAZAOSOCIAL = txtRazaoSocial.Text; filial.CNPJ = txtCNPJ.Text; filial.ENDERECO = txtEndereco.Text; filial.BAIRRO = txtBairro.Text; filial.CIDADE = txtCidade.Text; filial.ESTADO = txtEstado.Text; filial.CEP = txtCEP.Text; filial.TELEFONE = txtTelefone.Text; filial.TELEFONE2 = txtTelefone2.Text; filial.EMAIL = txtEmail.Text; filial.IDEMPRESA = Convert.ToInt32(txtIdEmpresa.Text); contexto.SubmitChanges(); }
protected void btnSalvar_Click(object sender, EventArgs e) { BancoDeDadosPadraoDataContext contexto = new BancoDeDadosPadraoDataContext(); EMPRESA empresa = null; if (_idEmpresa == -1) { empresa = new EMPRESA(); contexto.EMPRESAs.InsertOnSubmit(empresa); } else { empresa = (from emp in contexto.EMPRESAs where emp.ID == _idEmpresa select emp) .FirstOrDefault(); } empresa.NOMEFANTASIA = txtNomeFantasia.Text; empresa.RAZAOSOCIAL = txtRazaoSocial.Text; empresa.CNPJ = txtCNPJ.Text; empresa.ENDERECO = txtEndereco.Text; empresa.BAIRRO = txtBairro.Text; empresa.CIDADE = txtCidade.Text; empresa.ESTADO = txtEstado.Text; empresa.CEP = txtCEP.Text; empresa.TELEFONE = txtTelefone.Text; empresa.TELEFONE2 = txtTelefone2.Text; empresa.EMAIL = txtEmail.Text; contexto.SubmitChanges(); }
protected void btnSalvar_Click(object sender, EventArgs e) { BancoDeDadosPadraoDataContext contexto = new BancoDeDadosPadraoDataContext(); USUARIO usuario = null; if (_idUsusario == -1) { usuario = new USUARIO(); contexto.USUARIOs.InsertOnSubmit(usuario); } else { usuario = (from u in contexto.USUARIOs where u.ID == _idUsusario select u) .FirstOrDefault(); } usuario.NOME = txtNome.Text; usuario.CPFCNPJ = txtCPFCNPJ.Text; usuario.EMAIL = txtEmail.Text; usuario.SENHA = txtSenha.Text; usuario.TIPOPESSOA = txtTipoPessoa.Text; usuario.ATIVO = ckbAtivo.Checked; contexto.SubmitChanges(); }
protected void Page_Load(object sender, EventArgs e) { BancoDeDadosPadraoDataContext contexto = new BancoDeDadosPadraoDataContext(); var empresas = (from emp in contexto.EMPRESAs select emp) .ToList(); rptEmpresa.DataSource = empresas; rptEmpresa.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { BancoDeDadosPadraoDataContext contexto = new BancoDeDadosPadraoDataContext(); var usuarios = (from u in contexto.USUARIOs select u) .ToList(); rptUsuarios.DataSource = usuarios; rptUsuarios.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (Request["idEmpresa"] != null) { if (int.TryParse(Request["idEmpresa"].ToString(), out _idEmpresa)) { txtIdEmpresa.Text = _idEmpresa.ToString(); } else { Response.Write("empresa invalida"); } } if (Request["idFilial"] != null) { int.TryParse(Request["idFilial"].ToString(), out _idFilial); if (!Page.IsPostBack) { BancoDeDadosPadraoDataContext contexto = new BancoDeDadosPadraoDataContext(); var filial = (from emp in contexto.FILIALs where emp.ID == _idFilial select emp) .FirstOrDefault(); if (filial != null) { txtNomeFantasia.Text = filial.NOMEFANTASIA; txtRazaoSocial.Text = filial.RAZAOSOCIAL; txtCNPJ.Text = filial.CNPJ; txtEndereco.Text = filial.ENDERECO; txtBairro.Text = filial.BAIRRO; txtCidade.Text = filial.CIDADE; txtEstado.Text = filial.ESTADO; txtCEP.Text = filial.CEP; txtTelefone.Text = filial.TELEFONE; txtTelefone2.Text = filial.TELEFONE2; txtEmail.Text = filial.EMAIL; txtIdEmpresa.Text = filial.IDEMPRESA.ToString(); } } } }
protected void Page_Load(object sender, EventArgs e) { if (Request["idEmpresa"] != null) { int.TryParse(Request["idEmpresa"].ToString(), out _idEmpresa); if (!Page.IsPostBack) { BancoDeDadosPadraoDataContext contexto = new BancoDeDadosPadraoDataContext(); var empresa = (from emp in contexto.EMPRESAs where emp.ID == _idEmpresa select emp) .FirstOrDefault(); if (empresa != null) { txtNomeFantasia.Text = empresa.NOMEFANTASIA; txtRazaoSocial.Text = empresa.RAZAOSOCIAL; txtCNPJ.Text = empresa.CNPJ; txtEndereco.Text = empresa.ENDERECO; txtBairro.Text = empresa.BAIRRO; txtCidade.Text = empresa.CIDADE; txtEstado.Text = empresa.ESTADO; txtCEP.Text = empresa.CEP; txtTelefone.Text = empresa.TELEFONE; txtTelefone2.Text = empresa.TELEFONE2; txtEmail.Text = empresa.EMAIL; var filiais = (from f in contexto.FILIALs where f.IDEMPRESA == _idEmpresa select f) .ToList(); rptFilial.DataSource = filiais; rptFilial.DataBind(); } } } }
protected void Page_Load(object sender, EventArgs e) { if (Request["id"] != null) { int.TryParse(Request["id"].ToString(), out _idUsusario); if (!Page.IsPostBack) { BancoDeDadosPadraoDataContext contexto = new BancoDeDadosPadraoDataContext(); var usuario = (from u in contexto.USUARIOs where u.ID == _idUsusario select u) .FirstOrDefault(); if (usuario != null) { txtNome.Text = usuario.NOME; txtCPFCNPJ.Text = usuario.CPFCNPJ; txtEmail.Text = usuario.EMAIL; txtTipoPessoa.Text = usuario.TIPOPESSOA; ckbAtivo.Checked = usuario.ATIVO; } } } }