コード例 #1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (this.dgvPublisher.SelectedCells.Count > 0)
     {
         int selectedrowindex = this.dgvPublisher.SelectedCells[0].RowIndex;
         DataGridViewRow selectedRow = this.dgvPublisher.Rows[selectedrowindex];
         PublisherBLL publisherBLL = new PublisherBLL(Convert.ToInt32(selectedRow.Cells["clmnId"].Value), selectedRow.Cells["clmnName"].Value.ToString(), selectedRow.Cells["clmnPhone"].Value.ToString(), selectedRow.Cells["clmnAddress"].Value.ToString());
         DialogResult result = MessageBox.Show("Do you want to delete publisher: " + selectedRow.Cells["clmnName"].Value + "?", "Warning", MessageBoxButtons.OKCancel);
         switch (result)
         {
             case DialogResult.Cancel:
                 break;
             case DialogResult.OK:
                 if (PublisherDAL.getPublisherItem(publisherBLL) != null)
                 {
                     MessageBox.Show("Can't delete! Please delete all book title has publisher " + selectedRow.Cells["clmnName"].Value + " before delete this publisher!", "Error");
                     break;
                 }
                 else
                 {
                     PublisherDAL.deletePublisher(publisherBLL);
                     MessageBox.Show("Delete complete!", "Success");
                     this.LoadDataToGridView();
                     break;
                 }
         }
     }
 }
コード例 #2
0
 public frmKitapEkle()
 {
     InitializeComponent();
     _bookBLL      = new BookBLL();
     _publisherBLL = new PublisherBLL();
     _authorBLL    = new AuthorBLL();
 }
コード例 #3
0
        public static void addPublisher(PublisherBLL publisherBLL)
        {
            String sql = "INSERT INTO [nhaxuatban] (tennxb, sdtnxb, diachinxb)"
                         + " VALUES ( N'" + publisherBLL.Name + "', N'" + publisherBLL.Phone + "', N'" + publisherBLL.Address + "')";

            PublisherDAL._condb.ExecuteNonQuery(sql);
        }
コード例 #4
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            PublisherModel publisher = new PublisherModel(TextBox3.Text);

            Response.Write(PublisherBLL.AddPublisher(publisher));
            Label2.Text = PublisherBLL.GetPublisherCount().ToString();
        }
コード例 #5
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.dgvPublisher.SelectedCells.Count > 0)
            {
                int             selectedrowindex = this.dgvPublisher.SelectedCells[0].RowIndex;
                DataGridViewRow selectedRow      = this.dgvPublisher.Rows[selectedrowindex];
                PublisherBLL    publisherBLL     = new PublisherBLL(Convert.ToInt32(selectedRow.Cells["clmnId"].Value), selectedRow.Cells["clmnName"].Value.ToString(), selectedRow.Cells["clmnPhone"].Value.ToString(), selectedRow.Cells["clmnAddress"].Value.ToString());
                DialogResult    result           = MessageBox.Show("Do you want to delete publisher: " + selectedRow.Cells["clmnName"].Value + "?", "Warning", MessageBoxButtons.OKCancel);
                switch (result)
                {
                case DialogResult.Cancel:
                    break;

                case DialogResult.OK:
                    if (PublisherDAL.getPublisherItem(publisherBLL) != null)
                    {
                        MessageBox.Show("Can't delete! Please delete all book title has publisher " + selectedRow.Cells["clmnName"].Value + " before delete this publisher!", "Error");
                        break;
                    }
                    else
                    {
                        PublisherDAL.deletePublisher(publisherBLL);
                        MessageBox.Show("Delete complete!", "Success");
                        this.LoadDataToGridView();
                        break;
                    }
                }
            }
        }
コード例 #6
0
        public ActionResult Create()
        {
            var bookViewModel = new BookDetailsViewModel();

            bookViewModel.PublisherList = PublisherBLL.ListAll();
            bookViewModel.AuthorsList   = AuthorBLL.ListAll();
            return(View(bookViewModel));
        }
コード例 #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Label1.Text = AuthorBLL.GetAuthorCount().ToString();
         Label2.Text = PublisherBLL.GetPublisherCount().ToString();
     }
 }
コード例 #8
0
        private void LoadDataToGridView()
        {
            this.dgvPublisher.Rows.Clear();
            PublisherBLL        publiserBLL  = new PublisherBLL();
            List <PublisherBLL> publisherArr = new List <PublisherBLL>();

            publisherArr = PublisherDAL.getPublisherList();
            foreach (PublisherBLL row in publisherArr)
            {
                this.dgvPublisher.Rows.Add(row.PublisherId, row.Name, row.Phone, row.Address);
            }
            this.GetSelectedValue();
            this.dgvPublisher.CellClick += new DataGridViewCellEventHandler(dgvPublisher_CellClick);
        }
コード例 #9
0
 public static PublisherBLL getPublisherItem(PublisherBLL publiserBLL)
 {
     String sql = "SELECT * FROM [nhaxuatban] WHERE manxb=" + publiserBLL.PublisherId;
     DataTable dt = PublisherDAL._condb.getDataTable(sql);
     if (dt.Rows.Count > 0)
     {
         DataRow row = dt.Rows[0];
         return new PublisherBLL(Int32.Parse(row["manxb"].ToString()), row["tennxb"].ToString(), row["sdtnxb"].ToString(), row["diachinxb"].ToString());
     }
     else
     {
         return null;
     }
 }
コード例 #10
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     PublisherBLL publisherBLL = new PublisherBLL();
     publisherBLL.Name = this.txtPublisherName.Text;
     publisherBLL.Phone = this.txtPhone.Text;
     publisherBLL.Address = this.txtAddress.Text;
     if (publisherBLL.Name == "")
     {
         MessageBox.Show("Author name is not null!", "Notice");
         return;
     }
     PublisherDAL.addPublisher(publisherBLL);
     MessageBox.Show("Add success!", "Success");
     this.LoadDataToGridView();
 }
コード例 #11
0
        public ActionResult Create(BookDetailsViewModel bookViewModel)
        {
            if (ModelState.IsValid)
            {
                var bookModel = this.ConvertBookDetailsViewModelToBookModel(bookViewModel);

                BookBLL.Insert(bookModel);
                return(RedirectToAction("Index"));
            }

            bookViewModel.PublisherList = PublisherBLL.ListAll();
            bookViewModel.AuthorsList   = AuthorBLL.ListAll();

            return(View(bookViewModel));
        }
コード例 #12
0
        public static PublisherBLL getPublisherItem(PublisherBLL publiserBLL)
        {
            String    sql = "SELECT * FROM [nhaxuatban] WHERE manxb=" + publiserBLL.PublisherId;
            DataTable dt  = PublisherDAL._condb.getDataTable(sql);

            if (dt.Rows.Count > 0)
            {
                DataRow row = dt.Rows[0];
                return(new PublisherBLL(Int32.Parse(row["manxb"].ToString()), row["tennxb"].ToString(), row["sdtnxb"].ToString(), row["diachinxb"].ToString()));
            }
            else
            {
                return(null);
            }
        }
コード例 #13
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            PublisherBLL publisherBLL = new PublisherBLL();

            publisherBLL.Name    = this.txtPublisherName.Text;
            publisherBLL.Phone   = this.txtPhone.Text;
            publisherBLL.Address = this.txtAddress.Text;
            if (publisherBLL.Name == "")
            {
                MessageBox.Show("Author name is not null!", "Notice");
                return;
            }
            PublisherDAL.addPublisher(publisherBLL);
            MessageBox.Show("Add success!", "Success");
            this.LoadDataToGridView();
        }
コード例 #14
0
        public static List <PublisherBLL> getPublisherList()
        {
            String              sql = "SELECT * FROM [nhaxuatban]";
            DataTable           dt  = PublisherDAL._condb.getDataTable(sql);
            List <PublisherBLL> publisherBLLList = new List <PublisherBLL>();

            if (dt.Rows.Count > 1)
            {
                foreach (DataRow row in dt.Rows)
                {
                    PublisherBLL publisherBLL = new PublisherBLL(Int32.Parse(row["manxb"].ToString()), row["tennxb"].ToString(), row["sdtnxb"].ToString(), row["diachinxb"].ToString());
                    publisherBLLList.Add(publisherBLL);
                }
                return(publisherBLLList);
            }
            else
            {
                return(null);
            }
        }
コード例 #15
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.dgvPublisher.SelectedCells.Count > 0)
            {
                int selectedrowindex = this.dgvPublisher.SelectedCells[0].RowIndex;

                DataGridViewRow selectedRow = this.dgvPublisher.Rows[selectedrowindex];

                PublisherBLL publisherBLL = new PublisherBLL(Convert.ToInt32(selectedRow.Cells["clmnId"].Value), this.txtPublisherName.Text, this.txtPhone.Text, this.txtAddress.Text);

                if (publisherBLL.Name == "")
                {
                    MessageBox.Show("Author name is not null!", "Notice");
                    return;
                }
                PublisherDAL.updatePublisher(publisherBLL);
                MessageBox.Show("Update success!", "Success");
                this.LoadDataToGridView();
            }
        }
コード例 #16
0
        public static List <PublisherBLL> search(string catalog, string key)
        {
            string              sql = "SELECT * FROM [nhaxuatban] WHERE " + catalog + " LIKE '%" + key + "%'";
            DataTable           dt  = PublisherDAL._condb.getDataTable(sql);
            List <PublisherBLL> publisherBLLList = new List <PublisherBLL>();

            if (dt.Rows.Count > 1)
            {
                foreach (DataRow row in dt.Rows)
                {
                    PublisherBLL publisherBLL = new PublisherBLL(Int32.Parse(row["manxb"].ToString()), row["tennxb"].ToString(), row["sdtnxb"].ToString(), row["diachinxb"].ToString());
                    publisherBLLList.Add(publisherBLL);
                }
                return(publisherBLLList);
            }
            else
            {
                return(null);
            }
        }
コード例 #17
0
        private void LoadDataToDataGridViewBookTitle()
        {
            this.dgvBookTitle.Rows.Clear();
            List <BookTitleBLL> bookTitleList = new List <BookTitleBLL>();

            bookTitleList = BookTitleDAL.getBookTitleList();
            TypeOfBookBLL typeOfBookBLL = new TypeOfBookBLL();

            foreach (BookTitleBLL row in bookTitleList)
            {
                typeOfBookBLL = TypeOfBookDAL.getTypeOfBookItem(row.TypeOfBookId);
                PublisherBLL publisherBLL = new PublisherBLL();
                publisherBLL = PublisherDAL.getPublisherItem(row.PublisherId);
                BookTitleStatusBLL status = new BookTitleStatusBLL();
                status = BookTitleStatusDAL.getBookTitleStatusItem(row.BookTitleStatusId);
                this.dgvBookTitle.Rows.Add(row.BookTitleId, row.Name, row.TypeOfBookId, typeOfBookBLL.Name, row.PublisherId, publisherBLL.Name, row.BookTitleStatusId, status.Name, row.Summary);
            }
            GetSelectedValueDataGridViewBookTitle();
            this.dgvBookTitle.SelectionChanged += new EventHandler(dgvBookTitle_SelectionChanged);
        }
コード例 #18
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            BookModel book = BookBLL.FindBookById(id.Value);

            if (book == null)
            {
                return(HttpNotFound());
            }

            var bookViewModel = new BookDetailsViewModel(book);

            bookViewModel.BookID        = id.Value;
            bookViewModel.PublisherList = PublisherBLL.ListAll();
            bookViewModel.AuthorsList   = AuthorBLL.ListAll();

            return(View(bookViewModel));
        }
コード例 #19
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            string catalog = this.cboSearch.Text;
            string key     = this.txtSearch.Text;

            if (key == "")
            {
                MessageBox.Show("Please enter keyword!", "Notice");
                return;
            }
            PublisherBLL        publisherBLL = new PublisherBLL();
            List <PublisherBLL> publisherArr = new List <PublisherBLL>();

            publisherArr = PublisherDAL.search(catalog, key);
            this.dgvPublisher.Rows.Clear();
            foreach (PublisherBLL row in publisherArr)
            {
                this.dgvPublisher.Rows.Add(row.PublisherId, row.Name, row.Phone, row.Address);
            }
            this.GetSelectedValue();

            this.dgvPublisher.CellClick += new DataGridViewCellEventHandler(dgvPublisher_CellClick);
        }
コード例 #20
0
        public static void deletePublisher(PublisherBLL publisherBLL)
        {
            String sql = "DELETE FROM [nhaxuatban] WHERE manxb=" + publisherBLL.PublisherId;

            PublisherDAL._condb.ExecuteNonQuery(sql);
        }
コード例 #21
0
 public static void addPublisher(PublisherBLL publisherBLL)
 {
     String sql = "INSERT INTO [nhaxuatban] (tennxb, sdtnxb, diachinxb)"
             + " VALUES ( N'" + publisherBLL.Name + "', N'" + publisherBLL.Phone + "', N'"+publisherBLL.Address+"')";
         PublisherDAL._condb.ExecuteNonQuery(sql);
 }
コード例 #22
0
 public static void deletePublisher(PublisherBLL publisherBLL)
 {
     String sql = "DELETE FROM [nhaxuatban] WHERE manxb=" + publisherBLL.PublisherId;
         PublisherDAL._condb.ExecuteNonQuery(sql);
 }
コード例 #23
0
 public static List<PublisherBLL> getPublisherList()
 {
     String sql = "SELECT * FROM [nhaxuatban]";
     DataTable dt = PublisherDAL._condb.getDataTable(sql);
     List<PublisherBLL> publisherBLLList = new List<PublisherBLL>();
     if (dt.Rows.Count > 1)
     {
         foreach (DataRow row in dt.Rows)
         {
             PublisherBLL publisherBLL = new PublisherBLL(Int32.Parse(row["manxb"].ToString()), row["tennxb"].ToString(), row["sdtnxb"].ToString(), row["diachinxb"].ToString());
             publisherBLLList.Add(publisherBLL);
         }
         return publisherBLLList;
     }
     else
     {
         return null;
     }
 }
コード例 #24
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            string catalog = this.cboSearch.Text;
            string key = this.txtSearch.Text;
            if (key == "")
            {
                MessageBox.Show("Please enter keyword!", "Notice");
                return;
            }
            PublisherBLL publisherBLL = new PublisherBLL();
            List<PublisherBLL> publisherArr = new List<PublisherBLL>();
            publisherArr = PublisherDAL.search(catalog, key);
            this.dgvPublisher.Rows.Clear();
            foreach (PublisherBLL row in publisherArr)
            {
                this.dgvPublisher.Rows.Add(row.PublisherId, row.Name, row.Phone, row.Address);
            }
            this.GetSelectedValue();

            this.dgvPublisher.CellClick += new DataGridViewCellEventHandler(dgvPublisher_CellClick);
        }
コード例 #25
0
 private void LoadDataToGridView()
 {
     this.dgvPublisher.Rows.Clear();
     PublisherBLL publiserBLL = new PublisherBLL();
     List<PublisherBLL> publisherArr = new List<PublisherBLL>();
     publisherArr = PublisherDAL.getPublisherList();
     foreach (PublisherBLL row in publisherArr)
     {
         this.dgvPublisher.Rows.Add(row.PublisherId, row.Name, row.Phone, row.Address);
     }
     this.GetSelectedValue();
     this.dgvPublisher.CellClick += new DataGridViewCellEventHandler(dgvPublisher_CellClick);
 }
コード例 #26
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.dgvPublisher.SelectedCells.Count > 0)
            {

                int selectedrowindex = this.dgvPublisher.SelectedCells[0].RowIndex;

                DataGridViewRow selectedRow = this.dgvPublisher.Rows[selectedrowindex];

                PublisherBLL publisherBLL = new PublisherBLL(Convert.ToInt32(selectedRow.Cells["clmnId"].Value), this.txtPublisherName.Text, this.txtPhone.Text, this.txtAddress.Text);

                if (publisherBLL.Name == "")
                {
                    MessageBox.Show("Author name is not null!", "Notice");
                    return;
                }
                PublisherDAL.updatePublisher(publisherBLL);
                MessageBox.Show("Update success!", "Success");
                this.LoadDataToGridView();
            }
        }
コード例 #27
0
 public static void updatePublisher(PublisherBLL publisherBLL)
 {
     String sql = "UPDATE [nhaxuatban] SET tennxb=N'" + publisherBLL.Name + "', sdtnxb=N'" + publisherBLL.Phone + "', diachinxb=N'" + publisherBLL.Address + "' WHERE manxb=" + publisherBLL.PublisherId;
         PublisherDAL._condb.ExecuteNonQuery(sql);
 }
コード例 #28
0
 private void LoadDataToDataGridViewBookTitle()
 {
     this.dgvBookTitle.Rows.Clear();
     List<BookTitleBLL> bookTitleList = new List<BookTitleBLL>();
     bookTitleList = BookTitleDAL.getBookTitleList();
     TypeOfBookBLL typeOfBookBLL = new TypeOfBookBLL();
     foreach (BookTitleBLL row in bookTitleList)
     {
         typeOfBookBLL = TypeOfBookDAL.getTypeOfBookItem(row.TypeOfBookId);
         PublisherBLL publisherBLL = new PublisherBLL();
         publisherBLL = PublisherDAL.getPublisherItem(row.PublisherId);
         BookTitleStatusBLL status = new BookTitleStatusBLL();
         status = BookTitleStatusDAL.getBookTitleStatusItem(row.BookTitleStatusId);
         this.dgvBookTitle.Rows.Add(row.BookTitleId, row.Name, row.TypeOfBookId, typeOfBookBLL.Name, row.PublisherId, publisherBLL.Name, row.BookTitleStatusId, status.Name, row.Summary);
     }
     GetSelectedValueDataGridViewBookTitle();
     this.dgvBookTitle.SelectionChanged += new EventHandler(dgvBookTitle_SelectionChanged);
 }
コード例 #29
0
        public static void updatePublisher(PublisherBLL publisherBLL)
        {
            String sql = "UPDATE [nhaxuatban] SET tennxb=N'" + publisherBLL.Name + "', sdtnxb=N'" + publisherBLL.Phone + "', diachinxb=N'" + publisherBLL.Address + "' WHERE manxb=" + publisherBLL.PublisherId;

            PublisherDAL._condb.ExecuteNonQuery(sql);
        }
コード例 #30
0
 /// <summary>
 /// Returns all publishers in database
 /// </summary>
 /// <returns>A list of publishers</returns>
 public List <Publisher> FindAllPublishers()
 {
     return(PublisherBLL.FindAll());
 }
コード例 #31
0
 public static List<PublisherBLL> search(string catalog, string key)
 {
     string sql = "SELECT * FROM [nhaxuatban] WHERE "+catalog+" LIKE '%" + key + "%'";
     DataTable dt = PublisherDAL._condb.getDataTable(sql);
     List<PublisherBLL> publisherBLLList = new List<PublisherBLL>();
     if (dt.Rows.Count > 1)
     {
         foreach (DataRow row in dt.Rows)
         {
             PublisherBLL publisherBLL = new PublisherBLL(Int32.Parse(row["manxb"].ToString()), row["tennxb"].ToString(), row["sdtnxb"].ToString(), row["diachinxb"].ToString());
             publisherBLLList.Add(publisherBLL);
         }
         return publisherBLLList;
     }
     else
     {
         return null;
     }
 }