Beispiel #1
0
        public ActionResult Create([Bind(Include = "id,catname,status")] category category)
        {
            if (ModelState.IsValid)
            {
                db.category.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "id,name,address,phone")] member member)
        {
            if (ModelState.IsValid)
            {
                db.member.Add(member);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(member));
        }
        private void buttonAddBook_Click(object sender, EventArgs e)
        {
            if (textBoxDate.Text == "dd/mm/yyyy format")
            {
                textBoxDate.Text = "";
            }

            //Validate required fields..
            if (string.IsNullOrEmpty(textBoxBook.Text) || string.IsNullOrEmpty(textBoxAuthor.Text))
            {
                MessageBox.Show("Please input required fields to add, bookname and Author");
                return;
            }

            DateTime? release   = null;
            Publisher publisher = null;

            Author author = new Author
            {
                authorname = textBoxAuthor.Text
            };

            _database.Author.Add(author);

            Genre genre = _database.Genre.FirstOrDefault(x => x.genrename == comboBoxGenres.Text);

            if (textBoxPublisher.Text != "")
            {
                publisher = new Publisher {
                    publishername = textBoxPublisher.Text
                };
            }


            //Try to add a new book
            ConvertStringToDate.ConvertDate(textBoxDate.Text, ref release);

            //Add new book
            Book book = new Book();

            book.Author      = author;
            book.bookname    = textBoxBook.Text;
            book.Genre       = genre;
            book.Publisher   = publisher;
            book.releasedate = release;

            _database.Book.Add(book);
            _database.SaveChanges();

            Form1_Load(sender, e);
            MessageBox.Show("Successfully added a new book to the library");
        }
        public ActionResult Create([Bind(Include = "id,name,cat_id,a_id,p_id,contents,pages,edition")] book book)
        {
            if (ModelState.IsValid)
            {
                db.book.Add(book);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.a_id   = new SelectList(db.author, "id", "name", book.a_id);
            ViewBag.cat_id = new SelectList(db.category, "id", "catname", book.cat_id);
            ViewBag.p_id   = new SelectList(db.publisher, "id", "name", book.p_id);
            return(View(book));
        }
Beispiel #5
0
        public ActionResult Create(Member_Message member_message)
        {
            if (ModelState.IsValid)
            {
                db.Member_Message.Add(member_message);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(member_message));
        }
        private void buttonUpdate2_Click(object sender, EventArgs e)
        {
            DateTime?release = null;

            int       id        = Convert.ToInt32(textBoxId2.Text);
            Publisher publisher = null;

            Book book = _database.Book.FirstOrDefault(x => x.Id == id);

            book.bookname        = textBoxBook2.Text;
            book.Genre.genrename = comboBoxGenre2.Text;

            if (textBoxPublisher2.Text != "")
            {
                publisher = new Publisher
                {
                    publishername = textBoxPublisher2.Text
                };
            }

            book.Publisher = publisher;
            ConvertStringToDate.ConvertDate(textBoxDate2.Text, ref release);
            book.releasedate = release;
            _database.SaveChanges();
            this.Close();
        }
Beispiel #7
0
        public string ajaxEditnameCategory()
        {
            int    id   = Convert.ToInt32(Request["pk"]);
            string name = Request["value"];

            category cate = new category();

            cate.cat_id   = id;
            cate.cat_name = name;

            db.categories.AddOrUpdate(cate);

            db.SaveChanges();

            return("");
        }
        public string ajaxEditnameAuthor()
        {
            int    id   = Convert.ToInt32(Request["pk"]);
            string name = Request["value"];

            author author = new author();

            author.author_id   = id;
            author.author_name = name;

            db.authors.AddOrUpdate(author);

            db.SaveChanges();

            return("");
        }
Beispiel #9
0
 public static bool addotek(int codeB, int amount, double priceO, int numOt)
 {
     using (libraryEntities db = new libraryEntities())
     {
         for (int i = numOt - amount + 1; i <= numOt; i++)
         {
             db.Otakims.Add(new Otakim
             {
                 codeBook = codeB,
                 Serial   = i,
                 price    = Convert.ToInt32(priceO),
                 status   = "נמצא"
             });
         }
         try
         {
             db.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Beispiel #10
0
        public static bool updateSubsciber(SubsciberDTO a)
        {
            using (libraryEntities db = new libraryEntities())
            {
                Subscriber au = db.Subscribers.First(x => x.id == a.id);
                au.firstName = a.firstName;
                au.lastName  = a.lastName;
                au.id        = a.id;
                au.isDeleted = a.isDeleted;
                au.address   = a.address;
                au.phon      = a.phon;
                au.startDate = a.startDate;
                au.type      = a.type;
                au.email     = a.email;


                try
                {
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
Beispiel #11
0
 public static bool addWorker(WorkerDTO s)
 {
     using (libraryEntities db = new libraryEntities())
     {
         string mailBody = $" Hi " + s.name + " You have successfully joined our team  \n " +
                           $"your password is " + s.password + " \n Thanks ";
         if (db.Workers.FirstOrDefault(x => x.idWorker == s.idWorker) != null)
         {
             s.status = true;
             updateWorker(s);
         }
         else
         {
             db.Workers.Add(Converters.WorkerConverter.ConvertWorkerDTOToDAL(s));
             //bool b = SendMail(s.address, "ברוכים הבאים לצוות עובדנו", mailBody);
         }
         try
         {
             db.SaveChanges();
             bool b = SendMail(s.address, "ברוכים הבאים לצוות עובדנו", mailBody);
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Beispiel #12
0
        public static bool updateWorker(WorkerDTO a)
        {
            using (libraryEntities db = new libraryEntities())
            {
                Worker au = db.Workers.First(x => x.idWorker == a.idWorker);
                au.name     = a.name;
                au.status   = a.status;
                au.address  = a.address;
                au.phone    = a.phone;
                au.password = a.password;
                au.typeWork = a.typeWork;


                try
                {
                    db.SaveChanges();
                    bool b = SendMail(a.name, "ברוכים הבאים לצוות עובדנו", "פרטיך עודכנו בהצלחה במערכת ");
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
Beispiel #13
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //try
            //{
            //save
            int  x    = int.Parse(Session["newmemberId"].ToString());
            user User = library.users.Single(u => u.user_id == x);
            // User.password= int.Parse(newPass_txt.Text);
            int password = User.password;

            if (int.Parse(oldPass_txt.Text) == password)
            {
                library.users.Single(u => u.user_id == x).password = int.Parse(newPass_txt.Text);
                library.SaveChanges();
                Response.Redirect("/Members/Home.aspx");
            }
            else
            {
                lbl_status.Text = "plz re enter old password not exist";
            }
            //library.SaveChanges();

            //Response.Redirect("/Members/Home.aspx");
            //}
            //catch {
            //}
        }
Beispiel #14
0
 public static bool addCrowd(CrowdDTO c)
 {
     using (libraryEntities db = new libraryEntities())
     {
         db.Crowds.Add(Converters.CrowdConverter.ConvertCrowdDTOCToDAL(c));
         try
         {
             db.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Beispiel #15
0
 public static bool addAuther(AuthorDTO a)
 {
     using (libraryEntities db = new libraryEntities())
     {
         db.Aauthors.Add(Converters.AuthorConverter.ConvertAuthorDTOToDAL(a));
         try
         {
             db.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Beispiel #16
0
 public static bool addCategory(CategoryDTO c)
 {
     using (libraryEntities db = new libraryEntities())
     {
         db.Categories.Add(Converters.categoriesConverter.ConvertCategoryDTOToDAL(c));
         try
         {
             db.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Beispiel #17
0
 public static bool addLending(LendingDTO l)
 {
     using (libraryEntities db = new libraryEntities())
     {
         db.Lendings.Add(Converters.LendingConverter.ConvertLendingDTOToDAL(l));
         try
         {
             db.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
 public static bool addSubscriptionType(SubscriptionTypeDTO s)
 {
     using (libraryEntities db = new libraryEntities())
     {
         db.SubscriptionTypes.Add(Converters.SubsciptionTypeConverter.ConvertSubsciptionTypeDTOToDAL(s));
         try
         {
             db.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Beispiel #19
0
        public static bool deleteBook(BookDTO a)
        {
            using (libraryEntities db = new libraryEntities())
            {
                Book b = db.Books.First(x => x.codeBook == a.codeBook);
                b.isDeleted = true;

                try
                {
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
Beispiel #20
0
        public static bool updateCategory(CategoryDTO a)
        {
            using (libraryEntities db = new libraryEntities())
            {
                Category b = db.Categories.First(x => x.codeCategory == a.codeCategory);
                b.nameCategory = a.nameCategory;

                try
                {
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
Beispiel #21
0
        public static bool updateCrowd(CrowdDTO a)
        {
            using (libraryEntities db = new libraryEntities())
            {
                Crowd b = db.Crowds.First(x => x.codeCrowd == a.codeCrowd);
                b.nameCrowd = a.nameCrowd;

                try
                {
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
Beispiel #22
0
        public static bool updateOtekStatus(int code, string status)
        {
            using (libraryEntities db = new libraryEntities())
            {
                Otakim b = db.Otakims.First(x => x.codeOtek == code);
                b.status = status;

                try
                {
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
Beispiel #23
0
        public static bool deleteWorker(int a)
        {
            using (libraryEntities db = new libraryEntities())
            {
                Worker au = db.Workers.First(x => x.idWorker == a);

                au.status = false;

                try
                {
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
Beispiel #24
0
        public static bool deleteSubsciber(int a)
        {
            using (libraryEntities db = new libraryEntities())
            {
                Subscriber au = db.Subscribers.First(x => x.id == a);

                au.isDeleted = true;

                try
                {
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
Beispiel #25
0
        public static bool addLendingItems(LendingItemDTO l)
        {
            using (libraryEntities db = new libraryEntities())
            {
                LendingItem au = db.LendingItems.FirstOrDefault(x => x.codeOtek == l.codeOtek && x.returnDate == null);

                db.LendingItems.Add(Converters.LendingItemConverter.ConvertLendingItemDTOToDAL(l));
                db.Otakims.First(a => a.codeOtek == l.codeOtek).status = "מושאל";
                try
                {
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
Beispiel #26
0
        public static bool ReturnD(int code)
        {
            using (libraryEntities db = new libraryEntities())
            {
                LendingItem au = db.LendingItems.FirstOrDefault(x => x.codeOtek == code && x.returnDate == null);
                au.returnDate = DateTime.Today;

                db.Otakims.First(a => a.codeOtek == au.codeOtek).status = "נמצא";

                try
                {
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
Beispiel #27
0
        public static bool addBook(BookDTO bo)
        {
            int codeN;

            using (libraryEntities db = new libraryEntities())
            {
                Book newB = Converters.BookConverter.ConvertBookDTOToDAL(bo);
                newB.isDeleted = false;
                db.Books.Add(newB);
                try
                {
                    db.SaveChanges();
                    codeN = db.Books.First(b => b.name == bo.name).codeBook;
                    return(otekBL.addotek(codeN, Convert.ToInt32(bo.numOtakim), Convert.ToDouble(bo.price), Convert.ToInt32(bo.numOtakim)));
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
        protected void member_dl_ItemCommand(object source, DataListCommandEventArgs e)
        {
            Session["memberid"] = e.CommandArgument.ToString();
            if (e.CommandName == "update")
            {
                Response.Redirect("~/Employee/updatemember.aspx");
            }
            if (e.CommandName == "delete")
            {
                int id = int.Parse(e.CommandArgument.ToString());
                MsgBox("Do you want to delete !", this.Page, this);
                user deletuser = library.users.Single(u => u.user_id == id);
                deletuser.isDeleted = true;
                //library.users.Remove(deletuser);
                library.SaveChanges();

                var query = library.users.Where(member => member.role == null && member.isDeleted == false).Select(member => new { member.fName, member.lName, member.address, member.phone, member.user_id, member.email });
                member_dl.DataSource = query.ToList();
                member_dl.DataBind();
            }
        }
        public static bool updateSubscriptionType(SubscriptionTypeDTO a)
        {
            using (libraryEntities db = new libraryEntities())
            {
                SubscriptionType b = db.SubscriptionTypes.First(x => x.codeType == a.codeType);
                b.numOfBooks = a.numOfBooks;
                b.price      = a.price;
                b.status     = a.status;


                try
                {
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
Beispiel #30
0
        public static bool updateAuther(AuthorDTO a)
        {
            using (libraryEntities db = new libraryEntities())
            {
                Aauthor au = db.Aauthors.First(x => x.codAauthor == a.codAauthor);
                au.firstName     = a.firstName;
                au.lastName      = a.lastName;
                au.LiteraryAlias = a.LiteraryAlias;



                try
                {
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }