Advertisement
onzulin

FormPacientes

Apr 14th, 2012
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.52 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.IO;
  10. namespace dentalclinic
  11. {
  12.     public partial class FormPacientes : FormPlantilla
  13.     {
  14.        
  15.         private dentalclinicEntities contextoClinic = new dentalclinicEntities();
  16.        
  17.  
  18.  
  19.         public FormPacientes()
  20.         {
  21.             InitializeComponent();
  22.         }
  23.  
  24.         private void FormPacientes_Load(object sender, EventArgs e)
  25.         {
  26.            
  27.             using (dentalclinicEntities contextoClinic = new dentalclinicEntities())
  28.             {
  29.                 comboBoxDentistas.DisplayMember = "Nombre";
  30.                 comboBoxDentistas.ValueMember = "Nombre";
  31.                 comboBoxDentistas.DataSource = contextoClinic.dentistas;
  32.                 bindingSourcePacientes.DataSource = contextoClinic.pacientes;
  33.                 dentistasBindingSource.DataSource = contextoClinic.dentistas;
  34.             }
  35.  
  36.         }
  37.  
  38.         private void guardarToolStripButton_Click(object sender, EventArgs e)
  39.         {
  40.             try
  41.             {
  42.                 //para terminar los cambios antes de salvarlos y asi no haya problemas probando a verf como tira
  43.                 bindingSourcePacientes.EndEdit();
  44.                 contextoClinic.SaveChanges();
  45.             }
  46.             catch (Exception ex)
  47.             {
  48.                 MessageBox.Show(ex.Message);
  49.             }
  50.         }
  51.  
  52.         private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
  53.         {
  54.             DialogResult respuesta;
  55.             respuesta = MessageBox.Show("¿Desea borrar al paciente?", "Pregunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  56.             if (respuesta == DialogResult.Yes)
  57.             {
  58.                 bindingSourcePacientes.RemoveCurrent();
  59.                 this.bindingSourcePacientes.EndEdit();
  60.                 contextoClinic.SaveChanges();
  61.             }
  62.         }
  63.  
  64.         private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
  65.         {
  66.             tbNumero.Focus();
  67.             tbNumero.Text = "Introduzca un numero";
  68.             tbNumero.SelectAll();
  69.         }
  70.  
  71.         private void comboBoxDentistas_SelectedIndexChanged(object sender, EventArgs e)
  72.         {
  73.             //Table<dentistas> Dentistas = contextoClinic.GetTable<dentistas>();
  74.            
  75.            
  76.             //consulta
  77.             var dentista = from dentistas in contextoClinic.dentistas
  78.                            select dentistas;
  79.                            
  80.         }
  81.  
  82.         private void pictureBoxPaciente_DoubleClick(object sender, EventArgs e)
  83.         {
  84.             OpenFileDialog dlgAbrir = new OpenFileDialog();
  85.             dlgAbrir.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
  86.             dlgAbrir.Filter = "imagenes jpg (*.jpg) | *.jpg |imagenes png (*.png)| *.png |imagenes bmp (*.bmp)| *.bmp | todos (*.*)| *.*";
  87.             dlgAbrir.FilterIndex = 4;
  88.             dlgAbrir.RestoreDirectory = true;
  89.             //mostrar el cuadro de dialogo
  90.             if (dlgAbrir.ShowDialog() == DialogResult.OK)
  91.             {
  92.                 //ruta completa donde esta el fichero elegido
  93.                 string ruta = dlgAbrir.FileName;
  94.                 FileInfo fileInfo = new FileInfo(ruta);
  95.  
  96.                 if (fileInfo.Length > 1 * 1024 * 1024)
  97.                 {
  98.                     MessageBox.Show("No se puede almacenar imagenes de mas de 1 MB", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
  99.                     return;
  100.                 }
  101.             }
  102.         }
  103.  
  104.         private void pictureBoxPaciente_MouseEnter(object sender, EventArgs e)
  105.         {
  106.             toolTipPacientes.Show("doble click para insertar una imagen" + Environment.NewLine + "no puede ser mayor de 1 MB", pictureBoxPaciente);
  107.         }
  108.  
  109.         private void buttonMas_Click(object sender, EventArgs e)
  110.         {
  111.             bool visibles = false;
  112.             //este boton lo usaremos para poner o no visible el apartado de la 2ª direccion
  113.             lbDireccion2.Visible = true;
  114.             tbDireccion2.Visible = true;
  115.             buttonMas.Text = "-";
  116.             visibles = true;
  117.             /*
  118.             if (buttonMas.Text == "-")
  119.             {
  120.                 lbDireccion2.Visible = false;
  121.                 tbDireccion2.Visible = false;
  122.                 buttonMas.Text = "+";
  123.             }*/
  124.         }
  125.  
  126.        
  127.     }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement