Files
ayanova7/source/WinFormApp/ReportInfoForm.cs
2018-06-29 19:47:36 +00:00

705 lines
29 KiB
C#

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using GZTW.AyaNova.BLL;
using log4net;
namespace AyaNova
{
/// <summary>
/// Summary description for ReportInfoForm.
/// </summary>
public class ReportInfoForm : 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 Infragistics.Win.UltraWinToolbars.UltraToolbarsManager tbManager;
private System.Windows.Forms.Panel ReportInfoForm_Fill_Panel;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _ReportInfoForm_Toolbars_Dock_Area_Left;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _ReportInfoForm_Toolbars_Dock_Area_Right;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _ReportInfoForm_Toolbars_Dock_Area_Top;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _ReportInfoForm_Toolbars_Dock_Area_Bottom;
private System.Windows.Forms.SaveFileDialog dlgSave;
private System.Windows.Forms.ErrorProvider ErrorProvider;
private Infragistics.Win.UltraWinEditors.UltraTextEditor edName;
private Infragistics.Win.Misc.UltraLabel lblName;
private Infragistics.Win.UltraWinEditors.UltraCheckEditor ckActive;
private System.Windows.Forms.CheckBox ckIsDirty;
private GZTW.WinForm.Controls.GZUltraComboEditor cbRegion;
private Infragistics.Win.Misc.UltraLabel lblRegionID;
private GZTW.WinForm.Controls.GZUltraComboEditor cbSecurityGroupID;
private Infragistics.Win.Misc.UltraLabel lblSecurityGroupID;
private System.ComponentModel.IContainer components;
public ReportInfoForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <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("tbReport");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool1 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Save");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool2 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:Report.Label.ExportLayout");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool3 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Delete");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool4 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Delete");
Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance();
Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance();
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool5 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Save");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool6 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:Report.Label.ExportLayout");
this.tbManager = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components);
this.ReportInfoForm_Fill_Panel = new System.Windows.Forms.Panel();
this.cbRegion = new GZTW.WinForm.Controls.GZUltraComboEditor();
this.lblRegionID = new Infragistics.Win.Misc.UltraLabel();
this.ckActive = new Infragistics.Win.UltraWinEditors.UltraCheckEditor();
this.edName = new Infragistics.Win.UltraWinEditors.UltraTextEditor();
this.lblName = new Infragistics.Win.Misc.UltraLabel();
this._ReportInfoForm_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
this._ReportInfoForm_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
this._ReportInfoForm_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
this._ReportInfoForm_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
this.dlgSave = new System.Windows.Forms.SaveFileDialog();
this.ErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
this.ckIsDirty = new System.Windows.Forms.CheckBox();
this.cbSecurityGroupID = new GZTW.WinForm.Controls.GZUltraComboEditor();
this.lblSecurityGroupID = new Infragistics.Win.Misc.UltraLabel();
((System.ComponentModel.ISupportInitialize)(this.tbManager)).BeginInit();
this.ReportInfoForm_Fill_Panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.cbRegion)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.edName)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.ErrorProvider)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cbSecurityGroupID)).BeginInit();
this.SuspendLayout();
//
// tbManager
//
this.tbManager.DesignerFlags = 1;
this.tbManager.DockWithinContainer = this;
this.tbManager.DockWithinContainerBaseType = typeof(System.Windows.Forms.Form);
ultraToolbar1.DockedColumn = 0;
ultraToolbar1.DockedRow = 0;
ultraToolbar1.NonInheritedTools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
buttonTool1,
buttonTool2,
buttonTool3});
ultraToolbar1.Text = "tbReport";
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;
appearance1.Image = global::AyaNova.Resource1.Delete32;
buttonTool4.SharedProps.AppearancesLarge.Appearance = appearance1;
appearance2.Image = global::AyaNova.Resource1.Delete16;
buttonTool4.SharedProps.AppearancesSmall.Appearance = appearance2;
buttonTool4.SharedProps.Caption = "LT:UI.Command.Delete";
buttonTool5.SharedProps.Caption = "LT:UI.Command.Save";
buttonTool5.SharedProps.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways;
buttonTool6.SharedProps.Caption = "LT:Report.Label.ExportLayout";
buttonTool6.SharedProps.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways;
this.tbManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
buttonTool4,
buttonTool5,
buttonTool6});
this.tbManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.tbManager_ToolClick);
//
// ReportInfoForm_Fill_Panel
//
this.ReportInfoForm_Fill_Panel.Controls.Add(this.cbSecurityGroupID);
this.ReportInfoForm_Fill_Panel.Controls.Add(this.lblSecurityGroupID);
this.ReportInfoForm_Fill_Panel.Controls.Add(this.cbRegion);
this.ReportInfoForm_Fill_Panel.Controls.Add(this.lblRegionID);
this.ReportInfoForm_Fill_Panel.Controls.Add(this.ckActive);
this.ReportInfoForm_Fill_Panel.Controls.Add(this.edName);
this.ReportInfoForm_Fill_Panel.Controls.Add(this.lblName);
this.ReportInfoForm_Fill_Panel.Cursor = System.Windows.Forms.Cursors.Default;
this.ReportInfoForm_Fill_Panel.Dock = System.Windows.Forms.DockStyle.Fill;
this.ReportInfoForm_Fill_Panel.Location = new System.Drawing.Point(0, 27);
this.ReportInfoForm_Fill_Panel.Name = "ReportInfoForm_Fill_Panel";
this.ReportInfoForm_Fill_Panel.Size = new System.Drawing.Size(343, 196);
this.ReportInfoForm_Fill_Panel.TabIndex = 0;
//
// cbRegion
//
this.cbRegion.AllowEmptySelection = false;
this.cbRegion.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cbRegion.Location = new System.Drawing.Point(3, 72);
this.cbRegion.Name = "cbRegion";
this.cbRegion.Size = new System.Drawing.Size(332, 21);
this.cbRegion.TabIndex = 143;
this.cbRegion.NeedMoreData += new GZTW.WinForm.Controls.NeedMoreDataHandler(this.cbRegion_NeedMoreData);
//
// lblRegionID
//
this.lblRegionID.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lblRegionID.Location = new System.Drawing.Point(3, 57);
this.lblRegionID.Name = "lblRegionID";
this.lblRegionID.Size = new System.Drawing.Size(332, 16);
this.lblRegionID.TabIndex = 144;
this.lblRegionID.Tag = "";
this.lblRegionID.Text = "LT:O.Region";
this.lblRegionID.WrapText = false;
//
// ckActive
//
this.ckActive.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.ckActive.Location = new System.Drawing.Point(4, 166);
this.ckActive.Name = "ckActive";
this.ckActive.Size = new System.Drawing.Size(327, 16);
this.ckActive.TabIndex = 95;
this.ckActive.Tag = "";
this.ckActive.Text = "LT:Report.Label.Active";
//
// edName
//
this.edName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.edName.Location = new System.Drawing.Point(3, 20);
this.edName.Name = "edName";
this.edName.Size = new System.Drawing.Size(333, 21);
this.edName.TabIndex = 93;
//
// lblName
//
this.lblName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lblName.Location = new System.Drawing.Point(3, 4);
this.lblName.Name = "lblName";
this.lblName.Size = new System.Drawing.Size(333, 16);
this.lblName.TabIndex = 94;
this.lblName.Tag = "";
this.lblName.Text = "LT:Report.Label.Name";
//
// _ReportInfoForm_Toolbars_Dock_Area_Left
//
this._ReportInfoForm_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._ReportInfoForm_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control;
this._ReportInfoForm_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left;
this._ReportInfoForm_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText;
this._ReportInfoForm_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 27);
this._ReportInfoForm_Toolbars_Dock_Area_Left.Name = "_ReportInfoForm_Toolbars_Dock_Area_Left";
this._ReportInfoForm_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 196);
this._ReportInfoForm_Toolbars_Dock_Area_Left.ToolbarsManager = this.tbManager;
//
// _ReportInfoForm_Toolbars_Dock_Area_Right
//
this._ReportInfoForm_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._ReportInfoForm_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control;
this._ReportInfoForm_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right;
this._ReportInfoForm_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText;
this._ReportInfoForm_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(343, 27);
this._ReportInfoForm_Toolbars_Dock_Area_Right.Name = "_ReportInfoForm_Toolbars_Dock_Area_Right";
this._ReportInfoForm_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 196);
this._ReportInfoForm_Toolbars_Dock_Area_Right.ToolbarsManager = this.tbManager;
//
// _ReportInfoForm_Toolbars_Dock_Area_Top
//
this._ReportInfoForm_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._ReportInfoForm_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control;
this._ReportInfoForm_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top;
this._ReportInfoForm_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText;
this._ReportInfoForm_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0);
this._ReportInfoForm_Toolbars_Dock_Area_Top.Name = "_ReportInfoForm_Toolbars_Dock_Area_Top";
this._ReportInfoForm_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(343, 27);
this._ReportInfoForm_Toolbars_Dock_Area_Top.ToolbarsManager = this.tbManager;
//
// _ReportInfoForm_Toolbars_Dock_Area_Bottom
//
this._ReportInfoForm_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._ReportInfoForm_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control;
this._ReportInfoForm_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom;
this._ReportInfoForm_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText;
this._ReportInfoForm_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 223);
this._ReportInfoForm_Toolbars_Dock_Area_Bottom.Name = "_ReportInfoForm_Toolbars_Dock_Area_Bottom";
this._ReportInfoForm_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(343, 0);
this._ReportInfoForm_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.tbManager;
//
// ErrorProvider
//
this.ErrorProvider.ContainerControl = this;
//
// ckIsDirty
//
this.ckIsDirty.Location = new System.Drawing.Point(-280, 24);
this.ckIsDirty.Name = "ckIsDirty";
this.ckIsDirty.Size = new System.Drawing.Size(154, 24);
this.ckIsDirty.TabIndex = 6;
//
// cbSecurityGroupID
//
this.cbSecurityGroupID.AllowEmptySelection = true;
this.cbSecurityGroupID.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cbSecurityGroupID.Location = new System.Drawing.Point(4, 123);
this.cbSecurityGroupID.Name = "cbSecurityGroupID";
this.cbSecurityGroupID.Size = new System.Drawing.Size(332, 21);
this.cbSecurityGroupID.TabIndex = 145;
//
// lblSecurityGroupID
//
this.lblSecurityGroupID.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lblSecurityGroupID.Location = new System.Drawing.Point(4, 108);
this.lblSecurityGroupID.Name = "lblSecurityGroupID";
this.lblSecurityGroupID.Size = new System.Drawing.Size(332, 16);
this.lblSecurityGroupID.TabIndex = 146;
this.lblSecurityGroupID.Tag = "";
this.lblSecurityGroupID.Text = "LT:Report.Label.SecurityGroupID";
this.lblSecurityGroupID.WrapText = false;
//
// ReportInfoForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(343, 223);
this.Controls.Add(this.ckIsDirty);
this.Controls.Add(this.ReportInfoForm_Fill_Panel);
this.Controls.Add(this._ReportInfoForm_Toolbars_Dock_Area_Left);
this.Controls.Add(this._ReportInfoForm_Toolbars_Dock_Area_Right);
this.Controls.Add(this._ReportInfoForm_Toolbars_Dock_Area_Top);
this.Controls.Add(this._ReportInfoForm_Toolbars_Dock_Area_Bottom);
this.MaximumSize = new System.Drawing.Size(590, 250);
this.MinimumSize = new System.Drawing.Size(351, 200);
this.Name = "ReportInfoForm";
this.ShowInTaskbar = false;
this.Text = "LT:O.Report";
this.Load += new System.EventHandler(this.ReportInfoForm_Load);
this.Closing += new System.ComponentModel.CancelEventHandler(this.ReportInfoForm_Closing);
((System.ComponentModel.ISupportInitialize)(this.tbManager)).EndInit();
this.ReportInfoForm_Fill_Panel.ResumeLayout(false);
this.ReportInfoForm_Fill_Panel.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.cbRegion)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.edName)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.ErrorProvider)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cbSecurityGroupID)).EndInit();
this.ResumeLayout(false);
}
#endregion
// __ _ _ ___ ____ __ __ __ __ __ ___ ___
// / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _)
// ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _)
// \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___)
//
#region Toolbar click
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.Delete": // ButtonTool
RecordUpdate(RecordActionType.DeleteAndExit);
break;
case "LT:UI.Command.Save": // ButtonTool
RecordUpdate(RecordActionType.SaveOnly);
break;
case "LT:Report.Label.ExportLayout": // ButtonTool
//Prompt to save if required
if(!RecordUpdate(RecordActionType.PromptToSave)) return;
dlgSave.FileName=mReport.Name;
dlgSave.Filter=
Util.LocaleText.GetLocalizedText("Report.Label.ExportLayoutFile")+"|*.ayr";
dlgSave.RestoreDirectory=true;
dlgSave.FilterIndex=1;
if(dlgSave.ShowDialog()==DialogResult.OK)
{
Report.ExportLayout(mReport.ID,dlgSave.FileName);
// string strExportPath=Path.GetDirectoryName(dlgSave.FileName) + "\\" +Path.GetFileNameWithoutExtension(dlgSave.FileName);
}
break;
}
}
#endregion
#region Business object editing / adding / deletion related code
private GZTW.AyaNova.BLL.Report mReport;
/// <summary>
/// Report record to display
/// set by caller
/// </summary>
public GZTW.AyaNova.BLL.Report ReportToEdit
{
get
{
return mReport;
}
set
{
mReport=value;
//mReport.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
lblName.Focus();
switch(SaveType)
{
case RecordActionType.DeleteAndExit:
if(Util.PromptForDelete()==DialogResult.Yes)
{
//Delete, then exit
try
{
GZTW.AyaNova.BLL.Report.DeleteItem(mReport.ID);
}
catch(Exception ex)
{
Util.ReportSQLError(ex);
return false;
}
bClosingHandled=true;
this.Close();
mbChangesMade=true;
return true;
}
else return false;
case RecordActionType.SaveAndExit:
//Save if necessary and exit
if(mReport.IsSavable)
{
mReport.ApplyEdit();
mReport.Save();
bClosingHandled=true;
mbChangesMade=true;
this.Close();
return true;
}
if(mReport.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.SaveOnly:
if(mReport.IsSavable)
{
mReport.ApplyEdit();
mReport=(GZTW.AyaNova.BLL.Report)mReport.Save();
DataBind();
mbChangesMade=true;
return true;
}
return true;
case RecordActionType.PromptToSave:
//Prompt to save and save if
//required
if(mReport.IsDirty)
{
DialogResult dr=Util.PromptForSave();
if(dr==DialogResult.Cancel)
{
//Cancel
return false;
}
if(dr==DialogResult.Yes)
{
//Save before exit
if(mReport.IsSavable)
{
mReport.ApplyEdit();
mReport.Save();
mbChangesMade=true;
return true;
}
if(mReport.IsDirty)//dirty and unsaveable due to broken rules
{
if(Util.PromptForBrokenRulesCancelSave()==DialogResult.Yes)
{
return true;
}
else
return false;
}
}
}
return true;
}
return false;
}
#endregion
#region Form Load / Close
//variable to hold user form settings
//UIUserFormSetting mFormSetting;
private void ReportInfoForm_Load(object sender, System.EventArgs e)
{
//case 1039 //log.Debug("ReportInfoForm_Load");
Cursor.Current = Cursors.WaitCursor;
this.Visible=false;
this.Icon = Resource1.ReportTemplate16icon;
//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 Region edit screen from elsewhere in the program)
if(AyaBizUtils.Right("Object.Report")< (int)SecurityLevelTypes.ReadOnly)//Less than full rights
{
//Inform them of their wicked ways and boot them out of here...
MessageBox.Show(string.Format(
Util.LocaleText.GetLocalizedText("Error.Security.NotAuthorizedToChange"),
Util.LocaleText.GetLocalizedText("O.Report")));
this.Close();
return;
}
InitializeComboBoxes();
DataBind();
Util.LoadFormCustomization("ReportInfo", this, tbManager, false);
Util.PluginInsertMenu(tbManager, new Util.PluginMenuOptionData(true, RootObjectTypes.Report, mReport, null));//case 941
Util.LocalizeHelperInsertMenu(tbManager, this); //case 1810
Util.Localize(this);
Cursor.Current = Cursors.Default;
//Application.Idle+= new EventHandler(Application_Idle);
this.Visible=true;
//Set rights
Util.SetAccess((AyaBizUtils.Right("Object.Report")< (int)SecurityLevelTypes.ReadWrite),this,(AyaBizUtils.Right("Object.Report")< (int)SecurityLevelTypes.ReadWriteDelete) );
tbManager.Tools["LT:UI.Command.Delete"].SharedProps.Visible=AyaBizUtils.Right("Object.Report")== (int)SecurityLevelTypes.ReadWriteDelete;
//case 668
tbManager.Tools["LT:Report.Label.ExportLayout"].SharedProps.Visible = (AyaBizUtils.Right("Object.Report") > (int)SecurityLevelTypes.ReadOnly);
//Case 152
(new TabOrderManager(this)).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst);
if (AyaBizUtils.Lite)
{
cbRegion.Visible = false;
cbSecurityGroupID.Visible = false;
lblRegionID.Visible = false;
lblSecurityGroupID.Visible = false;
}
}
/// <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;
private void ReportInfoForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
//case 1039 //log.Debug("ReportInfoForm_Closing");
if(!bClosingHandled)
{
//Save record if necessary
//User may opt to not cancel exit
if(!RecordUpdate(RecordActionType.PromptToSave) )
{
e.Cancel=true;
return;
}
}
Util.SaveFormCustomization("ReportInfo", this, tbManager, false);
}
#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
mReport.GetBrokenRulesCollection().ListChanged += new System.ComponentModel.ListChangedEventHandler(OnBrokenRulesChanged);
//=-=-=-=-=-=- Form Field bindings =-=-=-=-=-=-=-=-=-=-=-=
//Text editors
Util.BindField(edName,"Text",mReport,"Name");
//Check boxes
Util.BindField(ckActive,"Checked",mReport,"Active");
//Combo boxes
Util.BindField(cbRegion, "Value", mReport, "RegionID");//case 58
Util.BindField(cbSecurityGroupID, "Value", mReport, "SecurityGroupID");//case 36
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//Bind IsDirty property to hidden checkbox to
//ensure isdirtychanged event is available
//to data binding infrastructure
Util.BindField(ckIsDirty,"Checked",mReport,"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,mReport,ErrorProvider);
}
#endregion
#region Form ComboBoxes (Setup / Events)
private void InitializeComboBoxes()
{
Util.FillGZComboBoxWithNameIDList("Region", cbRegion, true, mReport.RegionID, true);
//fetch all the security groups. Can't use util function because
//it assumes table has an "Active" column and security groups doesn't
//NVCHANGED
GenericNVList ls = GenericNVList.GetList("aSecurityGroup", "aID", "aName", true, false, false);
// cbSecurityGroup.ClearList();
//Added: 19-July-2006 Huge performance increase with large lists
Util.ComboBeginUpdate(cbSecurityGroupID);
foreach (DictionaryEntry d in ls.BindableList)
{
cbSecurityGroupID.Items.Add(new Guid(d.Key.ToString()), d.Value.ToString());
}
//Added: 19-July-2006 see above
Util.ComboEndUpdate(cbSecurityGroupID);
}
private void cbRegion_NeedMoreData()
{
Util.FillGZComboBoxWithNameIDList("Region", cbRegion, false, Guid.Empty, true);
}
#endregion
}
}