private void Button_Click(object sender, RoutedEventArgs e)
        {
            string ID     = this.IDS.Text.Trim();
            string name   = this.bookname.Text.Trim();
            string author = this.cbs.Text.Trim();
            string price  = this.price.Text.Trim();
            string store  = this.store.Text.Trim();

            if (ID == "" || name == "" || author == "" || price == "" || store == "")
            {
                // 有信息未填
                MessageBox.Show("所有信息不能为空!");
                return;
            }
            Book book = new Book();

            BookStore.BLL.BookBLL bll = new BookBLL();
            bool flag = false;

            book.Id     = Convert.ToInt32(this.IDS.Text.Trim());//int.Parse(ID);
            book.Name   = name;
            book.Price  = Convert.ToDouble(this.price.Text.Trim());
            book.store  = Convert.ToInt32(store);
            book.Author = author;
            flag        = bll.AddBook(book);
            if (flag)
            {
                MessageBoxResult boxResult = MessageBox.Show("图书信息添加成功!", "提示:", MessageBoxButton.YesNo, MessageBoxImage.Information, MessageBoxResult.No);
                if (boxResult == MessageBoxResult.Yes)
                {
                    BookWindow1 BookWindow = new BookWindow1();
                    BookWindow.WindowStartupLocation = WindowStartupLocation.Manual;
                    BookWindow.Left = this.Left;
                    BookWindow.Top  = this.Top;
                    BookWindow.Show();
                    this.Close();
                }
            }

            /*
             *  Book book = new Book();
             *  BookStore.BLL.BookBLL bll = new BookBLL();
             *  bool flag = false;
             *  book.Id =int.Parse(ID);
             *  book.Name = name;
             *  book.Price = int.Parse(price);
             *  book.Inventory = int.Parse(kc);
             *  book.Author = cbs;
             *
             *  flag = bll.AddBook(book);
             *  if (flag)
             *  {
             *
             *  }*/
        }
예제 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                bool NameNull     = string.IsNullOrEmpty(textboxBookName.Text);
                bool YearNull     = string.IsNullOrEmpty(textboxYear.Text);
                bool CompanyNull  = string.IsNullOrEmpty(textboxCompany.Text);
                bool CategoryNull = string.IsNullOrEmpty(cbbCategory.SelectedItem.ToString());
                bool AuthorsNull  = (listTacGia == null);

                if (!NameNull && !YearNull && !CompanyNull && !CategoryNull && !AuthorsNull)
                {
                    string name    = textboxBookName.Text;
                    int    year    = Int32.Parse(textboxYear.Text);
                    string company = textboxCompany.Text;

                    //get category
                    string category   = cbbCategory.SelectedItem.ToString();
                    string categoryID = CategoryController.GetCategoryIDByName(category);

                    //get authors
                    List <string> authorsID = new List <string>();
                    foreach (Button author in listTacGia.Controls)
                    {
                        authorsID.Add(AuthorController.GetAuthorIDByName(author.Text));
                    }

                    if (BookController.AddBook(name, categoryID, authorsID, company, year))
                    {
                        MessageBox.Show("Them thanh cong");
                        Clear();
                        this.Hide();
                        this.isShown = false;
                        if (parent != null)
                        {
                            this.parent.ClearAndShow();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Thêm thất bại, vui lòng kiểm tra lại thông tin");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Thông tin không hợp lệ");
            }
        }
예제 #3
0
        public ActionResult AddBook(FormCollection form)
        {
            BookBLL bookBLL = new BookBLL();

            Book book = new Book
            {
                Name       = Request.Form["Name"],
                IdAuthor   = int.Parse(Request.Form["IdAut"]),
                IdGenre    = int.Parse(Request.Form["IdGen"]),
                Indication = Request.Form["Indication"],
                Saga       = Request.Form["Saga"],
                DateCreate = DateTime.Today
            };

            bookBLL.AddBook(book);

            return(RedirectToAction("Index"));
        }
예제 #4
0
 public ResultModel Post([FromBody] Book book)
 {
     try
     {
         _bookBLL.AddBook(book);
         return(new ResultModel(Code.CREATED, "thành công"));
     }
     catch (Exception ex)
     {
         if (ex.Message.Contains("Mã sách không tồn tại") || ex.Message.Contains("Mã loại sách không tồn tại"))
         {
             return(new ResultModel(Code.SVERROR, ex.Message.ToString()));
         }
         else
         {
             return(new ResultModel(Code.SVERROR, "lỗi hệ thống"));
         }
     }
 }
예제 #5
0
        private void btnBookAdd_Click(object sender, EventArgs e)
        {
            Book book = new Book();

            try
            {
                book.PublisherID     = (int)cmbPublisherID.SelectedValue;
                book.AuthorID        = (int)cmbAuthorID.SelectedValue;
                book.BookName        = txtBookName.Text;
                book.Price           = numPrice.Value;
                book.PublicationDate = dateTimePicker1.Value;
                book.Pages           = (int)numPages.Value;
                book.Summary         = txtSummary.Text;
                book.BookStatus      = true;
                book.DamageStatus    = false;
                _bookBLL.AddBook(book);
                DataGridFillBookList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #6
0
        private int SaveNewBook()
        {
            if (this.txtPageCount.Text == "")
            {
                this.txtPageCount.Text = "0";
            }

            if (this.txtWordCount.Text == "")
            {
                this.txtWordCount.Text = "0";
            }


            BookBLL kBLL = new BookBLL();

            string strId = Request.QueryString.Get("knowledgeId");

            RailExam.Model.Book book = new RailExam.Model.Book();

            book.Memo = txtMemo.Text;
            if (PrjPub.CurrentLoginUser.SuitRange == 1)
            {
                book.bookName = txtBookName.Text;
            }
            else
            {
                OrganizationBLL orgBll  = new OrganizationBLL();
                string          orgName = orgBll.GetOrganization(PrjPub.CurrentLoginUser.StationOrgID).ShortName;
                book.bookName = orgName + txtBookName.Text;
            }
            book.Description      = txtDescription.Text;
            book.pageCount        = int.Parse(txtPageCount.Text);
            book.wordCount        = int.Parse(txtWordCount.Text);
            book.revisers         = txtRevisers.Text;
            book.authors          = hfEmployeeID.Value;
            book.bookmaker        = txtBookMaker.Text;
            book.bookNo           = txtBookNo.Text;
            book.coverDesigner    = txtCoverDesigner.Text;
            book.keyWords         = txtKeyWords.Text;
            book.knowledgeName    = txtKnowledgeName.Text;
            book.knowledgeId      = int.Parse(hfKnowledgeID.Value);
            book.publishOrg       = int.Parse(hfPublishOrgID.Value);
            book.publishDate      = DateTime.Parse(datePublishDate.DateValue.ToString());
            book.TechnicianTypeID = Convert.ToInt32(ddlTech.SelectedValue);
            book.IsGroupLearder   = Convert.ToInt32(ddlIsGroup.SelectedValue);

            ArrayList alTrainTypeID = new ArrayList();

            string strTrainTypeID = hfTrainTypeID.Value;

            string[] str1 = strTrainTypeID.Split(new char[] { ',' });

            for (int i = 0; i < str1.Length; i++)
            {
                if (!string.IsNullOrEmpty(str1[i]))
                {
                    alTrainTypeID.Add(str1[i]);
                }
            }

            book.trainTypeidAL = alTrainTypeID;

            ArrayList al = new ArrayList();

            book.orgidAL = GetOrg(tvOrg.Nodes, al);


            ArrayList al1 = new ArrayList();

            foreach (TreeViewNode tn in tvPost.Nodes)
            {
                if (tn.Checked)
                {
                    al1.Add(tn.ID);
                }

                if (tn.Nodes.Count > 0)
                {
                    foreach (TreeViewNode tns in tn.Nodes)
                    {
                        if (tns.Checked)
                        {
                            al1.Add(tns.ID);
                        }

                        if (tns.Nodes.Count > 0)
                        {
                            foreach (TreeViewNode tnss in tns.Nodes)
                            {
                                if (tnss.Checked)
                                {
                                    al1.Add(tnss.ID);
                                }
                            }
                        }
                    }
                }
            }


            book.postidAL = al1;

            string strNewID = kBLL.AddBook(book).ToString();

            string strPath = Server.MapPath("../Online/Book/" + strNewID);

            Directory.CreateDirectory(strPath);
            Directory.CreateDirectory(strPath + "/Upload");
            CopyTemplate(Server.MapPath("../Online/Book/template/"), Server.MapPath("../Online/Book/" + strNewID + "/"));

            SaveBookCover(strNewID);

            return(Convert.ToInt32(strNewID));
        }
예제 #7
0
        protected void btnInput_Click(object sender, EventArgs e)
        {
            string strSql;

            for (int i = 0; i < gvBook.Rows.Count; i++)
            {
                CheckBox chk = (CheckBox)gvBook.Rows[i].FindControl("chSelect");

                HiddenField hfKownledgeName = (HiddenField)gvBook.Rows[i].FindControl("hfKownledgeName");
                HiddenField hfKownledgeId   = (HiddenField)gvBook.Rows[i].FindControl("hfKownledgeId");
                HiddenField hfTrainTypeName = (HiddenField)gvBook.Rows[i].FindControl("hfTrainTypeName");
                HiddenField hfTrainTypeID   = (HiddenField)gvBook.Rows[i].FindControl("hfTrainTypeID");

                if (chk.Checked && hfKownledgeName.Value.Trim() == "")
                {
                    SessionSet.PageMessage = "请选择教材体系!";
                    return;
                }

                if (chk.Checked && hfTrainTypeName.Value.Trim() == "")
                {
                    SessionSet.PageMessage = "请选择培训类别!";
                    return;
                }

                if (chk.Checked)
                {
                    strSql = "select a.*,b.Short_Name from Book a inner join Org b on a.Publish_Org=b.Org_ID where a.Book_ID=" + gvBook.DataKeys[i].Value.ToString();
                    DataSet ds = RunSqlDataSet(strSql);
                    DataRow dr = ds.Tables[0].Rows[0];

                    BookBLL             bookBLL = new BookBLL();
                    RailExam.Model.Book book    = new RailExam.Model.Book();

                    book.bookId = Convert.ToInt32(dr["Book_ID"].ToString());

                    string strPath    = Server.MapPath(ConfigurationManager.AppSettings["BookDesigner"].ToString() + book.bookId + "/");
                    string strAimPath = Server.MapPath("../Online/Book/" + book.bookId + "/");
                    if (!Directory.Exists(strPath))
                    {
                        SessionSet.PageMessage = "有教材还未创建内容,暂不能导入!";
                        return;
                    }

                    book.bookName       = dr["Book_Name"].ToString();
                    book.bookNo         = dr["Book_No"].ToString();
                    book.authors        = dr["Authors"].ToString();
                    book.bookmaker      = dr["BookMaker"].ToString();
                    book.publishOrg     = Convert.ToInt32(dr["Publish_Org"].ToString());
                    book.publishOrgName = dr["Short_Name"].ToString();
                    book.revisers       = dr["Revisers"].ToString();
                    book.coverDesigner  = dr["Cover_Designer"].ToString();
                    book.keyWords       = dr["Keywords"].ToString();
                    book.pageCount      = Convert.ToInt32(dr["Page_Count"].ToString());
                    book.wordCount      = Convert.ToInt32(dr["Word_Count"].ToString());
                    book.Description    = dr["Description"].ToString();
                    book.url            = "../Book/" + dr["Book_ID"].ToString() + "/index.html";
                    book.Memo           = dr["Remark"].ToString();
                    book.knowledgeId    = Convert.ToInt32(hfKownledgeId.Value);
                    book.knowledgeName  = hfKownledgeName.Value;

                    ArrayList typeIDAL  = new ArrayList();
                    string[]  strTypeID = hfTrainTypeID.Value.Split(',');
                    for (int j = 0; j < strTypeID.Length; j++)
                    {
                        typeIDAL.Add(strTypeID[j]);
                    }
                    book.trainTypeidAL = typeIDAL;

                    bookBLL.AddBook(book);

                    strSql = "select * from Book_Chapter where Book_ID=" + gvBook.DataKeys[i].Value.ToString() + " order by Level_Num,Order_Index";
                    ds     = RunSqlDataSet(strSql);

                    BookChapterBLL bookChapterBll = new BookChapterBLL();
                    foreach (DataRow dr1 in ds.Tables[0].Rows)
                    {
                        RailExam.Model.BookChapter bookChapter = new RailExam.Model.BookChapter();

                        bookChapter.ChapterId           = Convert.ToInt32(dr1["Chapter_ID"].ToString());
                        bookChapter.BookId              = Convert.ToInt32(dr1["Book_ID"].ToString());
                        bookChapter.ChapterName         = dr1["Chapter_Name"].ToString();
                        bookChapter.ParentId            = Convert.ToInt32(dr1["Parent_ID"].ToString());
                        bookChapter.LevelNum            = Convert.ToInt32(dr1["Level_Num"].ToString());
                        bookChapter.OrderIndex          = Convert.ToInt32(dr1["Order_Index"].ToString());
                        bookChapter.ReferenceRegulation = dr1["REFERENCE_REGULATION"].ToString();
                        bookChapter.Description         = dr1["Description"].ToString();
                        bookChapter.Memo = dr1["Remark"].ToString();
                        bookChapter.Url  = "../Book/" + dr1["Book_ID"].ToString() + "/" + dr1["Chapter_ID"].ToString() + ".htm";

                        bookChapterBll.AddBookChapter(bookChapter);
                    }

                    CopyTemplate(strPath, strAimPath);
                }
            }
            BindGrid();
        }