Ejemplo n.º 1
0
        private void lvTextbook_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.lvTextbook.SelectedItems.Count == 0)
            {
                return;
            }

            if (this.IsAdd)
            {
                MessageBox.Show("尚未添加完成");
                return;
            }
            else if (this.IsEdit)
            {
                MessageBox.Show("尚未编辑完成");
                return;
            }


            if (this.lvTextbook.SelectedItems.Count > 1)
            {
                // MessageBox.Show("选中了多项");
                this.CurrentSelTextbook = null;
            }
            else
            {
                int selIndex = this.lvTextbook.SelectedIndices[0];
                this.CurrentSelTextbook = this.TextbookList[selIndex];
            }
            this.refreshRightUI();
        }
Ejemplo n.º 2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            Textbook textbook = new Textbook();

            textbook.Modify  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            textbook.Name    = this.tbName.Text.Trim();
            textbook.Uk_isbn = this.tbISBN.Text.Trim();
            textbook.Press   = this.tbPress.Text.Trim();
            textbook.Edition = this.tbEdition.Text.Trim();
            textbook.Other   = this.rtbOther.Text.Trim();
            if (IsAdd)
            {
                textbook.Id     = Guid.NewGuid().ToString("N");
                textbook.Create = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                this.ITextbookFormReq.AddOneTextbook(textbook);
                this.IsAdd = false;
            }
            if (IsEdit)
            {
                textbook.Id = this.CurrentSelTextbook.Id;
                this.ITextbookFormReq.UpdateOneTextbook(textbook);
                this.IsEdit = false;
            }
            this.btnSubmit.Visible       = false;
            this.btnCancelSubmit.Visible = false;
            this.initData();
            this.initView();
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("TextbookId,Name,Author,Price,CourseId")] Textbook textbook)
        {
            if (id != textbook.TextbookId)
            {
                return(RedirectToAction(nameof(Index)));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(textbook);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    TempData["message"] = $"{textbook.Name} update Failed";
                    return(RedirectToAction(nameof(Index)));
                }
                TempData["message"] = $"{textbook.Name} update Completed";
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"] = new SelectList(_context.Course, "CourseId", "CourseId", textbook.CourseId);
            return(View(textbook));
        }
Ejemplo n.º 4
0
        public static int createTextBook(Textbook book)
        {
            int BookId = -1;

            try
            {
                DataAccess da = new DataAccess();
                DataTable  dt = da.select(String.Format("ISBN = '{0}'", book.ISBN), "TextBooks", NumRows: 1);

                if (dt == null || dt.Rows.Count == 0)
                {
                    Dictionary <string, object> textbook = new Dictionary <string, object>();
                    textbook.Add("ISBN", book.ISBN);
                    textbook.Add("BookTitle", book.BookTitle);
                    textbook.Add("Author", book.Author);
                    textbook.Add("CourseId", book.CourseId);
                    textbook.Add("BookImageURL", book.BookImageUrl);
                    textbook.Add("StorePrice", book.StorePrice);
                    textbook.Add("IsActive", 1);
                    textbook.Add("IsDeleted", 0);
                    textbook.Add("CreatedDate", DateTime.Now);
                    textbook.Add("ModifiedDate", DateTime.Now);

                    BookId = da.insert(textbook, "TextBooks");
                }
            }
            catch (Exception ex) { Console.Write(ex.Message + "    " + ex.StackTrace); }

            return(BookId);
        }
Ejemplo n.º 5
0
        public static Textbook CreateTextbook(int bookID, string title)
        {
            Textbook textbook = new Textbook();

            textbook.BookID = bookID;
            textbook.Title  = title;
            return(textbook);
        }
Ejemplo n.º 6
0
        private void initView()
        {
            if (this.lvTextbookSel.Columns.Count == 0)
            {
                ColumnHeader chTextbookSel = new ColumnHeader();
                chTextbookSel.Text      = "已选择教材";                   //设置列标题
                chTextbookSel.Width     = this.gbSelList.Width - 35; //设置列宽度
                chTextbookSel.TextAlign = HorizontalAlignment.Left;  //设置列的对齐方式
                this.lvTextbookSel.Columns.Add(chTextbookSel);       //将列头添加到ListView控件。
                this.lvTextbookSel.FullRowSelect = true;             //选中整行
                this.lvTextbookSel.HeaderStyle   = ColumnHeaderStyle.None;
                this.lvTextbookSel.View          = System.Windows.Forms.View.Details;
            }
            if (this.lvTextbook.Columns.Count == 0)
            {
                ColumnHeader chTextbook = new ColumnHeader();
                chTextbook.Text      = "带选择教师";                   //设置列标题
                chTextbook.Width     = this.gbSelList.Width - 35; //设置列宽度
                chTextbook.TextAlign = HorizontalAlignment.Left;  //设置列的对齐方式
                this.lvTextbook.Columns.Add(chTextbook);          //将列头添加到ListView控件。
                this.lvTextbook.FullRowSelect = true;             //选中整行
                this.lvTextbook.HeaderStyle   = ColumnHeaderStyle.None;
                this.lvTextbook.View          = System.Windows.Forms.View.Details;
            }

            //初始化选中和未选中的列表
            this.lvTextbook.BeginUpdate();
            this.lvTextbook.Items.Clear();
            foreach (Textbook textbook in TextbookList)
            {
                this.lvTextbook.Items.Add(textbook.Name);
            }
            this.lvTextbook.EndUpdate();
            this.lvTextbookSel.BeginUpdate();
            this.lvTextbookSel.Items.Clear();
            foreach (Textbook textbook in this.TextbookSelList)
            {
                this.lvTextbookSel.Items.Add(textbook.Name);
            }
            this.lvTextbookSel.EndUpdate();
            //初始换当前选中的Item的数据项
            if (this.TextbookSelList.Count != 0)
            {
                this.CurrentSelTextbook = this.TextbookSelList[0];
                this.lvTextbookSel.Items[0].Selected = true;
            }
            else if (this.TextbookList.Count != 0)
            {
                this.CurrentSelTextbook           = this.TextbookList[0];
                this.lvTextbook.Items[0].Selected = true;
            }
            else
            {
                this.CurrentSelTextbook = null;
            }
        }
 public decimal GetDiscount(Textbook textbook)
 {
     if (IsDiscount(textbook.Name))
     {
         return 0.9m;
     }
     else
     {
         return 1.0M;
     }
 }
 public decimal GetDiscount(Textbook textbook)
 {
     if (IsDiscount(textbook.Name))
     {
         return(0.9m);
     }
     else
     {
         return(1.0M);
     }
 }
Ejemplo n.º 9
0
        public async Task <IActionResult> Create([Bind("TextbookId,Name,Author,Price,CourseId")] Textbook textbook)
        {
            if (ModelState.IsValid)
            {
                _context.Add(textbook);
                await _context.SaveChangesAsync();

                TempData["message"] = $"{textbook.Name} has been added";
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"] = new SelectList(_context.Course, "CourseId", "CourseId", textbook.CourseId);
            return(View(textbook));
        }
        public IActionResult Appraise(Textbook text)
        {
            if (ModelState.IsValid)
            {
                ViewData["Message"]   = "Your Textbook: " + text.title + ", Version: " + text.version + " is in " + text.condition + " condition.";
                ViewData["Appraisal"] = "This means we will pay you $" + text.CalculateCost().ToString() + " for your Textbook";

                return(View("Appraised", text));
            }
            else
            {
                return(View("Bad"));
            }
        }
Ejemplo n.º 11
0
        public void UpdateOneTextbook(Textbook textbook)
        {
            string          updateSql       = "UPDATE textbook SET textbook.utc8_modify = @modife,textbook.other = @other,textbook.`name` = @name,textbook.uk_isbn = @isbn,textbook.press = @press,textbook.edition = @edition WHERE textbook.id = @id;";
            MySqlConnection mySqlConnection = new MySqlConnection(Model.MySqlHelper.Conn);

            mySqlConnection.Open();
            Model.MySqlHelper.ExecuteNonQuery(mySqlConnection, CommandType.Text, updateSql,
                                              new MySqlParameter("@modife", textbook.Modify),
                                              new MySqlParameter("@other", textbook.Other),
                                              new MySqlParameter("@name", textbook.Name),
                                              new MySqlParameter("@isbn", textbook.Uk_isbn),
                                              new MySqlParameter("@press", textbook.Press),
                                              new MySqlParameter("@edition", textbook.Edition),
                                              new MySqlParameter("@id", textbook.Id));
            mySqlConnection.Close();
        }
Ejemplo n.º 12
0
        public static bool CancelTransaction(Transaction transaction)
        {
            bool success = CreateForbiddenMatch(transaction.BuyerPostId, transaction.SellerPostId) > 0 &&
                           CreateForbiddenMatch(transaction.SellerPostId, transaction.BuyerPostId) > 0;

            if (success)
            {
                Dictionary <string, object> updateDictionary = new Dictionary <string, object>();
                updateDictionary.Add("IsDeleted", 1);
                UpdateTransaction(transaction.TransactionId, updateDictionary);

                PostHandler.updatePostState(transaction.SellerPostId, 0);
                PostHandler.updatePostState(transaction.BuyerPostId, 0);

                Profile buyer  = ProfileHandler.GetProfile(transaction.BuyerId);
                Profile seller = ProfileHandler.GetProfile(transaction.SellerId);

                Textbook book = TextbookHandler.getTextbook(transaction.TextbookId);
                EmailUtility.SendEmail(
                    Convert.ToString(buyer.Email),
                    Convert.ToString(buyer.Name),
                    "Your transaction has been cancelled",
                    String.Format("Item: {0}</br>{1} has cancelled the transaction with you!<br/>" +
                                  "We'll try to match you with someone else for this item.",
                                  book.BookTitle,
                                  seller.Name)
                    );

                EmailUtility.SendEmail(
                    Convert.ToString(seller.Email),
                    Convert.ToString(seller.Name),
                    "Your transaction has been cancelled",
                    String.Format("Item: {0}<br/>{1} has cancelled the transaction with you!<br/>" +
                                  "We'll try to match you with someone else for this item.",
                                  book.BookTitle,
                                  buyer.Name)
                    );

                Post sellerPost = PostHandler.getPost(transaction.SellerPostId);
                Post buyerPost  = PostHandler.getPost(transaction.BuyerPostId);
                Task.Run(() => QueueWorker.AddPost(sellerPost));
                Task.Run(() => QueueWorker.AddPost(buyerPost));
            }

            return(success);
        }
Ejemplo n.º 13
0
        public static Textbook getTextbook(int textbookId)
        {
            Textbook book = null;

            try
            {
                DataAccess da = new DataAccess();
                DataTable  dt = da.select(String.Format("TextBookId = '{0}' AND IsActive = 1 AND IsDeleted = 0", textbookId), "TextBooks", NumRows: 1);

                if (dt != null && dt.Rows.Count > 0)
                {
                    DataRow row          = dt.Rows[0];
                    string  bookTitle    = Convert.ToString(row["BookTitle"]);
                    string  isbn         = Convert.ToString(row["ISBN"]);
                    string  author       = Convert.ToString(row["Author"]);
                    string  bookImageUrl = row["BookImageURL"] is DBNull ? null : Convert.ToString(row["BookImageURL"]);

                    int    courseId   = Convert.ToInt32(row["CourseId"]);
                    string courseName = CourseHandler.getCourseName(courseId);

                    decimal? storePrice   = row["StorePrice"] is DBNull ? (decimal?)null : Convert.ToDecimal(row["StorePrice"]);
                    int      isActive     = Convert.ToInt32(row["IsActive"]);
                    int      isDeleted    = Convert.ToInt32(row["IsDeleted"]);
                    DateTime createdDate  = Convert.ToDateTime(row["CreatedDate"]);
                    DateTime modifiedDate = Convert.ToDateTime(row["ModifiedDate"]);

                    book = new Textbook(
                        textbookId,
                        bookTitle,
                        isbn,
                        author,
                        courseId,
                        courseName,
                        bookImageUrl,
                        storePrice,
                        isActive,
                        isDeleted,
                        createdDate,
                        modifiedDate
                        );
                }
            }
            catch (Exception ex) { Console.Write(ex.Message + " " + ex.StackTrace); }

            return(book);
        }
Ejemplo n.º 14
0
        public void AddOneTextbook(Textbook textbook)
        {
            string          insertSql       = "INSERT INTO textbook(textbook.id,textbook.utc8_create,textbook.utc8_modify,textbook.other,textbook.`name`,textbook.uk_isbn,textbook.press,textbook.edition) VALUES (@id,@create,@modife,@other,@name,@isbn,@press,@edition)";
            MySqlConnection mySqlConnection = new MySqlConnection(Model.MySqlHelper.Conn);

            mySqlConnection.Open();
            Model.MySqlHelper.ExecuteNonQuery(mySqlConnection, CommandType.Text, insertSql,
                                              new MySqlParameter("@id", textbook.Id),
                                              new MySqlParameter("@create", textbook.Create),
                                              new MySqlParameter("@modife", textbook.Modify),
                                              new MySqlParameter("@other", textbook.Other),
                                              new MySqlParameter("@name", textbook.Name),
                                              new MySqlParameter("@isbn", textbook.Uk_isbn),
                                              new MySqlParameter("@press", textbook.Press),
                                              new MySqlParameter("@edition", textbook.Edition));
            mySqlConnection.Close();
        }
Ejemplo n.º 15
0
        public void FillLibrary()
        {
            Textbook myBook = new Textbook();

            myBook.Age        = 1215;
            myBook.NameOfBook = "Alaverdi";
            myBook.Price      = 3.55;
            myBook.Subject    = "Mathematic";

            Journal myJournal = new Journal();

            myJournal.Age    = 1815;
            myJournal.Price  = 50;
            myJournal.Period = "Monthly";

            Magazine myMagazine = new Magazine();

            myMagazine.Age   = 2015;
            myMagazine.Theme = "News";

            #region a
            //bool b = MyBook is Print_Edition;
            //Print_Edition d = MyBook as Print_Edition;
            //Console.WriteLine($"{b} - {d}");
            //bool x = MyJournal is IPerson;
            //IPerson y = MyJournal as IPerson;
            //Console.WriteLine($"{x} - {y}");
            //Console.WriteLine();
            //Console.WriteLine($"{MyMagazine.ToString()}");
            //Printer MyPrint = new Printer();
            //Console.WriteLine();
            //object[] mas = { MyJournal, MyMagazine, MyBook };
            //for (int i = 0; i < mas.Length; i++)
            //    Console.WriteLine($"{MyPrint.IAmPrinting(mas[i] as Print_Edition)}");
            #endregion

            if (_library == null)
            {
                _library = new Library();
            }
            _library.Add(myBook);
            _library.Add(myJournal);
            _library.Add(myMagazine);
        }
Ejemplo n.º 16
0
        private void initTextbookSelList()
        {
            string querySql = "SELECT textbook.id,textbook.uk_isbn,textbook.`name`,textbook.press,textbook.edition,textbook.other FROM textbook ";// WHERE teacher.id = @teacherID

            //拼接查询SQL和参数数组
            MySqlParameter[] mySqlParamArray = null;
            if (this.TextbookSelList.Count > 0)
            {
                mySqlParamArray = new MySqlParameter[this.TextbookSelList.Count];
                for (int i = 0; i < this.TextbookSelList.Count; i++)
                {
                    if (i != 0)
                    {
                        querySql += " OR textbook.id = @teacherID" + i + " ";
                    }
                    else
                    {
                        querySql += " WHERE textbook.id = @teacherID" + i + " ";
                    }
                    mySqlParamArray[i] = new MySqlParameter("@teacherID" + i, TextbookSelList[i].Id);
                }
            }
            else
            {
                return;
            }

            Console.WriteLine(querySql);
            MySqlDataReader mySqlDataReader = Model.MySqlHelper.ExecuteReader(Model.MySqlHelper.Conn, CommandType.Text, querySql, mySqlParamArray);

            this.TextbookSelList.Clear();
            while (mySqlDataReader.Read())
            {
                Textbook textbook = new Textbook();
                textbook.Id      = mySqlDataReader.IsDBNull(0) ? "" : mySqlDataReader.GetString(0);
                textbook.Uk_isbn = mySqlDataReader.IsDBNull(1) ? "" : mySqlDataReader.GetString(1);
                textbook.Name    = mySqlDataReader.IsDBNull(2) ? "" : mySqlDataReader.GetString(2);
                textbook.Press   = mySqlDataReader.IsDBNull(3) ? "" : mySqlDataReader.GetString(3);
                textbook.Edition = mySqlDataReader.IsDBNull(4) ? "" : mySqlDataReader.GetString(4);
                textbook.Other   = mySqlDataReader.IsDBNull(4) ? "" : mySqlDataReader.GetString(5);
                this.TextbookSelList.Add(textbook);
            }
            mySqlDataReader.Close();
        }
Ejemplo n.º 17
0
        public List <Textbook> QueryTextbookByCourse(string courseId)
        {
            List <Textbook> TextbookList = new List <Textbook>();

            string          cmdText    = "SELECT textbook.id,textbook.`name` FROM textbook_belong_course INNER JOIN course INNER JOIN textbook ON textbook_belong_course.uk_course_id = course.id AND textbook_belong_course.uk_textbook_id = textbook.id WHERE course.id = @courseID";
            MySqlDataReader mSqlReader = Model.MySqlHelper.ExecuteReader(
                Model.MySqlHelper.Conn, CommandType.Text, cmdText,
                new MySqlParameter("@courseID", courseId));

            while (mSqlReader.Read())
            {
                Textbook textbook = new Textbook();
                textbook.Id   = mSqlReader.IsDBNull(0) ? "" : mSqlReader.GetString(0);
                textbook.Name = mSqlReader.IsDBNull(1) ? "" : mSqlReader.GetString(1);
                TextbookList.Add(textbook);
            }
            mSqlReader.Close();
            return(TextbookList);
        }
Ejemplo n.º 18
0
        private void createObjectsButton_Click(object sender, EventArgs e)
        {
            // creating array of objects
            Textbook[] tb = new Textbook[3];

            //initializing objects by constructor
            tb[0] = new Textbook("Java How to Program, Early Objects", new string[] { "Harvey Deitel", "Paul Deitel" }, 1248, 44.99, 13, "Computer Programming Languages");
            tb[1] = new Textbook("Starting Out With Visual Basic", new string[] { "Kip R. Irvine", "Tony Gaddis" }, 936, 166.75, 13, "Computer Programming Languages");
            tb[2] = new Textbook("Starting Out With Visual C#", new string[] { "Tony Gaddis" }, 800, 153.32, 13, "Computer Programming Languages");

            // loop to display books using BookPrint method
            // loop to calculate total
            for (int index = 0; index <= tb.Length - 1; index++)
            {
                MessageBox.Show(tb[index].BookPrint());
                total += tb[index].Price;
            }

            MessageBox.Show("Total: " + total.ToString("c"));
        }
Ejemplo n.º 19
0
 public void Add(Textbook newTX)
 {
     _context.Add(newTX);
     _context.SaveChanges();
 }
Ejemplo n.º 20
0
        public ActionResult CreatePost(CreatePostModel model)
        {
            if (ModelState.IsValid)
            {
                int textbookId = model.TextBookId;

                // if we have a new textbook, store it
                if (model.IsNewBook)
                {
                    // proceed if course id exists; otherwise create the course first
                    Course course = CourseHandler.getCourseByName(model.CourseName);
                    if (course == null)
                    {
                        model.CourseId = CourseHandler.CreateCourse(model.CourseName);
                    }

                    var newTextbook = new Textbook(
                        -1, // id doesnt matter here
                        model.BookTitle,
                        model.ISBN,
                        model.Author,
                        model.CourseId,
                        model.CourseName,
                        model.BookImageUrl,
                        null,
                        1,
                        0,
                        DateTime.Now,
                        DateTime.Now
                        );

                    textbookId = TextbookHandler.createTextBook(newTextbook);
                }

                int      profileId = ProfileHandler.GetProfileId(User.Identity.Name);
                int      price     = model.Price;
                ActionBy actionBy  = model.ActionBy;

                if (model.IsNegotiable)
                {
                    if (actionBy == ActionBy.Buyer)
                    {
                        price = int.MaxValue;
                    }
                    else
                    {
                        price = 0;
                    }
                }

                var newPost = new Post(
                    -1, // id doesnt matter here
                    profileId,
                    textbookId,
                    actionBy,
                    price,
                    model.BookCondition,
                    0,
                    1,
                    0,
                    DateTime.Now,
                    DateTime.Now
                    );

                int postId = PostHandler.createPost(newPost);
                newPost.PostId = postId;
                Task.Run(() => QueueWorker.AddPost(newPost));

                // TODO: redirect to special "you've successfully created post" page
                // with links to create another buy/sell post
                return(RedirectToAction("Index", "Home"));
            }

            // If we got this far, something failed, redisplay form
            IEnumerable <Textbook> textBookCollection = TextbookHandler.getAllTextbooks();

            // test data
            //for(int i = 0; i < 100; i++) {
            //    Textbook book = new Textbook(
            //        i,
            //        "Financial Accounting " + i,
            //        "100000000000" + i,
            //        "Author " + i,
            //        100 + i,
            //        "AFM 10" + i,
            //        null,
            //        10 + i,
            //        1,
            //        0,
            //        DateTime.Now,
            //        DateTime.Now
            //    );
            //    textBookCollection.Add(book);
            //}

            model.PostTypes      = SelectListUtility.getPostTypes();
            model.BookConditions = SelectListUtility.getBookConditions();
            model.Textbooks      = textBookCollection;

            return(View("CreatePost", model));
        }
Ejemplo n.º 21
0
        public static void AddTestEntities(Database db)
        {
            // ------------------------------------------------------
            // INSTRUCTORS
            // ------------------------------------------------------
            var instr1 = new Instructor
            {
                FirstName  = "Matt",
                LastName   = "Saville",
                Department = "Mathematics"
            };
            var instr2 = new Instructor
            {
                FirstName  = "Smitty",
                LastName   = "Werbenjagermanjensen",
                Department = "Mathematics"
            };

            db.Instructors.AddRange(instr1, instr2);

            // ------------------------------------------------------
            // TEXTBOOKS
            // ------------------------------------------------------
            var textbook1 = new Textbook
            {
                Title       = "Calculus: An Intuitive and Physical Approach (Second Edition)",
                Description = "Application-oriented introduction relates the subject as closely as possible to science. In-depth explorations of the derivative, the differentiation and integration of the powers of x, and theorems on differentiation and antidifferentiation lead to a definition of the chain rule and examinations of trigonometric functions, logarithmic and exponential functions, techniques of integration, polar coordinates, much more. Clear-cut explanations, numerous drills, illustrative examples. 1967 edition. Solution guide available upon request.",
                ISBN        = "978-0486404530",
                ImageUrl    = "https://i.imgur.com/9Ly4XCY.png"
            };

            db.Textbooks.AddRange(textbook1);

            // ------------------------------------------------------
            // COURSES
            // ------------------------------------------------------
            db.Courses.AddRange(
                new Course
            {
                Title             = "Calculus I",
                Description       = "Prerequisite: MATH 108 or MATH 115. An introduction to calculus.The goal is to demonstrate fluency in the language of calculus; discuss mathematical ideas appropriately; and solve problems by identifying, representing, and modeling functional relationships. Topics include functions, the sketching of graphs of functions, limits, continuity, derivatives and applications of the derivative, definite and indefinite integrals, and calculation of area. Students may receive credit for only one of the following courses: MATH 130, MATH 131, or MATH 140.",
                Term              = 201901,
                Subject           = "MATH",
                Number            = 140,
                StartDate         = DateTime.Parse("2019/01/14"),
                EndDate           = DateTime.Parse("2019/03/10"),
                IsDateTBD         = false,
                Credits           = 4,
                Location          = "Online",
                Instructor        = instr1,
                Format            = CourseFormat.Hybrid,
                RequiredTextbooks = new List <Textbook> {
                    textbook1
                }
            },
                new Course
            {
                Title             = "Calculus II",
                Description       = "(A continuation of MATH 140.) Prerequisite: MATH 140. A study of integration and functions.The aim is to demonstrate fluency in the language of calculus; discuss mathematical ideas appropriately; model and solve problems using integrals and interpret the results; and use infinite series to approximate functions to model real-world scenarios.Focus is on techniques of integration, improper integrals, and applications of integration (such as volumes, work, arc length, and moments); inverse, exponential, and logarithmic functions; and sequences and series. Students may receive credit for only one of the following courses: MATH 131, MATH 132, or MATH 141.",
                Term              = 201901,
                Subject           = "MATH",
                Number            = 141,
                StartDate         = DateTime.Parse("2019/01/14"),
                EndDate           = DateTime.Parse("2019/03/10"),
                IsDateTBD         = false,
                Credits           = 4,
                Location          = "Online",
                Instructor        = instr2,
                Format            = CourseFormat.Online,
                RequiredTextbooks = new List <Textbook> {
                    textbook1
                }
            }
                );
        }
Ejemplo n.º 22
0
        public static bool ConfirmTransaction(Transaction transaction)
        {
            Dictionary <string, object> updateDictionary = new Dictionary <string, object>();

            if (transaction.FinalPrice != null && transaction.Confirmed == Confirmed.ByNone)
            {
                updateDictionary.Add("FinalPrice", (int)transaction.FinalPrice);

                Profile buyer  = ProfileHandler.GetProfile(transaction.BuyerId);
                Profile seller = ProfileHandler.GetProfile(transaction.SellerId);

                Textbook book = TextbookHandler.getTextbook(transaction.TextbookId);
                if (transaction.CurrentUser == ActionBy.Buyer)
                {
                    updateDictionary.Add("Confirmed", (int)Confirmed.ByBuyer);
                    EmailUtility.SendEmail(
                        Convert.ToString(seller.Email),
                        Convert.ToString(seller.Name),
                        "Please confirm your transaction",
                        String.Format("Item: {0}<br/>{1} has confirmed a transaction with you!<br/>" +
                                      "Please confirm it yourself to finalize the transaction.",
                                      book.BookTitle,
                                      buyer.Name)
                        );
                }
                else
                {
                    updateDictionary.Add("Confirmed", (int)Confirmed.BySeller);
                    EmailUtility.SendEmail(
                        Convert.ToString(buyer.Email),
                        Convert.ToString(buyer.Name),
                        "Please confirm your transaction",
                        String.Format("Item: {0}<br/>{1} has confirmed a transaction with you!<br/>" +
                                      "Please confirm it yourself to finalize the transaction.",
                                      book.BookTitle,
                                      seller.Name)
                        );
                }
            }
            else if (transaction.FinalPrice != null)
            {
                updateDictionary.Add("ConfirmPrice", (int)transaction.FinalPrice);
                updateDictionary.Add("Confirmed", (int)Confirmed.ByBoth);
                updateDictionary.Add("IsActive", 0);

                PostHandler.updatePostState(transaction.SellerPostId, 0, 0);
                PostHandler.updatePostState(transaction.BuyerPostId, 0, 0);

                Profile buyer  = ProfileHandler.GetProfile(transaction.BuyerId);
                Profile seller = ProfileHandler.GetProfile(transaction.SellerId);

                Textbook book = TextbookHandler.getTextbook(transaction.TextbookId);
                EmailUtility.SendEmail(
                    Convert.ToString(buyer.Email),
                    Convert.ToString(buyer.Name),
                    "Your transaction is now complete",
                    String.Format("Item: {0}<br/>Your transaction with {1} has finalized.<br/>" +
                                  "Thank you for using BookSpade!",
                                  book.BookTitle,
                                  seller.Name)
                    );

                EmailUtility.SendEmail(
                    Convert.ToString(seller.Email),
                    Convert.ToString(seller.Name),
                    "Your transaction is now complete",
                    String.Format("Item: {0}<br/>Your transaction with {1} has finalized.<br/>" +
                                  "Thank you for using BookSpade!",
                                  book.BookTitle,
                                  buyer.Name)
                    );
            }

            UpdateTransaction(transaction.TransactionId, updateDictionary);
            return(true);
        }
Ejemplo n.º 23
0
        private async void btnUpload_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            if (tbxName.Text.Trim() == "")
            {
                MessageDialog msgbox = new MessageDialog("You must provide a valid book name");
                await msgbox.ShowAsync();
            }
            else if (storageFile == null)
            {
                MessageDialog msgbox = new MessageDialog("You must provide a valid book picture");
                await msgbox.ShowAsync();
            }
            else
            {
                try
                {
                    btnUpload.IsEnabled = false;
                    btnUpload.Content   = "Uploading......";
                    string fileName    = "";
                    bool   imageExist  = false;
                    string fileAddress = "";
                    Random r           = new Random();
                    if (!storageFile.Equals(null))
                    {
                        imageExist = true;
                        // Source: https://azure.microsoft.com/en-us/documentation/articles/mobile-services-javascript-backend-windows-universal-dotnet-upload-data-blob-storage/#test
                        // Part one: upload images to database
                        // Create the connectionstring
                        String StorageConnectionString = "DefaultEndpointsProtocol=https;AccountName=uonlife;AccountKey=LzU9gRoJgvtKtY7rIPE3w1Z7Toc39AfcBO+Y+Q4ZCYoZmXd2KTgpZ5muya6JkxaZRtNAo3ib3FTpw7gAncpOPA==";
                        // Retrieve storage account from connection string.
                        CloudStorageAccount storageAccount = CloudStorageAccount.Parse(StorageConnectionString);
                        // Create the blob client.
                        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
                        // Retrieve a reference to a container. (pictures)
                        CloudBlobContainer container = blobClient.GetContainerReference("images");
                        await container.CreateIfNotExistsAsync();

                        string sFileName = img.Source.ToString();
                        fileName = tbxName.Text.Trim() + r.Next(10000000, 99999999).ToString() + ".jpg";
                        CloudBlockBlob blobFromSASCredential =
                            container.GetBlockBlobReference(fileName);
                        await blobFromSASCredential.UploadFromFileAsync(storageFile);
                    }
                    // Step two: store data into table
                    if (imageExist == true)
                    {
                        fileAddress = "https://uonlife.blob.core.windows.net/images/" + fileName;
                    }
                    Textbook textbook = new Textbook
                    {
                        bookName     = tbxName.Text,
                        courseID     = tbxCourseID.Text,
                        depreciation = tbxDepreciation.Text,
                        price        = tbxPrice.Text,
                        description  = tbxDescription.Text,
                        contact      = tbxContact.Text,
                        imageAddress = fileAddress,
                        publisher    = GlobalVariable.loginUser
                    };
                    await App.mobileService.GetTable <Textbook>().InsertAsync(textbook);

                    MessageDialog msgbox = new MessageDialog("Upload success");
                    await msgbox.ShowAsync();

                    Frame.Navigate(typeof(MainPage));
                }
                catch (Exception ex)
                {
                    MessageDialog msgbox = new MessageDialog("Error: " + ex.Message);
                    await msgbox.ShowAsync();

                    btnUpload.IsEnabled = true;
                    btnUpload.Content   = "Upload File To Cloud";
                }
            }
        }