Esempio n. 1
0
 public ClsUsers()
 {
     //allocate memory to the instance
     modelBooks = new ModelBooks();
     lstUser    = new List <Models.ModelBooks>();
     tblUsers   = new DataTable("tblUsers");
 }
        public ActionResult EditBook(ModelBooks _modelBooks)
        {
            modelBooks      = _modelBooks;
            ViewBag.Message = user.Create(modelBooks);

            return(View("Index"));
        }
Esempio n. 3
0
        //obtain required information from the user
        public Int32 Create(ModelBooks _modelBooks)
        {
            try
            {
                Command         = new SqlCommand();
                this.modelBooks = _modelBooks;
                if (modelBooks.BookID <= 0)
                {
                    Query = @"Insert into tblInventory(Title, Author,ISBN,Publisher,BYear)Values(@Title, @Author,@ISBN,@Publisher,@BYear);";
                }
                else
                {
                    Query = @"Update tblInventory Set Title = @Title, Author = @Author, 
                               ISBN = @ISBN, Publisher = @Publisher, BYear = @BYear
                                Where BookID = @BookID ";
                    Command.Parameters.Add("@BookID", SqlDbType.Int).Value = modelBooks.BookID;
                }


                Command.Parameters.Add("@Title", SqlDbType.VarChar, 100).Value     = modelBooks.Title;
                Command.Parameters.Add("@Author", SqlDbType.VarChar, 100).Value    = modelBooks.Author;
                Command.Parameters.Add("@ISBN", SqlDbType.VarChar, 100).Value      = modelBooks.ISBN;
                Command.Parameters.Add("@Publisher", SqlDbType.VarChar, 100).Value = modelBooks.Publisher;
                Command.Parameters.Add("@BYear", SqlDbType.VarChar, 100).Value     = modelBooks.BYear;
                //Set the Command Text
                Command.CommandText = Query;
                ExecuteNonQuery(Command);
                if (RowsAffected > 0)
                {
                    Message = " User Created ";
                }
                else
                {
                    Message = " User Creation Failed.";
                }
            }
            catch (Exception ex)
            {
                Message = "Error: " + ex.Message.ToString();
            }
            return(RowsAffected);
        }
 public ActionResult Edit(ModelBooks _modelBooks)
 {
     return(View());
 }
 public ActionResult Create(ModelBooks _modelBooks)
 {
     return(View());
 }
 public String Create(ModelBooks modelBooks)
 {
     users.Create(modelBooks);
     return(users.Message);
 }