Ejemplo n.º 1
0
		private void masterView_SelectionChanged(object sender, EventArgs e)
		{
			try
			{
				if (masterView.SelectedRows.Count > 0 && detailsTabs.SelectedItem != null)
				{
					object selectedObject = masterView.SelectedRows[0].Tag;
					if (selectedObject == null)

						return;

					long selectedId = (long) selectedObject;
					if (selectedId != 0 && selectedId == ReferencedObjectFor(detailsTabs.SelectedItem))
					{
						PropertiesTab.Instance.ShowObjectPropertiesTab = true;
						PropertiesTab.Instance.RefreshPropertiesTab(selectedId);
						return;
					}
				}

				if (masterView.SelectedRows.Count <= 0)
					return;

				DataGridViewRow row = masterView.SelectedRows[0];
				if (null == row)
					return;

				if (row.Tag != null)
				{
					OMETabStripItem foundTab = FindDetailsTabForObjectIndex(DetailsTabCaptionFor(row));
					if (null != foundTab)
					{
						detailsTabs.SelectedItem = foundTab;
						return;
					}
					 
					TreeGridView treeview = new RenderTreeGridView().RenderTreeGridViewDetails((long)row.Tag, ClassName);
					

					OMETabStripItem tabPage = new OMETabStripItem(DetailsTabCaptionFor(row), treeview);
					tabPage.Name = tabPage.Title;
					detailsTabs.AddTab(tabPage);

					RegisterTreeviewEvents(treeview);
					// This check helps in avoding recusrrion.
					if (masterView.SortOrder == SortOrder.None)
					{
						detailsTabs.SelectedItem = tabPage;
					}

				}
				else
					row.Selected = false;
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}
		}
Ejemplo n.º 2
0
		private void treeview_OnContextMenuItemClicked(object sender, ContextItemClickedEventArg e)
		{
		    try
		    {
		        TreeGridView treeview = (TreeGridView) e.Data;
		        if (treeview.SelectedRows.Count <= 0)
		            return;

		        treeview.ContextMenuStrip.Dispose();
		        DialogResult dialogRes =
		            MessageBox.Show("This will set the value to null in the database. Do you want to continue?",
		                            Helper.GetResourceString(Constants.PRODUCT_CAPTION), MessageBoxButtons.YesNo,
		                            MessageBoxIcon.Question);

		        if (dialogRes != DialogResult.Yes)
		            return;

		        TreeGridNode node = (TreeGridNode) treeview.SelectedCells[0].OwningRow;
                long id = (long)node.Parent.Tag;	
		    	    
		           

                AssemblyInspectorObject.DataSave.SetFieldToNull(id, CommonValues.UndecorateFieldName(node.Cells[0].Value.ToString()));
	           bool objectExist = false;
				if (id != 0)
				{
					objectExist =  AssemblyInspectorObject.DataPopulation.CheckIfObjectExists (id); 
				}
				else
				{
					MessageBox.Show("This object is already Null.", Helper.GetResourceString(Constants.PRODUCT_CAPTION),
										MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
				}

                if (objectExist)
				{
					AssemblyInspectorObject.DataSave.RefreshObject(id, DepthFor(node));
					UpdateResultTable(treeview.SelectedCells[0].OwningRow.Cells[0],
					                  "null",
					                  (TreeGridNode) treeview.SelectedCells[0].OwningRow.Cells[0].OwningRow,
					                  (OMETabStripItem) treeview.Parent, true);
                    treeview = new RenderTreeGridView().RenderTreeGridViewDetails((long)treeview.Nodes[0].Tag, FieldTypeNameFor(treeview.Nodes[0]));
					detailsTabs.SelectedItem.Controls.Clear();
					detailsTabs.SelectedItem.Controls.Add(treeview);
					RegisterTreeviewEvents(treeview);
				}
				else //delete tab as teh obj is deleted and delete it from db grid view
				{
					int index = OffsetInCurrentPageFor(ObjectIndexInMasterViewFor((OMETabStripItem) treeview.Parent));
					detailsTabs.RemoveTab(detailsTabs.SelectedItem);
					masterView.Rows.RemoveAt(index - 1);

					if( detailsTabs.SelectedItem !=null )
                        detailsTabs.SelectedItem .Controls.Clear();
					lstObjIdLong.Remove(id);

					int m_pageCount = CurrentPageNumber();
					int startIndex = (CurrentPageNumber()*PagingData.PAGE_SIZE) - PagingData.PAGE_SIZE;
					int endIndex = startIndex + PagingData.PAGE_SIZE;
					labelNoOfObjects.Text = lstObjIdLong.Count.ToString();

					PagingData pgData = new PagingData(startIndex, endIndex);
					pgData.ObjectId = lstObjIdLong;
					if (lstObjIdLong.Count > 0)
					{
						List<Hashtable> hashListResult = AssemblyInspectorObject.DataPopulation.ReturnQueryResults(pgData, false, omQuery.BaseClass,
						                                                                  omQuery.AttributeList);
						Hashtable hAttributes = null;

						if (omQuery != null)
						{
							hAttributes = omQuery.AttributeList;
						}
						masterView.SetDatagridRows(hashListResult, ClassName, hAttributes, 1);
					}

					treeview = new RenderTreeGridView().RenderTreeGridViewDetails(ReferencedObjectFor(detailsTabs.SelectedItem), ClassName);

				    if (detailsTabs.SelectedItem != null) detailsTabs.SelectedItem.Controls.Add(treeview);
				    RegisterTreeviewEvents(treeview);

					int delIndex = ObjectIndexInMasterViewFor(detailsTabs.SelectedItem);
					UpdateObjectDetailTablCaptions(delIndex);
				}
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}
		}
Ejemplo n.º 3
0
		private void UpdateDataTreeView(object objUpdated, DataGridViewRow row)
		{
			try
			{
				OMETrace.WriteFunctionStart();

				if (objUpdated != null)
				{
					OMETabStripItem detailsTab = FindDetailsTabForObjectIndex(DetailsTabCaptionFor(row));
					if (detailsTab != null)
					{
						
						TreeGridView treeview =new RenderTreeGridView().RenderTreeGridViewDetails((long)objUpdated, ClassName);
						detailsTab.Controls.Clear();
						detailsTab.Controls.Add(treeview);
						RegisterTreeviewEvents(treeview);
						detailsTab.Name = CONST_TRUE;
					}
				}

				OMETrace.WriteFunctionEnd();
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}
		}