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

364 lines
14 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;
namespace AyaNova
{
/// <summary>
/// Summary description for UserInfoSkillsForm.
/// </summary>
public class UserInfoSkillsForm : 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;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Panel panel1;
private Infragistics.Win.UltraWinEditors.UltraComboEditor cbSkills;
private System.Windows.Forms.Panel panel2;
private Infragistics.Win.Misc.UltraButton btnWorkorderItemTask;
private User mUser=null;
public UserInfoSkillsForm(User UserToEdit)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
mUser=UserToEdit;
}
/// <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()
{
Infragistics.Win.UltraWinEditors.EditorButton editorButton1 = new Infragistics.Win.UltraWinEditors.EditorButton();
Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance();
Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance();
this.Grid = new Infragistics.Win.UltraWinGrid.UltraGrid();
this.panel1 = new System.Windows.Forms.Panel();
this.cbSkills = new Infragistics.Win.UltraWinEditors.UltraComboEditor();
this.panel2 = new System.Windows.Forms.Panel();
this.btnWorkorderItemTask = new Infragistics.Win.Misc.UltraButton();
((System.ComponentModel.ISupportInitialize)(this.Grid)).BeginInit();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.cbSkills)).BeginInit();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// Grid
//
this.Grid.Dock = System.Windows.Forms.DockStyle.Fill;
this.Grid.Location = new System.Drawing.Point(0, 0);
this.Grid.Name = "Grid";
this.Grid.Size = new System.Drawing.Size(456, 502);
this.Grid.TabIndex = 0;
this.Grid.AfterRowsDeleted += new System.EventHandler(this.Grid_AfterRowsDeleted);
this.Grid.ClickCellButton += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.Grid_ClickCellButton);
//
// panel1
//
this.panel1.Controls.Add(this.Grid);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 55);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(456, 502);
this.panel1.TabIndex = 1;
//
// cbSkills
//
this.cbSkills.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cbSkills.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend;
appearance1.Image = global::AyaNova.Resource1.New16;
editorButton1.Appearance = appearance1;
this.cbSkills.ButtonsLeft.Add(editorButton1);
this.cbSkills.Location = new System.Drawing.Point(0, 28);
this.cbSkills.MaxDropDownItems = 25;
this.cbSkills.Name = "cbSkills";
this.cbSkills.Size = new System.Drawing.Size(456, 24);
this.cbSkills.SortStyle = Infragistics.Win.ValueListSortStyle.Ascending;
this.cbSkills.TabIndex = 2;
this.cbSkills.EditorButtonClick += new Infragistics.Win.UltraWinEditors.EditorButtonEventHandler(this.cbSkills_EditorButtonClick);
//
// panel2
//
this.panel2.Controls.Add(this.btnWorkorderItemTask);
this.panel2.Controls.Add(this.cbSkills);
this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
this.panel2.Location = new System.Drawing.Point(0, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(456, 55);
this.panel2.TabIndex = 3;
//
// btnWorkorderItemTask
//
this.btnWorkorderItemTask.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
appearance2.TextHAlignAsString = "Left";
this.btnWorkorderItemTask.Appearance = appearance2;
this.btnWorkorderItemTask.Location = new System.Drawing.Point(0, 0);
this.btnWorkorderItemTask.Name = "btnWorkorderItemTask";
this.btnWorkorderItemTask.Size = new System.Drawing.Size(456, 28);
this.btnWorkorderItemTask.TabIndex = 8;
this.btnWorkorderItemTask.Tag = "";
this.btnWorkorderItemTask.Text = "LT:UserSkill.Label.List";
this.btnWorkorderItemTask.UseHotTracking = Infragistics.Win.DefaultableBoolean.True;
this.btnWorkorderItemTask.Click += new System.EventHandler(this.btnWorkorderItemTask_Click);
//
// UserInfoSkillsForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
this.ClientSize = new System.Drawing.Size(456, 557);
this.Controls.Add(this.panel1);
this.Controls.Add(this.panel2);
this.Name = "UserInfoSkillsForm";
this.ShowInTaskbar = false;
this.Closing += new System.ComponentModel.CancelEventHandler(this.UserInfoSkillsForm_Closing);
this.Load += new System.EventHandler(this.UserInfoSkillsForm_Load);
((System.ComponentModel.ISupportInitialize)(this.Grid)).EndInit();
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.cbSkills)).EndInit();
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.ResumeLayout(false);
}
#endregion
// __ _ _ ___ ____ __ __ __ __ __ ___ ___
// / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _)
// ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _)
// \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___)
//
//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
#region Form load / close
//variable to hold user form settings
//UIUserFormSetting mFormSetting;
private void UserInfoSkillsForm_Load(object sender, System.EventArgs e)
{
//case 1039 //log.Debug("UserInfoSkillsForm_Load");
this.Icon = Resource1.UserSkill16icon;
//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 User edit screen from elsewhere in the program)
if(AyaBizUtils.Right("Object.UserSkillAssigned")< (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.UserSkillAssigned")));
this.Close();
return;
}
Util.BindField(Grid,"DataSource",mUser,"UserSkills");
Util.GridPreLocalize("UserSkill",Grid.DisplayLayout.Bands[0]);
Util.GridHideEditableBizObjectInternalFields(Grid);
Grid.DisplayLayout.Bands[0].Columns["UserID"].Hidden=true;
Grid.DisplayLayout.Bands[0].Columns["UserSkillID"].Header.Caption=Util.LocaleText.GetLocalizedText("O.UserSkill");
PopulateGridValueLists();
Grid.DisplayLayout.Override.HeaderClickAction=HeaderClickAction.SortSingle;
Grid.DisplayLayout.Override.AllowAddNew=AllowAddNew.No;
Grid.DisplayLayout.Override.AllowDelete=DefaultableBoolean.True;
Grid.DisplayLayout.Override.AllowUpdate=DefaultableBoolean.False;
Util.Localize(this);
FillAvailableSkillsCombo();
Util.LoadFormCustomization("UserInfoSkills", this, null, false);
if ((SecurityLevelTypes)AyaBizUtils.Right("Object.UserSkillAssigned") > SecurityLevelTypes.ReadWrite)
Util.GridAddDeleteButton(Grid);
else
Util.GridRemoveDeleteButton(Grid);
//Set rights
Util.SetAccess((AyaBizUtils.Right("Object.UserSkillAssigned")< (int)SecurityLevelTypes.ReadWrite),this,(AyaBizUtils.Right("Object.UserSkillAssigned")< (int)SecurityLevelTypes.ReadWriteDelete) );
}
private void UserInfoSkillsForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
//case 1039 //log.Debug("UserInfoSkillsForm_Closing");
//ensure any pending edits are committed before closing the form
Grid.UpdateData();
Util.SaveFormCustomization("UserInfoSkills", this, null, false);
}
#endregion
/// <summary>
/// Populate the drop down lists inside the grid
/// so they display and can select the correct underlying
/// value
/// </summary>
private void PopulateGridValueLists()
{
//case 1039 //log.Debug("PopulateGridValueLists");
//wipe old ones
Grid.DisplayLayout.ValueLists.Clear();
//Populate value lists
ValueList vl=Grid.DisplayLayout.ValueLists.Add("Skills");
//NVCHANGED
GenericNVList l=GenericNVList.GetList("aUserSkill","aID","aName",true,true, false);
//Loop through the items in the list and put them
//into the valuelist
for(int x=0;x<l.Count;x++)
{
ValueListItem vli=vl.ValueListItems.Add(new Guid(((DictionaryEntry)l.BindableList[x]).Key.ToString()),
((DictionaryEntry)l.BindableList[x]).Value.ToString());
}
//Bind value lists to correct columns in grid
Grid.DisplayLayout.Bands[0].Columns["UserSkillID"].ValueList=Grid.DisplayLayout.ValueLists["Skills"];
//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["UserSkillID"].Style=Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownValidate;//Case 96 for autocomplete (was DropDownList)
Grid.DisplayLayout.Bands[0].Columns["UserSkillID"].AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend;
}
/// <summary>
/// refresh combo with skills not previously added
/// </summary>
private void FillAvailableSkillsCombo()
{
//case 1039 //log.Debug("FillAvailableSkillsCombo");
cbSkills.Items.Clear();
//NVCHANGED
GenericNVList l=GenericNVList.GetList("aUserSkill","aID","aName",true,true, false);
//Loop through the items in the list and put them
//into the valuelist if they aren't already selected
for(int x=0;x<l.Count;x++)
{
if(!mUser.UserSkills.ContainsSkill(((DictionaryEntry)l.BindableList[x]).Key.ToString()))
cbSkills.Items.Add(new Guid(((DictionaryEntry)l.BindableList[x]).Key.ToString()),
((DictionaryEntry)l.BindableList[x]).Value.ToString());
}
}
/// <summary>
/// Add item to grid
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cbSkills_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
{
//case 1039 //log.Debug("cbSkills_EditorButtonClick");
if(cbSkills.SelectedItem==null) return;
if((Guid)cbSkills.SelectedItem.DataValue!=Guid.Empty)
{
UserSkillAssigned usa=mUser.UserSkills.Add(mUser);
usa.UserSkillID=(Guid)cbSkills.SelectedItem.DataValue;
FillAvailableSkillsCombo();
}
}
/// <summary>
/// refresh combo
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Grid_AfterRowsDeleted(object sender, System.EventArgs e)
{
//case 1039 //log.Debug("Grid_AfterRowsDeleted");
FillAvailableSkillsCombo();
}
private void btnWorkorderItemTask_Click(object sender, System.EventArgs e)
{
//case 1039 //log.Debug("UserSkillsButton_Click ");//(Actually UserSkillsButton <is misnamed>)
GenericListForm g10 = new GenericListForm();
UserSkills us = UserSkills.GetItems();
g10.GridDataSource=us;
g10.ShowDialog();
FillAvailableSkillsCombo();
PopulateGridValueLists();
}
private void Grid_ClickCellButton(object sender, CellEventArgs e)
{
//case 1105
if (e.Cell.Column.Key == "REMOVE")
{
Grid.DisplayLayout.ActiveRow.Delete();
}
}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}
}