added delete tool/shanks/family
This commit is contained in:
@@ -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<DemoFamilyModel> 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<ShankDataModel> 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<DemoPositionsModel> positionsData);
|
||||
void GetPositions(out List<MagazinePositionsModel> 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
|
||||
|
||||
|
||||
@@ -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<ShankModel> 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<FamilyModel> 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<MagazinePositionsModel> 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<DemoPositionsModel> 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<MagazinePositionsModel> 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
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -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
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -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)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -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
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -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
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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<FamilyModel> 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<ShankDataModel> 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<PositionsDataModel> positionsData);
|
||||
|
||||
[WebInvoke(Method = "PUT", UriTemplate = "tool_table/position", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
|
||||
void PutPosition(PositionsDataModel position);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<ShankDataModel> 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
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user