public void AddUser(String stringUser, User user) { if (user.AuthSuccess == true && user.UserRole == "Администратор") { ClassResource.User tempUser = JsonConvert.DeserializeObject <ClassResource.User>(stringUser); if (tempUser.Snapping != "") { DatabaseWork.ExecuteUpdate("INSERT INTO [Users] ([Login], [Password], [FIO User], [Role], [Snapping]) VALUES (" + "N'" + tempUser.Login + "'," + "N'" + tempUser.Password + "'," + "N'" + tempUser.Name + "'," + "N'" + tempUser.Role + "'," + "N'" + tempUser.Snapping + "')"); } else { DatabaseWork.ExecuteUpdate("INSERT INTO [Users] ([Login], [Password], [FIO User], [Role]) VALUES (" + "N'" + tempUser.Login + "'," + "N'" + tempUser.Password + "'," + "N'" + tempUser.Name + "'," + "N'" + tempUser.Role + "')"); } Server.UpdateUsers(); } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void DeleteRequest(String request, User user) { if (user.AuthSuccess == true && (user.UserRole == "Инженер" || user.UserRole == "Администратор")) { DatabaseWork.ExecuteUpdate($"DELETE FROM Requests WHERE [ID request] = '{request}'"); Server.UpdateRequests(); } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void DeleteDestination(String destination, User user) { if (user.AuthSuccess == true && (user.UserRole == "Руководитель экспедиторов" || user.UserRole == "Администратор")) { DatabaseWork.ExecuteUpdate($"DELETE FROM Destinations WHERE [ID destination] = '{destination}'"); Server.UpdateDestinations(); Server.UpdateRoutes(); } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void ChangeRouteStatus(String status, String route, User user) { if (user.AuthSuccess == true && (user.UserRole == "Руководитель экспедиторов" || user.UserRole == "Администратор")) { DatabaseWork.ExecuteUpdate("UPDATE [Routes] SET " + "[Route status] = N'" + status + "' " + "WHERE [ID route] = '" + route + "'"); Server.UpdateRoutes(); } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void ChangeDestinationNumber(String number, String destination, User user) { if (user.AuthSuccess == true && (user.UserRole == "Руководитель экспедиторов" || user.UserRole == "Администратор")) { DatabaseWork.ExecuteUpdate("UPDATE [Destinations] SET " + "[Number] = '" + number + "' " + "WHERE [ID destination] = '" + destination + "'"); Server.UpdateDestinations(); Server.UpdateRoutes(); } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void RequestDistribute(String requesID, String routeID, User user) { if (user.AuthSuccess == true && (user.UserRole == "Руководитель экспедиторов" || user.UserRole == "Администратор")) { DatabaseWork.ExecuteUpdate("INSERT INTO [Destinations] ([ID route], [ID request], [Number]) VALUES (" + "'" + routeID + "'," + "'" + requesID + "'," + "'" + (DatabaseWork.ExecuteQuery("SELECT * FROM [Destinations] WHERE [ID route] = '" + routeID + "'").Rows.Count + 1).ToString() + "')"); Server.UpdateDestinations(); Server.UpdateRoutes(); } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void AddRoute(User user) { if (user.AuthSuccess == true && (user.UserRole == "Руководитель экспедиторов" || user.UserRole == "Администратор")) { DatabaseWork.ExecuteUpdate("INSERT INTO [Routes] ([Name], [Car type], [Route status], [City / Country departure]) VALUES (" + "N'000000'," + "N'Легковой'," + "N'Открыт'," + "N'Барановичи')"); Server.UpdateRoutes(); } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void AddEngineer(String stringEngineer, User user) { if (user.AuthSuccess == true && user.UserRole == "Администратор") { ClassResource.Engineer engineer = JsonConvert.DeserializeObject <ClassResource.Engineer>(stringEngineer); DatabaseWork.ExecuteUpdate("INSERT INTO [Engineers] ([Name], [Сontact number], [Note]) VALUES (" + "N'" + engineer.Name + "'," + "N'" + engineer.ContactNumber + "'," + "N'" + engineer.Note + "')"); Server.UpdateEngineer(); } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void AddForwarder(String stringForwarder, User user) { if (user.AuthSuccess == true && (user.UserRole == "Руководитель экспедиторов" || user.UserRole == "Администратор")) { ClassResource.Forwarder company = JsonConvert.DeserializeObject <ClassResource.Forwarder>(stringForwarder); DatabaseWork.ExecuteUpdate("INSERT INTO [Forwarders] ([Name], [Contact number], [Note]) VALUES (" + "N'" + company.Name + "'," + "N'" + company.ContactNumber + "'," + "N'" + company.Note + "')"); Server.UpdateForwarders(); } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void UpdateDestination(String stringDestination, User user) { if (user.AuthSuccess == true && (user.UserRole == "Руководитель экспедиторов" || user.UserRole == "Администратор")) { ClassResource.Destination destination = JsonConvert.DeserializeObject <ClassResource.Destination>(stringDestination); DatabaseWork.ExecuteUpdate("UPDATE [Destinations] SET " + (destination.ArrivalDate != "" ? "[Arrival date] = CONVERT(DATETIME, '" + destination.ArrivalDate + "', 104)," : "") + "[Note] = N'" + destination.Note + "' " + "WHERE [ID destination] = '" + destination.ID + "'"); Server.UpdateDestinations(); Server.UpdateRoutes(); } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void UpdateForwarder(String stringForwarder, User user) { if (user.AuthSuccess == true && (user.UserRole == "Руководитель экспедиторов" || user.UserRole == "Администратор")) { ClassResource.Forwarder forwarder = JsonConvert.DeserializeObject <ClassResource.Forwarder>(stringForwarder); DatabaseWork.ExecuteUpdate("UPDATE [Forwarders] SET " + "[Name] = N'" + forwarder.Name + "'," + "[Contact number] = N'" + forwarder.ContactNumber + "'," + "[Note] = N'" + forwarder.Note + "' " + "WHERE [ID forwarder] = '" + forwarder.ID + "'"); Server.UpdateForwarders(); } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void UpdateRequest(String stringRequest, User user) { if (user.AuthSuccess == true && (user.UserRole == "Инженер" || user.UserRole == "Администратор")) { ClassResource.Request request = JsonConvert.DeserializeObject <ClassResource.Request>(stringRequest); DatabaseWork.ExecuteUpdate("UPDATE Requests SET " + "[Product weight] = N'" + request.ProductWeight + "'," + "[Product dimensions] = N'" + request.ProductDimensions + "'," + "[Quantity] = '" + request.Quantity + "' " + "WHERE [ID request] = '" + request.ID + "'"); Server.UpdateRequests(); } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void UpdateUser(String stringUser, User user) { if (user.AuthSuccess == true && user.UserRole == "Администратор") { ClassResource.User tempUser = JsonConvert.DeserializeObject <ClassResource.User>(stringUser); DatabaseWork.ExecuteUpdate("UPDATE [Users] SET" + "[Login] = N'" + tempUser.Login + "'," + "[FIO User] = N'" + tempUser.Name + "'," + "[Role] = N'" + tempUser.Role + "'," + (tempUser.Snapping != "" ? "[Snapping] = '" + tempUser.Snapping + "' " : "") + "WHERE [Login] = '" + tempUser.Engineer + "'"); Server.UpdateUsers(); } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void DeleteEngineer(String engineerID, User user) { if (user.AuthSuccess == true && user.UserRole == "Администратор") { if (DatabaseWork.ExecuteUpdate($"DELETE FROM Engineers WHERE [ID engineer] = '{engineerID}'") == "REFERENCE Conflicted") { user.SendMessage("ShowWarning", new String[] { "Удаление невозможно!", "Данный инженер связан с одной либо несколькими заявками. Сперва удалите заявки.", "Удаление невозможно" }); } else { Server.UpdateEngineer(); } } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void DeleteForwarder(String forwarderID, User user) { if (user.AuthSuccess == true && (user.UserRole == "Руководитель экспедиторовр" || user.UserRole == "Администратор")) { if (DatabaseWork.ExecuteUpdate($"DELETE FROM Forwarders WHERE [ID forwarder] = '{forwarderID}'") == "REFERENCE Conflicted") { user.SendMessage("ShowWarning", new String[] { "Удаление невозможно!", "Данный экспедитор связан с одним либо несколькими маршрутами. Сперва удалите маршруты.", "Удаление невозможно" }); } else { Server.UpdateForwarders(); } } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void DeleteUser(String userLogin, User user) { if (user.AuthSuccess == true && user.UserRole == "Администратор") { if (DatabaseWork.ExecuteUpdate($"DELETE FROM Users WHERE [Login] = '{userLogin}'") == "REFERENCE Conflicted") { user.SendMessage("ShowWarning", new String[] { "Удаление невозможно!", "Данный пользователь не может быть удален.", "Удаление невозможно" }); } else { Server.UpdateUsers(); } } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void AddCompany(String stringCompany, User user) { if (user.AuthSuccess == true && (user.UserRole == "Инженер" || user.UserRole == "Администратор")) { ClassResource.Company company = JsonConvert.DeserializeObject <ClassResource.Company>(stringCompany); DatabaseWork.ExecuteUpdate("INSERT INTO [Companies] ([Name], [Country], [City], [Address], [Name contact person], [Phone contact person]) VALUES (" + "N'" + company.Name + "'," + "N'" + company.Country + "'," + "N'" + company.City + "'," + "N'" + company.Address + "'," + "N'" + company.NameСontactPerson + "'," + "N'" + company.PhoneContactPerson + "')"); Server.UpdateCompanies(); } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void UpdateRoute(String stringRoute, User user) { if (user.AuthSuccess == true && (user.UserRole == "Руководитель экспедиторов" || user.UserRole == "Администратор")) { ClassResource.Route route = JsonConvert.DeserializeObject <ClassResource.Route>(stringRoute); DatabaseWork.ExecuteUpdate("UPDATE [Routes] SET " + "[Name] = N'" + route.Name + "'," + (route.DepartureDate != "" ? "[Departure date] = CONVERT(DATETIME, '" + route.DepartureDate + "', 104)," : "") + "[Car type] = N'" + route.CarType + "'," + (route.ReturnDate != "" ? "[Return date] = CONVERT(DATETIME, '" + route.ReturnDate + "', 104)," : "") + (route.IDForwarder != null ? "[ID forwarder] = '" + route.IDForwarder + "', " : "") + "[Note] = N'" + route.Note + "' " + "WHERE [ID route] = '" + route.ID + "'"); Server.UpdateRoutes(); } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }
public void AddRequest(String stringRequest, User user) { if (user.AuthSuccess == true && user.UserRole == "Инженер") { ClassResource.Request request = JsonConvert.DeserializeObject <ClassResource.Request>(stringRequest); DatabaseWork.ExecuteUpdate("INSERT INTO Requests ([Number], [Product name], [Product weight], [Product dimensions], [Quantity], [ID company], [ID engineer], [Note]) VALUES (" + "N'" + request.Number + "'," + "N'" + request.ProductName + "'," + "N'" + request.ProductWeight + "'," + "N'" + request.ProductDimensions + "'," + "'" + request.Quantity + "'," + "'" + request.IDCompany + "'," + "'" + user.UserSnapping + "'," + "N'" + request.Note + "')"); Server.UpdateRequests(); } else { Functions.AddJournalEntry($": __ATTENTION__ {user.UserID} {user.UserName} Попытка доступа без соответствующих прав."); } }