private void btnAdd_Click(object sender, EventArgs e) { int AlbumID = 1; string AlbumName = string.Empty; int ReleaseYear = 0; int Quantity = 0; int Status = 0; if (dtProduct.Rows.Count > 0) { AlbumID = int.Parse(dtProduct.Compute("MAX(AlbumID)", "").ToString()) + 1; } Album pro = new Album() { AlbumID = AlbumID, AlbumName = AlbumName, ReleaseYear = ReleaseYear, Quantity = Quantity, Status = Status }; frmProductDetails ProductDetail = new frmProductDetails(true, pro); DialogResult r = ProductDetail.ShowDialog(); if (r == DialogResult.OK) { pro = ProductDetail.ProductAddOrEdit; dtProduct.Rows.Add(pro.AlbumID, pro.AlbumName, pro.ReleaseYear, pro.Quantity, pro.Status); } getAllBooks(); }
private void btnEdit_Click(object sender, EventArgs e) { int ID = int.Parse(txtId.Text); string Name = txtName.Text; int Year = int.Parse(txtYear.Text); int Quantity = int.Parse(txtQuantity.Text); int Status = int.Parse(txtStatus.Text); Album pro = new Album() { AlbumID = ID, AlbumName = Name, ReleaseYear = Year, Quantity = Quantity, Status = Status }; frmProductDetails ProductDetail = new frmProductDetails(false, pro); DialogResult r = ProductDetail.ShowDialog(); if (r == DialogResult.OK) { DataRow row = dtProduct.Rows.Find(pro.AlbumID); row["Name"] = pro.AlbumName; row["Year"] = pro.ReleaseYear; row["Quantity"] = pro.Quantity; row["Status"] = pro.Status; } getAllBooks(); }
private void btnSearch_Click(object sender, EventArgs e) { if (txtSearch.Text == string.Empty) { MessageBox.Show("Please input ID"); return; } int ID = 0; try { ID = int.Parse(txtSearch.Text); } catch (Exception ex) { MessageBox.Show("Input invalid"); } Album pro = bm.FindProduct(ID); if (pro != null) { frmProductDetails ProductDetail = new frmProductDetails(false, pro); DialogResult r = ProductDetail.ShowDialog(); if (r == DialogResult.OK) { DataRow row = dtProduct.Rows.Find(pro.AlbumID); row["AlbumName"] = pro.AlbumName; row["ReleaseYear"] = pro.ReleaseYear; row["Quantity"] = pro.Quantity; } } else { MessageBox.Show("Product not exist!"); } getAllBooks(); }