Beispiel #1
0
        private void Menu_editar_Click(object sender, RoutedEventArgs e)
        {
            int si = dgDocumentos.SelectedIndex;

            if (si >= 0)
            {
                DataTable dt = new DataTable();
                dt = ((DataView)dgDocumentos.ItemsSource).ToTable();
                int    id  = Convert.ToInt32(dt.Rows[si][0]);
                string cod = dt.Rows[si][1].ToString();
                string doc = dt.Rows[si][2].ToString();
                blank  b   = new blank(new rdocumentoUI(id, cod, doc));
                b.ShowDialog();
            }
        }
        private void txtSearchDoc_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                if (radio_code.IsChecked == true)
                {
                    DataTable dt = new DataTable();
                    dt = db.read(string.Format("buscarCodigo '{0}'", txtSearchDoc.Text));


                    int    aidi = 0;
                    string cod  = "";
                    string doc  = "";
                    try
                    {
                        aidi = Convert.ToInt32(dt.Rows[0][0]);
                        cod  = "";
                        doc  = "";

                        blank b = new blank(new rdocumentoUI(aidi, cod, doc));
                        b.ShowDialog();
                    }
                    catch (Exception z)
                    {
                        MessageBox.Show("Documento no encontrado, favor de verificar el codigo");
                    }
                }

                if (radio_name.IsChecked == true)
                {
                    DataTable dt = new DataTable();
                    dt = db.read(string.Format("buscarNombre '{0}'", txtSearchDoc.Text));

                    try
                    {
                        int    aidi = Convert.ToInt32(dt.Rows[0][0]);
                        string cod  = "";
                        string doc  = "";
                        blank  b    = new blank(new rdocumentoUI(aidi, cod, doc));
                        b.ShowDialog();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Documento no encontrado, favor de verificar el nombre");
                    }
                }
            }
        }