1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Xml;
using System.Threading;
using System.Windows.Threading;
namespace application_finale
{
public partial class Form2 :Form
{
//String form1.firstLine = form1.textBox1.Lines[0];
String s = Form1.source;
String f=Form1.firstLine;
String cr=Form1.creat;
String tm=Form1.tmpg;
String cp=Form1.copie;
String ut = Form1.util;
String aj = Form3.txt;
String aj2 = Form3.txt2;
String aj3 = Form3.txt3;
public string text1;
public string text2;
public string text3;
DataGridViewRow r;
object a; EventArgs ee;
Dictionary<string, int> d = Form1.mots;
//Form2 frmm2 = new Form2();
// String dt = getCreationTime(s).ToLongDateString();
// String tmp = getLastAccessTime(s).ToLongTimeString();
public Form2()
{
// object a; EventArgs ee;
InitializeComponent();
// threadArgs at = new threadArgs();
//Thread th1 = new Thread(new ParameterizedThreadStart(personnaliserToolStripMenuItem1_Click));
// th1.Start(1);
//http://forum.lesite.fr/hfr/Programmation/CNET-managed/passer-thread-resolu-sujet_53664_1.htm
// Thread frm2 = new Thread(new ThreadStart(startfrm2));
//Thread th1 = new Thread(personnaliserToolStripMenuItem1_Click(a,ee));
// th1.Start();
// frm2.Start();
}
//Form2 frmm2=new Form2();
public void startfrm2()
{
// Application.Run(frmm2);
}
//******** thread pour lajout d element a la base**************
public Thread Startthethread(object sender, EventArgs e)
{
var t = new Thread(() => personnaliserToolStripMenuItem1_Click(a, ee));
t.Start();
return t;
}
private static DateTime getCreationTime(String ss)
{
return File.GetCreationTime(ss);
}
private static DateTime getLastAccessTime(String ss)
{
return File.GetLastAccessTime(ss);
}
private void collerToolStripMenuItem_Click(object sender, EventArgs e)
{
/* /* String s = Form1.source;
String r = Form1.copie;
ListViewItem lvi = new ListViewItem("r");
lvi.SubItems.Add("s");
lvi.SubItems.Add("ggggggg");
lvi.SubItems.Add("gggg");
listView1.Items.Add(lvi);
listView1.View = View.Details;
// Add a column with width 20 and left alignment.
listView1.Columns.Add("Mots", 100, HorizontalAlignment.Left);
listView1.Columns.Add("nbr", 80, HorizontalAlignment.Left);
listView1.Columns.Add("aaaaaaaaaaaaaaaaa", 80, HorizontalAlignment.Left);
string resultat = string.Empty;
foreach (string mot in d.Keys)
{
ListViewItem lv = new ListViewItem();
lv.Text = mot;
lv.SubItems.Add(d[mot].ToString());
listView1.Items.Add(lv);
}*/
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
/* DataGridViewRow r;
//DataGridView ligne;
// this.dataGridView1.SelectedRows ligne;
//DataGridViewRow r in dataGridView1.SelectedRows
//if(DataGridViewButtonColumn.){}
//dataGridView1.Refresh();
string strFilename = "Videos.xml";
XmlDocument xmlDoc = new XmlDocument();
if (File.Exists(strFilename))
{
xmlDoc.Load(strFilename);
XmlElement elmRoot = xmlDoc.DocumentElement;
XmlElement elmNew = xmlDoc.CreateElement("Video");
elmRoot.AppendChild(elmNew);
elmRoot = xmlDoc.DocumentElement;
elmNew = xmlDoc.CreateElement("FICHIER");
XmlText txtVideo = xmlDoc.CreateTextNode(s);
elmRoot.LastChild.AppendChild(elmNew);
elmRoot.LastChild.LastChild.AppendChild(txtVideo);
elmNew = xmlDoc.CreateElement("TITRE");
txtVideo = xmlDoc.CreateTextNode(f);
elmRoot.LastChild.AppendChild(elmNew);
elmRoot.LastChild.LastChild.AppendChild(txtVideo);
elmNew = xmlDoc.CreateElement("DATECREATION");
txtVideo = xmlDoc.CreateTextNode(cr);
elmRoot.LastChild.AppendChild(elmNew);
elmRoot.LastChild.LastChild.AppendChild(txtVideo);
elmNew = xmlDoc.CreateElement("HEUREDERNIERACCÉES");
txtVideo = xmlDoc.CreateTextNode(tm);
elmRoot.LastChild.AppendChild(elmNew);
elmRoot.LastChild.LastChild.AppendChild(txtVideo);
elmNew = xmlDoc.CreateElement("UTILISATEUR");
txtVideo = xmlDoc.CreateTextNode(ut);
elmRoot.LastChild.AppendChild(elmNew);
elmRoot.LastChild.LastChild.AppendChild(txtVideo);
elmNew = xmlDoc.CreateElement("COPIE");
txtVideo = xmlDoc.CreateTextNode(cp);
elmRoot.LastChild.AppendChild(elmNew);
elmRoot.LastChild.LastChild.AppendChild(txtVideo);
xmlDoc.Save(strFilename);
}
Console.WriteLine();*/
/* try
{
XmlDataDocument xmldata = new XmlDataDocument();
xmldata.DataSet.ReadXml(Application.StartupPath + "\\ text.xml");
dataGridView1.DataSource = xmldata.DataSet;
dataGridView1.DataMember = "ENREGISTREMENT";
}
catch (Exception) { MessageBox.Show("Error"); }*/
}
private void nouveauToolStripMenuItem1_Click(object sender, EventArgs e)
{
/* try
{
XmlDataDocument xmldata = new XmlDataDocument();
xmldata.DataSet.ReadXml(Application.StartupPath + "\\Videos.xml");
dataGridView1.DataSource = xmldata.DataSet;
dataGridView1.DataMember = "Videos";
}
catch (Exception) { MessageBox.Show("Error"); }*/
/* DataSet ds = new DataSet();
ds.ReadXml("Videos.xml");
dataGridView1.DataSource = ds;*/
try
{
XmlReader xmlFile;
xmlFile = XmlReader.Create("Videos.xml", new XmlReaderSettings());
DataSet ds = new DataSet();
ds.ReadXml(xmlFile);
dataGridView1.DataSource = ds.Tables[0];
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
public void personnaliserToolStripMenuItem1_Click(object sender, EventArgs e)
{
//*******ajouter une nouvelle ligne**********************
String util = System.Environment.UserName;//recupére le nom du session en cour ca veut dire le nom de l utilusateur
String creat = getCreationTime(s).ToLongDateString();
String creatpeti = getCreationTime(s).ToShortDateString();
String tmpg = getCreationTime(s).ToLongTimeString();
String tmpp = getCreationTime(s).ToShortTimeString();
//String f;
String c7=dataGridView1.CurrentRow.Cells[5].Value.ToString();
//String c7 = dataGridView1.SelectedCells[4].Value.ToString();
string strFilename = "Videos.xml";
XmlDocument xmlDoc = new XmlDocument();
try
{
if (File.Exists(strFilename))
{
xmlDoc.Load(strFilename);
XmlElement elmRoot = xmlDoc.DocumentElement;
XmlElement elmNew = xmlDoc.CreateElement("Video");
elmRoot.AppendChild(elmNew);
elmRoot = xmlDoc.DocumentElement;
elmNew = xmlDoc.CreateElement("FICHIER");
XmlText txtVideo = xmlDoc.CreateTextNode(s);
elmRoot.LastChild.AppendChild(elmNew);
elmRoot.LastChild.LastChild.AppendChild(txtVideo);
elmNew = xmlDoc.CreateElement("TITRE");
txtVideo = xmlDoc.CreateTextNode(f);
elmRoot.LastChild.AppendChild(elmNew);
elmRoot.LastChild.LastChild.AppendChild(txtVideo);
elmNew = xmlDoc.CreateElement("DATECREATION");
txtVideo = xmlDoc.CreateTextNode(creat);
elmRoot.LastChild.AppendChild(elmNew);
elmRoot.LastChild.LastChild.AppendChild(txtVideo);
elmNew = xmlDoc.CreateElement("HEUREDERNIERACCÉES");
txtVideo = xmlDoc.CreateTextNode(creatpeti);
elmRoot.LastChild.AppendChild(elmNew);
elmRoot.LastChild.LastChild.AppendChild(txtVideo);
elmNew = xmlDoc.CreateElement("UTILISATEUR");
txtVideo = xmlDoc.CreateTextNode(util);
elmRoot.LastChild.AppendChild(elmNew);
elmRoot.LastChild.LastChild.AppendChild(txtVideo);
elmNew = xmlDoc.CreateElement("COPIE");
txtVideo = xmlDoc.CreateTextNode(c7);
elmRoot.LastChild.AppendChild(elmNew);
elmRoot.LastChild.LastChild.AppendChild(txtVideo);
xmlDoc.Save(strFilename);
}
}
catch (Exception j)
{
MessageBox.Show(j.Message);
}
Console.WriteLine();
//dataGridView1.Refresh();
}
//******************************** suite suppression***********************************
//**************************************************************************
private void optionsToolStripMenuItem1_Click(object sender, EventArgs e)
{
string strFilename = "Videos.xml";
bool blnFlag = false;
XmlDocument objXMLDoc = new XmlDocument();
objXMLDoc.Load(Application.StartupPath + "/videos.xml");
//XmlDocument objXMLDoc = ReadXML();
XmlNodeList lstMovies = objXMLDoc.ChildNodes;
try
{
foreach (XmlNode objNode in lstMovies)
{
foreach (XmlNode moviesnode in objNode.ChildNodes)
{
XmlNodeList MovieDetaill = moviesnode.ChildNodes;
foreach (XmlNode MovieDetaillsub in MovieDetaill)
{
if (MovieDetaillsub.Name.ToUpper().Equals("COPIE") && MovieDetaillsub.InnerText.Trim().Equals(dataGridView1.SelectedRows[0].Cells[5].ToString()))
{
objNode.RemoveChild(moviesnode);
blnFlag = true;
break;
}
}
}
if (blnFlag)
break;
}
if (blnFlag)
dataGridView1.Rows.Remove(dataGridView1.SelectedRows[0]);
MessageBox.Show("aaaa");
//Save XML
objXMLDoc.Save(Application.StartupPath + "/videos.xml");
}
catch (Exception j)
{
MessageBox.Show(j.Message);
}
//***********************************************************************
/* string strFilename = "Videos.xml";
bool blnFlag = false;
XmlDocument objXMLDoc = new XmlDocument();
objXMLDoc.Load(Application.StartupPath + "/videos.xml");
//XmlDocument objXMLDoc = ReadXML();
XmlNodeList lstMovies = objXMLDoc.ChildNodes;
try
{
foreach (XmlNode objNode in lstMovies)
{
foreach (XmlNode moviesnode in objNode.ChildNodes)
{
XmlNodeList MovieDetaill = moviesnode.ChildNodes;
if (MovieDetaill[0].InnerText == this.dataGridView1.SelectedRows[0].Cells[5].ToString())
MessageBox.Show("aaaa");
{
objNode.RemoveChild(moviesnode);
blnFlag = true;
break;
}
}
if (blnFlag)
break;
}
//Save XML
objXMLDoc.Save(Application.StartupPath + "/videos.xml");
}
catch (Exception j)
{
MessageBox.Show(j.Message);
}*/
//******************************************************************
/* String getsno;
try{
int i= dataGridView1.SelectedCells[0].RowIndex;
getsno = dataGridView1.Rows[i].Cells[0].Value.ToString();
//string path = "Videos.xml";
XmlDocument doc = new XmlDocument();
doc.Load(Application.StartupPath + "/videos.xml");
XmlNode node = doc.ChildNodes[0];
MessageBox.Show("aaaaaaaaaaaaaaaaaaaa");
// XmlNode node =doc.SelectSingleNode(dataGridView1.SelectedRows[2].Cells[2].Value.ToString());
//this.dataGridView1.Rows.RemoveAt(this.dataGridView1.SelectedRows[0].Index);
this.dataGridView1.Rows.RemoveAt(this.dataGridView1.SelectedRows[0].Index);
node.ParentNode.RemoveChild(node);
doc.Save("Videos.xml");
MessageBox.Show("Selected Record Deleted Successfully");
}
catch (Exception j)
{
MessageBox.Show(j.Message);
}*/
//***************************** METHODE *********************************
/*string strFilename = "Videos.xml";
bool blnFlag = false;
XmlDocument objXMLDoc = new XmlDocument();
objXMLDoc.Load(Application.StartupPath + "/videos.xml");
//XmlDocument objXMLDoc = ReadXML();
XmlNodeList lstMovies = objXMLDoc.ChildNodes;
try
{
foreach (XmlNode objNode in lstMovies)
{
//XmlNodeList objNodeList = objNode.ChildNodes;
XmlNode objNodeList = objNode.ChildNodes[1];
foreach (XmlNode objInnerNode in objNodeList)
{
if (objInnerNode.Value != null)
{
if (objInnerNode.Value.ToString() == dataGridView1.SelectedRows[0].Cells[0].ToString())
{
objXMLDoc.RemoveChild(objNode);
blnFlag = true;
break;
}
}
}
if (blnFlag)
break;
}
//Save XML
objXMLDoc.Save(strFilename);
}
catch (Exception j)
{
MessageBox.Show(j.Message);
}*/
//************************************************************
/*String Io;
try{
DialogResult dr;
dr=MessageBox.Show("Voulez vous vraiment supprimer cet element","Attention",MessageBoxButtons.YesNo,MessageBoxIcon.Information);
if (dr == DialogResult.No)
{
return;
}
else
{
Io = (dataGridView1.SelectedRows[0].Cells[0].ToString());
XmlDocument Doc = new XmlDocument();
Doc.Load(Application.StartupPath + "\\Videos.xml");
XmlNode Node = Doc.SelectSingleNode("copie" + Io);
if (Node != null)
{
Doc.DocumentElement.RemoveChild(Node);
MessageBox.Show("suppression réeussite", "suppression", MessageBoxButtons.OK);
}
else { }
Doc.Save(Application.StartupPath + "\\Videos.xml");
}
}
catch (Exception j)
{
MessageBox.Show(j.Message);
}*/
//******************************* methoded*********************
/*DataGridViewCellEventArgs a;
if (a.RowIndex != -1)
{
//For Deleting following code
if (a.ColumnIndex == 0)
{
DataGridViewRow row = dataGridView1.Rows[a.RowIndex];
string acnum = row.Cells[3].Value.ToString();
string path = "Videos.xml";
XmlDocument doc = new XmlDocument();
doc.Load(path);
XmlNode node = doc.SelectSingleNode("/BankAccount_Details/BankAccount[AccountNumber='" + acnum + "']");
node.ParentNode.RemoveChild(node);
doc.Save(path);
MessageBox.Show("Selected Record Deleted Successfully");
}*/
}
/*******************methode autre*********************
string strFilename = "Videos.xml";
XmlDocument doc = new XmlDocument();
doc.Load("Videos.xml");
try{
XmlNodeList rowsToDelete =
doc.SelectNodes("dataGridView1.SelectedRows.ToString()");
foreach (XmlNode rowToDelete in rowsToDelete)
doc.DocumentElement.RemoveChild(rowToDelete);
//Save XML
doc.Save(strFilename);
}
catch (Exception j)
{
MessageBox.Show(j.Message);
}
//*********** suppresssion methode 3*****************
/* string strFilename = "Videos.xml";
bool blnFlag = false;
XmlDocument objXMLDoc = new XmlDocument();
objXMLDoc.Load(Application.StartupPath + "/videos.xml");
//XmlDocument objXMLDoc = ReadXML();
XmlNodeList lstMovies = objXMLDoc.GetElementsByTagName("video");
try
{
foreach (XmlNode objNode in lstMovies)
{
//XmlNodeList objNodeList = objNode.ChildNodes;
XmlNode objNodeList = objNode.ChildNodes[1];
foreach (XmlNode objInnerNode in objNodeList)
{
if (objInnerNode.InnerText == dataGridView1.SelectedRows[0].Cells[0].ToString())
{
objXMLDoc.DocumentElement.RemoveChild(objNode);
blnFlag = true;
break;
}
}
if (blnFlag)
break;
}
//Save XML
objXMLDoc.Save(strFilename);
}
catch (Exception j)
{
MessageBox.Show(j.Message);
}*/
//Display Movie List again
//***************
/* XmlDocument xDoc = new XmlDocument();
xDoc.Load(Application.StartupPath + "/releve.xml");
XmlNode rootNode = xDoc.DocumentElement;
XmlNode childNode;
//childNode = this.treeView1.SelectedNode;
rootNode.RemoveChild(childNode);
//rootNode.RemoveAll(); // supprime tous les releves
xDoc.Save(Application.StartupPath + "/releve.xml");
//this.treeView1.SelectedNode.Remove();*/
//*********supression autre methode ****************
/*String c0=dataGridView1.CurrentRow.Cells[5].Value.ToString();
String c1=dataGridView1.CurrentRow.Cells[5].Value.ToString();
String c2=dataGridView1.CurrentRow.Cells[5].Value.ToString();
String c3=dataGridView1.CurrentRow.Cells[5].Value.ToString();
String c4=dataGridView1.CurrentRow.Cells[5].Value.ToString();
String c5=dataGridView1.CurrentRow.Cells[5].Value.ToString();*/
//String c7 = dataGridView1.SelectedCells[4].Value.ToString();
/* string strFilename = "Videos.xml";
XmlDocument xmlDoc = new XmlDocument();
try
{
if (File.Exists(strFilename))
{
xmlDoc.Load(strFilename);
XmlElement elmRoot = xmlDoc.DocumentElement;
XmlElement elmNew = xmlDoc.CreateElement("Video");
elmRoot.AppendChild(elmNew);
elmRoot = xmlDoc.DocumentElement;
elmNew = xmlDoc.CreateElement("FICHIER");
XmlText txtVideo = xmlDoc.CreateTextNode(s);
xmlDoc.Save(strFilename);
}
}
catch (Exception j)
{
MessageBox.Show(j.Message);
}
Console.WriteLine();
dataGridView1.Refresh();*/
//********* supprtimer une ligne methode n 2**************************
/* string strFilename = "Videos.xml";
XmlDocument xmlDoc = new XmlDocument();
try
{
if (File.Exists(strFilename))
{
xmlDoc.Load(strFilename);
// Get a reference to the root node
XmlElement elmRoot = xmlDoc.DocumentElement;
// Create a list of the videos
XmlNodeList lstVideos = xmlDoc.GetElementsByTagName("Video");
// visit each video
/* foreach (XmlNode node in lstVideos)
{
// Within a video, create a list of its children
XmlNodeList lstChildren = node.ChildNodes;
// Visit each child node
foreach (XmlNode dir in lstChildren)
{
// If the child node is Bruce Beresford
if (dir.InnerText.Equals(dataGridView1.SelectedRows))
{
node.RemoveChild(dir);
// Save the file
xmlDoc.Save(strFilename);
// Stop
break;
}
}
}*/
/* }
}
catch (Exception j)
{
MessageBox.Show(j.Message);
}
Console.WriteLine();
dataGridView1.Refresh();*/
//***********************************************récuperer donner from form3*************************************************
internal void populate()
{
String a1 = text1;
String a2 = text2;
String a3 = text3;
String a4 = a1 + a2 + a3;
//MessageBox.Show(a4);
//******** opération dajout***
string strFilename = "Videos.xml";
XmlDocument xmlDoc = new XmlDocument();
try
{
if (File.Exists(strFilename))
{
xmlDoc.Load(strFilename);
// Get a reference to the root node
XmlElement elmRoot = xmlDoc.DocumentElement;
// Create a list of nodes whose name is Title
XmlNodeList lstTitles = xmlDoc.GetElementsByTagName("FICHIER");
// visit each node named Title
foreach (XmlNode node in lstTitles)
{
// When you get to a node, look for the element's value
// If you find an element whose value is Her Alibi
if (node.InnerText == a3)
{
// Create an element named Category
XmlElement elmNew = xmlDoc.CreateElement(a1);
// Create the text of the new element
XmlText txtCatetory = xmlDoc.CreateTextNode(a2);
// Get a reference to the parent of the node we have found
XmlNode elmParent = node.ParentNode;
// Add the new element to the node we found
elmParent.AppendChild(elmNew);
// Specify the text of the new node
elmParent.LastChild.AppendChild(txtCatetory);
// Save the file
xmlDoc.Save(strFilename);
}
}
}
Console.WriteLine();
}
catch (Exception j)
{
MessageBox.Show(j.Message);
}
}
void ajouterUnElementToolStripMenuItem_Click(object sender, EventArgs e)
{
// String ajout = "";
//string promptValue = Prompt.ShowDialog("Test", "123");
//String promptValue = Form3.ShowDialog("Test", "123");
Form3 frm = new Form3(this);
frm.Show();
//MessageBox.Show(aj);
//*****************************ajout dun element*******************
/*string strFilename = "Videos.xml";
XmlDocument xmlDoc = new XmlDocument();
try
{
if (File.Exists(strFilename))
{
xmlDoc.Load(strFilename);
XmlElement elmRoot = xmlDoc.DocumentElement;
XmlElement elmNew = xmlDoc.CreateElement("elemet nouveauuu");
XmlText txtVideo = xmlDoc.CreateTextNode("Basic Instinct");
elmRoot.AppendChild(elmNew);
elmRoot.LastChild.AppendChild(txtVideo);
xmlDoc.Save(strFilename);
}
Console.WriteLine();
//return 0;
}
catch (Exception j)
{
MessageBox.Show(j.Message);
}*/
//*********************** ajout 2*********************************
/* string strFilename = "Videos.xml";
XmlDocument xmlDoc = new XmlDocument();
try
{
if (File.Exists(strFilename))
{
xmlDoc.Load(strFilename);
// Get a reference to the root node
XmlElement elmRoot = xmlDoc.DocumentElement;
// Create a list of nodes whose name is Title
XmlNodeList lstTitles = xmlDoc.GetElementsByTagName("FICHIER");
// visit each node named Title
foreach (XmlNode node in lstTitles)
{
// When you get to a node, look for the element's value
// If you find an element whose value is Her Alibi
if (node.InnerText == "d.docx")
{
// Create an element named Category
XmlElement elmNew = xmlDoc.CreateElement("ak");
// Create the text of the new element
XmlText txtCatetory = xmlDoc.CreateTextNode("Comedy");
// Get a reference to the parent of the node we have found
XmlNode elmParent = node.ParentNode;
// Add the new element to the node we found
elmParent.AppendChild(elmNew);
// Specify the text of the new node
elmParent.LastChild.AppendChild(txtCatetory);
// Save the file
xmlDoc.Save(strFilename);
}
}
}
Console.WriteLine();
}
catch (Exception j)
{
MessageBox.Show(j.Message);
}*/
}
private void sommaireToolStripMenuItem1_Click(object sender, EventArgs e)
{
//MessageBox.Show(aj);
//*************ajout par utilisateur****************
/* string strNewModel = "";
try
{
Console.Write("Enter Car Model: ");
strNewModel = Console.ReadLine();
XmlDocument docXMLFile = new XmlDocument();
docXMLFile.Load("Videos.xml");
XmlElement nodRoot = docXMLFile.DocumentElement;
string allMyChildren = nodRoot.InnerText;
int indexNewModel =
allMyChildren.IndexOf("Video");
if (indexNewModel >= 0)
return;
else
{
XmlElement elmXML =
docXMLFile.CreateElement("Model");
XmlText txtXML =
docXMLFile.CreateTextNode("strNewModel");
docXMLFile.DocumentElement.AppendChild(elmXML);
docXMLFile.DocumentElement.LastChild.AppendChild(txtXML);
docXMLFile.Save("Videos.xml");
}
}
catch (Exception j)
{
MessageBox.Show(j.Message);
}*/
}
private void masquerUneLigneToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void supprimerUneColonneToolStripMenuItem_Click(object sender, EventArgs e)
{
}
}
//***************************** classe prompt*********************************
/*public static class Prompt:Form
{
public static string ShowDialog(string text, string caption)
{
Public String ajout;
Form prompt = new Form();
prompt.Width = 500;
prompt.Height = 200;
prompt.Text = caption;
Label textLabel = new Label() { Left = 50, Top = 20, Text = text };
TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 };
Button confirmation = new Button() { Text = "Ok", Left = 350, Width = 100, Top = 70 };
confirmation.Click += (sender, e) => { prompt.Close(); };
prompt.Controls.Add(confirmation);
prompt.Controls.Add(textLabel);
prompt.Controls.Add(textBox);
prompt.ShowDialog();
ajout = textBox.Text;
return textBox.Text;
}
}*/
} |