No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

MediabrolForm.cs

Description du code

MediabrolForm.cs est un fichier du projet BiblioBrol.
Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/src/.

Projet BiblioBrol :

Gestion de media en CSharp.

Pour plus d'infos, vous pouvez consulter la brève analyse.

Code source ou contenu du fichier

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using be.gaudry.bibliobrol.model.dao;
  9. using be.gaudry.bibliobrol.model;
  10. using be.gaudry.bibliobrol.view.utils;
  11. using be.gaudry.bibliobrol.view.dialogs;
  12. using be.gaudry.observer;
  13. using be.gaudry.view;
  14. using be.gaudry.view.utils;
  15.  
  16.  
  17. namespace be.gaudry.bibliobrol.view
  18. {
  19. public partial class MediabrolForm : MDIChildForm, IObserver, IMDIChild
  20. {
  21. #region constructors and declarations
  22. /// <summary>
  23. /// used to get the "mouse over cell" for the context menu
  24. /// </summary>
  25. private DataGridViewCellEventArgs mouseLocation;
  26. private BrolType brolType;
  27. private MediaBrol mediabrol;
  28. private const String BORROW_START = "Emprunter";
  29. private const String BORROW_STOP = "Rentrer";
  30. private List<DAOUtils.BORROW_FIELD> borrowFields;
  31. private BrolPropertiesForm brolPropertiesForm;
  32. private MediabrolPropertiesForm mediabrolPropertiesForm;
  33.  
  34. public MediabrolForm()
  35. {
  36. ModelAdapter.Instance.addObserver(this);
  37. Splasher.Status = "Initialisation des composants";
  38. brolPropertiesForm = new BrolPropertiesForm();
  39. mediabrolPropertiesForm = new MediabrolPropertiesForm();
  40. InitializeComponent();
  41. this.SuspendLayout();
  42. searchControl.setDataGridView(brolsDGV);
  43. Splasher.Status = "Initialisation des menus";
  44. addToolStrip(mediabrolTS);
  45. addToolStrip(borrowsTS);
  46. //BORROW_START = "Emprunter";
  47. //BORROW_STOP = "Rentrer";
  48. Splasher.Status = "Initialisation des emprunts";
  49. brolType = new BrolType(0, "Tous les types");
  50. initBorrowFields();
  51. mediaCB.DisplayMember = "Name";
  52. mediaCB.ValueMember = "Id";
  53. Splasher.Status = "Chargement du module d'exportation";
  54. importExportCtl.setBIblioItemForm(this);
  55. Splasher.Status ="Affichage des composants";
  56. this.ResumeLayout(false);
  57. }
  58.  
  59. #endregion
  60.  
  61. #region initializations
  62. private void initBorrowFields()
  63. {
  64. borrowFields = new List<DAOUtils.BORROW_FIELD>();
  65. borrowFields.Add(DAOUtils.BORROW_FIELD.borrower);
  66. borrowFields.Add(DAOUtils.BORROW_FIELD.comment);
  67. borrowFields.Add(DAOUtils.BORROW_FIELD.endDate);
  68. borrowFields.Add(DAOUtils.BORROW_FIELD.planDate);
  69. borrowFields.Add(DAOUtils.BORROW_FIELD.startDate);
  70. }
  71. #endregion
  72.  
  73. #region getters
  74. /// <summary>
  75. /// Ids of mediabrols displayed into left datagridview
  76. /// </summary>
  77. public List<int> MediabrolIds
  78. {
  79. get
  80. {
  81. List<int> ids = new List<int>();
  82. foreach (DataGridViewRow row in brolsDGV.Rows)
  83. {
  84. ids.Add((int)row.Cells["mbId"].Value);
  85. }
  86. return ids;
  87. }
  88. }
  89. /// <summary>
  90. /// Ids of brols displayed into left datagridview
  91. /// </summary>
  92. public List<int> BrolIds
  93. {
  94. get
  95. {
  96. List<int> ids = new List<int>();
  97. foreach (DataGridViewRow row in brolsDGV.Rows)
  98. {
  99. ids.Add((int)row.Cells["brolId"].Value);
  100. }
  101. return ids;
  102. }
  103. }
  104. #endregion
  105.  
  106. #region datagridview
  107. private void selectItem()
  108. {
  109. /*try
  110.   {
  111.   int id = (int)brolsDGV.Rows[mouseLocation.RowIndex].Cells["mbId"].Value;
  112.   mediabrol = ModelAdapter.loadMediaBrol(id, false);
  113.   fillMediaBrolInfos();
  114.   if (mainTC.SelectedTab.Name.Equals("borrowTP")) fillBorrowsDGV();
  115.   }
  116.   catch (Exception ex)
  117.   {
  118.   StaticObservable.notify(new Notification(Notification.VERBOSE.lowError, "Aucun media sélectionné", ex, this));
  119.   }*/
  120. selectItem((int)brolsDGV.Rows[mouseLocation.RowIndex].Cells["mbId"].Value);
  121. }
  122. private void selectItem(int id)
  123. {
  124. try
  125. {
  126. //int id = (int)brolsDGV.Rows[mouseLocation.RowIndex].Cells["mbId"].Value;
  127. mediabrol = ModelAdapter.loadMediaBrol(id, false);
  128. fillMediaBrolInfos();
  129. if (mainTC.SelectedTab.Name.Equals("borrowTP")) fillBorrowsDGV();
  130. startBorrowCMSTSMenuItem.Enabled = !mediabrol.Borrowed;
  131. startBorrowTSB.Enabled = !mediabrol.Borrowed;
  132. startBorrowTSMenuItem.Enabled = !mediabrol.Borrowed;
  133. stopBorrowCMSTSMenuItem.Enabled = mediabrol.Borrowed;
  134. stopBorrowTSB.Enabled = mediabrol.Borrowed;
  135. stopBorrowTSMenuItem.Enabled = mediabrol.Borrowed;
  136. }
  137. catch (Exception ex)
  138. {
  139. StaticObservable.notify(new Notification(Notification.VERBOSE.lowError, "Aucun media sélectionné", ex, this));
  140. }
  141. }
  142. private void mediabrolsDGV_SelectionChanged(object sender, EventArgs e)
  143. {
  144. try
  145. {
  146. selectItem((int)brolsDGV.CurrentRow.Cells["mbId"].Value);
  147. }
  148. catch (NullReferenceException) { }
  149. }
  150. private void mediabrolsDGV_CellClick(object sender, DataGridViewCellEventArgs e)
  151. {
  152. selectItem((int)brolsDGV.CurrentRow.Cells["mbId"].Value);
  153. }
  154. private void mediabrolsDGV_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
  155. {
  156. mouseLocation = e;
  157. }
  158.  
  159. private void mediabrolsDGVCMS_Opening(object sender, CancelEventArgs e)
  160. {
  161. if (mouseLocation.RowIndex < 0)
  162. {
  163. e.Cancel = true;
  164. }
  165. else
  166. {
  167. int id = (int)brolsDGV.Rows[mouseLocation.RowIndex].Cells["mbId"].Value;
  168. infoTSMenuItem.Text = String.Format(
  169. "Exemplaire {0}",
  170. id
  171. );
  172. if (mouseLocation.RowIndex != brolsDGV.CurrentRow.Index)
  173. {
  174. brolsDGV.CurrentRow.Selected = false;
  175. brolsDGV.Rows[mouseLocation.RowIndex].Selected = true;
  176. selectItem(id);
  177. }
  178. }
  179. }
  180. private void openWithTSMenuItem_Click(object sender, EventArgs e)
  181. {
  182. selectItem();
  183. mainTC.SelectedTab = mediabrolTP;
  184. }
  185.  
  186. private void onBrolInfo_Click(object sender, EventArgs e)
  187. {
  188. selectItem();
  189. if (mediabrol.Brol != null)
  190. {
  191. brolPropertiesForm.Brol = mediabrol.Brol;
  192. brolPropertiesForm.ShowDialog(this);
  193. }
  194. }
  195. private void onMediabrolInfo_Click(object sender, EventArgs e)
  196. {
  197. selectItem();
  198. if (mediabrol != null)
  199. {
  200. mediabrolPropertiesForm.MediaBrol = mediabrol;
  201. mediabrolPropertiesForm.ShowDialog(this);
  202. }
  203. }
  204. private void fillMediaBrolInfos()
  205. {
  206. bNameTB.Text = mediabrol.Name;
  207. bLocTB.Text = mediabrol.Localisation;
  208. bComTB.Text = mediabrol.Comment;
  209. mediaCB.SelectedIndex = -1;
  210. mediaCB.Items.Clear();
  211. mediaCB.Items.AddRange(ModelAdapter.loadMedias(mediabrol.Brol.BrolType.Id).ToArray());
  212. if (mediabrol.MediaType == null || mediabrol.MediaType.Id < 1)
  213. {
  214. mediaCB.SelectedIndex = -1;
  215. //editSpMediaCB.ResetText();
  216. mediaCB.Refresh();
  217. }
  218. else
  219. {
  220. mediaCB.SelectedItem = mediabrol.MediaType;
  221. }
  222. qualitiesAddCB.Items.Clear();
  223. qualitiesAddCB.Items.AddRange(ModelAdapter.loadQualities(mediabrol.Brol.BrolType).ToArray());
  224. qualitiesLB.Items.Clear();
  225. qualitiesLB.Items.AddRange(mediabrol.Qualities.ToArray());
  226. //qualitiesLB.DataSource = mediabrol.Qualities;
  227. brolInfoCtl.setBrol(mediabrol.Brol);
  228. fillOwnerFields();
  229. if (mediabrol.InsertionDate.Equals(new DateTime(0L)))
  230. {
  231. insertionDateDTP.Value = DateTime.Now;
  232. insertionDateDTP.Visible = false;
  233. insertionDateBtn.Visible = true;
  234. }
  235. else
  236. {
  237. insertionDateDTP.Value = mediabrol.InsertionDate;
  238. insertionDateDTP.Visible = true;
  239. insertionDateBtn.Visible = false;
  240. }
  241. }
  242.  
  243. private void fillOwnerFields()
  244. {
  245. ownerLastNameTB.Text = mediabrol.Owner.LastName;
  246. ownerFirstNameTB.Text = mediabrol.Owner.FirstName;
  247. ownerImg.ImageLocation = Img.getPersImgPath(mediabrol.Owner);
  248. }
  249.  
  250. #endregion
  251.  
  252. #region borrows
  253. /// <summary>
  254. /// Start borrow for only one mediabrol
  255. /// </summary>
  256. /// <param name="borrower"></param>
  257. private void defineBorrower(Person borrower)
  258. {
  259. ModelAdapter.startBorrow(mediabrol.Id, borrower.Id);
  260. }
  261. /// <summary>
  262. /// Start borrow for selected mediabrols
  263. /// </summary>
  264. /// <param name="borrower"></param>
  265. private void defineBorrowerMulti(Person borrower)
  266. {
  267. List<String> errors = new List<string>();
  268. foreach(DataGridViewRow row in brolsDGV.Rows)
  269. {
  270. if(!ModelAdapter.startBorrow((int)row.Cells["mbId"].Value, borrower.Id))
  271. {
  272. errors.Add((String)row.Cells[searchControl.TitleColumnId].Value);
  273. }
  274. }
  275. if(errors.Count>0)
  276. {
  277. StringBuilder str = new StringBuilder("Les ouvrages suivants n'ont pu être empruntés :\n");
  278. foreach (String s in errors)
  279. {
  280. str.AppendFormat("\n{0}", s);
  281. }
  282. DialogResult r = MessageBox.Show(
  283. this,
  284. str.ToString(),
  285. "Emprunts non réalisés",
  286. MessageBoxButtons.OK,
  287. MessageBoxIcon.Warning,
  288. MessageBoxDefaultButton.Button1);
  289. }
  290. }
  291. /// <summary>
  292. /// If this item is borrowed, set end date to now,
  293. /// else insert new row (set start date to now)
  294. /// and save modifications to the persistant layer.
  295. /// </summary>
  296. /// <param name="sender"></param>
  297. /// <param name="e"></param>
  298. private void borrowManageBtn_Click(object sender, EventArgs e)
  299. {
  300. if (mediabrol != null)
  301. {
  302. if (!mediabrol.Borrowed)
  303. {
  304. DiaSelectActor diaSelectPerson = new DiaSelectActor(new Person());
  305. diaSelectPerson.SelectedRole = ModelAdapter.getUserRole();
  306. if (brolsDGV.SelectedRows.Count > 1)
  307. {
  308. DialogResult q = MessageBox.Show(
  309. this,
  310. "Emprunter TOUS les exemplaires affichés ?\nNON pour emprunter seulement l'exemplaire sélectionné.",
  311. "Emprunts",
  312. MessageBoxButtons.YesNo,
  313. MessageBoxIcon.Question,
  314. MessageBoxDefaultButton.Button2
  315. );
  316. if (q == DialogResult.Yes)
  317. {
  318. diaSelectPerson.persSelected += new DiaSelectActor.SelectPersEventHandler(this.defineBorrowerMulti);
  319. }
  320. else
  321. {
  322. diaSelectPerson.persSelected += new DiaSelectActor.SelectPersEventHandler(this.defineBorrower);
  323. }
  324. }
  325. else
  326. {
  327. diaSelectPerson.persSelected += new DiaSelectActor.SelectPersEventHandler(this.defineBorrower);
  328. }
  329. diaSelectPerson.ShowDialog();
  330. //todo : prompt for plandate? and comment ?
  331. //todo : if borrower has yet other not closed borrows, send a warning
  332. }
  333. else
  334. {
  335. if (brolsDGV.SelectedRows.Count > 1)
  336. {
  337. DialogResult q = MessageBox.Show(
  338. this,
  339. "Retour d'emprunt pour TOUS les exemplaires affichés ?\nNON pour rentrer seulement l'exemplaire sélectionné.",
  340. "Retours d'emprunts",
  341. MessageBoxButtons.YesNo,
  342. MessageBoxIcon.Question,
  343. MessageBoxDefaultButton.Button2
  344. );
  345. if (q == DialogResult.Yes)
  346. {
  347. MessageBox.Show(
  348. this,
  349. "La méthode n'est pas encore implémentée pour les sélections multiples.",
  350. "Retours d'emprunts",
  351. MessageBoxButtons.OK,
  352. MessageBoxIcon.Information,
  353. MessageBoxDefaultButton.Button1
  354. );
  355. }
  356. else
  357. {
  358. stopBorrow();
  359. }
  360. }
  361. else
  362. {
  363. stopBorrow();
  364. }
  365. }
  366. fillBorrowsDGV();
  367. }
  368. else
  369. StaticObservable.notify(new Notification(Notification.VERBOSE.lowError, "Emprunts", "Aucun exemplaire sélectionné", this));
  370. }
  371. private void stopBorrow()
  372. {
  373. try
  374. {
  375. //ModelAdapter.stopBorrow((int)borrowsDGV.Rows[0].Cells["id"].Value);
  376. ModelAdapter.stopBorrow(mediabrol);
  377. //todo : prompt to enter comment...
  378. }
  379. catch (Exception ex)
  380. {
  381. StaticObservable.notify(new Notification(Notification.VERBOSE.lowError, "Sélection d'emprunt", "Aucun emprunt à rentrer sélectionné", ex, this));
  382. }
  383. }
  384. private void fillBorrowsDGV()
  385. {
  386. if (mediabrol != null && mediabrol.Id > 0)
  387. {
  388. borrowsDGV.DataSource = ModelAdapter.loadBorrows(mediabrol.Id, borrowFields);
  389. borrowsDGV.Visible = true;
  390. try
  391. {
  392. if (borrowsDGV.Rows.Count > 0 && borrowsDGV.Rows[0].Cells["endDate"].Value is DBNull)
  393. {
  394. borrowManageBtn.Image = global::be.gaudry.bibliobrol.Properties.Resources.brolBorrowClose;
  395. borrowManageBtn.Text = BORROW_STOP;
  396. }
  397. else
  398. {
  399. borrowManageBtn.Image = global::be.gaudry.bibliobrol.Properties.Resources.brolBorrowOpen;
  400. borrowManageBtn.Text = BORROW_START;
  401. }
  402. }
  403. catch (Exception ex2)
  404. {
  405. StaticObservable.notify(new Notification(Notification.VERBOSE.error, "Sélection d'emprunt", ex2, this));
  406. }
  407. fillSelectedBorrowInfos();
  408. }
  409. }
  410. /// <summary>
  411. /// Fill the form with infos from the selected borrow into borrowsDGV
  412. /// </summary>
  413. private void fillSelectedBorrowInfos()
  414. {
  415. String info = "";
  416. String planDate = "Non spécifié";
  417. if (borrowsDGV.Rows.Count > 0)
  418. {
  419. try
  420. {
  421. if (!(borrowsDGV.SelectedRows[0].Cells["comment"].Value is DBNull))
  422. info = (String)borrowsDGV.SelectedRows[0].Cells["comment"].Value;
  423.  
  424. if (!(borrowsDGV.SelectedRows[0].Cells["planDate"].Value is DBNull))
  425. planDate = ((DateTime)borrowsDGV.SelectedRows[0].Cells["planDate"].Value).ToShortDateString();
  426. }
  427. catch (Exception ex)
  428. {
  429. StaticObservable.notify(new Notification(Notification.VERBOSE.error, "Sélection d'emprunt", ex, this));
  430. }
  431. }
  432. borrowInfoRTB.Text = info;
  433. borrowPLanDateInfoLbl.Text = planDate;
  434. }
  435. private void borrowsDGV_CellClick(object sender, DataGridViewCellEventArgs e)
  436. {
  437. fillSelectedBorrowInfos();
  438. }
  439.  
  440. private void startBorrowTSMenuItem_Click(object sender, EventArgs e)
  441. {
  442. borrowManageBtn_Click(sender, e);
  443. }
  444.  
  445. private void stopBorrowCMSTSMenuItem_Click(object sender, EventArgs e)
  446. {
  447. borrowManageBtn_Click(sender, e);
  448. }
  449. #endregion
  450.  
  451. #region form
  452. private void BIblioItemForm_Enter(object sender, EventArgs e)
  453. {
  454. this.Icon = global::be.gaudry.bibliobrol.Properties.Resources.mediabrolIcon;
  455. //this.Icon = Icon.FromHandle(global::BiblioBrol.Properties.Resources.mediabrol_small.GetHicon());
  456. }
  457.  
  458. #endregion
  459.  
  460. #region qualities
  461.  
  462. private void qualityAddBtn_Click(object sender, EventArgs e)
  463. {
  464. qualitiesAddCB.Visible = true;
  465. }
  466. private void qualitiesAddCB_SelectedIndexChanged(object sender, EventArgs e)
  467. {
  468. if (qualitiesAddCB.SelectedItem != null)
  469. {
  470. Quality q = (Quality)qualitiesAddCB.SelectedItem;
  471. if (!qualitiesLB.Items.Contains(q))
  472. {
  473. q.Status = STATUS.toAdd;
  474. qualitiesLB.Items.Add(q);
  475. }
  476. else
  477. {
  478. StaticObservable.notify(new Notification(Notification.VERBOSE.error, "La caractéristique " + q + " est déjà présente dans la liste", this));
  479. }
  480. }
  481. qualitiesAddCB.Visible = false;
  482. }
  483.  
  484. private void qualitiesLB_SelectedIndexChanged(object sender, EventArgs e)
  485. {
  486. if (qualitiesLB.SelectedIndex >= 0)
  487. qualityRemBtn.Enabled = true;
  488. }
  489.  
  490. private void qualityRemBtn_Click(object sender, EventArgs e)
  491. {
  492. if (qualitiesLB.SelectedItem != null)
  493. {
  494. Quality q = (Quality)qualitiesLB.SelectedItem;
  495.  
  496. q.Status = STATUS.toDelete;
  497. editCategoriesLB.Refresh();
  498. qualityRemBtn.Enabled = false;
  499. }
  500. }
  501.  
  502. private void qualitiesLB_DrawItem(object sender, DrawItemEventArgs e)
  503. {
  504. if (e.Index >= 0)
  505. {
  506. ListBox listBox = (ListBox)sender;
  507. Quality q = (Quality)listBox.Items[e.Index];
  508. Brush brush;//forecolor
  509. Brush selBrushBkgnd;//background color
  510. switch (q.Status)
  511. {
  512. case STATUS.toAdd:
  513. brush = Brushes.ForestGreen;
  514. selBrushBkgnd = Brushes.LightGray;
  515. break;
  516. case STATUS.toDelete:
  517. brush = Brushes.Crimson;
  518. selBrushBkgnd = Brushes.Beige;
  519. break;
  520. default:
  521. brush = Brushes.Black;
  522. selBrushBkgnd = Brushes.White;
  523. break;
  524. }
  525. //selected item drawing : invert colors
  526. if (((e.State & DrawItemState.Selected) == DrawItemState.Selected))
  527. {
  528. Brush temp = (brush.Equals(Brushes.Black)) ? Brushes.SteelBlue : brush;
  529. brush = selBrushBkgnd;
  530. selBrushBkgnd = temp;
  531. }
  532. else
  533. selBrushBkgnd = Brushes.White;
  534. e.Graphics.FillRectangle(selBrushBkgnd, e.Bounds);
  535. e.Graphics.DrawString(q.ToString(), listBox.Font, brush, e.Bounds.X, e.Bounds.Y);
  536. }
  537. }
  538. #endregion
  539.  
  540. #region misceleanous mediabrol fct
  541.  
  542. private void mainTC_SelectedIndexChanged(object sender, EventArgs e)
  543. {
  544. switch (mainTC.SelectedTab.Name)
  545. {
  546. case "borrowTP":
  547. //todo : fill only the first time
  548. fillBorrowsDGV();
  549. enableBorrowsActions(true);
  550. enableMediabrolActions(false);
  551. enableSearchAction(false);
  552. break;
  553. case "searchTP":
  554. enableBorrowsActions(false);
  555. enableMediabrolActions(false);
  556. enableSearchAction(true);
  557. break;
  558. case "infoTP":
  559. enableBorrowsActions(false);
  560. enableMediabrolActions(false);
  561. enableSearchAction(false);
  562. break;
  563. case "mediabrolTP":
  564. enableBorrowsActions(false);
  565. enableMediabrolActions(true);
  566. enableSearchAction(false);
  567. break;
  568. case "exportTP":
  569. enableBorrowsActions(false);
  570. enableMediabrolActions(false);
  571. enableSearchAction(false);
  572. break;
  573. }
  574.  
  575. }
  576.  
  577. private void enableSearchAction(bool enabled)
  578. {
  579. showSearchResultTSB.Enabled = enabled;
  580. }
  581.  
  582. private void enableMediabrolActions(bool enabled)
  583. {
  584. saveMediabrolTSB.Enabled = enabled;
  585. saveMediabrolTSMenuItem.Enabled = enabled;
  586. deleteMediabrolTSB.Enabled = enabled;
  587. deleteMediabrolTSMenuItem.Enabled = enabled;
  588. }
  589.  
  590. private void enableBorrowsActions(bool enabled)
  591. {
  592. startBorrowTSB.Enabled = enabled;
  593. startBorrowTSMenuItem.Enabled = enabled;
  594. stopBorrowTSB.Enabled = enabled;
  595. stopBorrowTSMenuItem.Enabled = enabled;
  596. cleanBorrowTSB.Enabled = enabled;
  597. cleanBorrowTSMenuItem.Enabled = enabled;
  598. cleanAllBorrowsTSB.Enabled = enabled;
  599. cleanAllBorrowsTSMenuItem.Enabled = enabled;
  600. editBorrowTSB.Enabled = enabled;
  601. editBorrowTSMenuItem.Enabled = enabled;
  602. }
  603. private void setOwner(Person owner)
  604. {
  605. mediabrol.Owner = owner;
  606. fillOwnerFields();
  607. }
  608. private void selectPersonBtn_Click(object sender, EventArgs e)
  609. {
  610. DiaSelectActor diaSelectPerson = new DiaSelectActor(new Person());
  611. diaSelectPerson.persSelected += new DiaSelectActor.SelectPersEventHandler(setOwner);
  612. diaSelectPerson.ShowDialog();
  613. }
  614. private void insertionDateBtn_Click(object sender, EventArgs e)
  615. {
  616. insertionDateBtn.Visible = false;
  617. insertionDateDTP.Visible = true;
  618. }
  619.  
  620. private void remAllSelectedMediabrolsBtn_Click(object sender, EventArgs e)
  621. {
  622. DialogResult r = MessageBox.Show(
  623. this,
  624. "Supprimer l'ensemble des exemplaires affichés dans le panneau de gauche ?",
  625. "Suppression des exemplaires",
  626. MessageBoxButtons.YesNo,
  627. MessageBoxIcon.Question,
  628. MessageBoxDefaultButton.Button1);
  629. if (r == DialogResult.Yes)
  630. {
  631. DialogResult r2 = MessageBox.Show(
  632. this,
  633. "Supprimer les ouvrages en même temps que les exemplaires ?",
  634. "Suppression des exemplaires",
  635. MessageBoxButtons.YesNo,
  636. MessageBoxIcon.Question,
  637. MessageBoxDefaultButton.Button2);
  638.  
  639. MediaBrol mediabrolToDelete = new MediaBrol();
  640. String title;
  641. foreach (DataGridViewRow row in brolsDGV.Rows)
  642. {
  643. try
  644. {
  645. title = (String)row.Cells[searchControl.TitleColumnId].Value;
  646. }
  647. catch (Exception)
  648. {
  649. title = "";
  650. }
  651. ModelAdapter.deleteMediaBrol((int)row.Cells[0].Value, title, (r2 == DialogResult.Yes));
  652. }
  653. }
  654. }
  655. #endregion
  656.  
  657. #region manage mediabrol
  658.  
  659. private void setMediabrolFromForm()
  660. {
  661. mediabrol.Name = bNameTB.Text;
  662. mediabrol.Localisation = bLocTB.Text;
  663. mediabrol.Comment = bComTB.Text;
  664. mediabrol.MediaType = (Media)mediaCB.SelectedItem;
  665. mediabrol.Qualities.Clear();
  666. foreach (Object oQuality in qualitiesLB.Items)
  667. {
  668. try
  669. {
  670. mediabrol.Qualities.Add((Quality)oQuality);
  671. }
  672. catch (Exception cce)
  673. {
  674. StaticObservable.notify(new Notification(Notification.VERBOSE.error, "Impossible de charger les caractéristiques depuis le formulaire", cce, this));
  675. }
  676. }
  677.  
  678. mediabrol.InsertionDate = insertionDateDTP.Value;
  679. //mediabrol.Owner
  680. }
  681. #endregion
  682.  
  683. #region search
  684.  
  685. private void refreshResults_Click(object sender, EventArgs e)
  686. {
  687. if (this.Visible) searchControl.displaySearchResults();
  688. }
  689. #endregion
  690.  
  691. #region IObserver Membres
  692.  
  693. public void update(Notification notification)
  694. {
  695. if (autoRefreshResultsTsMi.Checked && notification.Level.Equals(Notification.VERBOSE.modified))
  696. {
  697. searchControl.displaySearchResults();
  698. }
  699. }
  700.  
  701. #endregion
  702.  
  703. #region actions
  704. private void searchMediabrolAction(object sender, EventArgs e)
  705. {
  706. mainTC.SelectedIndex = 0;
  707. this.Focus();
  708. }
  709.  
  710. private void deleteMediabrolAction(object sender, EventArgs e)
  711. {
  712. DialogResult dr = MessageBox.Show(
  713. this,
  714. string.Format("Confirmez-vous la suppression de l'exemplaire {0}?\nOuvrage de l'exemplaire : {1}.", mediabrol.Name, mediabrol.Brol.Title),
  715. "Suppression d'exemplaire",
  716. MessageBoxButtons.OKCancel,
  717. MessageBoxIcon.Question,
  718. MessageBoxDefaultButton.Button2
  719. );
  720. if (DialogResult.OK == dr)
  721. {
  722. ModelAdapter.deleteMediaBrol(mediabrol);
  723. //searchControl.showSearchResultAction(sender,e);
  724. this.Focus();
  725. }
  726. }
  727.  
  728. private void saveMediabrolAction(object sender, EventArgs e)
  729. {
  730.  
  731. DialogResult dr = MessageBox.Show(
  732. this,
  733. string.Format("Confirmez-vous la sauvegarde des modifications de l'exemplaire {0}?\nOuvrage de l'exemplaire : {1}.", mediabrol.Name, mediabrol.Brol.Title),
  734. "Sauvegarde d'exemplaire",
  735. MessageBoxButtons.OKCancel,
  736. MessageBoxIcon.Question,
  737. MessageBoxDefaultButton.Button2
  738. );
  739. if (DialogResult.OK == dr)
  740. {
  741. setMediabrolFromForm();
  742. ModelAdapter.updateMediaBrol(mediabrol);
  743. mediabrol = ModelAdapter.loadMediaBrol(mediabrol.Id, true);
  744. fillMediaBrolInfos();
  745. this.Focus();
  746. }
  747. }
  748.  
  749. /// <summary>
  750. /// Open new form to edit borrow infos.
  751. /// Give the selected borrow to the form.
  752. /// </summary>
  753. /// <param name="sender"></param>
  754. /// <param name="e"></param>
  755. private void borrowEditAction(object sender, EventArgs e)
  756. {
  757. //todo : fill with all infos
  758. Borrow borrow = null;
  759. try
  760. {
  761. borrow = ModelAdapter.loadBorrow((int)borrowsDGV.SelectedRows[0].Cells["id"].Value);
  762. }
  763. catch (Exception ex)
  764. {
  765. StaticObservable.notify(new Notification(Notification.VERBOSE.error, "Impossible de charger l'emprunt", ex, this));
  766. return;
  767. }
  768. EditBorrowForm editForm = new EditBorrowForm(borrow);
  769. DialogResult r = editForm.ShowDialog();
  770. //todo : prompt for plandate? and comment ?
  771. //todo : if borrower has yet other not closed borrows, send a warning
  772. if (r.Equals(DialogResult.OK))
  773. {
  774. ModelAdapter.updateBorrow(borrow);
  775. fillBorrowsDGV();
  776. }
  777. this.Focus();
  778. }
  779.  
  780. private void borrowRemAllAction(object sender, EventArgs e)
  781. {
  782. DialogResult r = MessageBox.Show(
  783. this,
  784. "Supprimer l'ensemble de l'historique des emprunts pour l'élément " + mediabrol.Name + "\nde [" + mediabrol.Brol.Title + "]",
  785. "Suppression de l'historique pour un élément",
  786. MessageBoxButtons.OKCancel,
  787. MessageBoxIcon.Question,
  788. MessageBoxDefaultButton.Button1);
  789. if (r == DialogResult.OK)
  790. {
  791. ModelAdapter.cleanBorrows(mediabrol.Id, true);
  792. fillBorrowsDGV();
  793. }
  794. this.Focus();
  795. }
  796.  
  797. private void borrowRemSelectedAction(object sender, EventArgs e)
  798. {
  799. DialogResult r = MessageBox.Show(
  800. this,
  801. "Supprimer cet emprunt de l'historique pour l'élément " + mediabrol.Name + "\nde [" + mediabrol.Brol.Title + "]",
  802. "Suppression d'un emprunt de l'historique",
  803. MessageBoxButtons.OKCancel,
  804. MessageBoxIcon.Information,
  805. MessageBoxDefaultButton.Button1);
  806. if (r == DialogResult.OK)
  807. {
  808. int selectedBorrowId = -1;
  809. if (!(borrowsDGV.SelectedRows[0].Cells["id"].Value is DBNull))
  810. selectedBorrowId = (int)borrowsDGV.SelectedRows[0].Cells["id"].Value;
  811. ModelAdapter.cleanBorrow(selectedBorrowId);
  812. fillBorrowsDGV();
  813. }
  814. this.Focus();
  815. }
  816. #endregion
  817.  
  818. #region save and print DGV actions
  819. private void printDGVAction(object sender, EventArgs e)
  820. {
  821. DgvFactory.print(brolsDGV, "Exemplaires de BiblioBrol", this);
  822. }
  823.  
  824. private void saveDGVAction(object sender, EventArgs e)
  825. {
  826. DgvFactory.save(brolsDGV, "Exemplaires de BiblioBrol", this);
  827. }
  828. #endregion
  829.  
  830. #region IMDIChild Members
  831.  
  832. public MenuStrip getMainMenuStrip()
  833. {
  834. return mainMenuStrip;
  835. }
  836.  
  837. #endregion
  838.  
  839.  
  840. }
  841. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/src/view/ 
IcôneNomTailleModification
IcôneNomTailleModification
| _ Répertoire parent0 octets1715800778 15/05/2024 21:19:38
| _wizards0 octets1541007184 31/10/2018 18:33:04
| _utils0 octets1541007184 31/10/2018 18:33:04
| _controls0 octets1541007178 31/10/2018 18:32:58
| _dialogs0 octets1541007183 31/10/2018 18:33:03
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/src/view/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .resx|.resxMediabrolForm.resx32.55 Ko31/10/2018 18:32:27-refusé-
Afficher le fichier .resx|.resxAWSForm.resx188.27 Ko31/10/2018 18:32:25-refusé-
Afficher le fichier .resx|.resxMainForm.resx6.07 Ko31/10/2018 18:32:27-refusé-
Afficher le fichier .resx|.resxConsoleForm.resx256.48 Ko31/10/2018 18:32:27-refusé-
Afficher le fichier .cs|.csAWSForm.Designer.cs23.45 Ko31/10/2018 18:32:25-refusé-
Afficher le fichier .cs|.csActorForm.cs9.09 Ko31/10/2018 18:32:25-refusé-
Afficher le fichier .cs|.csBiblioBrolAboutBox.Designer.cs11.22 Ko31/10/2018 18:32:25-refusé-
Afficher le fichier .cs|.csAWSForm.cs7.68 Ko31/10/2018 18:32:25-refusé-
Afficher le fichier .cs|.csBorrowsForm.cs1.66 Ko31/10/2018 18:32:25-refusé-
Afficher le fichier .cs|.csCopy of MainForm.Designer.cs16.91 Ko31/10/2018 18:32:27-refusé-
Afficher le fichier .cs|.csConsoleForm.Designer.cs2.71 Ko31/10/2018 18:32:26-refusé-
Afficher le fichier .cs|.csWebServiceForm.cs6.34 Ko31/10/2018 18:32:29-refusé-
Afficher le fichier .resx|.resxOldMainForm.resx58.06 Ko31/10/2018 18:32:28-refusé-
Afficher le fichier .cs|.csCopy of MainForm.cs30.81 Ko31/10/2018 18:32:26-refusé-
Afficher le fichier .resx|.resxActorForm.resx44.98 Ko31/10/2018 18:32:25-refusé-
Afficher le fichier .resx|.resxBorrowsForm.resx73.4 Ko31/10/2018 18:32:26-refusé-
Afficher le fichier .cs|.csMainForm.cs37.45 Ko31/10/2018 18:32:27-refusé-
Afficher le fichier .resx|.resxWebServiceForm.resx9.71 Ko31/10/2018 18:32:29-refusé-
Afficher le fichier .cs|.csMainForm.Designer.cs7.16 Ko31/10/2018 18:32:27-refusé-
Afficher le fichier .cs|.csBorrowsForm.Designer.cs10.51 Ko31/10/2018 18:32:25-refusé-
Afficher le fichier .cs|.csTasksForm.cs389 octets31/10/2018 18:32:28-refusé-
Afficher le fichier .resx|.resxBiblioBrolAboutBox.resx5.68 Ko31/10/2018 18:32:25-refusé-
Afficher le fichier .cs|.csBrolForm.cs25.87 Ko31/10/2018 18:32:26-refusé-
Afficher le fichier .cs|.csWebServiceForm.Designer.cs13.12 Ko31/10/2018 18:32:29-refusé-
Afficher le fichier .cs|.csMediabrolForm.Designer.cs142.05 Ko31/10/2018 18:32:27-refusé-
Afficher le fichier .cs|.csConsoleForm.cs2.79 Ko31/10/2018 18:32:26-refusé-
Afficher le fichier .cs|.csBrolForm.designer.cs41.73 Ko31/10/2018 18:32:26-refusé-
Afficher le fichier .cs|.csMediabrolForm.cs31.94 Ko31/10/2018 18:32:27-refusé-
Afficher le fichier .cs|.csStatsForm.Designer.cs11.59 Ko31/10/2018 18:32:28-refusé-
Afficher le fichier .cs|.csActorForm.Designer.cs28.26 Ko31/10/2018 18:32:25-refusé-
Afficher le fichier .cs|.csOldMainForm.Designer.cs83.98 Ko31/10/2018 18:32:28-refusé-
Afficher le fichier .cs|.csStatsForm.cs5 Ko31/10/2018 18:32:28-refusé-
Afficher le fichier .cs|.csBiblioBrolAboutBox.cs5.51 Ko31/10/2018 18:32:25-refusé-
Afficher le fichier .cs|.csOldMainForm.cs27.08 Ko31/10/2018 18:32:27-refusé-
Afficher le fichier .resx|.resxTasksForm.resx187.31 Ko31/10/2018 18:32:29-refusé-
Afficher le fichier .cs|.csTasksForm.Designer.cs2.26 Ko31/10/2018 18:32:28-refusé-
Afficher le fichier .resx|.resxBrolForm.resx45.52 Ko31/10/2018 18:32:26-refusé-
Afficher le fichier .resx|.resxCopy of MainForm.resx7.53 Ko31/10/2018 18:32:27-refusé-
Afficher le fichier .resx|.resxStatsForm.resx187.5 Ko31/10/2018 18:32:28-refusé-

Utilisation de l'explorateur de code

  • Navigation :
    • Un clic sur une icône de répertoire ouvre ce répertoire pour en afficher les fichiers.
    • Lorsque le répertoire en cours ne contient pas de sous-répertoires il est possible de remonter vers le répertoire parent.
    • La structure de répertoires en treetable (tableau en forme d'arborescence) n'est plus possibledans cette version.
    • Un clic sur une icône de fichier ouvre ce fichier pour en afficher le code avec la coloration syntaxique adaptée en fonction du langage principal utilisé dans le fichier.
  • Affichage :
    • Il est possible de trier les répertoires ou les fichiers selon certains critères (nom, taille, date).
  • Actions :
    • Les actions possible sur les fichiers dépendent de vos droits d'utilisateur sur le site. Veuillez activer le mode utilisateur pour activer les actions.

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 16/10/2009, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/cs-bibliobrol-source-rf-view//MediabrolForm.cs.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.