public static void ReadProductsOnTableFromFile(List <IUsedTable> tablesInUse) { bool fileExist = false; fileExist = File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\ProductsOnTables.txt"); if (fileExist) { string text = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\ProductsOnTables.txt", Encoding.UTF8); string[] lines = text.Split('\n'); for (int i = 0; i < lines.Length - 1; i++) { IAreaOfTables addingArea = new AreaOfTables(); IUsedTable addingFullTable = new UsedTable(); string[] groups = lines[i].Split('|'); string[] elements = groups[0].Split('^'); addingFullTable.Id = int.Parse(elements[0]); addingFullTable.NumberOfTable = int.Parse(elements[1]); addingArea.AreaName = elements[2]; addingArea.Id = int.Parse(elements[3]); addingFullTable.AreaId = int.Parse(elements[3]); addingFullTable.ShowOccupied = elements[4]; addingFullTable.Area = addingArea; for (int j = 1; j < groups.Length - 1; j++) { IProduct addingProduct = new Product(); ICategory addingCategory = new Category(); elements = groups[j].Split('^'); addingProduct.Id = int.Parse(elements[0]); addingProduct.Name = elements[1]; addingCategory.Name = elements[2]; addingCategory.Id = int.Parse(elements[3]); addingProduct.CategoryId = int.Parse(elements[3]); addingProduct.Price = decimal.Parse(elements[4]); addingProduct.Detail = elements[5]; addingProduct.Category = addingCategory; addingFullTable.Products.Add(addingProduct); } tablesInUse.Add(addingFullTable); } } }
/// <summary> /// Returns the visible and selected Relationship types from the visible relationship type grid /// </summary> /// <returns></returns> private string GetSelectedRelationshipsAsCsv(bool directRelationship = false) { String RelationshipTypeList = ""; DataTable UsedTable; if ((rbtDirectRelationship.Checked && !CalledFromExtracts) || directRelationship) { UsedTable = FDirectRelationshipTable; } else { UsedTable = FReciprocalRelationshipTable; } DataRow[] VisibleRows = UsedTable.Select(UsedTable.DefaultView.RowFilter); for (int Counter = 0; Counter < VisibleRows.Length; ++Counter) { if ((bool)VisibleRows[Counter]["Selection"]) { String CurrentType = VisibleRows[Counter][PRelationTable.GetRelationNameDBName()].ToString(); RelationshipTypeList = RelationshipTypeList + CurrentType + ','; } } if (RelationshipTypeList.Length > 0) { // Remove the last comma RelationshipTypeList = RelationshipTypeList.Remove(RelationshipTypeList.Length - 1, 1); // Check if we have to use escape sequences for ' // for example G'PARENT to G''PARENT RelationshipTypeList = RelationshipTypeList.Replace("'", "''"); } return(RelationshipTypeList); }