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
|
namespace AdvBase
{
public class FrmBase : System.Windows.Forms.Form
{
protected DataTable DtMain;
protected bool global_Permettre_Action = false;
private CurrencyManager Cr_local = null;
private ClsApplication App = null;
private string sNomtable="";
private Int32 usrcrt,crtdte,usrupd,upddte,objsup;
private System.Windows.Forms.ImageList img1;
protected System.Windows.Forms.ToolBar TbMain;
private System.Windows.Forms.ToolBarButton toolBarButton1;
private System.Windows.Forms.ToolBarButton toolBarButton2;
private System.Windows.Forms.ToolBarButton toolBarButton3;
private System.Windows.Forms.ToolBarButton toolBarButton4;
private System.Windows.Forms.ToolBarButton toolBarButton5;
private System.Windows.Forms.ToolBarButton toolBarButton6;
private System.Windows.Forms.ToolBarButton toolBarButton7;
private System.Windows.Forms.ToolBarButton toolBarButton8;
private System.Windows.Forms.ToolBarButton toolBarButton9;
private System.Windows.Forms.ToolBarButton toolBarButton10;
private System.Windows.Forms.ToolBarButton toolBarButton11;
private System.Windows.Forms.ToolBarButton toolBarButton12;
private System.Windows.Forms.ToolBarButton tbFiltre;
private System.Windows.Forms.ToolBarButton toolBarButton14;
private System.Windows.Forms.ToolBarButton tbSearch;
private System.Windows.Forms.ToolBarButton tbRefresh;
private System.Windows.Forms.ToolBarButton toolBarButton16;
protected System.Windows.Forms.ToolBarButton tbAdd;
protected System.Windows.Forms.ToolBarButton tbUpdate;
protected System.Windows.Forms.ToolBarButton tbDelete;
private System.Windows.Forms.ToolBarButton toolBarButton18;
private System.Windows.Forms.ToolBarButton tbTraitement;
private System.Windows.Forms.ToolBarButton tbEdition;
private System.Windows.Forms.ToolBarButton tbConsult;
private System.Windows.Forms.ToolBarButton toolBarButton15;
private System.Windows.Forms.ToolBarButton toolBarButton17;
private System.Windows.Forms.ToolBarButton toolBarButton19;
private System.Windows.Forms.ToolBarButton toolBarButton20;
private System.Windows.Forms.ToolBarButton toolBarButton21;
private System.Windows.Forms.ToolBarButton toolBarButton22;
private System.Windows.Forms.ToolBarButton toolBarButton23;
private System.Windows.Forms.ToolBarButton toolBarButton24;
private System.Windows.Forms.ToolBarButton toolBarButton25;
private System.Windows.Forms.ToolBarButton tbTri;
private System.Windows.Forms.ToolBarButton toolBarButton27;
private System.Windows.Forms.ToolBarButton tbFirst;
private System.Windows.Forms.ToolBarButton tbPrevious;
private System.Windows.Forms.ToolBarButton tbNext;
private System.Windows.Forms.ToolBarButton tbLast;
private System.Windows.Forms.ToolBarButton toolBarButton13;
private System.Windows.Forms.ToolBarButton tbMail;
private System.Windows.Forms.ToolBarButton tbImport;
private System.Windows.Forms.ToolBarButton tbStat;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox cboFiltre;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox cboTri;
protected System.Windows.Forms.GroupBox groupBox1;
protected System.Windows.Forms.TabControl TcMain;
protected System.Windows.Forms.TabPage TpDetail;
protected System.Windows.Forms.TabPage TpListe;
protected System.Windows.Forms.DataGrid dgListe;
protected System.Windows.Forms.TabPage TpGen;
private System.Windows.Forms.Label lblPos;
private System.ComponentModel.IContainer components;
public FrmBase()
{
// Cet appel est requis par le Concepteur de formulaires Windows.Forms.
InitializeComponent();
// TODO*: ajoutez les initialisations après l'appel à InitComponent
}
public FrmBase(string sTable,ref ClsApplication ap)
{
this.App = ap;
Thread.CurrentThread.CurrentUICulture = App.p_AppCulture;
//
// Requis pour la prise en charge du Concepteur Windows Forms
//
InitializeComponent();
//
// TODO : ajoutez le code du constructeur après l'appel à InitializeComponent
//
this.App = ap;
this.sNomtable = sTable;
//this.dgListe.DataSource = App.P_DataSet.Tables[sTable];
this.dgListe.DataSource = DtMain;
DtMain = App.P_DataSet.Tables[sTable];
//this.Cr_local = (CurrencyManager) this.BindingContext[App.P_DataSet.Tables[sNomtable]];
this.Cr_local = (CurrencyManager) this.BindingContext[DtMain];
this.dgListe.DataSource = DtMain;
//DtMain.ColumnChanged +=new DataColumnChangeEventHandler(DtMain_ColumnChanged);
//DtMain.RowChanged +=new DataRowChangeEventHandler(DtMain_RowChanged);
DtMain.RowChanged +=new DataRowChangeEventHandler(DtMain_RowChanged);
}
~FrmBase()
{
GC.SuppressFinalize(this);
this.Dispose();
}
#region Propriétés de la classe
public DataTable Table_Principale
{
get {return this.DtMain;}
}
#endregion
/// <summary>
/// Nettoyage des ressources utilisées.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
#region Code généré par le Concepteur de composants
/// <summary>
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
/// le contenu de cette méthode avec l'éditeur de code.
/// </summary>
private void InitializeComponent()
{
this.tbStat = new System.Windows.Forms.ToolBarButton();
this.label1 = new System.Windows.Forms.Label();
this.cboFiltre = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.cboTri = new System.Windows.Forms.ComboBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.TcMain = new System.Windows.Forms.TabControl();
this.TpDetail = new System.Windows.Forms.TabPage();
this.TpListe = new System.Windows.Forms.TabPage();
this.dgListe = new System.Windows.Forms.DataGrid();
this.TpGen = new System.Windows.Forms.TabPage();
this.lblPos = new System.Windows.Forms.Label();
this.TcMain.SuspendLayout();
this.TpListe.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgListe)).BeginInit();
this.TpGen.SuspendLayout();
this.SuspendLayout();
//
// img1
//
this.img1.ImageSize = new System.Drawing.Size(16, 16);
this.img1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("img1.ImageStream")));
this.img1.TransparentColor = System.Drawing.Color.Transparent;
//
// TbMain
//
this.TbMain.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
this.TbMain.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.TbMain.DropDownArrows = true;
this.TbMain.ImageList = this.img1;
this.TbMain.Location = new System.Drawing.Point(0, 0);
this.TbMain.Name = "TbMain";
this.TbMain.ShowToolTips = true;
this.TbMain.Size = new System.Drawing.Size(832, 73);
this.TbMain.TabIndex = 0;
this.TbMain.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.tb_ButtonClick);
//
// toolBarButton1
//
this.toolBarButton1.Enabled = false;
//
// toolBarButton2
//
this.toolBarButton2.Enabled = false;
//
// toolBarButton3
//
this.toolBarButton3.Enabled = false;
//
// toolBarButton10
//
this.toolBarButton10.Enabled = false;
//
// toolBarButton11
//
this.toolBarButton11.Enabled = false;
//
// toolBarButton12
//
this.toolBarButton12.Enabled = false;
this.toolBarButton12.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// tbFiltre
//
this.tbFiltre.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton;
this.tbFiltre.ToolTipText = "Gestion des filtres";
//
// toolBarButton14
//
this.toolBarButton14.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// tbSearch
//
this.tbSearch.ImageIndex = 1;
//
// tbRefresh
//
this.tbRefresh.ImageIndex = 9;
//
// toolBarButton16
//
this.toolBarButton16.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// tbAdd
//
this.tbAdd.ImageIndex = 18;
//
// tbUpdate
//
this.tbUpdate.ImageIndex = 0;
//
// tbDelete
//
this.tbDelete.ImageIndex = 12;
this.tbDelete.ToolTipText = "Supprimer l\'enregistrement";
//
// toolBarButton18
//
this.toolBarButton18.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// tbTraitement
//
this.tbTraitement.ImageIndex = 10;
this.tbTraitement.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton;
this.tbTraitement.ToolTipText = "Traitements";
//
// tbEdition
//
this.tbEdition.ImageIndex = 11;
this.tbEdition.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton;
this.tbEdition.ToolTipText = "Editions";
//
// tbConsult
//
this.tbConsult.ImageIndex = 15;
this.tbConsult.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton;
this.tbConsult.ToolTipText = "Consultations";
//
// toolBarButton15
//
this.toolBarButton15.Enabled = false;
this.toolBarButton15.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// toolBarButton17
//
this.toolBarButton17.Enabled = false;
//
// toolBarButton19
//
this.toolBarButton19.Enabled = false;
//
// toolBarButton20
//
this.toolBarButton20.Enabled = false;
//
// toolBarButton21
//
this.toolBarButton21.Enabled = false;
//
// toolBarButton22
//
this.toolBarButton22.Enabled = false;
//
// toolBarButton23
//
this.toolBarButton23.Enabled = false;
//
// toolBarButton24
//
this.toolBarButton24.Enabled = false;
//
// toolBarButton25
//
this.toolBarButton25.Enabled = false;
//
// tbTri
//
this.tbTri.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton;
this.tbTri.ToolTipText = "Gestion des tris";
//
// toolBarButton27
//
this.toolBarButton27.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// tbFirst
//
this.tbFirst.ImageIndex = 5;
this.tbFirst.ToolTipText = "Premier enregistrement";
//
// tbPrevious
//
this.tbPrevious.ImageIndex = 8;
this.tbPrevious.ToolTipText = "Enregistrement précédent";
//
// tbNext
//
this.tbNext.ImageIndex = 7;
this.tbNext.ToolTipText = "Enregistrement suivant";
//
// tbLast
//
this.tbLast.ImageIndex = 6;
this.tbLast.ToolTipText = "Dernier enregistrement";
//
// toolBarButton13
//
this.toolBarButton13.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// tbMail
//
this.tbMail.ImageIndex = 4;
this.tbMail.ToolTipText = "Envoi mail";
//
// tbImport
//
this.tbImport.ImageIndex = 17;
this.tbImport.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton;
this.tbImport.ToolTipText = "Gestion des imports - exports";
//
// tbStat
//
this.tbStat.ImageIndex = 16;
this.tbStat.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton;
this.tbStat.ToolTipText = "Gestion des statistiques";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(8, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(36, 16);
this.label1.TabIndex = 7;
this.label1.Text = "Filtre :";
//
// cboFiltre
//
this.cboFiltre.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboFiltre.Location = new System.Drawing.Point(48, 5);
this.cboFiltre.Name = "cboFiltre";
this.cboFiltre.Size = new System.Drawing.Size(208, 21);
this.cboFiltre.TabIndex = 0;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(568, 8);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(24, 16);
this.label2.TabIndex = 9;
this.label2.Text = "Tri :";
//
// cboTri
//
this.cboTri.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboTri.Location = new System.Drawing.Point(592, 5);
this.cboTri.Name = "cboTri";
this.cboTri.Size = new System.Drawing.Size(160, 21);
this.cboTri.TabIndex = 1;
//
// groupBox1
//
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top;
this.groupBox1.Location = new System.Drawing.Point(0, 73);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(832, 80);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1";
//
// TcMain
//
this.TcMain.Appearance = System.Windows.Forms.TabAppearance.FlatButtons;
this.TcMain.Controls.Add(this.TpDetail);
this.TcMain.Controls.Add(this.TpListe);
this.TcMain.Controls.Add(this.TpGen);
this.TcMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.TcMain.Location = new System.Drawing.Point(0, 153);
this.TcMain.Name = "TcMain";
this.TcMain.SelectedIndex = 0;
this.TcMain.Size = new System.Drawing.Size(832, 220);
this.TcMain.TabIndex = 2;
//
// TpDetail
//
this.TpDetail.Location = new System.Drawing.Point(4, 25);
this.TpDetail.Name = "TpDetail";
this.TpDetail.Size = new System.Drawing.Size(824, 191);
this.TpDetail.TabIndex = 0;
this.TpDetail.Text = "Détail";
//
// TpListe
//
this.TpListe.Controls.Add(this.dgListe);
this.TpListe.Location = new System.Drawing.Point(4, 25);
this.TpListe.Name = "TpListe";
this.TpListe.Size = new System.Drawing.Size(824, 191);
this.TpListe.TabIndex = 1;
this.TpListe.Text = "Liste";
//
// dgListe
//
this.dgListe.AlternatingBackColor = System.Drawing.Color.Bisque;
this.dgListe.DataMember = "";
this.dgListe.Dock = System.Windows.Forms.DockStyle.Left;
this.dgListe.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dgListe.Location = new System.Drawing.Point(0, 0);
this.dgListe.Name = "dgListe";
this.dgListe.ReadOnly = true;
this.dgListe.Size = new System.Drawing.Size(568, 191);
this.dgListe.TabIndex = 0;
//
// TpGen
//
this.TpGen.Controls.Add(this.lblPos);
this.TpGen.Location = new System.Drawing.Point(4, 25);
this.TpGen.Name = "TpGen";
this.TpGen.Size = new System.Drawing.Size(824, 191);
this.TpGen.TabIndex = 2;
this.TpGen.Text = "Informations générales";
//
// lblPos
//
this.lblPos.Dock = System.Windows.Forms.DockStyle.Bottom;
this.lblPos.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblPos.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(0)));
this.lblPos.Location = new System.Drawing.Point(0, 167);
this.lblPos.Name = "lblPos";
this.lblPos.Size = new System.Drawing.Size(824, 24);
this.lblPos.TabIndex = 0;
this.lblPos.Text = "0/0";
this.lblPos.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// FrmBase
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(832, 373);
this.Controls.Add(this.TcMain);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.cboTri);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.cboFiltre);
this.Controls.Add(this.TbMain);
this.Name = "FrmBase";
this.Load += new System.EventHandler(this.FrmBase_Load);
this.TcMain.ResumeLayout(false);
this.TpListe.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dgListe)).EndInit();
this.TpGen.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
#region Méthode
protected virtual void b_DataSource_Reserved(Boolean etat)
{
global_Permettre_Action = etat;
MessageBox.Show("Je passe dans le contrôle du datasource " + etat.ToString());
}
protected virtual void OnModeEnregistrementChanged(ModeEnCoursEventArgs e)
{
if (Ev_ModeEnregistrement != null)
{
Ev_ModeEnregistrement(this,e);
}
}
private void Appliquer_EtatEnregistrement()
{
ModeEnCoursEventArgs e = new ModeEnCoursEventArgs(ModeEnregistrement); // ((EModeEnregistrement) ModeEnregistrement);
ModeEnCoursEventArgs act = new ModeEnCoursEventArgs(ModeAction);
switch (ModeEnregistrement)
{
case EModeEnregistrement.Edition :
tbAdd.Enabled = false; tbUpdate.Enabled = false; tbDelete.Enabled = false;
tbFirst.Enabled = false; tbPrevious.Enabled = false; tbNext.Enabled = false; tbLast.Enabled = false;
tbSearch.Tag = "UPD"; tbSearch.ToolTipText = "Valider les modifications";tbSearch.ImageIndex = 19;
tbRefresh.Tag = "UPD"; tbRefresh.ToolTipText = "Annuler les modifications";tbRefresh.ImageIndex = 3;
OnModeEnregistrementChanged(e);
break;
case EModeEnregistrement.Nouveau :
tbAdd.Enabled = false; tbUpdate.Enabled = false; tbDelete.Enabled = false;
tbFirst.Enabled = false; tbPrevious.Enabled = false; tbNext.Enabled = false; tbLast.Enabled = false;
tbSearch.Tag = "ADD"; tbSearch.ToolTipText = "Valider l'ajout";tbSearch.ImageIndex = 19;
tbRefresh.Tag = "ADD"; tbRefresh.ToolTipText = "Annuler le nouvel enregistrement";tbRefresh.ImageIndex = 3;
//this.cr.EndCurrentEdit();
//this.cr.AddNew();
OnModeEnregistrementChanged(e);
break;
case EModeEnregistrement.Suppression :
tbAdd.Enabled = false; tbUpdate.Enabled = false; tbDelete.Enabled = false;
tbFirst.Enabled = false; tbPrevious.Enabled = false; tbNext.Enabled = false; tbLast.Enabled = false;
tbSearch.Tag = "DEL"; tbSearch.ToolTipText = "Valider la suppression";tbSearch.ImageIndex = 19;
tbRefresh.Tag = "DEL"; tbRefresh.ToolTipText = "Annuler la suppression";tbRefresh.ImageIndex = 3;
OnModeEnregistrementChanged(e);
break;
case EModeEnregistrement.Visualisation :
tbAdd.Enabled = true; tbUpdate.Enabled = true; tbDelete.Enabled = true;
tbFirst.Enabled = true; tbPrevious.Enabled = true; tbNext.Enabled = true; tbLast.Enabled = true;
tbSearch.Tag = "VIS"; tbSearch.ToolTipText = "Rechercher";tbSearch.ImageIndex = 1;
tbRefresh.Tag = "VIS"; tbRefresh.ToolTipText = "Rafrîchir";tbRefresh.ImageIndex = 9;
OnModeEnregistrementChanged(e);
ModeAction = EModeAction.Aucune;
OnModeActionValidate_Cancel(act);
if (Cr_local != null)
{
//cr.Position = (int) cr.Current;
}
break;
}
}
protected virtual void tb_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
ModeEnCoursEventArgs em = new ModeEnCoursEventArgs(ModeEnregistrement);
ModeEnCoursEventArgs act = new ModeEnCoursEventArgs(ModeAction);
switch (TbMain.Buttons.IndexOf(e.Button))
{
case 12 : // Bouton du filtre
break;
case 14 : // Bouton recherche et add
if (tbSearch.Tag.ToString() != "VIS")
{
if (tbSearch.Tag.ToString() == "DEL")
{
ModeAction = EModeAction.ValiderSuppression;
OnModeActionValidate_Cancel(act);
this.Cr_local.RemoveAt(this.Cr_local.Position);
}
if (tbSearch.Tag.ToString() == "ADD")
{
ModeAction = EModeAction.ValiderAjout;
OnModeActionValidate_Cancel(act);
MessageBox.Show("Je valide le nouvel enregistrement");
FrmBase_PositionChanged(this,null);
}
if (tbSearch.Tag.ToString() == "UPD")
{
ModeAction = EModeAction.ValiderModification;
OnModeActionValidate_Cancel(act);
}
ModeEnregistrement = EModeEnregistrement.Visualisation;
Appliquer_EtatEnregistrement();
}
break;
case 15 : // Bouton Rafraîchir et annuler
if (tbRefresh.Tag.ToString() != "VIS")
{
this.Cr_local.CancelCurrentEdit();
//OnModeEnregistrementValidate_Cancel(em);
ModeEnregistrement = EModeEnregistrement.Visualisation;
Appliquer_EtatEnregistrement();
}
else
{
}
break;
case 17 : // Bouton ajouter
//this.BindingContext[DtMain];
if (!global_Permettre_Action)
{
ModeEnregistrement = EModeEnregistrement.Nouveau;
Cr_local.EndCurrentEdit();
Cr_local.AddNew();
Appliquer_EtatEnregistrement();
FrmBase_PositionChanged(this,null);
}
break;
case 18 : // Bouton Modifier
if (!global_Permettre_Action)
{
ModeEnregistrement = EModeEnregistrement.Edition;
Appliquer_EtatEnregistrement();
}
break;
case 19 : // Bouton supprimer
if (!global_Permettre_Action)
{
ModeEnregistrement = EModeEnregistrement.Suppression;
Appliquer_EtatEnregistrement();
}
break;
case 21 : // Bouton de traitement
break;
case 22 : // Bouton des éditions
break;
case 23 : //Bouton des consultations
break;
case 33 : // Bouton des tris
break;
case 35 : // Premier enregistrement
MoveFirst();
break;
case 36 : // Enregistrement précédent
MovePrevious();
break;
case 37 : // Prochain enregistrement
MoveNext();
break;
case 38 : // Dernier enregistrement
MoveLast();
break;
case 41 : // Bouton des imports - export
break;
case 42 : // Bouton des stats
break;
}
}
protected virtual void MoveNext()
{
// Increment the Position property value by one.
this.Cr_local.Position += 1;
}
protected virtual void MovePrevious()
{
// Decrement the Position property value by one.
if (this.Cr_local.Count > 0)
{
this.Cr_local.Position -= 1;
}
}
protected virtual void MoveFirst()
{
// Go to the first item in the list.
this.Cr_local.Position = 0;
}
protected virtual void MoveLast()
{
// Go to the last row in the list.
this.Cr_local.Position = Cr_local.Count - 1;
}
protected virtual void OnModeEnregistrementAction(ModeEnCoursEventArgs e)
{
if (Ev_ModeEnregistrement != null)
{
Ev_ModeEnregistrement(this,e);
}
}
protected virtual void OnModeActionValidate_Cancel(ModeEnCoursEventArgs e)
{
if (Ev_Action != null)
{
Ev_Action(this,e);
}
}
public void BooleanToSmallInt(object sender, ConvertEventArgs cevent)
{
// The method converts only to string type. Test this using the DesiredType.
if (cevent.DesiredType != typeof(bool)) return;
// Use the ToString method to format the value as currency ("c").
cevent.Value = ((bool) cevent.Value);
}
public void SmallIntToBoolean(object sender, ConvertEventArgs cevent)
{
// ' The method converts only to decimal type.
if (cevent.DesiredType != typeof(Int16)) return;
// Converts the string back to decimal using the static ToDecimal method.
cevent.Value = Convert.ToInt16(cevent.Value);
}
#endregion
private void FrmBase_Load(object sender, System.EventArgs e)
{
this.TcMain.SelectedTab = TpGen;
//if (this.BindingContext[App.P_DataSet.Tables[sNomtable]] != null)
if (this.BindingContext[DtMain] != null)
{
//this.BindingContext[App.P_DataSet.Tables[sNomtable]].PositionChanged +=new EventHandler(FrmBase_PositionChanged);
this.BindingContext[DtMain].PositionChanged +=new EventHandler(FrmBase_PositionChanged);
ModeEnregistrement = EModeEnregistrement.Visualisation;
Appliquer_EtatEnregistrement();
}
}
protected virtual void FrmBase_PositionChanged(object sender, EventArgs e)
{
lblPos.Text = (Cr_local.Position + 1).ToString() + "/" + Cr_local.Count.ToString();
}
private void DtMain_RowChanged(object sender, DataRowChangeEventArgs e)
{
/*MessageBox.Show(e.Action.ToString() + " action en cours");
MessageBox.Show(DtMain.Rows.Count.ToString());
*/
switch (e.Action)
{
case DataRowAction.Add :
e.Row["USRCRT"] = this.App.p_AppNomUtilisateur;
e.Row["CRTDTE"]= DateTime.Now.ToShortDateString();
e.Row["OBJSUP"]= 0;
e.Row.AcceptChanges();
break;
case DataRowAction.Change :
//if (ModeEnregistrement == EModeEnregistrement.Edition)
//{
e.Row.BeginEdit();
e.Row["USRUPD"] = this.App.p_AppNomUtilisateur;
e.Row["UPDDTE"]= DateTime.Now.ToShortDateString();
e.Row.EndEdit();
//e.Row.AcceptChanges();
//}
break;
case DataRowAction.Delete :
e.Row["USRUPD"] = this.App.p_AppNomUtilisateur;
e.Row["UPDDTE"]= DateTime.Now.ToShortDateString();
e.Row["OBJSUP"]= 1;
e.Row.AcceptChanges();
break;
}
}
} |
Partager