コード例 #1
0
        /// <summary>
        /// Este metodo se encarga de agregar  una entidad en la base de datos
        /// </summary>
        /// <param name="datosContactoDM">la entidad que se va a ingresar en la base de datos</param>
        /// <returns>regresa un valor booleano</returns>
        public bool AddUpdateTelefono(DatosContactoDomainModel datosContactoDM)
        {
            bool respuesta = false;

            if (datosContactoDM.IdTelefono > 0)
            {
                //buscamos por id y lo almacenamos en nuestra entidad de entityframework
                tblTelefono datosContacto = telefonoRepository.SingleOrDefault(p => p.idTelefono == datosContactoDM.IdTelefono);

                if (datosContacto != null)
                {
                    datosContacto.idPersonal         = datosContactoDM.IdPersonal;
                    datosContacto.idTelefono         = datosContactoDM.IdTelefono;
                    datosContacto.strTelefonoCasa    = datosContactoDM.TelefonoCasa;
                    datosContacto.strTelefonoCelular = datosContactoDM.TelefonoCelular;
                    datosContacto.strTelefonoRecados = datosContactoDM.TelefonoRecados;
                    //datosContacto.tblPersonal = personal;
                    //actualizamos los datos en la base de datos.
                    telefonoRepository.Update(datosContacto);
                    respuesta = true;
                }
            }
            else
            {
                tblTelefono tblTelefono = new tblTelefono();
                tblTelefono.strTelefonoCasa    = datosContactoDM.TelefonoCasa;
                tblTelefono.strTelefonoCelular = datosContactoDM.TelefonoCelular;
                tblTelefono.strTelefonoRecados = datosContactoDM.TelefonoRecados;
                tblTelefono.idPersonal         = datosContactoDM.IdPersonal;
                telefonoRepository.Insert(tblTelefono);
                respuesta = true;
            }
            return(respuesta);
        }
コード例 #2
0
        protected tblEmpleado GetDatosVista(tblEmpleado empl)
        {
            var rol      = cmbRol.SelectedItem.Value;
            var EstaMuni = ddlMunicipio.SelectedItem.Value;
            var random   = new Random();
            var value    = random.Next(0, 999999);


            tblDireccion direccion = new tblDireccion();

            direccion.fkEstadoMunicipio = Int32.Parse(EstaMuni);
            direccion.strCalle          = txtCalle.Text.ToUpper();
            direccion.strColonia        = txtColonia.Text.ToUpper();
            direccion.intCodpost        = txtCodPos.Text;
            direccion.strNumInt         = txtNumInt.Text.ToUpper();
            direccion.strNumExt         = txtNumExt.Text.ToUpper();
            direccion.strReferencias    = txtReferencia.Text.ToUpper();

            tblTelefono telefono = new tblTelefono();

            telefono.strCelular = txtCelular.Text.ToUpper();
            telefono.strTelCasa = txtTelCasa.Text.ToUpper();
            telefono.strOtro    = txtTelOtro.Text.ToUpper();

            tblUsuario login = new tblUsuario();

            login.strUsuario     = txtCorreo.Text;
            login.strPassword    = value.ToString();
            login.strTipousuario = rol;
            login.idActivo       = 1;

            ControllerEmpleado ctrlEmpl = new ControllerEmpleado();

            ctrlEmpl.enviarcorreo(empl.strCorreo, value.ToString());

            empl.tblDireccion = direccion;
            empl.tblTelefono  = telefono;
            empl.tblUsuario   = login;

            return(empl);
        }
コード例 #3
0
        protected tblCliente GetDatosVista(tblCliente cli)
        {
            var EstaMuni = ddlMunicipio.SelectedItem.Value;
            var random   = new Random();
            var value    = random.Next(0, 999999);


            tblDireccion direccion = new tblDireccion();

            direccion.fkEstadoMunicipio = Int32.Parse(EstaMuni);
            direccion.strCalle          = txtCalle.Text.ToUpper();
            direccion.strColonia        = txtColonia.Text.ToUpper();
            direccion.intCodpost        = txtCodPos.Text;
            direccion.strNumInt         = txtNumInt.Text.ToUpper();
            direccion.strNumExt         = txtNumExt.Text.ToUpper();
            direccion.strReferencias    = txtReferencia.Text.ToUpper();

            tblTelefono telefono = new tblTelefono();

            telefono.strCelular = txtCelular.Text.ToUpper();
            telefono.strTelCasa = txtTelEncargador.Text.ToUpper();
            telefono.strOtro    = txtTelOtro.Text.ToUpper();

            tblUsuario login = new tblUsuario();

            login.strUsuario     = txtCorreo.Text;
            login.strPassword    = value.ToString();
            login.strTipousuario = "CLIENTE";
            login.idActivo       = 1;

            ControllerCliente ctrlClie = new ControllerCliente();

            //ctrlClie.enviarcorreo(cli.strCorreo, value.ToString());

            cli.tblDireccion = direccion;
            cli.tblTelefono  = telefono;
            cli.tblUsuario   = login;

            return(cli);
        }
コード例 #4
0
        public void Editar(tblEmpleado empl, tblTelefono tel)
        {
            tblEmpleado emplBd = contexto.tblEmpleado
                                 .Where(t => t.idEmpleado == empl.idEmpleado).FirstOrDefault();

            if (emplBd != null)
            {
                emplBd.strCorreo = empl.strCorreo;
                contexto.SubmitChanges();
            }

            tblTelefono telBd = contexto.tblTelefono
                                .Where(t => t.idTelefono == tel.idTelefono).FirstOrDefault();

            if (telBd != null)
            {
                telBd.strCelular = tel.strCelular;
                telBd.strTelCasa = tel.strTelCasa;
                telBd.strOtro    = tel.strOtro;
                contexto.SubmitChanges();
            }
        }
コード例 #5
0
        /// <summary>
        /// Este Metodo se encarga de agregar o actualizar un registro a la base de datos
        /// </summary>
        /// <param name="datosContactoDM">recibe un objeto del tipo datosContactoDM</param>
        /// <returns>regresa un valor booleano</returns>
        public bool AddUpdateDatosContacto(DatosContactoDomainModel datosContactoDM)
        {
            bool        respuesta = false;
            tblPersonal personal  = null;

            if (datosContactoDM.IdDatosContacto > 0)
            {
                //buscamos por id y lo almacenamos en nuestra entidad de entityframework
                tblDatosContacto datosContacto = datosContactoRepository.SingleOrDefault(p => p.idDatosContacto == datosContactoDM.IdDatosContacto);

                if (datosContacto != null)
                {
                    tblTelefono tblTelefono = new tblTelefono();

                    tblTelefono.strTelefonoCasa    = datosContactoDM.TelefonoCasa;
                    tblTelefono.strTelefonoCelular = datosContactoDM.TelefonoCelular;
                    tblTelefono.strTelefonoRecados = datosContactoDM.TelefonoRecados;

                    datosContacto.tblTelefono.Add(tblTelefono);

                    datosContacto.idDatosContacto       = datosContactoDM.IdDatosContacto;
                    datosContacto.idPersonal            = datosContactoDM.IdPersonal;
                    datosContacto.strEmailPersonal1     = datosContactoDM.MailPersonal;
                    datosContacto.strNombreFacebook     = datosContactoDM.NombreFacebook;
                    datosContacto.strNombreTwitter      = datosContactoDM.NombreTwitter;
                    datosContacto.strNombre             = datosContactoDM.strNombre;
                    datosContacto.strApellidoPaterno    = datosContactoDM.strApellidoPaterno;
                    datosContacto.strApellidoMaterno    = datosContactoDM.strApellidoMaterno;
                    datosContacto.strDireccion          = datosContactoDM.strDireccion;
                    datosContacto.bitContactoEmergencia = datosContactoDM.bitContactoEmergencia;
                    //asociasion de la tabla principal
                    datosContacto.tblPersonal = personal;
                    //actualizamos los datos en la base de datos.
                    datosContactoRepository.Update(datosContacto);

                    respuesta = true;
                }
            }
            else
            {
                tblDatosContacto datosContacto = new tblDatosContacto();
                tblTelefono      tblTelefono   = new tblTelefono();

                tblTelefono.strTelefonoCasa    = datosContactoDM.TelefonoCasa;
                tblTelefono.strTelefonoCelular = datosContactoDM.TelefonoCelular;
                tblTelefono.strTelefonoRecados = datosContactoDM.TelefonoRecados;

                datosContacto.tblTelefono.Add(tblTelefono);

                datosContacto.idPersonal            = datosContactoDM.IdPersonal;
                datosContacto.strEmailPersonal1     = datosContactoDM.MailPersonal;
                datosContacto.strNombreFacebook     = datosContactoDM.NombreFacebook;
                datosContacto.strNombreTwitter      = datosContactoDM.NombreTwitter;
                datosContacto.strNombre             = datosContactoDM.strNombre;
                datosContacto.strApellidoPaterno    = datosContactoDM.strApellidoPaterno;
                datosContacto.strApellidoMaterno    = datosContactoDM.strApellidoMaterno;
                datosContacto.strDireccion          = datosContactoDM.strDireccion;
                datosContacto.bitContactoEmergencia = datosContactoDM.bitContactoEmergencia;

                ///insertamos en la entidad
                datosContactoRepository.Insert(datosContacto);
                respuesta = true;
            }
            return(respuesta);
        }