コード例 #1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (this.dgvBookTitleStatus.SelectedCells.Count > 0)
     {
         int selectedrowindex = this.dgvBookTitleStatus.SelectedCells[0].RowIndex;
         DataGridViewRow selectedRow = this.dgvBookTitleStatus.Rows[selectedrowindex];
         BookTitleStatusBLL bookTitleStatusBLL = new BookTitleStatusBLL(Convert.ToInt32(selectedRow.Cells["clmnId"].Value), selectedRow.Cells["clmnName"].Value.ToString());
         DialogResult result = MessageBox.Show("Do you want to delete book title status: " + selectedRow.Cells["clmnName"].Value + "?", "Warning", MessageBoxButtons.OKCancel);
         switch (result)
         {
             case DialogResult.Cancel:
                 break;
             case DialogResult.OK:
                 BookTitleStatusBLL bookTitleStatusDLL = new BookTitleStatusBLL();
                 if (BookTitleStatusDAL.getBookTitleStatusItem(bookTitleStatusBLL) != null)
                 {
                     MessageBox.Show("Can't delete! Please delete all book title has status: '" + selectedRow.Cells["clmnName"].Value + "' before delete this status!", "Error");
                     break;
                 }
                 else
                 {
                     BookTitleStatusDAL.deleteBookTitleStatus(bookTitleStatusBLL);
                     this.LoadDataToGridView();
                     break;
                 }
         }
     }
 }
コード例 #2
0
 public static BookTitleStatusBLL getBookTitleStatusItem(BookTitleStatusBLL bookTitleStatusBLL)
 {
     String sql = "SELECT * FROM [dausach] WHERE matinhtrang=" + bookTitleStatusBLL.BookTitleStatusId;
     DataTable dt = BookTitleStatusDAL._condb.getDataTable(sql);
     if (dt.Rows.Count > 0)
     {
         DataRow row = dt.Rows[0];
         return new BookTitleStatusBLL(Int32.Parse(row["matinhtrang"].ToString()), row["tentinhtrang"].ToString());
     }
     return null;
 }
コード例 #3
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     BookTitleStatusBLL bookTitleStatusBLL = new BookTitleStatusBLL();
     bookTitleStatusBLL.Name = this.txtBookTitleStatusName.Text;
     if (bookTitleStatusBLL.Name == "")
     {
         MessageBox.Show("Author name is not null!", "Notice");
         return;
     }
     BookTitleStatusDAL.addBookTitleStatus(bookTitleStatusBLL);
     MessageBox.Show("Add success!", "Success");
     this.LoadDataToGridView();
 }
コード例 #4
0
 public static List<BookTitleStatusBLL> getBookTitleStatusList()
 {
     String sql = "SELECT * FROM [tinhtrangdausach]";
     DataTable dt = new DataTable();
     dt = BookTitleStatusDAL._condb.getDataTable(sql);
     List<BookTitleStatusBLL> bookTitleStatusBLLList = new List<BookTitleStatusBLL>();
     if (dt.Rows.Count > 0)
     {
         foreach (DataRow row in dt.Rows)
         {
             BookTitleStatusBLL bookTitleStatusBLL = new BookTitleStatusBLL(Int32.Parse(row["matinhtrang"].ToString()), row["tentinhtrang"].ToString());
             bookTitleStatusBLLList.Add(bookTitleStatusBLL);
         }
         return bookTitleStatusBLLList;
     }
     return null;
 }
コード例 #5
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);
 }
コード例 #6
0
 public static List<BookTitleStatusBLL> search(string catalog, string key)
 {
     string sql = "SELECT * FROM [tinhtrangdausach] WHERE " + catalog + " LIKE '%" + key + "%'";
     DataTable dt = new DataTable();
     dt = BookTitleStatusDAL._condb.getDataTable(sql);
     List<BookTitleStatusBLL> bookTitleStatusBLLList = new List<BookTitleStatusBLL>();
     if (dt.Rows.Count > 0)
     {
         foreach (DataRow row in dt.Rows)
         {
             BookTitleStatusBLL bookTitleStatusBLL = new BookTitleStatusBLL(Int32.Parse(row["matinhtrang"].ToString()), row["tentinhtrang"].ToString());
             bookTitleStatusBLLList.Add(bookTitleStatusBLL);
         }
         return bookTitleStatusBLLList;
     }
     return null;
 }
コード例 #7
0
 public static void deleteBookTitleStatus(BookTitleStatusBLL bookTitleStatus)
 {
     String sql = "DELETE FROM [tinhtrangdausach] WHERE matinhtrang=" + bookTitleStatus.BookTitleStatusId;
     BookTitleStatusDAL._condb.ExecuteNonQuery(sql);
 }
コード例 #8
0
 public static void addBookTitleStatus(BookTitleStatusBLL bookTitleStatus)
 {
     String sql = "INSERT INTO [tinhtrangdausach] (tentinhtrang) VALUES ( N'" + bookTitleStatus.Name + "')";
     BookTitleStatusDAL._condb.ExecuteNonQuery(sql);
 }
コード例 #9
0
 public static void updateBookTitleStatus(BookTitleStatusBLL bookTitleStatusBLL)
 {
     String sql = "UPDATE [tinhtrangdausach] SET tentinhtrang=N'" + bookTitleStatusBLL.Name + "' WHERE matinhtrang=" + bookTitleStatusBLL.BookTitleStatusId;
     BookTitleStatusDAL._condb.ExecuteNonQuery(sql);
 }
コード例 #10
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.dgvBookTitleStatus.SelectedCells.Count > 0)
            {

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

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

                BookTitleStatusBLL bookTitleStatusBLL = new BookTitleStatusBLL(Convert.ToInt32(selectedRow.Cells["clmnId"].Value), this.txtBookTitleStatusName.Text);

                if (bookTitleStatusBLL.Name == "")
                {
                    MessageBox.Show("Author name is not null!", "Notice");
                    return;
                }
                BookTitleStatusDAL.updateBookTitleStatus(bookTitleStatusBLL);
                MessageBox.Show("Update success!", "Success");
                this.LoadDataToGridView();
            }
        }
コード例 #11
0
 private void LoadDataToGridView()
 {
     this.dgvBookTitleStatus.Rows.Clear();
     BookTitleStatusBLL bookTitleStatusBLL = new BookTitleStatusBLL();
     List<BookTitleStatusBLL> bookTitleStatusArr = new List<BookTitleStatusBLL>();
     bookTitleStatusArr = BookTitleStatusDAL.getBookTitleStatusList();
     foreach (BookTitleStatusBLL row in bookTitleStatusArr)
     {
         this.dgvBookTitleStatus.Rows.Add(row.BookTitleStatusId, row.Name);
     }
     this.GetSelectedValue();
     this.dgvBookTitleStatus.CellClick += new DataGridViewCellEventHandler(this.dgvBookTitleStatus_CellClick);
 }
コード例 #12
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;
            }
            BookTitleStatusBLL bookTitleStatusBLL = new BookTitleStatusBLL();
            List<BookTitleStatusBLL> bookTitleStatusArr = new List<BookTitleStatusBLL>();
            bookTitleStatusArr = BookTitleStatusDAL.search(catalog, key);
            this.dgvBookTitleStatus.Rows.Clear();
            foreach (BookTitleStatusBLL row in bookTitleStatusArr)
            {
                this.dgvBookTitleStatus.Rows.Add(row.BookTitleStatusId, row.Name);
            }

            this.GetSelectedValue();
            this.dgvBookTitleStatus.CellClick += new DataGridViewCellEventHandler(this.dgvBookTitleStatus_CellClick);
        }