Esempio n. 1
0
        public DoctorCLS RecuperarDoctor(int iidDoctor)
        {
            using (BDDoctorDataContext bd = new BDDoctorDataContext())
            {
                DoctorCLS oDoctorCLS = bd.Doctor.Where(p => p.IIDDOCTOR == iidDoctor)
                                       .Select(p => new DoctorCLS
                {
                    iidDoctor       = p.IIDDOCTOR,
                    nombre          = p.NOMBRE,
                    apPaterno       = p.APPATERNO,
                    apMaterno       = p.APMATERNO,
                    email           = p.EMAIL,
                    fechaContrato   = (DateTime)p.FECHACONTRATO,
                    archivo         = p.ARCHIVO,
                    iidSexo         = (int)p.IIDSEXO,
                    nombreArchivo   = p.NOMBREARCHIVO,
                    sueldo          = (decimal)p.SUELDO,
                    telefonoCelular = p.TELEFONOCELULAR,
                    iidClinica      = (int)p.IIDCLINICA,
                    iidEspecialidad = (int)p.IIDESPECIALIDAD
                }

                                               ).First();

                return(oDoctorCLS);
            }
        }
Esempio n. 2
0
        private async void btnAceptar_Click(object sender, EventArgs e)
        {
            DoctorAPI oDoctorAPI = new DoctorAPI();
            DoctorCLS oDoctor    = new DoctorCLS();

            oDoctor.iidDoctor       = int.Parse(txtidDoctor.Text);
            oDoctor.nombre          = txtNombre.Text;
            oDoctor.apPaterno       = txtApPaterno.Text;
            oDoctor.apMaterno       = txtApMaterno.Text;
            oDoctor.email           = txtEmail.Text;
            oDoctor.iidClinica      = (int)cboClinica.SelectedValue;
            oDoctor.iidEspecialidad = (int)cboEspecialidad.SelectedValue;;
            oDoctor.iidSexo         = rdMascu.Checked?1:2;
            oDoctor.sueldo          = decimal.Parse(txtSueldo.Text);
            oDoctor.telfCelular     = txtCelular.Text;
            oDoctor.fechaContrato   = dtFecha.Value == null ? DateTime.Now : dtFecha.Value;

            //Manejo de imagen
            byte[] buffer;
            Image  img = pbFoto.Image;
            //ImageFormat format = img.RawFormat;
            ImageFormat format = img.RawFormat as ImageFormat;

            if (img != null)
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    Bitmap bmp = new Bitmap(img);
                    bmp.Save(ms, format);
                    buffer = ms.ToArray();
                }
                string fotoBase64       = Convert.ToBase64String(buffer);
                string extensionArchivo = Path.GetExtension(nombreArchivo).Substring(1);
                oDoctor.archivo       = "data:image/" + extensionArchivo + ";base64," + fotoBase64;
                oDoctor.nombreArchivo = nombreArchivo;
            }
            oDoctor.bhabilitado = 1;

            int rpta = await oDoctorAPI.AgregarEditarInformacion(oDoctor);

            if (rpta == 1)
            {
                MessageBox.Show("Se guardo correctamente");
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("Ocurrio un error");
                this.DialogResult = DialogResult.None;
            }
        }
Esempio n. 3
0
        private async void frmPopupDoctor_Load(object sender, EventArgs e)
        {
            if (iidDoctor == 0)
            {
                rdMascu.Checked = true;
                this.Text       = "Agregando Doctor";
            }
            else
            {
                this.Text = "Editando Doctor";
                DoctorAPI oDoctorApi = new DoctorAPI();
                oDoctorCLS = await oDoctorApi.RecuperarDoctor(iidDoctor);

                txtidDoctor.Text  = oDoctorCLS.iidDoctor.ToString();
                txtNombre.Text    = oDoctorCLS.nombre;
                txtApPaterno.Text = oDoctorCLS.apPaterno;
                txtApMaterno.Text = oDoctorCLS.apMaterno;
                txtEmail.Text     = oDoctorCLS.email;
                dtFecha.Value     = oDoctorCLS.fechaContrato;
                //cboClinica.SelectedValue = oDoctorCLS.iidClinica;
                //cboEspecialidad.SelectedValue = oDoctorCLS.iidEspecialidad;
                //Aqui vamos a llenar los combos
                if (oDoctorCLS.iidSexo == 1)
                {
                    rdMascu.Checked = true;
                }
                else
                {
                    rdFeme.Checked = true;
                }

                txtSueldo.Text  = oDoctorCLS.sueldo.ToString();
                txtCelular.Text = oDoctorCLS.telfCelular == null ? "" : oDoctorCLS.telfCelular;
                string foto = oDoctorCLS.archivo;
                nombreArchivo = oDoctorCLS.nombreArchivo;
                if (foto != null && foto != "" && nombreArchivo != null && nombreArchivo != "")
                {
                    string extension = Path.GetExtension(nombreArchivo).Substring(1);
                    foto = foto.Replace("data:image/" + extension + ";base64,", "");
                    byte[] fotoArray = Convert.FromBase64String(foto);
                    using (MemoryStream ms = new MemoryStream(fotoArray))
                    {
                        pbFoto.Image = Image.FromStream(ms);
                    }
                }
            }
            llenarCombo();
        }
Esempio n. 4
0
        public async Task <DoctorCLS> RecuperarDoctor(int iidDoctor)
        {
            string              rpta     = "";
            HttpClient          cliente  = new HttpClient();
            string              url      = "http://192.168.100.43/api/Doctor?iidDoctor=" + iidDoctor;
            HttpResponseMessage response = await cliente.GetAsync(url);

            DoctorCLS oDoctor = new DoctorCLS();

            if (response != null)
            {
                rpta = await response.Content.ReadAsStringAsync();

                oDoctor = JsonConvert.DeserializeObject <DoctorCLS>(rpta);
            }
            return(oDoctor);
        }
Esempio n. 5
0
        public async Task <int> AgregarEditarInformacion(DoctorCLS oDoctorCLS)
        {
            int                 rpta        = 0;
            HttpClient          cliente     = new HttpClient();
            string              url         = "http://192.168.100.43/api/Doctor";
            var                 jsonRequest = JsonConvert.SerializeObject(oDoctorCLS);
            var                 content     = new StringContent(jsonRequest, Encoding.UTF8, "text/json");
            HttpResponseMessage reponse     = await cliente.PostAsync(url, content);

            if (reponse != null)
            {
                string rptaCadena = await reponse.Content.ReadAsStringAsync();

                rpta = int.Parse(rptaCadena);
            }
            return(rpta);
        }
Esempio n. 6
0
        public async Task <int> eliminarDoctor(int iidDoctor)
        {
            int        rpta    = 0;
            HttpClient cliente = new HttpClient();
            string     url     = "http://192.168.100.43/api/Doctor?iidDoctor=" + iidDoctor;
            DoctorCLS  oDoctor = new DoctorCLS
            {
                iidDoctor = iidDoctor
            };
            var jsonRequest             = JsonConvert.SerializeObject(oDoctor);
            var content                 = new StringContent(jsonRequest, Encoding.UTF8, "text/json");
            HttpResponseMessage reponse = await cliente.PutAsync(url, content);

            if (reponse != null)
            {
                string rptaCadena = await reponse.Content.ReadAsStringAsync();

                rpta = int.Parse(rptaCadena);
            }
            return(rpta);
        }