735 lines
28 KiB
C#
735 lines
28 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Collections;
|
|
using System.ComponentModel;
|
|
using System.Windows.Forms;
|
|
using GZTW.AyaNova.BLL;
|
|
using Infragistics.Win;
|
|
using Infragistics.Win.UltraWinGrid;
|
|
using log4net;
|
|
using System.Data;
|
|
using System.Text;
|
|
|
|
|
|
namespace AyaNova
|
|
{
|
|
/// <summary>
|
|
/// Summary description for MemoComposerForm.
|
|
/// </summary>
|
|
public class MemoComposerForm : System.Windows.Forms.Form
|
|
{
|
|
// Create a logger for use in this class
|
|
//case 1039 private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
private System.Windows.Forms.CheckBox ckIsDirty;
|
|
private System.Windows.Forms.ErrorProvider ErrorProvider;
|
|
private System.Windows.Forms.Panel panelLeft;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsManager tbManager;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _MemoComposerForm_Toolbars_Dock_Area_Left;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _MemoComposerForm_Toolbars_Dock_Area_Right;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _MemoComposerForm_Toolbars_Dock_Area_Top;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _MemoComposerForm_Toolbars_Dock_Area_Bottom;
|
|
private Infragistics.Win.UltraWinEditors.UltraTextEditor edSubject;
|
|
private Infragistics.Win.Misc.UltraLabel lblSubject;
|
|
private Infragistics.Win.Misc.UltraLabel lblMessage;
|
|
private Infragistics.Win.UltraWinEditors.UltraTextEditor edMessage;
|
|
private Infragistics.Win.Misc.UltraButton btnTo;
|
|
private Infragistics.Win.UltraWinEditors.UltraTextEditor edTo;
|
|
private System.ComponentModel.IContainer components;
|
|
|
|
|
|
public MemoComposerForm()
|
|
{
|
|
//
|
|
// Required for Windows Form Designer support
|
|
//
|
|
InitializeComponent();
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Clean up any resources being used.
|
|
/// </summary>
|
|
protected override void Dispose( bool disposing )
|
|
{
|
|
if( disposing )
|
|
{
|
|
if(components != null)
|
|
{
|
|
components.Dispose();
|
|
}
|
|
}
|
|
base.Dispose( disposing );
|
|
}
|
|
|
|
#region Windows Form Designer generated code
|
|
/// <summary>
|
|
/// Required method for Designer support - do not modify
|
|
/// the contents of this method with the code editor.
|
|
/// </summary>
|
|
private void InitializeComponent()
|
|
{
|
|
this.components = new System.ComponentModel.Container();
|
|
Infragistics.Win.UltraWinToolbars.UltraToolbar ultraToolbar1 = new Infragistics.Win.UltraWinToolbars.UltraToolbar("RegionEntryMenuBar");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool1 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.SaveClose");
|
|
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool2 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.SaveClose");
|
|
Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance();
|
|
this.ckIsDirty = new System.Windows.Forms.CheckBox();
|
|
this.tbManager = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components);
|
|
this.panelLeft = new System.Windows.Forms.Panel();
|
|
this.edTo = new Infragistics.Win.UltraWinEditors.UltraTextEditor();
|
|
this.btnTo = new Infragistics.Win.Misc.UltraButton();
|
|
this.lblMessage = new Infragistics.Win.Misc.UltraLabel();
|
|
this.edMessage = new Infragistics.Win.UltraWinEditors.UltraTextEditor();
|
|
this.lblSubject = new Infragistics.Win.Misc.UltraLabel();
|
|
this.edSubject = new Infragistics.Win.UltraWinEditors.UltraTextEditor();
|
|
this.ErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
|
((System.ComponentModel.ISupportInitialize)(this.tbManager)).BeginInit();
|
|
this.panelLeft.SuspendLayout();
|
|
((System.ComponentModel.ISupportInitialize)(this.edTo)).BeginInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.edMessage)).BeginInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.edSubject)).BeginInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.ErrorProvider)).BeginInit();
|
|
this.SuspendLayout();
|
|
//
|
|
// ckIsDirty
|
|
//
|
|
this.ckIsDirty.Location = new System.Drawing.Point(-336, 28);
|
|
this.ckIsDirty.Name = "ckIsDirty";
|
|
this.ckIsDirty.Size = new System.Drawing.Size(191, 27);
|
|
this.ckIsDirty.TabIndex = 5;
|
|
//
|
|
// tbManager
|
|
//
|
|
this.tbManager.DesignerFlags = 1;
|
|
this.tbManager.DockWithinContainer = this;
|
|
this.tbManager.DockWithinContainerBaseType = typeof(System.Windows.Forms.Form);
|
|
this.tbManager.ShowFullMenusDelay = 500;
|
|
ultraToolbar1.DockedColumn = 0;
|
|
ultraToolbar1.DockedRow = 0;
|
|
ultraToolbar1.NonInheritedTools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
|
|
buttonTool1});
|
|
ultraToolbar1.Text = "RegionEntryMenuBar";
|
|
this.tbManager.Toolbars.AddRange(new Infragistics.Win.UltraWinToolbars.UltraToolbar[] {
|
|
ultraToolbar1});
|
|
this.tbManager.ToolbarSettings.AllowCustomize = Infragistics.Win.DefaultableBoolean.False;
|
|
this.tbManager.ToolbarSettings.AllowFloating = Infragistics.Win.DefaultableBoolean.False;
|
|
this.tbManager.ToolbarSettings.AllowHiding = Infragistics.Win.DefaultableBoolean.False;
|
|
buttonTool2.SharedPropsInternal.AccessibleDescription = "recorddd";
|
|
appearance2.Image = global::AyaNova.Resource1.SaveExit32;
|
|
buttonTool2.SharedPropsInternal.AppearancesLarge.Appearance = appearance2;
|
|
appearance3.Image = global::AyaNova.Resource1.SaveExit16;
|
|
buttonTool2.SharedPropsInternal.AppearancesSmall.Appearance = appearance3;
|
|
buttonTool2.SharedPropsInternal.Caption = "LT:UI.Command.SaveClose";
|
|
this.tbManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
|
|
buttonTool2});
|
|
this.tbManager.UseLargeImagesOnToolbar = true;
|
|
this.tbManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.tbManager_ToolClick);
|
|
//
|
|
// panelLeft
|
|
//
|
|
this.panelLeft.Controls.Add(this.edTo);
|
|
this.panelLeft.Controls.Add(this.btnTo);
|
|
this.panelLeft.Controls.Add(this.lblMessage);
|
|
this.panelLeft.Controls.Add(this.edMessage);
|
|
this.panelLeft.Controls.Add(this.lblSubject);
|
|
this.panelLeft.Controls.Add(this.edSubject);
|
|
this.panelLeft.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
this.panelLeft.Location = new System.Drawing.Point(0, 43);
|
|
this.panelLeft.Name = "panelLeft";
|
|
this.panelLeft.Size = new System.Drawing.Size(600, 483);
|
|
this.panelLeft.TabIndex = 96;
|
|
//
|
|
// edTo
|
|
//
|
|
this.edTo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
| System.Windows.Forms.AnchorStyles.Right)));
|
|
this.edTo.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
|
this.edTo.Location = new System.Drawing.Point(10, 37);
|
|
this.edTo.Multiline = true;
|
|
this.edTo.Name = "edTo";
|
|
this.edTo.ReadOnly = true;
|
|
this.edTo.Scrollbars = System.Windows.Forms.ScrollBars.Vertical;
|
|
this.edTo.Size = new System.Drawing.Size(580, 55);
|
|
this.edTo.TabIndex = 148;
|
|
//
|
|
// btnTo
|
|
//
|
|
appearance1.TextHAlignAsString = "Left";
|
|
this.btnTo.Appearance = appearance1;
|
|
this.btnTo.Location = new System.Drawing.Point(10, 9);
|
|
this.btnTo.Name = "btnTo";
|
|
this.btnTo.Size = new System.Drawing.Size(115, 24);
|
|
this.btnTo.TabIndex = 95;
|
|
this.btnTo.Tag = "";
|
|
this.btnTo.Text = "LT:Memo.Label.ToID";
|
|
this.btnTo.UseHotTracking = Infragistics.Win.DefaultableBoolean.True;
|
|
this.btnTo.WrapText = false;
|
|
this.btnTo.Click += new System.EventHandler(this.btnTo_Click);
|
|
//
|
|
// lblMessage
|
|
//
|
|
this.lblMessage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
| System.Windows.Forms.AnchorStyles.Right)));
|
|
this.lblMessage.Location = new System.Drawing.Point(10, 175);
|
|
this.lblMessage.Name = "lblMessage";
|
|
this.lblMessage.Size = new System.Drawing.Size(559, 19);
|
|
this.lblMessage.TabIndex = 94;
|
|
this.lblMessage.Tag = "";
|
|
this.lblMessage.Text = "LT:Memo.Label.Message";
|
|
//
|
|
// edMessage
|
|
//
|
|
this.edMessage.AcceptsReturn = true;
|
|
this.edMessage.AcceptsTab = true;
|
|
this.edMessage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
| System.Windows.Forms.AnchorStyles.Right)));
|
|
this.edMessage.Location = new System.Drawing.Point(10, 194);
|
|
this.edMessage.Multiline = true;
|
|
this.edMessage.Name = "edMessage";
|
|
this.edMessage.Scrollbars = System.Windows.Forms.ScrollBars.Vertical;
|
|
this.edMessage.Size = new System.Drawing.Size(561, 268);
|
|
this.edMessage.TabIndex = 93;
|
|
//
|
|
// lblSubject
|
|
//
|
|
this.lblSubject.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
| System.Windows.Forms.AnchorStyles.Right)));
|
|
this.lblSubject.Location = new System.Drawing.Point(10, 129);
|
|
this.lblSubject.Name = "lblSubject";
|
|
this.lblSubject.Size = new System.Drawing.Size(559, 19);
|
|
this.lblSubject.TabIndex = 92;
|
|
this.lblSubject.Tag = "";
|
|
this.lblSubject.Text = "LT:Memo.Label.Subject";
|
|
//
|
|
// edSubject
|
|
//
|
|
this.edSubject.AcceptsTab = true;
|
|
this.edSubject.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
| System.Windows.Forms.AnchorStyles.Right)));
|
|
this.edSubject.Location = new System.Drawing.Point(10, 148);
|
|
this.edSubject.Name = "edSubject";
|
|
this.edSubject.Size = new System.Drawing.Size(561, 24);
|
|
this.edSubject.TabIndex = 0;
|
|
//
|
|
// ErrorProvider
|
|
//
|
|
this.ErrorProvider.ContainerControl = this;
|
|
//
|
|
// _MemoComposerForm_Toolbars_Dock_Area_Left
|
|
//
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control;
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left;
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 43);
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Left.Name = "_MemoComposerForm_Toolbars_Dock_Area_Left";
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 483);
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Left.ToolbarsManager = this.tbManager;
|
|
//
|
|
// _MemoComposerForm_Toolbars_Dock_Area_Right
|
|
//
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control;
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right;
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(600, 43);
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Right.Name = "_MemoComposerForm_Toolbars_Dock_Area_Right";
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 483);
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Right.ToolbarsManager = this.tbManager;
|
|
//
|
|
// _MemoComposerForm_Toolbars_Dock_Area_Top
|
|
//
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control;
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top;
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0);
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Top.Name = "_MemoComposerForm_Toolbars_Dock_Area_Top";
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(600, 43);
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Top.ToolbarsManager = this.tbManager;
|
|
//
|
|
// _MemoComposerForm_Toolbars_Dock_Area_Bottom
|
|
//
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control;
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom;
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 526);
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Bottom.Name = "_MemoComposerForm_Toolbars_Dock_Area_Bottom";
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(600, 0);
|
|
this._MemoComposerForm_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.tbManager;
|
|
//
|
|
// MemoComposerForm
|
|
//
|
|
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
|
this.ClientSize = new System.Drawing.Size(600, 526);
|
|
this.Controls.Add(this.panelLeft);
|
|
this.Controls.Add(this.ckIsDirty);
|
|
this.Controls.Add(this._MemoComposerForm_Toolbars_Dock_Area_Left);
|
|
this.Controls.Add(this._MemoComposerForm_Toolbars_Dock_Area_Right);
|
|
this.Controls.Add(this._MemoComposerForm_Toolbars_Dock_Area_Bottom);
|
|
this.Controls.Add(this._MemoComposerForm_Toolbars_Dock_Area_Top);
|
|
this.MinimumSize = new System.Drawing.Size(374, 563);
|
|
this.Name = "MemoComposerForm";
|
|
this.ShowInTaskbar = false;
|
|
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
|
|
this.Closing += new System.ComponentModel.CancelEventHandler(this.MemoComposerForm_Closing);
|
|
this.Load += new System.EventHandler(this.MemoComposerForm_Load);
|
|
((System.ComponentModel.ISupportInitialize)(this.tbManager)).EndInit();
|
|
this.panelLeft.ResumeLayout(false);
|
|
this.panelLeft.PerformLayout();
|
|
((System.ComponentModel.ISupportInitialize)(this.edTo)).EndInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.edMessage)).EndInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.edSubject)).EndInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.ErrorProvider)).EndInit();
|
|
this.ResumeLayout(false);
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
// __ _ _ ___ ____ __ __ __ __ __ ___ ___
|
|
// / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _)
|
|
// ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _)
|
|
// \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___)
|
|
//
|
|
|
|
#region Form Load / Close
|
|
//variable to hold user form settings
|
|
//UIUserFormSetting mFormSetting;
|
|
|
|
|
|
/// <summary>
|
|
/// Prepare the form
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void MemoComposerForm_Load(object sender, System.EventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("MemoComposerForm_Load");
|
|
|
|
|
|
Cursor.Current = Cursors.WaitCursor;
|
|
this.Visible=false;
|
|
this.Icon = Resource1.Memo16icon;
|
|
|
|
//See if user has any rights to be here...
|
|
//(this is done here to ensure that no matter what happens if a user has no rights they can't get here
|
|
//useful in case we miss a way of getting to a Memo edit screen from elsewhere in the program)
|
|
if(AyaBizUtils.Right("Object.Memo")< (int)SecurityLevelTypes.ReadOnly)//Less than read only instead of NoAccess to catch records where it's zero instead of 1
|
|
{
|
|
//Inform them of their wicked ways and boot them out of here...
|
|
|
|
MessageBox.Show(string.Format(
|
|
Util.LocaleText.GetLocalizedText("Error.Security.NotAuthorizedToRetrieve"),
|
|
Util.LocaleText.GetLocalizedText("O.Memo")));
|
|
|
|
this.Close();
|
|
return;
|
|
}
|
|
|
|
|
|
InitializeRecipientTable();
|
|
UpdateRecipientsDisplay();
|
|
DataBind();
|
|
Util.LoadFormCustomization("MemoComposer", this, tbManager, false);
|
|
|
|
Util.PluginInsertMenu(tbManager, new Util.PluginMenuOptionData(true, RootObjectTypes.Memo, mMemo, null));//case 941
|
|
Util.LocalizeHelperInsertMenu(tbManager, this); //case 1810
|
|
Util.Localize(this);
|
|
Cursor.Current = Cursors.Default;
|
|
|
|
//Case 152
|
|
(new TabOrderManager(this)).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst);
|
|
|
|
Application.Idle+= new EventHandler(Application_Idle);
|
|
|
|
this.Visible=true;
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Used to track whether the close was done by the program
|
|
/// or done by the user clicking on the upper left corner X control
|
|
/// </summary>
|
|
bool bClosingHandled=false;
|
|
/// <summary>
|
|
/// Save form layout and grid layout for next time
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void MemoComposerForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("MemoComposerForm_Closing");
|
|
|
|
|
|
if(!bClosingHandled)
|
|
{
|
|
//Save record if necessary
|
|
//User may opt to not cancel exit
|
|
if(!RecordUpdate(RecordActionType.PromptToSave) )
|
|
{
|
|
e.Cancel=true;
|
|
return;
|
|
}
|
|
}
|
|
Application.Idle-= new EventHandler(Application_Idle);
|
|
Util.SaveFormCustomization("MemoComposer", this, tbManager, false);
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Form UI commands
|
|
|
|
#region Toolbar menu items
|
|
|
|
/// <summary>
|
|
/// Respond to a click on a toolbar menu item
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void tbManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
|
|
{
|
|
//case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("ToolClick: "+e.Tool.Key);
|
|
|
|
switch (e.Tool.Key)
|
|
{
|
|
case "LT:UI.Command.SaveClose": // ButtonTool
|
|
RecordUpdate(RecordActionType.SaveAndExit);
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
#endregion Toolbar menu items
|
|
|
|
private void btnTo_Click(object sender, System.EventArgs e)
|
|
{
|
|
MemoToSelector mts=new MemoToSelector();
|
|
mts.SelectedRecipients=this.dtRecipients;
|
|
mts.ShowDialog();
|
|
UpdateRecipientsDisplay();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion Form UI commands
|
|
|
|
#region Form UI / Business object synchronization
|
|
/// <summary>
|
|
/// Synchronize the state of the UI to the BO's
|
|
/// </summary>
|
|
private void SyncUI()
|
|
{
|
|
|
|
|
|
|
|
//display Memo name in title bar
|
|
this.Text=mMemo.Subject;
|
|
|
|
}
|
|
/// <summary>
|
|
/// When the application enters an idle state
|
|
/// update the UI to reflect changs in BO status
|
|
/// (required because grids don't tell the UI to update when they are
|
|
/// bound to a business object and are edited)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Application_Idle(object sender, EventArgs e)
|
|
{
|
|
SyncUI();
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region Form DataBinding and BrokenRules handling
|
|
|
|
|
|
/// <summary>
|
|
/// Bind controls to business objects
|
|
/// </summary>
|
|
private void DataBind()
|
|
{
|
|
//case 1039 //log.Debug("DataBind");
|
|
|
|
//Subscribe to broken rules changed event OnBrokenRulesChanged
|
|
mMemo.GetBrokenRulesCollection().ListChanged += new System.ComponentModel.ListChangedEventHandler(OnBrokenRulesChanged);
|
|
|
|
|
|
//=-=-=-=-=-=- Form Field bindings =-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
//Text editors
|
|
Util.BindField(edSubject,"Text",mMemo,"Subject");
|
|
Util.BindField(this.edMessage,"Text",mMemo,"Message");
|
|
|
|
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
|
|
|
//Bind IsDirty property to hidden checkbox to
|
|
//ensure isdirtychanged event is available
|
|
//to data binding infrastructure
|
|
Util.BindField(ckIsDirty,"Checked",mMemo,"IsDirty");
|
|
|
|
//Setup initial link to broken rules
|
|
OnBrokenRulesChanged(null,null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Handle a change in broken rules
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnBrokenRulesChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
|
|
{
|
|
Util.BrokenRuleFeedback(this,mMemo,ErrorProvider);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region Business object editing / adding / deletion related code
|
|
|
|
|
|
private GZTW.AyaNova.BLL.Memo mMemo;
|
|
/// <summary>
|
|
/// Memo record to display
|
|
/// set by caller
|
|
/// </summary>
|
|
public GZTW.AyaNova.BLL.Memo MemoToEdit
|
|
{
|
|
get
|
|
{
|
|
return mMemo;
|
|
}
|
|
set
|
|
{
|
|
mMemo=value;
|
|
//mMemo.BeginEdit();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
//Used to signal to main form that there are changes
|
|
//which could affect it if true
|
|
private bool mbChangesMade=false;
|
|
public bool ChangesMade
|
|
{
|
|
get
|
|
{
|
|
return mbChangesMade;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Update record and quit if requested
|
|
///
|
|
/// </summary>
|
|
/// <returns>True if handled, false if not handled</returns>
|
|
private bool RecordUpdate(RecordActionType SaveType)
|
|
{
|
|
//case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("SaveHandler(Action="+SaveType.ToString()+")");
|
|
|
|
//switch the focus to a non-editable control
|
|
//so that any changes in the current editable control
|
|
//will get updated before attempting to save
|
|
lblSubject.Focus();
|
|
switch(SaveType)
|
|
{
|
|
|
|
|
|
case RecordActionType.SaveAndExit:
|
|
//Save if necessary and exit
|
|
if(mMemo.IsSavable)
|
|
{
|
|
SaveMemo();
|
|
bClosingHandled=true;
|
|
mbChangesMade=true;
|
|
this.Close();
|
|
return true;
|
|
}
|
|
if(mMemo.IsDirty)//dirty and unsaveable due to broken rules
|
|
{
|
|
if(Util.PromptForBrokenRulesCancelSave()==DialogResult.Yes)
|
|
{
|
|
bClosingHandled=true;
|
|
this.Close();
|
|
return true;
|
|
}
|
|
else
|
|
return false;
|
|
}
|
|
//not dirty so just exit
|
|
bClosingHandled=true;
|
|
this.Close();
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case RecordActionType.PromptToSave:
|
|
//Prompt to save and save if
|
|
//required
|
|
if(mMemo.IsDirty)
|
|
{
|
|
DialogResult dr=Util.PromptForSave();
|
|
if(dr==DialogResult.Cancel)
|
|
{
|
|
//Cancel
|
|
return false;
|
|
}
|
|
if(dr==DialogResult.Yes)
|
|
{
|
|
//Save before exit
|
|
|
|
if(mMemo.IsSavable)
|
|
{
|
|
SaveMemo();
|
|
mbChangesMade=true;
|
|
return true;
|
|
}
|
|
if(mMemo.IsDirty)//dirty and unsaveable due to broken rules
|
|
{
|
|
if(Util.PromptForBrokenRulesCancelSave()==DialogResult.Yes)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
///Creates and saves a memo for each recipient
|
|
///in datatable of recipients
|
|
/// </summary>
|
|
private void SaveMemo()
|
|
{
|
|
|
|
//case 1039 //log.Debug("SaveMemo");
|
|
mMemo.ApplyEdit();
|
|
foreach(DataRow dr in this.dtRecipients.Rows)
|
|
{
|
|
if((bool)dr["SELECTED"]==true)
|
|
{
|
|
GZTW.AyaNova.BLL.Memo m = GZTW.AyaNova.BLL.Memo.NewItem();
|
|
m.ToID=(Guid)dr["RECIPIENTID"];
|
|
m.Subject=mMemo.Subject;
|
|
m.Message=mMemo.Message;
|
|
m.Save();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region Recipient list DataTable initialization and handling
|
|
private DataTable dtRecipients = new DataTable("RECIPIENTS");
|
|
|
|
|
|
private void InitializeRecipientTable()
|
|
{
|
|
dtRecipients.Columns.Add("RECIPIENT",typeof(System.String));
|
|
dtRecipients.Columns.Add("RECIPIENTTYPE",typeof(UserTypes));
|
|
dtRecipients.Columns.Add("SUBCONTRACTOR",typeof(bool));
|
|
dtRecipients.Columns.Add("RECIPIENTID",typeof(System.Guid));
|
|
dtRecipients.Columns.Add("SELECTED",typeof(bool));
|
|
|
|
//case 2000
|
|
//UserPickList UList = UserPickList.GetList(false);
|
|
UserPickList UList= UserPickList.GetInternalStaffOnlyList(false);
|
|
|
|
foreach(UserPickList.UserPickListInfo ui in UList)
|
|
{
|
|
//case 2025
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dtRecipients.NewRow();
|
|
dr["RECIPIENT"] = ui.Name;
|
|
dr["RECIPIENTTYPE"] = ui.Type;
|
|
dr["SUBCONTRACTOR"] = ui.SubContractor;
|
|
dr["RECIPIENTID"] = ui.ID;
|
|
//In case of reply:
|
|
if (mMemo.ToID == ui.ID)
|
|
dr["SELECTED"] = true;
|
|
else
|
|
dr["SELECTED"] = false;
|
|
dtRecipients.Rows.Add(dr);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Update user viewed display of recipients selected
|
|
/// called after coming back from MemoToSelector form
|
|
/// </summary>
|
|
private void UpdateRecipientsDisplay()
|
|
{
|
|
this.edTo.Text="";
|
|
StringBuilder sb=new StringBuilder();
|
|
foreach(DataRow dr in dtRecipients.Rows)
|
|
{
|
|
if((bool)dr["SELECTED"]==true)
|
|
{
|
|
sb.Append((string)dr["RECIPIENT"] + "; ");
|
|
|
|
}
|
|
|
|
}
|
|
this.edTo.Text=sb.ToString();
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
}
|
|
}
|