679 lines
30 KiB
C#
679 lines
30 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 Infragistics.Win.UltraWinEditors;
|
|
using log4net;
|
|
|
|
namespace AyaNova
|
|
{
|
|
/// <summary>
|
|
/// This form is used by all editable root collection objects
|
|
/// Mostly name/value and/or color or notes items
|
|
/// </summary>
|
|
public class GenericListForm : 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.UltraWinGrid.UltraGrid Grid;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsManager ToolBarManager;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _GenericListForm_Toolbars_Dock_Area_Left;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _GenericListForm_Toolbars_Dock_Area_Right;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _GenericListForm_Toolbars_Dock_Area_Top;
|
|
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _GenericListForm_Toolbars_Dock_Area_Bottom;
|
|
private System.Windows.Forms.HelpProvider helpProvider1;
|
|
private System.ComponentModel.IContainer components;
|
|
|
|
public GenericListForm()
|
|
{
|
|
//
|
|
// 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("GenericListForm");
|
|
Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool1 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("LT:UI.Toolbar.Print");
|
|
Infragistics.Win.UltraWinToolbars.ListTool listTool1 = new Infragistics.Win.UltraWinToolbars.ListTool("REPORTLIST");
|
|
Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool2 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("LT:UI.Toolbar.Print");
|
|
Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance();
|
|
Infragistics.Win.UltraWinToolbars.ListTool listTool2 = new Infragistics.Win.UltraWinToolbars.ListTool("REPORTLIST");
|
|
this.Grid = new Infragistics.Win.UltraWinGrid.UltraGrid();
|
|
this.ToolBarManager = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components);
|
|
this._GenericListForm_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
|
this._GenericListForm_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
|
this._GenericListForm_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
|
this._GenericListForm_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
|
this.helpProvider1 = new System.Windows.Forms.HelpProvider();
|
|
((System.ComponentModel.ISupportInitialize)(this.Grid)).BeginInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.ToolBarManager)).BeginInit();
|
|
this.SuspendLayout();
|
|
//
|
|
// Grid
|
|
//
|
|
this.Grid.Cursor = System.Windows.Forms.Cursors.Hand;
|
|
this.Grid.DisplayLayout.Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.TemplateOnBottom;
|
|
this.Grid.DisplayLayout.Override.AllowColSwapping = Infragistics.Win.UltraWinGrid.AllowColSwapping.NotAllowed;
|
|
this.Grid.DisplayLayout.Override.AllowDelete = Infragistics.Win.DefaultableBoolean.True;
|
|
this.Grid.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.True;
|
|
this.Grid.DisplayLayout.Override.SelectTypeCol = Infragistics.Win.UltraWinGrid.SelectType.None;
|
|
this.Grid.DisplayLayout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.Extended;
|
|
this.Grid.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
this.Grid.Location = new System.Drawing.Point(0, 23);
|
|
this.Grid.Name = "Grid";
|
|
this.Grid.Size = new System.Drawing.Size(704, 494);
|
|
this.Grid.TabIndex = 0;
|
|
this.Grid.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(this.Grid_InitializeRow);
|
|
this.Grid.AfterRowsDeleted += new System.EventHandler(this.Grid_AfterRowsDeleted);
|
|
this.Grid.CellChange += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.Grid_CellChange);
|
|
this.Grid.ClickCellButton += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.Grid_ClickCellButton);
|
|
this.Grid.MouseEnterElement += new Infragistics.Win.UIElementEventHandler(this.Grid_MouseEnterElement);
|
|
//
|
|
// ToolBarManager
|
|
//
|
|
this.ToolBarManager.DesignerFlags = 1;
|
|
this.ToolBarManager.DockWithinContainer = this;
|
|
this.ToolBarManager.DockWithinContainerBaseType = typeof(System.Windows.Forms.Form);
|
|
this.ToolBarManager.ShowFullMenusDelay = 500;
|
|
ultraToolbar1.DockedColumn = 0;
|
|
ultraToolbar1.DockedRow = 0;
|
|
ultraToolbar1.NonInheritedTools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
|
|
popupMenuTool1});
|
|
ultraToolbar1.Settings.AllowCustomize = Infragistics.Win.DefaultableBoolean.False;
|
|
ultraToolbar1.Settings.AllowHiding = Infragistics.Win.DefaultableBoolean.False;
|
|
ultraToolbar1.Text = "GenericListForm";
|
|
this.ToolBarManager.Toolbars.AddRange(new Infragistics.Win.UltraWinToolbars.UltraToolbar[] {
|
|
ultraToolbar1});
|
|
listTool1.DisplayCheckmark = false;
|
|
appearance1.Image = global::AyaNova.Resource1.Print32;
|
|
popupMenuTool2.SharedPropsInternal.AppearancesLarge.Appearance = appearance1;
|
|
appearance2.Image = global::AyaNova.Resource1.Print16;
|
|
popupMenuTool2.SharedPropsInternal.AppearancesSmall.Appearance = appearance2;
|
|
popupMenuTool2.SharedPropsInternal.Caption = "LT:UI.Toolbar.Print";
|
|
popupMenuTool2.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.ImageOnlyOnToolbars;
|
|
popupMenuTool2.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
|
|
listTool2});
|
|
this.ToolBarManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
|
|
listTool1,
|
|
popupMenuTool2});
|
|
this.ToolBarManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.ToolBarManager_ToolClick);
|
|
//
|
|
// _GenericListForm_Toolbars_Dock_Area_Left
|
|
//
|
|
this._GenericListForm_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
|
this._GenericListForm_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control;
|
|
this._GenericListForm_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left;
|
|
this._GenericListForm_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
this._GenericListForm_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 23);
|
|
this._GenericListForm_Toolbars_Dock_Area_Left.Name = "_GenericListForm_Toolbars_Dock_Area_Left";
|
|
this._GenericListForm_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 494);
|
|
this._GenericListForm_Toolbars_Dock_Area_Left.ToolbarsManager = this.ToolBarManager;
|
|
//
|
|
// _GenericListForm_Toolbars_Dock_Area_Right
|
|
//
|
|
this._GenericListForm_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
|
this._GenericListForm_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control;
|
|
this._GenericListForm_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right;
|
|
this._GenericListForm_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
this._GenericListForm_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(704, 23);
|
|
this._GenericListForm_Toolbars_Dock_Area_Right.Name = "_GenericListForm_Toolbars_Dock_Area_Right";
|
|
this._GenericListForm_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 494);
|
|
this._GenericListForm_Toolbars_Dock_Area_Right.ToolbarsManager = this.ToolBarManager;
|
|
//
|
|
// _GenericListForm_Toolbars_Dock_Area_Top
|
|
//
|
|
this._GenericListForm_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
|
this._GenericListForm_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control;
|
|
this._GenericListForm_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top;
|
|
this._GenericListForm_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
this._GenericListForm_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0);
|
|
this._GenericListForm_Toolbars_Dock_Area_Top.Name = "_GenericListForm_Toolbars_Dock_Area_Top";
|
|
this._GenericListForm_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(704, 23);
|
|
this._GenericListForm_Toolbars_Dock_Area_Top.ToolbarsManager = this.ToolBarManager;
|
|
//
|
|
// _GenericListForm_Toolbars_Dock_Area_Bottom
|
|
//
|
|
this._GenericListForm_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
|
this._GenericListForm_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control;
|
|
this._GenericListForm_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom;
|
|
this._GenericListForm_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
this._GenericListForm_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 517);
|
|
this._GenericListForm_Toolbars_Dock_Area_Bottom.Name = "_GenericListForm_Toolbars_Dock_Area_Bottom";
|
|
this._GenericListForm_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(704, 0);
|
|
this._GenericListForm_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.ToolBarManager;
|
|
//
|
|
// GenericListForm
|
|
//
|
|
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
|
this.ClientSize = new System.Drawing.Size(704, 517);
|
|
this.Controls.Add(this.Grid);
|
|
this.Controls.Add(this._GenericListForm_Toolbars_Dock_Area_Left);
|
|
this.Controls.Add(this._GenericListForm_Toolbars_Dock_Area_Right);
|
|
this.Controls.Add(this._GenericListForm_Toolbars_Dock_Area_Bottom);
|
|
this.Controls.Add(this._GenericListForm_Toolbars_Dock_Area_Top);
|
|
this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);
|
|
this.Name = "GenericListForm";
|
|
this.helpProvider1.SetShowHelp(this, true);
|
|
this.ShowInTaskbar = false;
|
|
this.Closing += new System.ComponentModel.CancelEventHandler(this.GenericActiveName_Closing);
|
|
this.Load += new System.EventHandler(this.GenericActiveName_Load);
|
|
((System.ComponentModel.ISupportInitialize)(this.Grid)).EndInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.ToolBarManager)).EndInit();
|
|
this.ResumeLayout(false);
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
// __ _ _ ___ ____ __ __ __ __ __ ___ ___
|
|
// / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _)
|
|
// ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _)
|
|
// \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___)
|
|
//
|
|
|
|
#region Load / Close
|
|
//variable to hold user form settings
|
|
//UIUserFormSetting mFormSetting;
|
|
string DataSourceObjectName = "";
|
|
SecurityLevelTypes _Rights = SecurityLevelTypes.NoAccess;
|
|
private void GenericActiveName_Load(object sender, System.EventArgs e)
|
|
{
|
|
//
|
|
// helpProvider1
|
|
//
|
|
this.helpProvider1.HelpNamespace = Util.BaseHelpUrl + "adding_editing_and_deleting_d2.htm";//case 3650
|
|
|
|
//case 1039 //log.Debug("GenericActiveName_Load");
|
|
this.Icon = Resource1.GenericSubgrid16icon;
|
|
|
|
//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 here from elsewhere in the program)
|
|
if (_Rights < 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"),
|
|
DataSourceObjectName));
|
|
|
|
this.Close();
|
|
return;
|
|
}
|
|
switch (_Rights)
|
|
{
|
|
case SecurityLevelTypes.ReadOnly:
|
|
Grid.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.False;
|
|
Grid.DisplayLayout.Override.AllowAddNew = AllowAddNew.No;
|
|
Grid.DisplayLayout.Override.AllowDelete = DefaultableBoolean.False;
|
|
break;
|
|
case SecurityLevelTypes.ReadWrite:
|
|
Grid.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.True;
|
|
Grid.DisplayLayout.Override.AllowAddNew = AllowAddNew.TemplateOnBottom;
|
|
Grid.DisplayLayout.Override.AllowDelete = DefaultableBoolean.False;
|
|
break;
|
|
case SecurityLevelTypes.ReadWriteDelete:
|
|
Grid.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.True;
|
|
Grid.DisplayLayout.Override.AllowAddNew = AllowAddNew.TemplateOnBottom;
|
|
Grid.DisplayLayout.Override.AllowDelete = DefaultableBoolean.True;
|
|
break;
|
|
}
|
|
|
|
|
|
Grid.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.SortSingle;
|
|
|
|
//Grid.DisplayLayout.AutoFitColumns=true;
|
|
Grid.Text = "";
|
|
Util.LoadFormCustomization(DataSourceObjectName, this, ToolBarManager, false);
|
|
Util.LocalizeHelperInsertMenu(ToolBarManager, this); //case 1810
|
|
Util.Localize(this);
|
|
|
|
if (_Rights > SecurityLevelTypes.ReadWrite)
|
|
Util.GridAddDeleteButton(Grid);
|
|
else
|
|
Util.GridRemoveDeleteButton(Grid);
|
|
}
|
|
|
|
|
|
|
|
|
|
bool _ClosingHandled = false;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void GenericActiveName_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("GenericActiveName_Closing");
|
|
|
|
|
|
Grid.UpdateData();
|
|
try
|
|
{
|
|
if (!_ClosingHandled)
|
|
{
|
|
if (((CSLA.BusinessCollectionBase)Grid.DataSource).IsSavable)
|
|
{
|
|
mbChangesMade = true;
|
|
((CSLA.BusinessCollectionBase)Grid.DataSource).Save();
|
|
|
|
}
|
|
else//Case 355 put this in an else block, the logic was incorrect before
|
|
{
|
|
//Is it dirty?
|
|
//If so then prompt for broken rules
|
|
//(if it's not dirty then no changes were made and so nothing needs to be done further
|
|
if (((CSLA.BusinessCollectionBase)Grid.DataSource).IsDirty)
|
|
{
|
|
if (Util.PromptForBrokenRulesCancelSave() != DialogResult.Yes)
|
|
{
|
|
e.Cancel = true;
|
|
return;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Util.ReportSQLError(ex);
|
|
e.Cancel = true;
|
|
return;
|
|
}
|
|
finally
|
|
{
|
|
Util.SaveGridLayout(DataSourceObjectName, "", "", Grid);
|
|
Util.SaveFormCustomization(DataSourceObjectName, this, ToolBarManager, false);
|
|
|
|
}
|
|
}
|
|
|
|
//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;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region Colorcolumn stuff
|
|
/// <summary>
|
|
/// Insert a color picker column
|
|
/// (assumes there is a "Color" column in the data source containing an int ARGB value)
|
|
/// </summary>
|
|
private void AddColorColumn(bool bSetOnly)
|
|
{
|
|
//case 1039 //log.Debug("AddColorColumn");
|
|
|
|
if (!bSetOnly)
|
|
{
|
|
|
|
Grid.DisplayLayout.Bands[0].Columns.Add("COLORCOLUMN", Util.LocaleText.GetLocalizedText("Priority.Label.Color"));
|
|
}
|
|
Grid.DisplayLayout.Bands[0].Columns["COLORCOLUMN"].DataType = typeof(Color);
|
|
|
|
|
|
foreach (UltraGridRow r in Grid.Rows)
|
|
{
|
|
r.Cells["COLORCOLUMN"].Value = Color.FromArgb((int)r.Cells[mColorColumnName].Value);
|
|
|
|
}
|
|
|
|
Grid.UpdateData();
|
|
|
|
|
|
}
|
|
|
|
|
|
//Update dependant cells if other cell changes
|
|
private void Grid_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
|
|
{
|
|
if (e.Cell.Column.Key == "COLORCOLUMN")
|
|
{
|
|
Color c = (Color)e.Cell.EditorResolved.Value;
|
|
e.Cell.Row.Cells[mColorColumnName].Value = c.ToArgb();
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region RegionID column
|
|
private void FillRegionList()
|
|
{
|
|
|
|
if (Grid.DisplayLayout.ValueLists.Exists("Regions"))
|
|
Grid.DisplayLayout.ValueLists.Remove("Regions");
|
|
|
|
//WorkorderStatusID
|
|
ValueList vl = Grid.DisplayLayout.ValueLists.Add("Regions");
|
|
|
|
|
|
GenericNVList l = GenericNVList.GetList("aRegion", "aID", "aName", true, true, true);
|
|
|
|
//Loop through the items in the list and put them
|
|
//into the valuelist
|
|
for (int x = 0; x < l.Count; x++)
|
|
{
|
|
vl.ValueListItems.Add(new Guid(((DictionaryEntry)l.BindableList[x]).Key.ToString()),
|
|
((DictionaryEntry)l.BindableList[x]).Value.ToString());
|
|
}
|
|
vl.SortStyle = ValueListSortStyle.Ascending;
|
|
|
|
//Bind value lists to correct columns in grid
|
|
Grid.DisplayLayout.Bands[0].Columns["RegionID"].ValueList = Grid.DisplayLayout.ValueLists["Regions"];
|
|
|
|
//Set column to dropdownlist style so that user can not type an invalid value in a cell
|
|
//but must select from the list only
|
|
Grid.DisplayLayout.Bands[0].Columns["RegionID"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownValidate;//Case 96 for autocomplete (was DropDownList)
|
|
Grid.DisplayLayout.Bands[0].Columns["RegionID"].AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend;
|
|
|
|
Grid.DisplayLayout.Bands[0].Columns["RegionID"].Hidden = false;
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Set data source
|
|
|
|
private Guid mSelectedRecordID = Guid.Empty;
|
|
private string mColorColumnName = "";
|
|
public object SelectedRecordID
|
|
{
|
|
set
|
|
{
|
|
if (value != null)
|
|
mSelectedRecordID = (Guid)value;
|
|
}
|
|
get
|
|
{
|
|
return mSelectedRecordID;
|
|
}
|
|
}
|
|
|
|
|
|
public Object GridDataSource
|
|
{
|
|
set
|
|
{
|
|
|
|
Grid.DataSource = value;
|
|
|
|
Util.GridHideEditableBizObjectInternalFields(Grid);
|
|
DataSourceObjectName = Util.GetBizObjectLocaleKey(value);
|
|
if (DataSourceObjectName == "ClientNoteType.Label.List")
|
|
_Rights = (SecurityLevelTypes)AyaBizUtils.Right(RootObjectTypes.Client);
|
|
else if (DataSourceObjectName == "UnitModelCategory.Label.List")
|
|
_Rights = (SecurityLevelTypes)AyaBizUtils.Right(RootObjectTypes.UnitModel);
|
|
else
|
|
_Rights = (SecurityLevelTypes)AyaBizUtils.Right("Object." + DataSourceObjectName.Substring(0, DataSourceObjectName.IndexOf(".")));
|
|
|
|
if (AyaBizUtils.Right("Object.Report") < (int)SecurityLevelTypes.ReadOnly)
|
|
{
|
|
ToolBarManager.Tools["LT:UI.Toolbar.Print"].SharedProps.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
ToolBarManager.Tools["LT:UI.Toolbar.Print"].SharedProps.Visible = true;
|
|
Util.ReportFillList(this.ToolBarManager.Tools["REPORTLIST"], DataSourceObjectName, "");
|
|
}
|
|
//case 1039 //log.Debug("GridDataSource.SET:" + DataSourceObjectName + " Rights: " + _Rights.ToString());
|
|
|
|
|
|
this.Text = Util.LocaleText.GetLocalizedText(DataSourceObjectName);
|
|
|
|
|
|
Util.FetchGridLayout(DataSourceObjectName, "", Grid);
|
|
|
|
//Check for color column
|
|
if (Grid.DisplayLayout.Bands[0].Columns.Exists("Color"))
|
|
{
|
|
mColorColumnName = "Color";
|
|
if (!Grid.DisplayLayout.Bands[0].Columns.Exists("COLORCOLUMN"))
|
|
{
|
|
Grid.DisplayLayout.Bands[0].Columns["Color"].Hidden = true;
|
|
AddColorColumn(false);
|
|
}
|
|
else
|
|
AddColorColumn(true);
|
|
}
|
|
|
|
if (Grid.DisplayLayout.Bands[0].Columns.Exists("ARGB"))
|
|
{
|
|
mColorColumnName = "ARGB";
|
|
if (!Grid.DisplayLayout.Bands[0].Columns.Exists("COLORCOLUMN"))
|
|
{
|
|
Grid.DisplayLayout.Bands[0].Columns["ARGB"].Hidden = true;
|
|
AddColorColumn(false);
|
|
}
|
|
else
|
|
AddColorColumn(true);
|
|
}
|
|
|
|
//Check for notes column
|
|
if (Grid.DisplayLayout.Bands[0].Columns.Exists("Notes"))
|
|
{
|
|
//make multi-line
|
|
Grid.DisplayLayout.Bands[0].Columns["Notes"].CellMultiLine = DefaultableBoolean.True;
|
|
Grid.DisplayLayout.Bands[0].Columns["Notes"].VertScrollBar = true;
|
|
Grid.DisplayLayout.Bands[0].Columns["Notes"].AutoSizeEdit = DefaultableBoolean.True;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Check for RegionID column
|
|
if (Grid.DisplayLayout.Bands[0].Columns.Exists("RegionID"))
|
|
{
|
|
FillRegionList();
|
|
}
|
|
|
|
|
|
Util.GridPreLocalize(DataSourceObjectName.Substring(0, DataSourceObjectName.IndexOf(".")), Grid.DisplayLayout.Bands[0]);
|
|
Util.LocalizeGrid(Grid);
|
|
|
|
//case 1020 color column header not localized properly
|
|
if (Grid.DisplayLayout.Bands[0].Columns.Exists("COLORCOLUMN"))
|
|
Grid.DisplayLayout.Bands[0].Columns["COLORCOLUMN"].Header.Caption = Util.LocaleText.GetLocalizedText("Priority.Label.Color");
|
|
|
|
|
|
|
|
//Allow empty string entry on grid
|
|
Util.SetTextColumnsNullable(Grid);
|
|
|
|
//Move to selected record if one
|
|
if (mSelectedRecordID != Guid.Empty)
|
|
{
|
|
if (Grid.DisplayLayout.Bands[0].Columns.Exists("ID"))
|
|
{
|
|
foreach (UltraGridRow r in Grid.Rows)
|
|
{
|
|
if ((Guid)r.Cells["ID"].Value == mSelectedRecordID)
|
|
{
|
|
r.Selected = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region GridBrokenRuleFeedBack
|
|
|
|
/// <summary>
|
|
/// Show error icons if rules broken
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Grid_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
|
|
{
|
|
Util.GridShowBrokenRulesErrorIcons(e);
|
|
|
|
}
|
|
|
|
|
|
//Tool tip to use for displaying broken rules
|
|
private System.Windows.Forms.ToolTip tipError = new System.Windows.Forms.ToolTip();
|
|
|
|
/// <summary>
|
|
/// Display broken rules in tool tip if hovering over
|
|
/// error icon
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Grid_MouseEnterElement(object sender, Infragistics.Win.UIElementEventArgs e)
|
|
{
|
|
Util.GridShowBrokenRulesToolTip(e, tipError);
|
|
}
|
|
|
|
#endregion
|
|
|
|
private void Grid_AfterRowsDeleted(object sender, System.EventArgs e)
|
|
{
|
|
//attempt a save now to avoid losing any more changes if it doesn't save later
|
|
//case 1039 //log.Debug("Grid_AfterRowsDeleted");
|
|
Grid.UpdateData();
|
|
try
|
|
{
|
|
if (((CSLA.BusinessCollectionBase)Grid.DataSource).IsSavable)
|
|
{
|
|
mbChangesMade = true;
|
|
|
|
Grid.DataSource = ((CSLA.BusinessCollectionBase)Grid.DataSource).Save();
|
|
|
|
}
|
|
|
|
|
|
|
|
// //Is it dirty?
|
|
// //if so, it wasn't saved previously
|
|
// //so we have broken rules here
|
|
// if(((CSLA.BusinessCollectionBase) Grid.DataSource).IsDirty)
|
|
// {
|
|
// if(Util.PromptForBrokenRulesCancelSave()!=DialogResult.Yes)
|
|
// {
|
|
// e.Cancel=true;
|
|
// return;
|
|
// }
|
|
//
|
|
// }
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//User tried to delete a record with active relationships
|
|
//so bail out to protect stuff
|
|
Util.ReportSQLError(ex);
|
|
_ClosingHandled = true;//to bypass regular save in Form_closing event handler
|
|
this.Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
#region Menu tool items
|
|
private void ToolBarManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
|
|
{
|
|
|
|
switch (e.Tool.Key)
|
|
{
|
|
case "REPORTLIST":
|
|
{
|
|
|
|
//if(Util.ReportHandleToolClickIsSummary(e.Tool))
|
|
Util.ReportHandleToolClick(e.Tool, DataSourceObjectName, Grid.DataSource);
|
|
//else
|
|
//{
|
|
|
|
//bool bFiltered=false;
|
|
//Util.ReportHandleToolClick(e.Tool,ClientListDetailed.ReportKey,ClientListDetailed.GetListByCriteria(Util.GetGridSortAndFilterXML(Grid.DisplayLayout.Bands[0],false,ref bFiltered)));
|
|
//}
|
|
Util.ReportFillList(this.ToolBarManager.Tools["REPORTLIST"], DataSourceObjectName, "");
|
|
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
//case 1105
|
|
private void Grid_ClickCellButton(object sender, CellEventArgs e)
|
|
{
|
|
if (e.Cell.Column.Key == "REMOVE")
|
|
{
|
|
Cursor.Current = Cursors.WaitCursor;
|
|
Grid.DisplayLayout.ActiveRow.Delete();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------
|
|
}
|
|
}
|