using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; using Ease.CoreV35.Model; using Ease.CoreV35.Caching; using Payroll.BO; namespace Ease.UICreator { internal partial class FrmMasterTreeView : Form { #region variables private MasterForm _masterForm; public event Ease.UICreator.UIConfiguration UpdateUIDesign; #endregion #region Constructor public FrmMasterTreeView() { InitializeComponent(); } #endregion #region Property public MasterForm UIBEMF { get { if (_masterForm == null) { _masterForm = new MasterForm(); } return _masterForm; } set { _masterForm = value; } } #endregion #region Functions #region showDLg public void showDLg(MasterForm UIBEMF) { try { _masterForm = UIBEMF; _masterForm.Listviewcloumns.IsDuplicateCtlName(); if (CheckSpellListView()) { this.Text = _masterForm.Caption; RefreshListview(); if (UpdateUIDesign != null) { this.Name = _masterForm.FormName; UpdateUIDesign(this); } this.ShowDialog(); } } catch (Exception e) { MessageBox.Show("Error: " + e.Message, "For Devloper:"); } } public void showDLg() { try { _masterForm.Listviewcloumns.IsDuplicateCtlName(); if (CheckSpellListView()) { this.Text = _masterForm.Caption; CreateListView(); RefreshListview(); this.ShowDialog(); } } catch (Exception e) { MessageBox.Show("Error: " + e.Message, "For Devloper:"); } } #endregion #region CreateListView private void CreateListView() { //_totColWid = 0; //int noOfCol = 0; //foreach (MasterFormlvw UIBEMFitem in _masterForm.Listviewcloumns) //{ // _totColWid += UIBEMFitem.Width; // noOfCol++; //} //int imageIndex = 0; //if (_totColWid< this.lvwBEMF.Width-15) //{ // int extraWidth = (this.lvwBEMF.Width-15) - _totColWid; // int devidedExtraWidth = (int)extraWidth / noOfCol; // foreach (MasterFormlvw UIBEMFitem in _masterForm.Listviewcloumns) // { // this.lvwBEMF.Columns.Add(UIBEMFitem.PropertyName, UIBEMFitem.Caption, UIBEMFitem.Width + devidedExtraWidth, UIBEMFitem.ColumnAlignment, imageIndex); // } //} //else //{ // foreach (MasterFormlvw UIBEMFitem in _masterForm.Listviewcloumns) // { // this.lvwBEMF.Columns.Add(UIBEMFitem.PropertyName, UIBEMFitem.Caption, UIBEMFitem.Width, UIBEMFitem.ColumnAlignment, imageIndex); // } //} } #endregion #region CheckSpellListView private bool CheckSpellListView() { bool correct = true; //lvwBEMF.Items.Clear(); //foreach (var item in _masterForm.SourceCollection) //{ // int count = 0; // foreach (MasterFormlvw UIBEMFitem in _masterForm.Listviewcloumns) // { // count++; // System.Reflection.PropertyInfo dispMem = item.GetType().GetProperty(UIBEMFitem.PropertyName); // if (dispMem == null) // { // MessageBox.Show("The property name " + UIBEMFitem.PropertyName.ToString() + "\n" + "does not belong to the object " + (item.GetType()).Name.ToString()); // correct = false; // break; // } // if (correct == false) // { // break; // } // } //} return correct; } #endregion #region RefreshListview private void RefreshSourceCollection() { //System.Reflection.MethodInfo methodInfo = (_masterForm.SingleForm.Source.GetType()).GetMethod("GetParents", new Type[0]); //object ox = methodInfo.Invoke(_masterForm.SingleForm.Source, null); //List items = (List)ox; //tvMaster.Nodes.Clear(); //object[] parameters = new object[1]; //parameters[0] = parentID; //System.Reflection.MethodInfo methodInfo = (_masterForm.SingleForm.Source.GetType()).GetMethod("GetParents"); //object ox = methodInfo.Invoke(_masterForm.SingleForm.Source, parameters); //if (ox == null) return; //IList il = ox as IList; //foreach (var item in il) //{ // TreeNode node = new TreeNode(); // System.Reflection.PropertyInfo dispMem = item.GetType().GetProperty(_masterForm.TreeView.PropertyNames); // string str = dispMem.GetValue(item, null).ToString(); // System.Reflection.PropertyInfo dispMem1 = item.GetType().GetProperty("Status"); // string str1 = dispMem1.GetValue(item, null).ToString(); // node.Text = str; // //node.Text = str + "(" + str1 + ")"; // node.Tag = ((ObjectTemplate)item).ID; // parent.Nodes.Add(node); //} try { Type EnumPrpType = _masterForm.SingleForm.Source.GetType().GetProperty("Status").PropertyType; object enumValue = Enum.Parse(EnumPrpType, Convert.ToString(2)); System.Type[] pararemterTypes = new System.Type[1]; pararemterTypes[0] = EnumPrpType; System.Reflection.MethodInfo methodInfo = null; if (_masterForm.GetFunctionName == "") methodInfo = (_masterForm.SingleForm.Source.GetType()).GetMethod("GetParents", pararemterTypes); else methodInfo = (_masterForm.SingleForm.Source.GetType()).GetMethod(_masterForm.GetFunctionName, pararemterTypes); object[] parameterValue = new object[1]; parameterValue[0] = enumValue; object ox = methodInfo.Invoke(_masterForm.SingleForm.Source, parameterValue); IList il = ox as IList; this._masterForm.SourceCollection = new ObjectsTemplate(); foreach (var item in il) { this._masterForm.SourceCollection.Add((ObjectTemplate)item); } } catch (Exception ex) { MessageBox.Show("failed to call the function: get(status). Actual reason:" + ex.Message, "failed to call", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void RefreshListview() { tvMaster.Nodes.Clear(); TreeNode rootNode = new TreeNode(); rootNode.Text = (_masterForm.TreeView.RootNodeText == "") ? _masterForm.Caption : _masterForm.TreeView.RootNodeText; tvMaster.Nodes.Add(rootNode); foreach (var item in _masterForm.SourceCollection) { TreeNode NodeItem = new TreeNode(); string str = ""; string sStatus = ""; string sCode = ""; System.Reflection.PropertyInfo dispMem = item.GetType().GetProperty(_masterForm.TreeView.PropertyNames); str = dispMem.GetValue(item, null).ToString(); System.Reflection.PropertyInfo dispMem1 = item.GetType().GetProperty("Status"); sStatus = dispMem1.GetValue(item, null).ToString(); if (sStatus.Trim() != EnumStatus.Active.ToString()) { NodeItem.BackColor = Color.Red; NodeItem.ForeColor = Color.White; } System.Reflection.PropertyInfo dispMem2 = item.GetType().GetProperty("Code"); if (dispMem2 != null) { sCode = dispMem2.GetValue(item, null).ToString(); str = str + " [" + sCode + "]"; } str = str.Replace("\r\n", ", "); str = str.Replace(",,", ","); sCode = sCode.Replace("\r\n", ", "); sCode = sCode.Replace(",,", ","); NodeItem.Text = str; //NodeItem.Text = str + "(" + sCode + ")"; //NodeItem.Text = str + "(" + str1 + ")"; NodeItem.Tag = item.ID; //NodeItem.Tag = item; rootNode.Nodes.Add(NodeItem); } } #endregion #endregion #region Events public void UpdateSingleFormCaption(ObjectTemplate tmp, bool fromAdd) { int tier = 0; if (tmp != null) { if (tmp.GetType().GetProperty("Tier") == null) throw new ServiceException("Object does not has the property; name: Tier"); tier = Convert.ToInt32(tmp.GetType().GetProperty("Tier").GetValue(tmp, null)); } if (fromAdd == true) tier = tier + 1; if (_masterForm.TreeView.Tiers.Count >= tier) _masterForm.SingleForm.Caption = _masterForm.TreeView.Tiers.GetTierName(tier); } private void btnAdd_Click(object sender, EventArgs e) { if (tvMaster.SelectedNode == null) { MessageBox.Show("Select a Node first to add child", "Input validation", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } try { FrmBasicEntryForm form = new FrmBasicEntryForm(); form.RefreshParent += new System.EventHandler(this.AddToColl); form.IncpUIConfig += new UIConfiguration(this.SingleFormUIConfiguration); ObjectTemplate ot = null; if (tvMaster.SelectedNode.Tag != null) { object[] parameters = new object[1]; parameters[0] = (ID)tvMaster.SelectedNode.Tag; Type[] oType = new Type[1]; oType[0] = parameters[0].GetType(); System.Reflection.MethodInfo methodInfo = (_masterForm.SingleForm.Source.GetType()).GetMethod("Get", oType); ot = (ObjectTemplate)methodInfo.Invoke(_masterForm.SingleForm.Source, parameters); if (ot == null) return; form.ParentObject = ot; this.UpdateSingleFormCaption(ot, true); } else this.UpdateSingleFormCaption(null, true); form.ShowDialog(_masterForm.SingleForm, _masterForm.SingleForm.Source); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } } private void AddToColl(object sender, EventArgs e) { if (sender != null) { ObjectTemplate oTemplate = (ObjectTemplate)sender; TreeNode oNode = new TreeNode(); oNode.Text = Convert.ToString(oTemplate.GetType().GetProperty(_masterForm.TreeView.PropertyNames).GetValue(oTemplate, null)); System.Reflection.PropertyInfo dispMem1 = oTemplate.GetType().GetProperty("Status"); string sStatus = dispMem1.GetValue(oTemplate, null).ToString(); if (sStatus.Trim() != EnumStatus.Active.ToString()) { oNode.BackColor = Color.Red; oNode.ForeColor = Color.White; } System.Reflection.PropertyInfo dispMem2 = oTemplate.GetType().GetProperty("Code"); if (dispMem2 != null) { string sCode = dispMem2.GetValue(oTemplate, null).ToString(); oNode.Text = oNode.Text + " [" + sCode + "]"; } oNode.Tag = oTemplate.ID; tvMaster.SelectedNode.Nodes.Add(oNode); //RefreshListview(); } } private void btnEdit_Click(object sender, EventArgs e) { if (tvMaster.SelectedNode.Tag == null) { MessageBox.Show("Select an Item", "Edit", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } try { object[] parameters = new object[1]; parameters[0] = (ID)tvMaster.SelectedNode.Tag; Type[] oType = new Type[1]; oType[0] = parameters[0].GetType(); System.Reflection.MethodInfo methodInfo = (_masterForm.SingleForm.Source.GetType()).GetMethod("Get", oType); ObjectTemplate oTemplate = (ObjectTemplate)methodInfo.Invoke(_masterForm.SingleForm.Source, parameters); if (oTemplate == null) MessageBox.Show("Object ID not found in the Tree view Tab", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); ; //object itemLocked = oTemplate.GetType().GetProperty("Locked").GetValue(oTemplate, null); //if (!(bool)itemLocked) //{ // MessageBox.Show("Inorder to edit first lock the record.", "Cannot Edit", MessageBoxButtons.OK, MessageBoxIcon.Stop); // return; //} FrmBasicEntryForm form = new FrmBasicEntryForm(); form.IncpUIConfig += new UIConfiguration(this.SingleFormUIConfiguration); this.UpdateSingleFormCaption(oTemplate, false); form.ShowDialog(_masterForm.SingleForm, oTemplate); TreeNode oNode = tvMaster.SelectedNode; oNode.Text = Convert.ToString(oTemplate.GetType().GetProperty( _masterForm.TreeView.PropertyNames).GetValue(oTemplate, null)); oNode.Tag = oTemplate.ID; System.Reflection.PropertyInfo dispMem2 = oTemplate.GetType().GetProperty("Code"); if (dispMem2 != null) { string sCode = dispMem2.GetValue(oTemplate, null).ToString(); oNode.Text = oNode.Text + " [" + sCode + "]"; } // RefreshListview(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void DecorateNode() { ObjectTemplate oTemplate = (ObjectTemplate)tvMaster.SelectedNode.Tag; System.Reflection.PropertyInfo dispMem = oTemplate.GetType().GetProperty(_masterForm.TreeView.PropertyNames); string str = dispMem.GetValue(oTemplate, null).ToString(); tvMaster.SelectedNode.Text = str; } private void btnDel_Click(object sender, EventArgs e) { if (tvMaster.SelectedNode.Tag == null) { MessageBox.Show("Select an Item", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (MessageBox.Show("Are you sure to delete selected item.!", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } try { ID oDeledID = (ID)tvMaster.SelectedNode.Tag; object[] obj = new object[1]; obj[0] = oDeledID; System.Reflection.MethodInfo methodInfoDel = (_masterForm.SingleForm.Source.GetType()).GetMethod("Delete"); methodInfoDel.Invoke(_masterForm.SingleForm.Source, obj); tvMaster.SelectedNode.Remove(); MessageBox.Show("Data deleted successfully. ", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception exp) { MessageBox.Show(exp.InnerException.Message, "Can't Delete", MessageBoxButtons.OK, MessageBoxIcon.Error); } } #endregion private void btnClose_Click(object sender, EventArgs e) { this.Close(); } private void SingleFormUIConfiguration(System.Windows.Forms.Form frm) { if (UpdateUIDesign != null) { UpdateUIDesign(frm); } } private void lvwBEMF_ColumnClick(object sender, ColumnClickEventArgs e) { try { object[] param = new object[2]; param[0] = _masterForm.Listviewcloumns[e.Column].PropertyName; param[1] = System.Windows.Forms.SortOrder.Descending; System.Reflection.MethodInfo methodInfoDel = (_masterForm.SourceCollection.GetType()).GetMethod("Sort"); if (methodInfoDel != null) methodInfoDel.Invoke(_masterForm.SourceCollection, param); RefreshListview(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void lvwBEMF_SelectedIndexChanged(object sender, EventArgs e) { } //private void btnPreview_Click(object sender, EventArgs e) //{ // Report report = new Report(_masterForm); // report.ReportOutput(Ease.Report.Designer.OutputType.OutPutTypePreview); //} //private void btnPrint_Click(object sender, EventArgs e) //{ // Report report = new Report(_masterForm); // report.ReportOutput(Ease.Report.Designer.OutputType.OutPutTypePrint); //} //private void btnExport_Click(object sender, EventArgs e) //{ // Report report = new Report(_masterForm); // report.ReportOutput(Ease.Report.Designer.OutputType.OutPutTypeExportXL); //} private void FrmMasterForm_Load(object sender, EventArgs e) { } /// /// Paint the bottom of the panel /// /// /// private void pnlBottom_Paint(object sender, PaintEventArgs e) { Rectangle BaseRectangle = new Rectangle(0, 0, this.pnlBottom.Width, this.pnlBottom.Height); Brush Gradient_Brush = new LinearGradientBrush(BaseRectangle, System.Drawing.Color.LightBlue, System.Drawing.Color.DarkBlue, LinearGradientMode.Vertical); e.Graphics.FillRectangle(Gradient_Brush, BaseRectangle); } private void FrmMasterForm_Paint(object sender, PaintEventArgs e) { //Rectangle BaseRectangle = new Rectangle(0, 0, this.Width, this.Height); //Brush Gradient_Brush = new LinearGradientBrush(BaseRectangle, System.Drawing.Color.WhiteSmoke, System.Drawing.Color.Gainsboro, LinearGradientMode.Horizontal); //e.Graphics.FillRectangle(Gradient_Brush, BaseRectangle); } private void tvMaster_AfterSelect(object sender, TreeViewEventArgs e) { //btnAdd.Enabled = true; if (tvMaster.SelectedNode.Tag != null) { if (tvMaster.SelectedNode.Level == _masterForm.TreeView.NumberOfTier) { btnAdd.Enabled = false; } else { btnAdd.Enabled = true; } if (e.Node.Nodes.Count == 0) RefreshTree(e.Node, (ID)tvMaster.SelectedNode.Tag); } } private void RefreshTree(TreeNode parent, ID parentID) { try { parent.Nodes.Clear(); object[] parameters = new object[1]; parameters[0] = parentID; System.Reflection.MethodInfo methodInfo = (_masterForm.SingleForm.Source.GetType()).GetMethod("GetChilds"); object ox = methodInfo.Invoke(_masterForm.SingleForm.Source, parameters); if (ox == null) return; IList il = ox as IList; foreach (var item in il) { TreeNode node = new TreeNode(); System.Reflection.PropertyInfo dispMem = item.GetType().GetProperty(_masterForm.TreeView.PropertyNames); string str = dispMem.GetValue(item, null).ToString(); //System.Reflection.PropertyInfo dispMem1 = item.GetType().GetProperty("Status"); //string sStatus = dispMem1.GetValue(item, null).ToString(); dispMem = item.GetType().GetProperty("Code"); if (dispMem != null) { str = str + "[" + dispMem.GetValue(item, null).ToString() + "]"; } System.Reflection.PropertyInfo dispMem1 = item.GetType().GetProperty("Status"); string sStatus = dispMem1.GetValue(item, null).ToString(); if (sStatus.Trim() != EnumStatus.Active.ToString()) { node.BackColor = Color.Red; node.ForeColor = Color.White; } node.Text = str; //node.Text = str + "(" + str1 + ")"; node.Tag = ((ObjectTemplate)item).ID; parent.Nodes.Add(node); } } catch (ServiceException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } } private void btnActive_Click(object sender, EventArgs e) { if (tvMaster.SelectedNode.Tag == null) { MessageBox.Show("Select an Item", "Active/InActive", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (MessageBox.Show("Are you sure to status change selected item.!", "Confirm Active/InActive", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } try { object[] parameters = new object[1]; parameters[0] = (ID)tvMaster.SelectedNode.Tag; Type[] oType = new Type[1]; oType[0] = parameters[0].GetType(); System.Reflection.MethodInfo methodInfo = (_masterForm.SingleForm.Source.GetType()).GetMethod("Get", oType); ObjectTemplate oActive = (ObjectTemplate)methodInfo.Invoke(_masterForm.SingleForm.Source, parameters); if (oActive == null) MessageBox.Show("Object ID not found in the Tree view Tab", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); object status = oActive.GetType().GetProperty("Status").GetValue(oActive, null); object enumValue = null; if (status.ToString() == "Active") { Type EnumPrpType = _masterForm.SingleForm.Source.GetType().GetProperty("Status").PropertyType; enumValue = Enum.Parse(EnumPrpType, Convert.ToString(2)); System.Reflection.PropertyInfo pinfo = (oActive.GetType()).GetProperty("Status"); pinfo.SetValue(oActive, enumValue, null); System.Reflection.MethodInfo methodInfoDel = (oActive.GetType()).GetMethod("Save"); methodInfoDel.Invoke(oActive, null); tvMaster.Refresh(); RefreshSourceCollection(); RefreshListview(); MessageBox.Show("Data InActive successfully. ", "InActive", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Type EnumPrpType = _masterForm.SingleForm.Source.GetType().GetProperty("Status").PropertyType; enumValue = Enum.Parse(EnumPrpType, Convert.ToString(1)); System.Reflection.PropertyInfo pinfo = (oActive.GetType()).GetProperty("Status"); pinfo.SetValue(oActive, enumValue, null); System.Reflection.MethodInfo methodInfoDel = (oActive.GetType()).GetMethod("Save"); methodInfoDel.Invoke(oActive, null); tvMaster.Refresh(); RefreshSourceCollection(); RefreshListview(); MessageBox.Show("Data Activated successfully. ", "Activated", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception exp) { MessageBox.Show(exp.InnerException.Message, "Can't Active", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void btnUp_Click(object sender, EventArgs e) { if(tvMaster.SelectedNode.Tag == null) { MessageBox.Show("Select a node first", "Selection", MessageBoxButtons.OK, MessageBoxIcon.Error); } try { //tvMaster. } catch(Exception ex) { MessageBox.Show(ex.InnerException.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void btnDown_Click(object sender, EventArgs e) { if (tvMaster.SelectedNode.Tag == null) { MessageBox.Show("Select a node first", "Selection", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void tvMaster_Click(object sender, EventArgs e) { if (tvMaster.SelectedNode.Tag == null) { return; } try { ObjectTemplate oTemplate = null; object[] parameters = new object[1]; parameters[0] = (ID)tvMaster.SelectedNode.Tag; Type[] oType = new Type[1]; oType[0] = parameters[0].GetType(); System.Reflection.MethodInfo methodInfo = (_masterForm.SingleForm.Source.GetType()).GetMethod("Get", oType); oTemplate = (ObjectTemplate)methodInfo.Invoke(_masterForm.SingleForm.Source, parameters); if (oTemplate == null) MessageBox.Show("Object ID not found in the Tree view Tab", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); object status = oTemplate.GetType().GetProperty("Status").GetValue(oTemplate, null); //object locked = oTemplate.GetType().GetProperty("Locked").GetValue(oTemplate, null); if (status.ToString() == "Active") { btnActive.Text = "InActive"; } else { btnActive.Text = "Active"; } //if (Convert.ToBoolean(locked)) //{ // btnLock.Text = "Unlock"; //} //else //{ // btnLock.Text = "Lock"; //} } catch (Exception exp) { MessageBox.Show(exp.InnerException.Message, "Active", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void chkActive_CheckedChanged(object sender, EventArgs e) { //if (chkActive.Checked == true) //{ // chkActive.Text = "Only Active"; // Type EnumPrpType = _masterForm.SingleForm.Source.GetType().GetProperty("Status").PropertyType; // object enumValue = Enum.Parse(EnumPrpType, Convert.ToString(1)); // System.Type[] pararemterTypes = new System.Type[1]; // pararemterTypes[0] = EnumPrpType; // System.Reflection.MethodInfo methodInfo = (_masterForm.SingleForm.Source.GetType()).GetMethod("GetParents", pararemterTypes); // object[] parameterValue = new object[1]; // parameterValue[0] = enumValue; // object ox = methodInfo.Invoke(_masterForm.SingleForm.Source, parameterValue); // IList il = ox as IList; // this._masterForm.SourceCollection = new ObjectsTemplate(); // foreach (var item in il) // { // this._masterForm.SourceCollection.Add((ObjectTemplate)item); // } //} //else //{ // chkActive.Text = "All"; // Type EnumPrpType = _masterForm.SingleForm.Source.GetType().GetProperty("Status").PropertyType; // object enumValue = Enum.Parse(EnumPrpType, Convert.ToString(2)); // System.Type[] pararemterTypes = new System.Type[1]; // pararemterTypes[0] = EnumPrpType; // System.Reflection.MethodInfo methodInfo = (_masterForm.SingleForm.Source.GetType()).GetMethod("GetParents", pararemterTypes); // object[] parameterValue = new object[1]; // parameterValue[0] = enumValue; // object ox = methodInfo.Invoke(_masterForm.SingleForm.Source, parameterValue); // IList il = ox as IList; // this._masterForm.SourceCollection = new ObjectsTemplate(); // foreach (var item in il) // { // this._masterForm.SourceCollection.Add((ObjectTemplate)item); // } //} //RefreshListview(); } private void chkAuthorized_CheckedChanged(object sender, EventArgs e) { //if (chkAuthorized.Checked == true) //{ // chkActive.Text = "Only Authorized"; // Type EnumPrpType = _masterForm.SingleForm.Source.GetType().GetProperty("Authorized").PropertyType; // object enumValue = true; // System.Type[] pararemterTypes = new System.Type[1]; // pararemterTypes[0] = EnumPrpType; // System.Reflection.MethodInfo methodInfo = (_masterForm.SingleForm.Source.GetType()).GetMethod("Get", pararemterTypes); // object[] parameterValue = new object[1]; // parameterValue[0] = enumValue; // object ox = methodInfo.Invoke(_masterForm.SingleForm.Source, parameterValue); // IList il = ox as IList; // this._masterForm.SourceCollection = new ObjectsTemplate(); // foreach (var item in il) // { // this._masterForm.SourceCollection.Add((ObjectTemplate)item); // } //} //else //{ // chkActive.Text = "All Data"; // Type EnumPrpType = _masterForm.SingleForm.Source.GetType().GetProperty("Authorized").PropertyType; // object enumValue = false; // System.Type[] pararemterTypes = new System.Type[1]; // pararemterTypes[0] = EnumPrpType; // System.Reflection.MethodInfo methodInfo = (_masterForm.SingleForm.Source.GetType()).GetMethod("GetParents", pararemterTypes); // object[] parameterValue = new object[1]; // parameterValue[0] = enumValue; // object ox = methodInfo.Invoke(_masterForm.SingleForm.Source, parameterValue); // IList il = ox as IList; // this._masterForm.SourceCollection = new ObjectsTemplate(); // foreach (var item in il) // { // this._masterForm.SourceCollection.Add((ObjectTemplate)item); // } //} //RefreshListview(); } private void btnLock_Click(object sender, EventArgs e) { //if (tvMaster.SelectedNode.Tag == null) //{ // MessageBox.Show("Select an Item", "Active/InActive", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} //if (MessageBox.Show("Are you sure to status change selected item.!", "Confirm Active/InActive", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) //{ // return; //} //try //{ // object[] parameters = new object[1]; // parameters[0] = (ID)tvMaster.SelectedNode.Tag; // Type[] oType = new Type[1]; // oType[0] = parameters[0].GetType(); // System.Reflection.MethodInfo methodInfo = (_masterForm.SingleForm.Source.GetType()).GetMethod("Get", oType); // ObjectTemplate oLocked = (ObjectTemplate)methodInfo.Invoke(_masterForm.SingleForm.Source, parameters); // if (oLocked == null) MessageBox.Show("Object ID not found in the Tree view Tab", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); // object item = oLocked.GetType().GetProperty("Locked").GetValue(oLocked, null); // object itemUSer = oLocked.GetType().GetProperty("ModifiedBy").GetValue(oLocked, null); // object enumValue = null; // if ((Boolean)item) // { // if (User.CurrentUser.ID.Integer == Convert.ToInt16(itemUSer.ToString())) // { // enumValue = false; // System.Reflection.PropertyInfo pinfo = (oLocked.GetType()).GetProperty("Locked"); // pinfo.SetValue(oLocked, enumValue, null); // System.Reflection.MethodInfo methodInfoDel = (oLocked.GetType()).GetMethod("Save"); // methodInfoDel.Invoke(oLocked, null); // tvMaster.Refresh(); // RefreshSourceCollection(); // MessageBox.Show("Data unlocked successfully. ", "Unlocked", MessageBoxButtons.OK, MessageBoxIcon.Information); // } // else // { // MessageBox.Show("This record is locked by another user\nYou cannot unlock this record. ", "Unlock Faild", MessageBoxButtons.OK, MessageBoxIcon.Error); // } // } // else // { // enumValue = true; // System.Reflection.PropertyInfo pinfo = (oLocked.GetType()).GetProperty("Locked"); // pinfo.SetValue(oLocked, enumValue, null); // System.Reflection.MethodInfo methodInfoDel = (oLocked.GetType()).GetMethod("Save"); // methodInfoDel.Invoke(oLocked, null); // tvMaster.Refresh(); // RefreshSourceCollection(); // MessageBox.Show("Data locked successfully. ", "Locked", MessageBoxButtons.OK, MessageBoxIcon.Information); // } //} //catch (Exception exp) //{ // MessageBox.Show(exp.InnerException.Message, "Can't Lock", MessageBoxButtons.OK, MessageBoxIcon.Error); //} } private void btnAuthorized_Click(object sender, EventArgs e) { //if (tvMaster.SelectedNode.Tag == null) //{ // MessageBox.Show("Select an Item", "Active/InActive", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} //if (MessageBox.Show("Are you sure to status change selected item.!", "Confirm Active/InActive", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) //{ // return; //} //try //{ // object[] parameters = new object[1]; // parameters[0] = (ID)tvMaster.SelectedNode.Tag; // Type[] oType = new Type[1]; // oType[0] = parameters[0].GetType(); // System.Reflection.MethodInfo methodInfo = (_masterForm.SingleForm.Source.GetType()).GetMethod("Get", oType); // ObjectTemplate oLocked = (ObjectTemplate)methodInfo.Invoke(_masterForm.SingleForm.Source, parameters); // if (oLocked == null) MessageBox.Show("Object ID not found in the Tree view Tab", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); // object itemLocked = oLocked.GetType().GetProperty("Locked").GetValue(oLocked, null); // object item = oLocked.GetType().GetProperty("Authorized").GetValue(oLocked, null); // object enumValue = null; // if ((bool)itemLocked) // { // MessageBox.Show("Selected item is locked,you canott authorize", "Authorization Failed", MessageBoxButtons.OK, MessageBoxIcon.Stop); // return; // } // enumValue = true; // System.Reflection.PropertyInfo pinfo = (oLocked.GetType()).GetProperty("Authorized"); // pinfo.SetValue(oLocked, enumValue, null); // System.Reflection.MethodInfo methodInfoDel = (oLocked.GetType()).GetMethod("Save"); // methodInfoDel.Invoke(oLocked, null); // tvMaster.Refresh(); // RefreshSourceCollection(); // MessageBox.Show("Data authorized successfully. ", "Authorized", MessageBoxButtons.OK, MessageBoxIcon.Information); //} //catch (Exception exp) //{ // MessageBox.Show(exp.InnerException.Message, "Can't Lock", MessageBoxButtons.OK, MessageBoxIcon.Error); //} } } }