Exemple #1
0
        public string SaveBook(Book book)
        {
            bool isExisted = bookGateway.ExistISBN(book);

            if (isExisted)
            {
                return("Already Exists");
            }

            else
            {
                if (book.ISBN.Length == 13)
                {
                    bool isSaved = bookGateway.SaveBook(book);

                    if (isSaved)
                    {
                        return("Book Saved Successfully");
                    }
                    else
                    {
                        return("Failed to Save");
                    }
                }

                else
                {
                    return("ISBN must be 13 digit");
                }
            }
        }
Exemple #2
0
 public string SaveBook(Book book)
 {
     if (book.Isbn.Length == 13)
     {
         int rowEffect = bookGateway.SaveBook(book);
         if (rowEffect > 0)
         {
             return("Saved Successfully");
         }
         else
         {
             return("Failed to Save");
         }
     }
     else
     {
         return("Isbn must be 13 Characters long");
     }
 }
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                BookGateway gateway = new BookGateway();
                List <Book> books   = new List <Book>();
                int         count   = dataGridView1.RowCount;
                for (int i = 0; i < count; i++)
                {
                    DataGridViewRow row = this.dataGridView1.Rows[i];

                    string s1            = row.Cells["S#No"].Value.ToString();
                    string name          = row.Cells["Name"].Value.ToString();
                    string writer        = row.Cells["Writer"].Value.ToString();
                    string edition       = row.Cells["Edition"].Value.ToString();
                    string type          = row.Cells["Type"].Value.ToString();
                    string print         = row.Cells["Book_Print"].Value.ToString();
                    int    quantity      = Convert.ToInt16(row.Cells["Quantiy"].Value);
                    double bookUnitPrice = Convert.ToDouble(row.Cells["B_Unit_Price"].Value);
                    //double totalPrice = Convert.ToDouble(row.Cells["Total_Price"].Value);
                    string date  = row.Cells["Purchase_Date"].Value.ToString();
                    Book   aBook = new Book();
                    aBook.SerialNo      = s1;
                    aBook.BookName      = name;
                    aBook.AuthorName    = writer;
                    aBook.Edition       = edition;
                    aBook.TypeOfBook    = type;
                    aBook.BookPrint     = print;
                    aBook.Quantity      = quantity;
                    aBook.UnitPrice     = bookUnitPrice;
                    aBook.PurchasesDate = date;

                    gateway.SaveBook(aBook);
                    //books.Add(aBook);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Saved");
            }
        }
        public string SaveBook(Book book)
        {
            bool isMemberId = bookGateway.CheckBookName(book);

            if (isMemberId == false)
            {
                int rowAffected = bookGateway.SaveBook(book);
                if (rowAffected > 0)
                {
                    return("Book submit Successfully.");
                }
                else
                {
                    return("Book submit Failed, Try Again.");
                }
            }
            else
            {
                return("This Name Already Used, please try Another Author Name");
            }
        }
        public string SaveBookS(Book aBook)
        {
            string st = bGateway.SaveBook(aBook);

            return(st);
        }