public WinNuevoLibro(Common.Libros librooo)
 {
     InitializeComponent();
     this.lib       = librooo;
     tbkTItulo.Text = "Actualizar Libros";
     opcion         = 1;
 }
        private void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (pathFotografia != string.Empty)
                {
                    switch (opcion)
                    {
                    case 0:     //insertamos
                        lib    = new Common.Libros(txtTitulo.Text, txtAutor.Text, txtAnoPublicacion.SelectedDate.Value, txtIsbn.Text, txtFechaRegistro.SelectedDate.Value);
                        libbrl = new LibroBRL(lib);
                        libbrl.Insert();

                        //capturamos la imagen

                        // short id = MethodsBRL.GetMaxIDTable("idLibro", "Libro");

                        //se copia la imagen
                        // File.Copy(pathFotografia, Config.pathFotoEmpleado + id + ".jpg");
                        MessageBox.Show("Correcto");
                        break;

                    case 1:    //modificacion
                        //asignacion de valores
                        lib.Titulo         = txtTitulo.Text;
                        lib.Autor          = txtAutor.Text;
                        lib.AnoPublicacion = txtAnoPublicacion.SelectedDate.Value;
                        lib.Isbn           = txtIsbn.Text;
                        lib.FechaRegistro  = txtFechaRegistro.SelectedDate.Value;

                        //IMAGEN
                        if (pathFotografia != pathFotoEmpleadoServer)
                        {
                            GC.Collect();
                            GC.WaitForPendingFinalizers();
                            if (lib.Foto == 1)
                            {
                                File.Delete(pathFotoEmpleadoServer);
                                File.Copy(pathFotografia, Config.pathFotoEmpleado + lib.IdLibro + ".jpg");
                            }
                            else
                            {
                                File.Copy(pathFotografia, Config.pathFotoEmpleado + lib.IdLibro + ".jpg");
                            }
                            //File.Delete(pathFotoEmpleadoServer);
                            //File.Copy(pathFotografia, Config.pathFotoEmpleado + empleado.IdEmpleado + ".jpg");
                        }

                        libbrl = new LibroBRL(lib);
                        libbrl.Update();
                        MessageBox.Show("El registro se modifico con exito");

                        this.Close();
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("Es necesario elegir una fotografia del empleado");
                }
            }
            catch (Exception err)
            {
                MessageBox.Show("Error al insertar el cliente" + err);
                throw err;
            }
        }