Exemple #1
0
 public void PassBook(int book_id)
 {
     using (newlibrary_dbEntities db = new newlibrary_dbEntities())
     {
         SqlParameter param1 = new SqlParameter("@_BookID", book_id);
         db.Database.Connection.Open();
         db.Database.ExecuteSqlCommand("exec Pass @_BookID", param1);
         db.Database.Connection.Close();
         db.SaveChanges();
     }
 }
Exemple #2
0
 public void IssueBook(int user_id, int book_id, string date_of_issue)
 {
     using (newlibrary_dbEntities db = new newlibrary_dbEntities())
     {
         SqlParameter param1 = new SqlParameter("@_UserID", user_id);
         SqlParameter param2 = new SqlParameter("@_BookID", book_id);
         SqlParameter param3 = new SqlParameter("@_DateOfIssue", date_of_issue);
         db.Database.Connection.Open();
         db.Database.ExecuteSqlCommand("exec Issue @_UserID, @_BookID, @_DateOfIssue", param1, param2, param3);
         db.Database.Connection.Close();
         db.SaveChanges();
     }
 }
Exemple #3
0
        public void AddBook(string title, string author, string year, string genre)
        {
            using (newlibrary_dbEntities db = new newlibrary_dbEntities())
            {
                SqlParameter param1 = new SqlParameter("@_Title", title);
                SqlParameter param2 = new SqlParameter("@_Author", author);
                SqlParameter param3 = new SqlParameter("@_Year", year);
                SqlParameter param4 = new SqlParameter("@_Genre", genre);

                db.Database.Connection.Open();
                db.Database.ExecuteSqlCommand("exec Addbook @_Title, @_Author, @_Year, @_Genre", param1, param2, param3, param4);
                db.Database.Connection.Close();
                db.SaveChanges();
            }
        }
Exemple #4
0
 public bool Authentification(string PhoneNumber, string Password)
 {
     using (newlibrary_dbEntities db = new newlibrary_dbEntities())
     {
         var res = GetUserList();
         if (res.Where(x => x.phone_number == PhoneNumber && x.password == Password).Count() == 1)
         {
             db.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemple #5
0
        public void AddUser(string last_name, string name, string middle_name, string phone_number, string adress)
        {
            using (newlibrary_dbEntities db1 = new newlibrary_dbEntities())
            {
                var res = GetUserList();

                int nums = 0;

                for (int i = 0; i < res.Count(); i++)
                {
                    if (res[i].phone_number != phone_number)
                    {
                        nums++;
                        if (nums == res.Count())
                        {
                            Console.WriteLine("Регистрирую пользователя..");
                            newlibrary_dbEntities db     = new newlibrary_dbEntities();
                            SqlParameter          param1 = new SqlParameter("@_LastName", last_name.Trim());
                            SqlParameter          param2 = new SqlParameter("@_Name", name.Trim());
                            SqlParameter          param3 = new SqlParameter("@_MiddleName", middle_name.Trim());
                            SqlParameter          param4 = new SqlParameter("@_PhoneNumber", phone_number.Trim());
                            SqlParameter          param5 = new SqlParameter("@_Adress", adress.Trim());
                            SqlParameter          param6 = new SqlParameter("@_Password", "12345");

                            db.Database.Connection.Open();
                            db.Database.ExecuteSqlCommand("exec AddUser @_LastName, @_Name, @_MiddleName, @_PhoneNumber, @_Adress, @_Password", param1, param2, param3, param4, param5, param6);
                            db.Database.Connection.Close();
                            db.SaveChanges();

                            Console.WriteLine("Пользователь зарегистрирован!");
                            return;
                        }
                    }
                    Console.WriteLine("Пользователь с таким номером уже создан!");
                }
            }
        }