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; } } } }
public frmKitapEkle() { InitializeComponent(); _bookBLL = new BookBLL(); _publisherBLL = new PublisherBLL(); _authorBLL = new AuthorBLL(); }
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); }
protected void Button2_Click(object sender, EventArgs e) { PublisherModel publisher = new PublisherModel(TextBox3.Text); Response.Write(PublisherBLL.AddPublisher(publisher)); Label2.Text = PublisherBLL.GetPublisherCount().ToString(); }
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; } } } }
public ActionResult Create() { var bookViewModel = new BookDetailsViewModel(); bookViewModel.PublisherList = PublisherBLL.ListAll(); bookViewModel.AuthorsList = AuthorBLL.ListAll(); return(View(bookViewModel)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Label1.Text = AuthorBLL.GetAuthorCount().ToString(); Label2.Text = PublisherBLL.GetPublisherCount().ToString(); } }
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); }
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; } }
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(); }
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)); }
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); } }
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(); }
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); } }
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(); } }
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); } }
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); }
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)); }
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); }
public static void deletePublisher(PublisherBLL publisherBLL) { String sql = "DELETE FROM [nhaxuatban] WHERE manxb=" + publisherBLL.PublisherId; PublisherDAL._condb.ExecuteNonQuery(sql); }
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); }
public static void deletePublisher(PublisherBLL publisherBLL) { String sql = "DELETE FROM [nhaxuatban] WHERE manxb=" + publisherBLL.PublisherId; PublisherDAL._condb.ExecuteNonQuery(sql); }
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; } }
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); }
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); }
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(); } }
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); }
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); }
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); }
/// <summary> /// Returns all publishers in database /// </summary> /// <returns>A list of publishers</returns> public List <Publisher> FindAllPublishers() { return(PublisherBLL.FindAll()); }
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; } }