public ViewDataClient() { tuObject = new TUObjects(); tuObjectData = new TUObjectsDTO(); dbAction = DBAction.Edit; listEnteredValues = new List<string>(); referencedFieldsIds = new List<int>(); listLabels = new List<Label>(); listTextBoxes = new List<TextBox>(); listButtons = new List<Button>(); InitializeComponent(); }
public ViewDataClient(TUObjects tuObject, TUObjectsDTO tuObjectData, DBAction dbAction) { this.tuObject = tuObject; this.tuObjectData = tuObjectData; this.dbAction = dbAction; listEnteredValues = new List<string>(); referencedFieldsIds = new List<int>(); listLabels = new List<Label>(); listTextBoxes = new List<TextBox>(); listButtons = new List<Button>(); InitializeComponent(); }
//TUObjects //private void insertToolStripMenuItem_Click(object sender, EventArgs e) //{ //} //recursive function for deleting nodes from tree - delete subtree private void DeleteTreeNodes(TUObjects fuObject, int Id, bool IsFirst) { dbConnection.Open(); List<int> LId = new List<int>(); bool IsDel = false; string className; dbCommand.CommandText = "Select Count(Id) From TUObjects Where Major =" + Id; int count = (int)dbCommand.ExecuteScalar(); if (count > 0) { if (IsFirst) { DialogResult d = MessageBox.Show("This node has douter nodes. Do you want to delete them?", "Deleting nodes", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (d == DialogResult.Yes) IsDel = true; } else IsDel = true; if (IsDel) { dbCommand.CommandText = "Select Id From TUObjects Where Major = " + Id; dbDataReader = dbCommand.ExecuteReader(); while (dbDataReader.Read()) { LId.Add(dbDataReader.GetInt32(0)); } dbDataReader.Close(); dbConnection.Close(); foreach (int i in LId) { dbConnection.Open(); dbCommand.CommandText = "Select FormName From Classes_ Where ClassId = " + "(Select ClassId From TUObjects Where Id = " + i + ")"; className = (string)dbCommand.ExecuteScalar(); TUObjects tuObject; Type t = Type.GetType(DefinedConstants.logicLeyerNameSpace + "." + className + ", " + DefinedConstants.logicLeyerNameSpace); tuObject = (TUObjects)Activator.CreateInstance(t, dbConnection, dbServer); dbConnection.Close(); // DeleteTreeNodes(tuObject, i, false); } dbConnection.Open(); fuObject.Delete(Id); clickNode.Remove(); } } else { fuObject.Delete(Id); clickNode.Remove(); } dbConnection.Close(); }