示例#1
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#2
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#3
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#4
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#5
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#6
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#7
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#8
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#9
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#10
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#11
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#12
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#13
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#14
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#15
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#16
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#17
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#18
0
 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} Попытка доступа без соответствующих прав.");
     }
 }
示例#19
0
 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} Попытка доступа без соответствующих прав.");
     }
 }