示例#1
0
        private void btnKaydet_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtKitapAdi.Text) & !string.IsNullOrEmpty(txtISBNNo.Text) & cmbKitapYazari.SelectedIndex != -1 & cmbRafNo.SelectedIndex != -1 & cmbTur.SelectedIndex != -1 & cmbYayinEvi.SelectedIndex != -1)
            {
                DateTime dtpBasimTar = Convert.ToDateTime(dtpBasimTarihi.Text);
                if (dtpBasimTar <= DateTime.Now)
                {
                    List <EBooks> bookList = BLLBooks.GetAll();

                    bookList = (from l in bookList
                                where l.ISBNNO.Trim().ToLower().Equals(txtISBNNo.Text.Trim().ToLower())
                                select l).ToList();
                    if (bookList.Count == 0)
                    {
                        EBooks book = new EBooks();
                        book.Author = new EAuthors();
                        book.Shelf  = new EShelf();

                        book.Name          = txtKitapAdi.Text;
                        book.Author.ID     = Convert.ToInt32(cmbKitapYazari.SelectedValue);
                        book.Shelf.ID      = Convert.ToInt32(cmbRafNo.SelectedValue);
                        book.ISBNNO        = txtISBNNo.Text;
                        book.DateOfPublish = dtpBasimTarihi.Value;

                        EBookCategory bookCategory = new EBookCategory();
                        bookCategory.CategoryID = Convert.ToInt32(cmbTur.SelectedValue);
                        bookCategory.BookID     = BLLBooks.InsertNewBook(book);

                        EBookPublisher bookPublisher = new EBookPublisher();
                        bookPublisher.PublisherID = Convert.ToInt32(cmbYayinEvi.SelectedValue);
                        bookPublisher.BookID      = bookCategory.BookID;

                        if (BLLBookCategory.InsertNewBookCategory(bookCategory) & BLLBookPublisher.InsertNewBookPublisher(bookPublisher))
                        {
                            MessageBox.Show("Kitap kayıt işleminiz başarıyla gerçekleşmiştir!");
                            dataGridView1.DataSource = BLLBooks.GetAll();
                            Clear();
                            txtKitapAdi.Focus();
                        }
                        else
                        {
                            MessageBox.Show("Bir hata oluştu!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Girmiş olduğunuz ISBN Numaralı kitap zaten kayıtlı!");
                    }
                }
                else
                {
                    MessageBox.Show("Basım Tarihi Bugünün Tarihinden Büyük Olamaz!");
                }
            }
            else
            {
                MessageBox.Show("Eksik bilgi girdiniz. Lütfen kontrol ediniz!");
            }
        }
 public static bool InsertNewBookCategory(EBookCategory bookcategory)
 {
     if (bookcategory.CategoryID < 1)
     {
         return(false);
     }
     else
     {
         DALBookCategory.InsertNewBooksCategory(bookcategory);
         return(true);
     }
 }
        public static void InsertNewBooksCategory(EBookCategory category)
        {
            SqlCommand cmd = new SqlCommand("spBookCategory_Insert", Baglanti.conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@CategoryID", category.CategoryID);
            cmd.Parameters.AddWithValue("@BookID", category.BookID);

            Baglanti.conn.Open();
            cmd.ExecuteNonQuery();
            Baglanti.conn.Close();
        }
示例#4
0
        private EasyuiTreeNode GetChildSorts(EBookCategory category, List <EBookCategory> categorys)
        {
            var list = categorys.Where(p => p.ParentId == category.CategoryId);
            var cate = new EasyuiTreeNode()
            {
                id = category.CategoryId.ToString(), text = category.CategoryName
            };

            foreach (var c in list)
            {
                cate.children.Add(GetChildSorts(c, categorys));
            }
            return(cate);
        }
示例#5
0
        public JsonResult SaveCategory(int parentId, int id, string cname, string desc)
        {
            EBookCategory category;

            if (id == 0)
            {
                category = new EBookCategory
                {
                    ParentId    = parentId,
                    TenantId    = CurrentTenant.TenantId,
                    CreateUser  = CurrentUser.UserId,
                    CreateTime  = DateTime.Now,
                    Description = "",
                    IsDelete    = 0
                };
            }
            else
            {
                category = _eBookManager.GetCategory(id);
                if (category.TenantId != CurrentTenant.TenantId)
                {
                    return(Json(new { result = 0, msg = "没有找到要修改的数据!" }, JsonRequestBehavior.DenyGet));
                }
            }
            category.CategoryName = cname;
            category.Description  = desc;
            if (category.ParentId == 0)
            {
                category.LevelDesc = cname;
            }
            else
            {
                var parent = _eBookManager.GetCategory(parentId);
                category.LevelDesc = parent.LevelDesc + "\\" + cname;
            }
            if (id == 0)
            {
                _eBookManager.AddCategory(category);
            }
            else
            {
                _eBookManager.UpdateCategory(category);
            }
            return(Json(new { result = 1 }, JsonRequestBehavior.DenyGet));
        }
示例#6
0
        public ActionResult EditCategory(int cateId, int parentId = 0)
        {
            EBookCategory model;

            ViewBag.parentId = parentId;
            if (cateId == 0)
            {
                //新增
                model = new EBookCategory();
                var parent = _eBookManager.GetCategory(parentId);
                ViewBag.parentName = parent == null ? CurrentTenant.TenantName : parent.CategoryName;
            }
            else
            {
                model = _eBookManager.GetCategory(cateId);
                ViewBag.parentName = model.ParentName == "" ? CurrentTenant.TenantName : model.ParentName;
            }
            return(View(model));
        }
示例#7
0
 /// <summary>
 /// 修改分类
 /// </summary>
 /// <param name="category"></param>
 /// <returns></returns>
 public bool UpdateCategory(EBookCategory category)
 {
     return(_dataAccess.UpdateEntity(category) > 0);
 }
示例#8
0
 /// <summary>
 /// 添加分类
 /// </summary>
 /// <param name="category"></param>
 /// <returns></returns>
 public int AddCategory(EBookCategory category)
 {
     category.CategoryId = _dataAccess.AddEntity(category);
     return(category.CategoryId);
 }
示例#9
0
        protected void btnKaydet_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtKitapAdi.Text) & !string.IsNullOrEmpty(dtpBasimTarihi.Text) & !string.IsNullOrEmpty(txtISBNNo.Text))
            {
                DateTime dtpBasimTar = Convert.ToDateTime(dtpBasimTarihi.Text);
                if (dtpBasimTar <= DateTime.Now)
                {
                    List <EBooks> bookList = BLLBooks.GetAll();

                    bookList = (from l in bookList
                                where l.ISBNNO.Trim().ToLower().Equals(txtISBNNo.Text.Trim().ToLower())
                                select l).ToList();
                    if (bookList.Count == 0)
                    {
                        EBooks book = new EBooks();
                        book.Author = new EAuthors();
                        book.Shelf  = new EShelf();

                        book.Name      = txtKitapAdi.Text;
                        book.Author.ID = Convert.ToInt32(cmbKitapYazari.SelectedValue);
                        book.Shelf.ID  = Convert.ToInt32(cmbRafNo.SelectedValue);
                        book.ISBNNO    = txtISBNNo.Text;

                        string[] basimTarArr = dtpBasimTarihi.Text.Split(new string[] { "." }, StringSplitOptions.None);
                        book.DateOfPublish = new DateTime(int.Parse(basimTarArr[2]), int.Parse(basimTarArr[1]), int.Parse(basimTarArr[0]));

                        EBookCategory bookCategory = new EBookCategory();
                        bookCategory.CategoryID = Convert.ToInt32(cmbTur.SelectedValue);
                        bookCategory.BookID     = BLLBooks.InsertNewBook(book);

                        EBookPublisher bookPublisher = new EBookPublisher();
                        bookPublisher.PublisherID = Convert.ToInt32(cmbYayinEvi.SelectedValue);
                        bookPublisher.BookID      = bookCategory.BookID;

                        if (BLLBookCategory.InsertNewBookCategory(bookCategory) & BLLBookPublisher.InsertNewBookPublisher(bookPublisher))
                        {
                            Response.Write("<script>alert('Kitap kayıt işleminiz başarıyla gerçekleşmiştir.')</script>");
                        }
                        else
                        {
                            Response.Write("<script>alert('Hata Oluştu!')</script>");
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('Girmiş olduğunuz ISBN Numaralı kitap zaten kayıtlı!')</script>");
                    }


                    txtKitapAdi.Text    = String.Empty;
                    txtISBNNo.Text      = String.Empty;
                    dtpBasimTarihi.Text = String.Empty;
                    cmbKitapYazari.ClearSelection();
                    cmbRafNo.ClearSelection();
                    cmbTur.ClearSelection();
                    cmbYayinEvi.ClearSelection();
                    txtKitapAdi.Focus();
                }
                else
                {
                    Response.Write("<script>alert('Basım Tarihi Bugünün Tarihinden Büyük Olamaz!')</script>");
                    dtpBasimTarihi.Text = String.Empty;
                }
            }
            else
            {
                Response.Write("<script>alert('Eksik bilgi girdiniz. Lütfen kontrol ediniz!')</script>");
            }
        }