using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; using Payroll.BO; using Ease.CoreV35.Model; using System.Reflection; namespace Payroll.Controls { public delegate void CustomControlChanged(bool bItemSelected); public interface ICustomControl where T : ObjectsTemplate { T SelectedObjectsI { get; } } public partial class ctlCustomControl : UserControl { ObjectsTemplate _oCategories = null; ObjectsTemplate _oDesig = null; ObjectsTemplate _oGrades = null; ObjectsTemplate _oGradeSags = null; ObjectsTemplate _oReligions = null; ObjectsTemplate _oCompany = null; ObjectsTemplate _oFunction = null; ObjectsTemplate _oTrainingType = null; ObjectsTemplate _oComplain = null; ObjectsTemplate _oPunishment = null; ObjectsTemplate _oSkills = null; ObjectsTemplate _oSkillLevels = null; ObjectsTemplate _oPopulatedDepts = new ObjectsTemplate(); ObjectsTemplate _oPopulatedLocs = new ObjectsTemplate(); private ObjectsTemplate _oCollectionBase = null; #region Decleration private ControlManager _Manager = null; private ToolTip _oToolTip = new ToolTip(); public event CustomControlChanged ClearEnabledDisabled; public event System.EventHandler Changed; private System.Windows.Forms.TextBox lblText; private System.Windows.Forms.Button btnPick; private System.Windows.Forms.Button btnClear; private System.ComponentModel.Container components = null; protected override void Dispose(bool disposing) { if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); } #endregion #region Component Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.lblText = new System.Windows.Forms.TextBox(); this.btnPick = new System.Windows.Forms.Button(); this.btnClear = new System.Windows.Forms.Button(); this.SuspendLayout(); // // lblText // this.lblText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lblText.BackColor = System.Drawing.SystemColors.Window; this.lblText.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.lblText.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblText.Location = new System.Drawing.Point(3, 1); this.lblText.Name = "lblText"; this.lblText.Size = new System.Drawing.Size(268, 22); this.lblText.TabIndex = 0; this.lblText.TextChanged += new System.EventHandler(this.lblText_TextChanged); // // btnPick // this.btnPick.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnPick.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btnPick.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btnPick.ForeColor = System.Drawing.SystemColors.Desktop; this.btnPick.Location = new System.Drawing.Point(271, 1); this.btnPick.Name = "btnPick"; this.btnPick.Size = new System.Drawing.Size(23, 22); this.btnPick.TabIndex = 1; this.btnPick.TabStop = false; this.btnPick.Text = "..."; this.btnPick.Click += new System.EventHandler(this.btnPick_Click); // // btnClear // this.btnClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnClear.Enabled = false; this.btnClear.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btnClear.ForeColor = System.Drawing.SystemColors.Desktop; this.btnClear.Location = new System.Drawing.Point(294, 1); this.btnClear.Name = "btnClear"; this.btnClear.Size = new System.Drawing.Size(54, 22); this.btnClear.TabIndex = 2; this.btnClear.Text = "Clear"; this.btnClear.Click += new System.EventHandler(this.btnClear_Click); // // ctlCustomControl // this.BackColor = System.Drawing.Color.Transparent; this.Controls.Add(this.btnClear); this.Controls.Add(this.btnPick); this.Controls.Add(this.lblText); this.Name = "ctlCustomControl"; this.Size = new System.Drawing.Size(351, 23); this.Load += new System.EventHandler(this.ctlCustomControl_Load); this.Resize += new System.EventHandler(this.ctlCustomBasicControl_Resize); this.Enter += new System.EventHandler(this.ctlCustomControl_Enter); this.ResumeLayout(false); this.PerformLayout(); } #endregion #region Events private void ctlCustomBasicControl_Resize(object sender, System.EventArgs e) { lblText.Left = 1; btnPick.Left = lblText.Width + 1; btnClear.Left = btnPick.Left + btnPick.Width + 3; } #endregion #region Properties #region Output Type public void CopyCollList(List source) where T : ObjectTemplate { _oCollectionBase = new ObjectsTemplate(); foreach (var item in source) _oCollectionBase.Add(item); } private EnumCustomBasicControl _eOutputType; public EnumCustomBasicControl OutputType { get { return _eOutputType; } set { _eOutputType = value; } } #endregion #region Control Type //private EnumControlType _eAutoCompleteType; //public EnumControlType AutoCompleteType //{ // get { return _eAutoCompleteType; } // set { _eAutoCompleteType = value; } //} #endregion #region Multiple Selection private bool _isMultiple; public bool MultipleSelection { get { return _isMultiple; } set { _isMultiple = value; } } #endregion #region Control Type private EnumCustomBasicControlType _controlType; // Tree or List public EnumCustomBasicControlType ControlType { get { return _controlType; } set { _controlType = value; } } #endregion #region Picker Caption private string _pickerCaption; public string PickerCaption { get { return _pickerCaption; } set { _pickerCaption = value; } } #endregion #region Child Property Name private string _childPropertyName; public string ChildPropertyName { get { return _childPropertyName; } set { _childPropertyName = value; } } private string _customSearchString; public string CustomSearchString { get { return _customSearchString; } set { _customSearchString = value; } } #endregion //#region Selected IDs #region Selected IDs private int[] _nSelectedIDs; public int[] SelectedIDs { get { return _nSelectedIDs; } set { _nSelectedIDs = value; RefreshMe(); } } #endregion public bool IsItemSelected { get { if (_Manager != null) { return (_Manager.SelectedObjects.Count > 0); } else return false; } } #region get String Seleceted IDs private string GetStringSelectedIDs { get { if (_nSelectedIDs == null) { return ""; } string sValues = ""; for (int n = 0; n < _nSelectedIDs.Length; n++) { if (sValues == "") sValues = _nSelectedIDs[n].ToString(); else sValues = sValues + ", " + _nSelectedIDs[n].ToString(); } if (sValues != "") sValues = "(" + sValues + ")"; return sValues; } } #endregion public ObjectsTemplate GetSelectedObjects() where T : ObjectTemplate { ObjectsTemplate temp = new ObjectsTemplate(); if (_Manager == null) return null; foreach (ObjectTemplate rob in _Manager.SelectedObjects) { T obj = (T)rob; ; temp.Add(obj); } return temp; } public T GetSelectedObject() where T : ObjectTemplate { if (_Manager.SelectedObjects == null || _Manager.SelectedObjects.Count == 0) return null; T obj = (T)_Manager.SelectedObjects[0]; return obj; } public void SetSelectedObjects(List source) where T : ObjectTemplate { if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); _Manager.SelectedObjects = new ObjectsTemplate(); string ids = ""; int ncount = 0; int nSelID = 0; if (source.Count > 0) nSelID = source.Count; else nSelID = 0; int[] nSelIDs = new int[nSelID]; foreach (var item in source) { nSelIDs[ncount] = item.ID.Integer; _Manager.SelectedObjects.Add(item); if (ncount != source.Count) ids = ids + _Manager.SelectedObjects[ncount].GetType().GetProperty("Name").GetValue(_Manager.SelectedObjects[ncount], null).ToString() + ", "; else ids = ids + _Manager.SelectedObjects[ncount].GetType().GetProperty("Name").GetValue(_Manager.SelectedObjects[ncount], null).ToString(); ncount = ncount + 1; } _Manager.SelectedValues = ids; _Manager.SelectedIDs = nSelIDs; RefreshMe(); } public void SetSelectedObject(T source) where T : ObjectTemplate { if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); _Manager.SelectedObjects = new ObjectsTemplate(); _Manager.SelectedObjects.Add(source); _Manager.SelectedValues = _Manager.SelectedObjects[0].GetType().GetProperty("Name").GetValue(_Manager.SelectedObjects[0], null).ToString(); RefreshMe(); } #region get String Seleceted IDs public Payroll.BO.SearchManager.SearchParameter SearchParam { get { if (_Manager != null) { return _Manager.SearchParam; } return null; } } #endregion #region HeadLine private string _sHeadLine = ""; public string PickerHeadLine { get { return _sHeadLine; } set { _sHeadLine = value; } } #endregion #region MHLevel private int _nMHTire = 0; public int MHTire { get { return _nMHTire; } set { _nMHTire = value; } } #endregion #region LastLevel private int _nLastLevel = -1; public int LastLevel { get { return _nLastLevel; } set { _nLastLevel = value; } } #endregion #region ObjectsTemplate _fixedItems = null; public void SetFixedItems(List source) where T : ObjectTemplate { _fixedItems = new ObjectsTemplate(); foreach (var item in source) { _fixedItems.Add(item); } } private EnumSearchParameter GetParameter() { switch (this._eOutputType) { case EnumCustomBasicControl.Grade: return EnumSearchParameter.GradeID; case EnumCustomBasicControl.Category: return EnumSearchParameter.CategoryID; case EnumCustomBasicControl.Department: return EnumSearchParameter.DepartmentID; case EnumCustomBasicControl.Designation: return EnumSearchParameter.DesignationID; case EnumCustomBasicControl.Religion: return EnumSearchParameter.ReligionID; case EnumCustomBasicControl.Company: return EnumSearchParameter.CompanyID; case EnumCustomBasicControl.TrainingType: return EnumSearchParameter.TrainingTypeID; case EnumCustomBasicControl.Complaints: return EnumSearchParameter.ComplaintID; case EnumCustomBasicControl.Punishment: return EnumSearchParameter.PunishmentID; case EnumCustomBasicControl.Skills: return EnumSearchParameter.SkillID; case EnumCustomBasicControl.ProdBonusSetup: return EnumSearchParameter.SkillID; } return EnumSearchParameter.GradeID; } #endregion public SearchManager.SearchParameter GetSearchParameter() { SearchManager.SearchParameter param = new SearchManager.SearchParameter(); param.ParameterValue = _Manager.SelectedValues; param.DataType = EnumSearchObjDataType.String; return param; } #endregion public ctlCustomControl() { InitializeComponent(); } public void Clear() { this.btnClear_Click(null, null); } #region RefreshMe private void RefreshMe() { lblText.Text = ""; //_nSelectedIDs = _Manager.SelectedIDs; if (_Manager == null || _Manager.SelectedIDs == null) { _nSelectedIDs = null; btnClear.Enabled = false; } else { lblText.Text = _Manager.SelectedValues; if (_Manager.SelectedIDs.Length == 0) { _nSelectedIDs = null; btnClear.Enabled = false; } else { _nSelectedIDs = _Manager.SelectedIDs; btnClear.Enabled = true; } } if (_Manager != null && _Manager.SelectedValues != null && _Manager.SelectedValues.Trim().Length > 0) { btnClear.Enabled = true; if (!(lblText.Text.Trim().Length > 0)) lblText.Text = _Manager.SelectedValues; } else { btnClear.Enabled = false; } if (_Manager != null && _Manager.SelectedValues != null) { _oToolTip.SetToolTip(lblText, _Manager.SelectedValues); } if (ClearEnabledDisabled != null) ClearEnabledDisabled(btnClear.Enabled); } private void RefreshMe2() { if (_Manager == null || _Manager.SelectedIDs == null) { _nSelectedIDs = null; btnClear.Enabled = false; } else { if (_Manager.SelectedIDs.Length == 0) { _nSelectedIDs = null; btnClear.Enabled = false; } else { _nSelectedIDs = _Manager.SelectedIDs; btnClear.Enabled = true; } } if (_Manager != null && _Manager.SelectedValues != null && _Manager.SelectedValues.Trim().Length > 0) { btnClear.Enabled = true; } else { btnClear.Enabled = false; } //if (_Manager != null && _Manager.SelectedValues != null) //{ // _oToolTip.SetToolTip(lblText, _Manager.SelectedValues); //} if (ClearEnabledDisabled != null) ClearEnabledDisabled(btnClear.Enabled); } #endregion #region Button Clear private void btnClear_Click(object sender, System.EventArgs e) { if (_Manager != null) { _Manager.SelectedObjects = null; _Manager.SelectedIDs = null; _Manager.SelectedValues = string.Empty; RefreshMe(); if (Changed != null) Changed(sender, e); } } //public void SetValues(int[] selectedIDs, string selectedValues) //{ // _nSelectedIDs = selectedIDs; // _SelectedValues = selectedValues; // RefreshMe(); //} //public void SetValues(string[] selectedIDs, string selectedValues) //{ // _nSelectedIDs = new int[selectedIDs.Length]; // for (int count = 0; count < selectedIDs.Length; count++) // { // _nSelectedIDs[count] = Convert.ToInt32(selectedIDs[count]); // } // _SelectedValues = selectedValues; // RefreshMe(); //} //public void SetValues(int selectedID, string selectedValues) //{ // _nSelectedIDs = new int[1]; // _nSelectedIDs[0] = selectedID; // _SelectedValues = selectedValues; // RefreshMe(); //} #endregion #region Set LabelText public void SetLabelText(string sText) { lblText.Text = sText; } #endregion #region Get LabelText public string GetLabelText() { return lblText.Text; } #endregion private void btnPick_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; //_Manager = new ControlManager(); frmCustomBasic oFrom = new frmCustomBasic(); Payroll.BO.SearchManager.SearchParameter searchParam = null; if (_isMultiple == false && _Manager != null) _Manager.SelectedObjects.Clear(); #region NewObjects switch (_eOutputType) { case EnumCustomBasicControl.Category: if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); ObjectsTemplate oCategories = Category.Get(EnumStatus.Active); this.Cursor = Cursors.Default; oFrom.CopyCollList(oCategories); oFrom.ShowDialog(_Manager); RefreshMe(); break; case EnumCustomBasicControl.CostCenter: if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", false, EnumCustomBasicControlType.TreeView, ChildPropertyName, PickerCaption, _eOutputType); int tier = 3; //ObjectsTemplate oCCs = Costcenter.Get(EnumStatus.Active, tier); ObjectsTemplate oCCs = Costcenter.GetParents(EnumStatus.Active); this.Cursor = Cursors.Default; oFrom.CopyCollList(oCCs); oFrom.ShowDialog(_Manager); RefreshMe(); break; case EnumCustomBasicControl.Department: if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); ObjectsTemplate oDepts = Department.GetParents(EnumStatus.Active); this.Cursor = Cursors.Default; oFrom.CopyCollList(oDepts); oFrom.ShowDialog(_Manager); _Manager.SearchParam = searchParam; RefreshMe(); break; case EnumCustomBasicControl.Designation: if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); if (_fixedItems == null) { ObjectsTemplate oDesigs = Designation.Get(EnumStatus.Active); this.Cursor = Cursors.Default; oFrom.CopyCollList(oDesigs); } else { oFrom.CopyCollList(_fixedItems); } oFrom.ShowDialog(_Manager); RefreshMe(); break; case EnumCustomBasicControl.Grade: if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); if (_fixedItems == null) { ObjectsTemplate oGrades = Grade.Get(EnumStatus.Active); this.Cursor = Cursors.Default; oFrom.CopyCollList(oGrades); } else { oFrom.CopyCollList(_fixedItems); } oFrom.ShowDialog(_Manager); RefreshMe(); break; case EnumCustomBasicControl.GradeSagment: if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); ObjectsTemplate oGradeSags = GradeSegment.Get(EnumStatus.Active); this.Cursor = Cursors.Default; oFrom.CopyCollList(oGradeSags); oFrom.ShowDialog(_Manager); RefreshMe(); break; case EnumCustomBasicControl.Location: if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); ObjectsTemplate oLocations = Payroll.BO.Location.GetParents(EnumStatus.Active); this.Cursor = Cursors.Default; oFrom.CopyCollList(oLocations); oFrom.ShowDialog(_Manager); RefreshMe(); break; case EnumCustomBasicControl.Religion: if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); ObjectsTemplate oReligions = Payroll.BO.Religion.Get(EnumStatus.Active); this.Cursor = Cursors.Default; oFrom.CopyCollList(oReligions); oFrom.ShowDialog(_Manager); _Manager.SearchParam = searchParam; RefreshMe(); break; case EnumCustomBasicControl.Company: if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); ObjectsTemplate oCompany = Company.Get(EnumStatus.Active); this.Cursor = Cursors.Default; oFrom.CopyCollList(oCompany); oFrom.ShowDialog(_Manager); RefreshMe(); break; case EnumCustomBasicControl.Function: if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); ObjectsTemplate oFunction = Function.Get(EnumStatus.Active); this.Cursor = Cursors.Default; oFrom.CopyCollList(oFunction); oFrom.ShowDialog(_Manager); RefreshMe(); break; case EnumCustomBasicControl.TrainingType: if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); ObjectsTemplate oTrainingType = TrainingType.Get(EnumStatus.Active); this.Cursor = Cursors.Default; oFrom.CopyCollList(oTrainingType); oFrom.ShowDialog(_Manager); RefreshMe(); break; case EnumCustomBasicControl.Complaints: if (_Manager == null) _Manager = new ControlManager("Code,Description", "Code,Description", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); ObjectsTemplate oComplain = Complain.Get(EnumStatus.Active); this.Cursor = Cursors.Default; oFrom.CopyCollList(oComplain); oFrom.ShowDialog(_Manager); RefreshMe(); break; case EnumCustomBasicControl.Punishment: if (_Manager == null) _Manager = new ControlManager("Code,Description", "Code,Description", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); ObjectsTemplate oPunishment = Punishment.Get(EnumStatus.Active); this.Cursor = Cursors.Default; oFrom.CopyCollList(oPunishment); oFrom.ShowDialog(_Manager); RefreshMe(); break; case EnumCustomBasicControl.Skills: if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); ObjectsTemplate oSkills = Skill.GetParents(EnumStatus.Active); this.Cursor = Cursors.Default; oFrom.CopyCollList(oSkills); oFrom.ShowDialog(_Manager); RefreshMe(); break; case EnumCustomBasicControl.SkillLevel: if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); ObjectsTemplate oSkillLevels = SkillLevel.Get(EnumStatus.Active); this.Cursor = Cursors.Default; oFrom.CopyCollList(oSkillLevels); oFrom.ShowDialog(_Manager); RefreshMe(); break; //Added by Ashek case EnumCustomBasicControl.SurveyQuestion: if (_Manager == null) _Manager = new ControlManager("QuestionCategoryDes,QuestionBody", "QuestionCategoryDes,QuestionBody", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); ObjectsTemplate oQuestion = Question.Get(); this.Cursor = Cursors.Default; oFrom.CopyCollList(oQuestion); oFrom.ShowDialog(_Manager); RefreshMe(); break; //Added by Chapal case EnumCustomBasicControl.ProdBonusSetup: if (_Manager == null) _Manager = new ControlManager("SalaryMonth,DesignNo", "SalaryMonth,DesignNo", MultipleSelection, ControlType, ChildPropertyName, PickerCaption, _eOutputType); ObjectsTemplate oProdBonusSetup = ProductionBonusSetup.Get(); this.Cursor = Cursors.Default; oFrom.CopyCollList(oProdBonusSetup); oFrom.ShowDialog(_Manager); RefreshMe(); break; } #endregion try { if (Changed != null) { Changed(sender, e); } this.Cursor = Cursors.Default; } catch (Exception ex) { throw new Exception(ex.Message); } } public void SetValues(int[] ids, string values) { _nSelectedIDs = ids; lblText.Text = values; RefreshMe(); } private void lblText_TextChanged(object sender, EventArgs e) { //if (AutoCompleteType == EnumControlType.AutoComplete) //{ switch (_eOutputType) { case EnumCustomBasicControl.Category: _Manager.SelectedObjects = new ObjectsTemplate(); if (_oCategories == null) { _oCategories = Category.Get(EnumStatus.Active); CopyCollList(_oCategories); } Category oCat = _oCategories.Find(delegate(Category item) { return item.Name == lblText.Text; }); if (oCat != null) { _Manager.SelectedIDs = new int[1]; _Manager.SelectedIDs[0] = oCat.ID.Integer; _Manager.SelectedValues = oCat.Name; _Manager.SelectedCode = oCat.Code; _Manager.SelectedDescription = oCat.Name; _Manager.SelectedObjects.Add(_oCollectionBase.GetItem(ID.FromInteger(_Manager.SelectedIDs[0]))); RefreshMe2(); } break; //case EnumCustomBasicControl.Designation: // _Manager.SelectedObjects = new ObjectsTemplate(); // if (_oDesig == null) // { // _oDesig = Designation.Get(EnumStatus.Active); // CopyCollList(_oDesig); // } // Designation deg = _oDesig.Find(delegate(Designation item) { return item.Name == lblText.Text; }); // if (deg != null) // { // _Manager.SelectedIDs = new int[1]; // _Manager.SelectedIDs[0] = deg.ID.Integer; // _Manager.SelectedValues = deg.Name; // _Manager.SelectedCode = deg.Code; // _Manager.SelectedDescription = deg.Name; // _Manager.SelectedObjects.Add(_oCollectionBase.GetItem(ID.FromInteger(_Manager.SelectedIDs[0]))); // RefreshMe2(); // } // break; //case EnumCustomBasicControl.Department: // _Manager.SelectedObjects = new ObjectsTemplate(); // Department dep = _oPopulatedDepts.Find(delegate(Department item) { return item.Name == lblText.Text; }); // if (dep != null) // { // _Manager.SelectedIDs = new int[1]; // _Manager.SelectedIDs[0] = dep.ID.Integer; // _Manager.SelectedValues = dep.Name; // _Manager.SelectedCode = dep.Code; // _Manager.SelectedDescription = dep.Name; // _Manager.SelectedObjects.Add(_oCollectionBase.GetItem(ID.FromInteger(_Manager.SelectedIDs[0]))); // RefreshMe2(); // } // break; //case EnumCustomBasicControl.Location: // _Manager.SelectedObjects = new ObjectsTemplate(); // Location loc = _oPopulatedLocs.Find(delegate(Payroll.BO.Location item) { return item.Name == lblText.Text; }); // if (loc != null) // { // _Manager.SelectedIDs = new int[1]; // _Manager.SelectedIDs[0] = loc.ID.Integer; // _Manager.SelectedValues = loc.Name; // _Manager.SelectedCode = loc.Code; // _Manager.SelectedDescription = loc.Name; // _Manager.SelectedObjects.Add(_oCollectionBase.GetItem(ID.FromInteger(_Manager.SelectedIDs[0]))); // RefreshMe2(); // } // break; case EnumCustomBasicControl.Grade: _Manager.SelectedObjects = new ObjectsTemplate(); if (_oGrades == null) { _oGrades = Grade.Get(EnumStatus.Active); CopyCollList(_oGrades); } Grade grd = _oGrades.Find(delegate(Grade item) { return item.Name == lblText.Text; }); if (grd != null) { _Manager.SelectedIDs = new int[1]; _Manager.SelectedIDs[0] = grd.ID.Integer; _Manager.SelectedValues = grd.Name; _Manager.SelectedCode = grd.Code; _Manager.SelectedDescription = grd.Name; _Manager.SelectedObjects.Add(_oCollectionBase.GetItem(ID.FromInteger(_Manager.SelectedIDs[0]))); RefreshMe2(); } break; case EnumCustomBasicControl.GradeSagment: _Manager.SelectedObjects = new ObjectsTemplate(); if (_oGradeSags == null) { _oGradeSags = GradeSegment.Get(EnumStatus.Active); CopyCollList(_oGradeSags); } GradeSegment grdseg = _oGradeSags.Find(delegate(GradeSegment item) { return item.Name == lblText.Text; }); if (grdseg != null) { _Manager.SelectedIDs = new int[1]; _Manager.SelectedIDs[0] = grdseg.ID.Integer; _Manager.SelectedValues = grdseg.Name; _Manager.SelectedCode = grdseg.Code; _Manager.SelectedDescription = grdseg.Name; _Manager.SelectedObjects.Add(_oCollectionBase.GetItem(ID.FromInteger(_Manager.SelectedIDs[0]))); RefreshMe2(); } break; case EnumCustomBasicControl.Religion: _Manager.SelectedObjects = new ObjectsTemplate(); if (_oReligions == null) { _oReligions = Religion.Get(EnumStatus.Active); CopyCollList(_oReligions); } Religion reli = _oReligions.Find(delegate(Religion item) { return item.Name == lblText.Text; }); if (reli != null) { _Manager.SelectedIDs = new int[1]; _Manager.SelectedIDs[0] = reli.ID.Integer; _Manager.SelectedValues = reli.Name; _Manager.SelectedCode = reli.Code; _Manager.SelectedDescription = reli.Name; _Manager.SelectedObjects.Add(_oCollectionBase.GetItem(ID.FromInteger(_Manager.SelectedIDs[0]))); RefreshMe2(); } break; case EnumCustomBasicControl.Company: _Manager.SelectedObjects = new ObjectsTemplate(); if (_oCompany == null) { _oCompany = Company.Get(EnumStatus.Active); CopyCollList(_oCompany); } Company com = _oCompany.Find(delegate(Company item) { return item.Name == lblText.Text; }); if (com != null) { _Manager.SelectedIDs = new int[1]; _Manager.SelectedIDs[0] = com.ID.Integer; _Manager.SelectedValues = com.Name; _Manager.SelectedCode = com.Code; _Manager.SelectedDescription = com.Name; _Manager.SelectedObjects.Add(_oCollectionBase.GetItem(ID.FromInteger(_Manager.SelectedIDs[0]))); RefreshMe2(); } break; case EnumCustomBasicControl.Function: _Manager.SelectedObjects = new ObjectsTemplate(); if (_oFunction == null) { _oFunction = Function.Get(EnumStatus.Active); CopyCollList(_oFunction); } Function fun = _oFunction.Find(delegate(Function item) { return item.Name == lblText.Text; }); if (fun != null) { _Manager.SelectedIDs = new int[1]; _Manager.SelectedIDs[0] = fun.ID.Integer; _Manager.SelectedValues = fun.Name; _Manager.SelectedCode = fun.Code; _Manager.SelectedDescription = fun.Name; _Manager.SelectedObjects.Add(_oCollectionBase.GetItem(ID.FromInteger(_Manager.SelectedIDs[0]))); RefreshMe2(); } break; case EnumCustomBasicControl.TrainingType: _Manager.SelectedObjects = new ObjectsTemplate(); if (_oTrainingType == null) { _oTrainingType = TrainingType.Get(EnumStatus.Active); CopyCollList(_oTrainingType); } TrainingType tt = _oTrainingType.Find(delegate(TrainingType item) { return item.Name == lblText.Text; }); if (tt != null) { _Manager.SelectedIDs = new int[1]; _Manager.SelectedIDs[0] = tt.ID.Integer; _Manager.SelectedValues = tt.Name; _Manager.SelectedCode = tt.Code; _Manager.SelectedDescription = tt.Name; _Manager.SelectedObjects.Add(_oCollectionBase.GetItem(ID.FromInteger(_Manager.SelectedIDs[0]))); RefreshMe2(); } break; case EnumCustomBasicControl.Complaints: _Manager.SelectedObjects = new ObjectsTemplate(); if (_oComplain == null) { _oComplain = Complain.Get(EnumStatus.Active); CopyCollList(_oComplain); } Complain comp = _oComplain.Find(delegate(Complain item) { return item.Description == lblText.Text; }); if (comp != null) { _Manager.SelectedIDs = new int[1]; _Manager.SelectedIDs[0] = comp.ID.Integer; _Manager.SelectedValues = comp.Description; _Manager.SelectedCode = comp.Code; _Manager.SelectedDescription = comp.Description; _Manager.SelectedObjects.Add(_oCollectionBase.GetItem(ID.FromInteger(_Manager.SelectedIDs[0]))); RefreshMe2(); } break; case EnumCustomBasicControl.Punishment: _Manager.SelectedObjects = new ObjectsTemplate(); if (_oPunishment == null) { _oPunishment = Punishment.Get(EnumStatus.Active); CopyCollList(_oPunishment); } Punishment pun = _oPunishment.Find(delegate(Punishment item) { return item.Description == lblText.Text; }); if (pun != null) { _Manager.SelectedIDs = new int[1]; _Manager.SelectedIDs[0] = pun.ID.Integer; _Manager.SelectedValues = pun.Description; _Manager.SelectedCode = pun.Code; _Manager.SelectedDescription = pun.Description; _Manager.SelectedObjects.Add(_oCollectionBase.GetItem(ID.FromInteger(_Manager.SelectedIDs[0]))); RefreshMe2(); } break; case EnumCustomBasicControl.Skills: _Manager.SelectedObjects = new ObjectsTemplate(); if (_oSkills == null) { _oSkills = Skill.Get(); CopyCollList(_oSkills); } Skill sk = _oSkills.Find(delegate(Skill item) { return item.Name == lblText.Text; }); if (sk != null) { _Manager.SelectedIDs = new int[1]; _Manager.SelectedIDs[0] = sk.ID.Integer; _Manager.SelectedValues = sk.Name; _Manager.SelectedCode = sk.Code; _Manager.SelectedDescription = sk.Name; _Manager.SelectedObjects.Add(_oCollectionBase.GetItem(ID.FromInteger(_Manager.SelectedIDs[0]))); RefreshMe2(); } break; case EnumCustomBasicControl.SkillLevel: _Manager.SelectedObjects = new ObjectsTemplate(); if (_oSkillLevels == null) { _oSkillLevels = SkillLevel.Get(); CopyCollList(_oSkillLevels); } SkillLevel sklev = _oSkillLevels.Find(delegate(SkillLevel item) { return item.Name == lblText.Text; }); if (sklev != null) { _Manager.SelectedIDs = new int[1]; _Manager.SelectedIDs[0] = sklev.ID.Integer; _Manager.SelectedValues = sklev.Name; _Manager.SelectedCode = sklev.Code; _Manager.SelectedDescription = sklev.Name; _Manager.SelectedObjects.Add(_oCollectionBase.GetItem(ID.FromInteger(_Manager.SelectedIDs[0]))); RefreshMe2(); } break; } //end of switch // } } private void ctlCustomControl_Load(object sender, EventArgs e) { //lblText.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //lblText.AutoCompleteSource = AutoCompleteSource.CustomSource; //AutoCompleteStringCollection col = new AutoCompleteStringCollection(); //frmCustomBasic oFrom = new frmCustomBasic(); //Payroll.BO.SearchManager.SearchParameter searchParam = null; ////if (_isMultiple == false && _Manager != null) _Manager.SelectedObjects.Clear(); ////MultipleSelection = false; ////ControlType = EnumCustomBasicControlType.ListView; //switch (_eOutputType) //{ // case EnumCustomBasicControl.Category: // if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, // ControlType, ChildPropertyName, PickerCaption, _eOutputType); // _oCategories = Category.Get(EnumStatus.Active); // foreach (Category grd in _oCategories) // { // col.Add(grd.Name); // } // CopyCollList(_oCategories); // break; // case EnumCustomBasicControl.CostCenter: // if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, // ControlType, ChildPropertyName, PickerCaption, _eOutputType); // ObjectsTemplate oCCs = Costcenter.GetParents(EnumStatus.Active); // this.Cursor = Cursors.Default; // oFrom.CopyCollList(oCCs); // RefreshMe(); // break; // //case EnumCustomBasicControl.Department: // // if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, EnumCustomBasicControlType.TreeView, // // ChildPropertyName, PickerCaption, _eOutputType); // // ObjectsTemplate oDepts = Department.Get(); // // this.Cursor = Cursors.Default; // // foreach (Department oDept in oDepts) // // { // // string sDept = ""; // // sDept = oDept.Name; // // Department item = new Department(); // // Department tempItem = new Department(); // // tempItem = oDept; // // for (int i = 1; i < oDept.Tier; i++) // // { // // tempItem = tempItem.Parent; // // sDept = tempItem.Name + " / " + sDept; // // } // // tempItem.SetObjectID(oDept.ID.Integer); // // tempItem.Name = sDept; // // col.Add(sDept); // // _oPopulatedDepts.Add(tempItem); // // } // // CopyCollList(_oPopulatedDepts); // // ////oFrom.CopyCollList(oDepts); // // //// oFrom.ShowDialog(_Manager); // // //_Manager.SearchParam = searchParam; // // RefreshMe(); // // break; // case EnumCustomBasicControl.Designation: // if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, // ChildPropertyName, PickerCaption, _eOutputType); // _oDesig = Designation.Get(EnumStatus.Active); // foreach (Designation grd in _oDesig) // { // col.Add(grd.Name); // } // CopyCollList(_oDesig); // break; // case EnumCustomBasicControl.Grade: // if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, // ControlType, ChildPropertyName, PickerCaption, _eOutputType); // _oGrades = Grade.Get(EnumStatus.Active); // foreach (Grade grd in _oGrades) // { // col.Add(grd.Name); // } // CopyCollList(_oGrades); // break; // case EnumCustomBasicControl.GradeSagment: // if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, // ControlType, ChildPropertyName, PickerCaption, _eOutputType); // _oGradeSags = GradeSegment.Get(EnumStatus.Active); // foreach (GradeSegment grd in _oGradeSags) // { // col.Add(grd.Name); // } // CopyCollList(_oGradeSags); // break; // //case EnumCustomBasicControl.Location: // // if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, // // EnumCustomBasicControlType.TreeView, ChildPropertyName, PickerCaption, _eOutputType); // // ObjectsTemplate oLocations = Payroll.BO.Location.Get(EnumStatus.Active); // // this.Cursor = Cursors.Default; // // foreach (Location oDept in oLocations) // // { // // string sDept = ""; // // sDept = oDept.Name; // // Location item = new Location(); // // Location tempItem = new Location(); // // tempItem = oDept; // // for (int i = 1; i < oDept.Tier; i++) // // { // // tempItem = tempItem.Parent; // // sDept = tempItem.Name + " / " + sDept; // // } // // tempItem.SetObjectID(oDept.ID.Integer); // // tempItem.Name = sDept; // // col.Add(sDept); // // _oPopulatedLocs.Add(tempItem); // // } // // CopyCollList(_oPopulatedLocs); // // //oFrom.CopyCollList(oLocations); // // //oFrom.ShowDialog(_Manager); // // //RefreshMe(); // // break; // case EnumCustomBasicControl.Religion: // if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, // ChildPropertyName, PickerCaption, _eOutputType); // _oReligions = Payroll.BO.Religion.Get(EnumStatus.Active); // foreach (Religion grd in _oReligions) // { // col.Add(grd.Name); // } // CopyCollList(_oReligions); // break; // case EnumCustomBasicControl.Company: // if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, // ChildPropertyName, PickerCaption, _eOutputType); // _oCompany = Company.Get(EnumStatus.Active); // foreach (Company grd in _oCompany) // { // col.Add(grd.Name); // } // CopyCollList(_oCompany); // break; // case EnumCustomBasicControl.Function: // if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, // ChildPropertyName, PickerCaption, _eOutputType); // _oFunction = Function.Get(EnumStatus.Active); // foreach (Function grd in _oFunction) // { // col.Add(grd.Name); // } // CopyCollList(_oFunction); // break; // case EnumCustomBasicControl.TrainingType: // if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, // ChildPropertyName, PickerCaption, _eOutputType); // _oTrainingType = TrainingType.Get(EnumStatus.Active); // foreach (TrainingType grd in _oTrainingType) // { // col.Add(grd.Name); // } // CopyCollList(_oTrainingType); // break; // case EnumCustomBasicControl.Complaints: // if (_Manager == null) _Manager = new ControlManager("Code,Description", "Code,Description", MultipleSelection, ControlType, // ChildPropertyName, PickerCaption, _eOutputType); // _oComplain = Complain.Get(EnumStatus.Active); // foreach (Complain grd in _oComplain) // { // col.Add(grd.Description); // } // CopyCollList(_oComplain); // break; // case EnumCustomBasicControl.Punishment: // if (_Manager == null) _Manager = new ControlManager("Code,Description", "Code,Description", MultipleSelection, ControlType, // ChildPropertyName, PickerCaption, _eOutputType); // _oPunishment = Punishment.Get(EnumStatus.Active); // foreach (Punishment grd in _oPunishment) // { // col.Add(grd.Description); // } // CopyCollList(_oPunishment); // break; // case EnumCustomBasicControl.Skills: // if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, // ChildPropertyName, PickerCaption, _eOutputType); // _oSkills = Skill.GetParents(EnumStatus.Active); // foreach (Skill grd in _oSkills) // { // col.Add(grd.Name); // } // CopyCollList(_oSkills); // break; // case EnumCustomBasicControl.SkillLevel: // if (_Manager == null) _Manager = new ControlManager("Code,Name", "Code,Name", MultipleSelection, ControlType, // ChildPropertyName, PickerCaption, _eOutputType); // _oSkillLevels = SkillLevel.Get(EnumStatus.Active); // foreach (SkillLevel grd in _oSkillLevels) // { // col.Add(grd.Name); // } // CopyCollList(_oSkillLevels); // break; // //Added by Ashek // //case EnumCustomBasicControl.SurveyQuestion: // // if (_Manager == null) _Manager = new ControlManager("QuestionCategoryDes,QuestionBody", "QuestionCategoryDes,QuestionBody", MultipleSelection, ControlType, // // ChildPropertyName, PickerCaption, _eOutputType); // // ObjectsTemplate oQuestion = Question.Get(); // // foreach (Question grd in oQuestion) // // { // // col.Add(grd.Des); // // } // // //this.Cursor = Cursors.Default; // // //oFrom.CopyCollList(oQuestion); // // //oFrom.ShowDialog(_Manager); // // RefreshMe(); // // break; // //Added by Chapal // //case EnumCustomBasicControl.ProdBonusSetup: // // if (_Manager == null) _Manager = new ControlManager("SalaryMonth,DesignNo", "SalaryMonth,DesignNo", MultipleSelection, ControlType, // // ChildPropertyName, PickerCaption, _eOutputType); // // ObjectsTemplate oProdBonusSetup = ProductionBonusSetup.Get(); // // foreach (ProductionBonusSetup grd in oProdBonusSetup) // // { // // col.Add(grd.desc); // // } // // //this.Cursor = Cursors.Default; // // //oFrom.CopyCollList(oProdBonusSetup); // // //oFrom.ShowDialog(_Manager); // // RefreshMe(); // // break; //} //lblText.AutoCompleteCustomSource = col; } private void ctlCustomControl_Enter(object sender, EventArgs e) { } //End of method } }