diff --git a/CMS_CORE_Library/Demo/ILibraryService.cs b/CMS_CORE_Library/Demo/ILibraryService.cs index 1ae624e..5ee8f69 100644 --- a/CMS_CORE_Library/Demo/ILibraryService.cs +++ b/CMS_CORE_Library/Demo/ILibraryService.cs @@ -163,12 +163,15 @@ namespace Nc_Demo_Application.Server.Service [WebGet(UriTemplate = "tool_table/families", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void GetFamilies(out List families); - [WebInvoke(Method = "PUT", UriTemplate = "tool_table/family", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] - void PutFamily(DemoFamilyModel familyData); + [WebInvoke(Method = "PUT", UriTemplate = "tool_table/family/{oldName}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void PutFamily(string oldName, DemoFamilyModel family); [WebInvoke(Method = "POST", UriTemplate = "tool_table/family", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] void AddFamily(ref FamilyModel family); + [WebInvoke(Method = "DELETE", UriTemplate = "tool_table/family/{name}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void DeleteFamily(string name); + #endregion #region Tools @@ -179,17 +182,27 @@ namespace Nc_Demo_Application.Server.Service [WebInvoke(Method = "POST", UriTemplate = "tool_table/tool", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] void AddTool(ref SiemensToolModel tool); + [WebInvoke(Method = "PUT", UriTemplate = "tool_table/tool", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void PutTool(SiemensToolModel tool); + + [WebInvoke(Method = "DELETE", UriTemplate = "tool_table/tool/{id}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void DeleteTool(string id); + + [WebGet(UriTemplate = "tool_table/shanks", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void GetShanks(out List shanksData); [WebInvoke(Method = "POST", UriTemplate = "tool_table/shank", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] void AddShank(out ShankModel shankData); + [WebInvoke(Method = "DELETE", UriTemplate = "tool_table/shank/{id}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void DeleteShank(string id); + [WebGet(UriTemplate = "tool_table/positions", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] - void GetPositions(out List positionsData); + void GetPositions(out List positionsData); [WebInvoke(Method = "PUT", UriTemplate = "tool_table/position", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] - void PutPosition(DemoPositionsModel position); + void PutPosition(MagazinePositionsModel position); #endregion diff --git a/CMS_CORE_Library/Demo/Nc_Demo.cs b/CMS_CORE_Library/Demo/Nc_Demo.cs index 0c54365..d2083df 100644 --- a/CMS_CORE_Library/Demo/Nc_Demo.cs +++ b/CMS_CORE_Library/Demo/Nc_Demo.cs @@ -1791,6 +1791,44 @@ namespace CMS_CORE.Demo } } + public override CmsError TOOLS_WUpdateTool(SiemensToolModel tool) + { + // Check if the NC Demo is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + + try + { + serverService.PutTool(tool); + + return NO_ERROR; + } + catch (Exception ex) + { + return ManageException(ex); + } + } + + public override CmsError TOOLS_WDeleteTool(int id) + { + // Check if the NC Demo is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + + try + { + serverService.DeleteTool(id.ToString()); + + return NO_ERROR; + } + catch (Exception ex) + { + return ManageException(ex); + } + } + public override CmsError TOOLS_RShanksData(ref List shanks) { // Check if the NC Demo is Connected @@ -1847,6 +1885,25 @@ namespace CMS_CORE.Demo } + public override CmsError TOOLS_WDeleteShank(int id) + { + // Check if the NC Demo is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + + try + { + serverService.DeleteShank(id.ToString()); + + return NO_ERROR; + } + catch (Exception ex) + { + return ManageException(ex); + } + } + public override CmsError TOOLS_RFamilyData(ref List families) { // Check if the NC Demo is Connected @@ -1882,32 +1939,6 @@ namespace CMS_CORE.Demo } } - //public override CmsError TOOLS_WUpdateFamilyData(int id, string name) - //{ - // // Check if the NC Demo is Connected - // CmsError cmsError = CheckConnection(); - // if (cmsError.IsError()) - // return cmsError; - // try - // { - // DemoFamilyModel demo = new DemoFamilyModel() - // { - // Id = id, - // Name = name - // }; - - // // Get families data - // serverService.PutFamily(); - - - // return NO_ERROR; - // } - // catch (Exception ex) - // { - // return ManageException(ex); - // } - //} - public override CmsError TOOLS_WAddFamily(ref FamilyModel family) { // Check if the NC Demo is Connected @@ -1927,6 +1958,51 @@ namespace CMS_CORE.Demo } } + public override CmsError TOOLS_WUpdateFamilyData(string oldName, string newName) + { + // Check if the NC Demo is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + try + { + DemoFamilyModel demoFamilyData = new DemoFamilyModel() + { + Name = newName + }; + + // Get families data + serverService.PutFamily(oldName, demoFamilyData); + + + return NO_ERROR; + } + catch (Exception ex) + { + return ManageException(ex); + } + } + + public override CmsError TOOLS_WDeleteFamily(string name) + { + // Check if the NC Demo is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + + try + { + serverService.DeleteFamily(name); + + return NO_ERROR; + } + catch (Exception ex) + { + return ManageException(ex); + } + } + + public override CmsError TOOLS_RMagazinePositions(ref List positions) { // Check if the NC Demo is Connected @@ -1938,17 +2014,17 @@ namespace CMS_CORE.Demo try { // Get position data from demo - serverService.GetPositions(out List demoPositions); - // Populate output model - foreach (DemoPositionsModel position in demoPositions) - { - positions.Add(new MagazinePositionsModel() - { - Id = position.Id, - MagazineId = position.MagazineId, - Type = position.Type - }); - } + serverService.GetPositions(out List demoPositions); + //// Populate output model + //foreach (DemoPositionsModel position in demoPositions) + //{ + // positions.Add(new MagazinePositionsModel() + // { + // Id = position.Id, + // MagazineId = position.MagazineId, + // Type = position.Type + // }); + //} return NO_ERROR; } @@ -1957,7 +2033,27 @@ namespace CMS_CORE.Demo return ManageException(ex); } } - + + public override CmsError TOOLS_WUpdateMagazinesPositions(MagazinePositionsModel position) + { + // Check if the NC Demo is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + + try + { + // Call demo update + serverService.PutPosition(position); + + return NO_ERROR; + } + catch (Exception ex) + { + return ManageException(ex); + } + } + #endregion Tools Management /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs index 9b259da..0c09e0d 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -1705,6 +1705,36 @@ namespace CMS_CORE.Fanuc return NO_ERROR; } + public override CmsError TOOLS_WUpdateFamilyData(string oldName, string newName) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WUpdateMagazinesPositions(MagazinePositionsModel position) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WUpdateTool(SiemensToolModel tool) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WDeleteTool(int id) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WDeleteShank(int id) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WDeleteFamily(string name) + { + return NO_ERROR; + } + #endregion Tools Management /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Nc.cs b/CMS_CORE_Library/Nc.cs index 79da1d6..c609c8e 100644 --- a/CMS_CORE_Library/Nc.cs +++ b/CMS_CORE_Library/Nc.cs @@ -1315,6 +1315,18 @@ namespace CMS_CORE public abstract CmsError TOOLS_WAddShank(ref ShankModel shank); + public abstract CmsError TOOLS_WUpdateFamilyData(string oldName, string newName); + + public abstract CmsError TOOLS_WUpdateMagazinesPositions(MagazinePositionsModel position); + + public abstract CmsError TOOLS_WUpdateTool(SiemensToolModel tool); + + public abstract CmsError TOOLS_WDeleteTool(int id); + + public abstract CmsError TOOLS_WDeleteShank(int id); + + public abstract CmsError TOOLS_WDeleteFamily(string name); + #endregion File Management (To override) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index 9240866..fe56859 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -2074,6 +2074,37 @@ namespace CMS_CORE.Osai { return NO_ERROR; } + + public override CmsError TOOLS_WUpdateFamilyData(string oldName, string newName) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WUpdateMagazinesPositions(MagazinePositionsModel position) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WUpdateTool(SiemensToolModel tool) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WDeleteTool(int id) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WDeleteShank(int id) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WDeleteFamily(string name) + { + return NO_ERROR; + } + #endregion Tools Management /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index 57505ea..ccd901a 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -1897,6 +1897,36 @@ namespace CMS_CORE.Siemens return NO_ERROR; } + public override CmsError TOOLS_WUpdateFamilyData(string oldName, string newName) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WUpdateMagazinesPositions(MagazinePositionsModel position) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WUpdateTool(SiemensToolModel tool) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WDeleteTool(int id) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WDeleteShank(int id) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WDeleteFamily(string name) + { + return NO_ERROR; + } + #endregion Tool Management /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/DatabaseController.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/DatabaseController.cs index 12dbb8b..d4c20ca 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/DatabaseController.cs +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/DatabaseController.cs @@ -612,11 +612,11 @@ namespace Nc_Demo_Application.Database UpdateDatabaseFromGridView(families, READ_FAMILIES_QUERY); } - public void UpdateFamily(FamilyModel familyData) + public void UpdateFamily(string oldName, string newName) { - DataRow row = FamiliesDataTable.AsEnumerable().SingleOrDefault(x => Convert.ToInt32(x["id"]) == familyData.Id); + DataRow row = FamiliesDataTable.AsEnumerable().FirstOrDefault(x => x["name"].ToString() == oldName); - row["name"] = familyData.Name; + row["name"] = newName; UpdateFamilies(FamiliesDataTable); } @@ -662,6 +662,35 @@ namespace Nc_Demo_Application.Database } } + public void DeleteFamily(string name) + { + try + { + SetConnection(); + + // Open the connection with database + sqlConnection.Open(); + // Create a SQLite command with query, adapter and commandbuilder in order to update. + sqlCommand = new SQLiteCommand(READ_FAMILIES_QUERY, sqlConnection); + SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlCommand); + SQLiteCommandBuilder commandBuilder = new SQLiteCommandBuilder(adapter); + + // Delete row with matching id + DataRow row = FamiliesDataTable.AsEnumerable().FirstOrDefault(x => x["name"].ToString() == name); + + row.Delete(); + // Update database + adapter.Update(FamiliesDataTable); + + // Close the connection with database + sqlConnection.Close(); + } + catch (Exception ex) + { + Console.WriteLine("Delete family exception: " + ex.Message); + } + } + #endregion Families #region Shanks @@ -764,6 +793,35 @@ namespace Nc_Demo_Application.Database } } + public void DeleteShank(int id) + { + try + { + SetConnection(); + + // Open the connection with database + sqlConnection.Open(); + // Create a SQLite command with query, adapter and commandbuilder in order to update. + sqlCommand = new SQLiteCommand(READ_SHANKS_QUERY, sqlConnection); + SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlCommand); + SQLiteCommandBuilder commandBuilder = new SQLiteCommandBuilder(adapter); + + // Delete row with matching id + DataRow row = ShanksDataTable.AsEnumerable().FirstOrDefault(x => Convert.ToInt32(x["id"]) == id); + + row.Delete(); + // Update database + adapter.Update(ShanksDataTable); + + // Close the connection with database + sqlConnection.Close(); + } + catch (Exception ex) + { + Console.WriteLine("Delete shank exception: " + ex.Message); + } + } + #endregion Shanks #region Tools @@ -836,23 +894,14 @@ namespace Nc_Demo_Application.Database DataRow row = ToolsDataTable.NewRow(); // Find & set new item Id toolData.Id = Convert.ToInt32(ToolsDataTable.Rows[ToolsDataTable.Rows.Count - 1]["id"]) + 1; - - var family = toolData.FamilyName; - // Find next child id - var childs = ToolsDataTable.AsEnumerable() - .Where(x => x["family"].ToString() == family)? - .Select(x => Convert.ToInt32(x["childId"])).ToList(); - - int newChildId = 1; - if (childs.Count != 0) - newChildId = childs.Max() + 1; - toolData.ChildId = newChildId; + // Get child id + toolData.ChildId = GetFamilyChildId(toolData.FamilyName); // Setup autoincrement Id row["id"] = toolData.Id; row["family"] = toolData.FamilyName; row["magazine"] = toolData.MagazineId; - row["childId"] = newChildId; + row["childId"] = toolData.ChildId; row["magazinePositionType"] = toolData.MagazinePositionType; row["toolType"] = toolData.ToolType; row["sizeLeft"] = toolData.LeftSize; @@ -901,12 +950,12 @@ namespace Nc_Demo_Application.Database SQLiteCommandBuilder commandBuilder = new SQLiteCommandBuilder(adapter); // Create new row that must be inserted - DataRow row = ToolsDataTable.AsEnumerable().SingleOrDefault(x => Convert.ToInt32(x["id"]) == toolData.Id); + DataRow row = ToolsDataTable.AsEnumerable().FirstOrDefault(x => Convert.ToInt32(x["id"]) == toolData.Id); row["family"] = toolData.FamilyName; row["magazine"] = toolData.MagazineId; row["magazinePositionType"] = toolData.MagazinePositionType; - row["childId"] = toolData.ChildId; + row["childId"] = GetFamilyChildId(toolData.FamilyName); row["toolType"] = toolData.ToolType; row["shankId"] = toolData.ShanksId; row["sizeLeft"] = toolData.LeftSize; @@ -933,8 +982,21 @@ namespace Nc_Demo_Application.Database Console.WriteLine("Update tool exception: " + ex.Message); } } + + private int GetFamilyChildId(string familyName) + { + // Find next child id + var childs = ToolsDataTable.AsEnumerable() + .Where(x => x["family"].ToString() == familyName)? + .Select(x => Convert.ToInt32(x["childId"])).ToList(); - public void DeleteToolFromDatabase(int id) + if (childs.Count != 0) + return childs.Max() + 1; + + return 1; + } + + public void DeleteTool(int id) { try { @@ -948,7 +1010,7 @@ namespace Nc_Demo_Application.Database SQLiteCommandBuilder commandBuilder = new SQLiteCommandBuilder(adapter); // Delete row with matching id - DataRow row = ToolsDataTable.AsEnumerable().SingleOrDefault(x => Convert.ToInt32(x["id"]) == id); + DataRow row = ToolsDataTable.AsEnumerable().FirstOrDefault(x => Convert.ToInt32(x["id"]) == id); row.Delete(); // Update database @@ -1011,7 +1073,7 @@ namespace Nc_Demo_Application.Database // Find position to be updated DataRow row = MagazinesPositionDataTable .AsEnumerable() - .SingleOrDefault(x => Convert.ToInt32(x["positionId"]) == position.Id && Convert.ToInt32(x["magazineId"]) == position.MagazineId); + .FirstOrDefault(x => Convert.ToInt32(x["positionId"]) == position.Id && Convert.ToInt32(x["magazineId"]) == position.MagazineId); // Update positions type row["type"] = position.Type; @@ -1023,6 +1085,7 @@ namespace Nc_Demo_Application.Database { UpdateDatabaseFromGridView(positions, READ_MAGAZINES_QUERY); } + #endregion Magazines } } \ No newline at end of file diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/ILibraryService.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/ILibraryService.cs index 321ced4..c6e0451 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/ILibraryService.cs +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/ILibraryService.cs @@ -166,12 +166,14 @@ namespace Nc_Demo_Application.Server.Service [WebGet(UriTemplate = "tool_table/families", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void GetFamilies(out List families); - [WebInvoke(Method = "PUT", UriTemplate = "tool_table/family", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] - void PutFamily(FamilyModel familyData); + [WebInvoke(Method = "PUT", UriTemplate = "tool_table/family/{oldName}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void PutFamily(string oldName, FamilyModel family); [WebInvoke(Method = "POST", UriTemplate = "tool_table/family", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] void AddFamily(ref FamilyModel family); + [WebInvoke(Method = "DELETE", UriTemplate = "tool_table/family/{name}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void DeleteFamily(string name); #endregion #region Tools @@ -182,18 +184,26 @@ namespace Nc_Demo_Application.Server.Service [WebInvoke(Method = "POST", UriTemplate = "tool_table/tool", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] void AddTool(ref ToolsDataModel tool); + [WebInvoke(Method = "PUT", UriTemplate = "tool_table/tool", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void PutTool(ToolsDataModel tool); + + [WebInvoke(Method = "DELETE", UriTemplate = "tool_table/tool/{id}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void DeleteTool(string id); + [WebGet(UriTemplate = "tool_table/shanks", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void GetShanks(out List shanksData); [WebInvoke(Method = "POST", UriTemplate = "tool_table/shank", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] void AddShank(out ShankDataModel shankData); + [WebInvoke(Method = "DELETE", UriTemplate = "tool_table/shank/{id}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void DeleteShank(string id); + [WebGet(UriTemplate = "tool_table/positions", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void GetPositions(out List positionsData); [WebInvoke(Method = "PUT", UriTemplate = "tool_table/position", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] void PutPosition(PositionsDataModel position); - #endregion } } diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/LibraryService.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/LibraryService.cs index b11f837..db84804 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/LibraryService.cs +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/LibraryService.cs @@ -461,9 +461,9 @@ namespace Nc_Demo_Application.Server.Service families = DatabaseController.getInstance().GetFamilies(); } - public void PutFamily(FamilyModel familyData) + public void PutFamily(string oldName, FamilyModel family) { - DatabaseController.getInstance().UpdateFamily(familyData); + DatabaseController.getInstance().UpdateFamily(oldName, family.Name); } public void AddFamily(ref FamilyModel family) @@ -482,7 +482,12 @@ namespace Nc_Demo_Application.Server.Service public void AddTool(ref ToolsDataModel tool) { - tool = DatabaseController.getInstance(). AddToolToDatabase(tool); + tool = DatabaseController.getInstance().AddToolToDatabase(tool); + } + + public void PutTool(ToolsDataModel tool) + { + DatabaseController.getInstance().UpdateToolData(tool); } public void GetShanks(out List shanksData) @@ -505,6 +510,20 @@ namespace Nc_Demo_Application.Server.Service DatabaseController.getInstance().UpdatePosition(position); } + public void DeleteTool(string id) + { + DatabaseController.getInstance().DeleteTool(Convert.ToInt32(id)); + } + + public void DeleteShank(string id) + { + DatabaseController.getInstance().DeleteShank(Convert.ToInt32(id)); + } + + public void DeleteFamily(string name) + { + DatabaseController.getInstance().DeleteFamily(name); + } #endregion Tools } } \ No newline at end of file diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.cs index b3dd9f2..d9b859c 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.cs +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.cs @@ -566,7 +566,7 @@ namespace Nc_Demo_Application try { // Delete database row - DatabaseController.getInstance().DeleteToolFromDatabase(Convert.ToInt32(toolsTreeView.SelectedNode.Tag)); + DatabaseController.getInstance().DeleteTool(Convert.ToInt32(toolsTreeView.SelectedNode.Tag)); // Remove from treeView toolsTreeView.SelectedNode.Remove(); }