private void bttnAddNew_Click(object sender, System.EventArgs e) { FORMBooks_Modify.ADD_STATE = true; FORMBooks_Modify sForm = new FORMBooks_Modify(); sForm.ShowDialog(); }
private void bttnModify_Click(object sender, System.EventArgs e) { if (lvBooks.Items.Count > 0) { try { FORMBooks_Modify.ADD_STATE = false; FORMBooks_Modify.sBookID = lvBooks.Items[lvBooks.FocusedItem.Index].SubItems[0].Text; FORMBooks_Modify sForm = new FORMBooks_Modify(); sForm.ShowDialog(); } catch (ArgumentOutOfRangeException aooreE) { MessageBox.Show("" + aooreE.Message); } catch (NullReferenceException nreE) {} } else { MessageBox.Show("No record to edit.", clsVariables.sMSGBOX, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void FORMBooks_Modify_Load(object sender, System.EventArgs e) { if (ADD_STATE == true) { picLOGO.Image = MDIFORM.i32x32.Images[13]; bttnModification.Enabled = false; bttnBarrowed.Enabled = false; //Set Add OleDbCommand cmdAddBook = new OleDbCommand("INSERT INTO tblBooks(BookNo,ISBN,Author,BookTitle,CategoryIndex,YearPublished,DateArrived,Price,Qty,AddedBy,DateAdd) VALUES(@getBookNo,@getISBN,@getAuthor,@getBookTitle,@getCategoryIndex,@getYearPublished,@getDateArrived,@getPrice,@getQty,@getAddedBy,@getDateAdd)", clsConnections.CN); this.Text = "Add New"; } else { picLOGO.Image = MDIFORM.i32x32.Images[14]; //Set Edit OleDbCommand cmdAddBook = new OleDbCommand("UPDATE tblBooks SET BookNo =@getBookNo, ISBN =@getISBN, Author =@getAuthor, BookTitle =@getBookTitle, CategoryIndex =@getCategoryIndex, YearPublished =@getYearPublished, DateArrived =@getDateArrived, Price =@getPrice, Qty =@getQty, ModifyBy =@getModifyBy, DateModify =@getDateModify WHERE BookNo LIKE '" + sBookID + "' ", clsConnections.CN); FillFields(); txtBookNO.ReadOnly = true; this.Text = "Edit Existing"; } cmdAddBook.Parameters.Add("@getBookNo", OleDbType.VarChar); cmdAddBook.Parameters.Add("@getISBN", OleDbType.VarChar); cmdAddBook.Parameters.Add("@getAuthor", OleDbType.VarChar); cmdAddBook.Parameters.Add("@getBookTitle", OleDbType.VarChar); cmdAddBook.Parameters.Add("@getCategoryIndex", OleDbType.Double); cmdAddBook.Parameters.Add("@getYearPublished", OleDbType.VarChar); cmdAddBook.Parameters.Add("@getDateArrived", OleDbType.Date); cmdAddBook.Parameters.Add("@getPrice", OleDbType.Currency); cmdAddBook.Parameters.Add("@getQty", OleDbType.Double); cmdAddBook.Parameters.Add("@getAddedBy", OleDbType.VarChar); cmdAddBook.Parameters.Add("@getDateAdd", OleDbType.Date); cmdAddBook.Parameters.Add("@getModifyBy", OleDbType.VarChar); cmdAddBook.Parameters.Add("@getDateModify", OleDbType.Date); publicBooksList = this; }