public void LoadBook() { // Load BookInfo string[] LbName, LbWriter, LbPrice, LbPropagator, LbIsbn, LbNumberPage, LbDate, LbTranslator, LbHaveCd, LbB; // LbB ==> Load book Bailment LbName = System.IO.File.ReadAllLines((Form1.patchBook + @"\BehzadBName.sys")); LbWriter = System.IO.File.ReadAllLines((Form1.patchBook + @"\BehzadBWriter.sys")); LbPrice = System.IO.File.ReadAllLines((Form1.patchBook + @"\BehzadBPrice.sys")); LbPropagator = System.IO.File.ReadAllLines((Form1.patchBook + @"\BehzadBPropagator.sys")); LbIsbn = System.IO.File.ReadAllLines((Form1.patchBook + @"\BehzadBIsbn.sys")); LbNumberPage = System.IO.File.ReadAllLines((Form1.patchBook + @"\BehzadBNumberPage.sys")); LbDate = System.IO.File.ReadAllLines((Form1.patchBook + @"\BehzadBDate.sys")); LbTranslator = System.IO.File.ReadAllLines((Form1.patchBook + @"\BehzadBTranslator.sys")); LbHaveCd = System.IO.File.ReadAllLines((Form1.patchBook + @"\BehzadBHaveCd.sys")); LbB = System.IO.File.ReadAllLines((Form1.patchBook + @"\BehzadBookBailment.sys")); long i = LbName.LongCount() - 1; for (; i >= 0; i--) { BookInfo Copy = new BookInfo(); Copy.BookName = LbName[i]; Copy.WriterName = LbWriter[i]; Copy.Price = LbPrice[i]; Copy.Propagator = LbPropagator[i]; Copy.Isbn = LbIsbn[i]; Copy.NumberPage = LbNumberPage[i]; Copy.DateOfBook = LbDate[i]; Copy.Translator = LbTranslator[i]; Copy.HaveCd = LbHaveCd[i]; Copy.Bailment = LbB[i]; Form1.arrBookInfo.Add(Copy.Isbn, Copy); } // Show In ListBox lstBookInfo.Items.Clear(); foreach (BookInfo name in Form1.arrBookInfo.Values) { lstBookInfo.Items.Add(name); } // // Load Book Bailment string[] LbBName, LbBDate, LbBBookName, LbBIsbn; // LbBIsbn ==> Load book Bailment ISBN LbBName = System.IO.File.ReadAllLines((Form1.patchBook + @"\BehzadBBName.sys")); LbBDate = System.IO.File.ReadAllLines((Form1.patchBook + @"\BehzadBBDate.sys")); LbBBookName = System.IO.File.ReadAllLines((Form1.patchBook + @"\BehzadBBBookName.sys")); LbBIsbn = System.IO.File.ReadAllLines((Form1.patchBook + @"\BehzadBBIsbn.sys")); i = LbBName.LongCount() - 1; for (; i >= 0; i--) { BookBailment Copy = new BookBailment(); Copy.BailmentName = LbBName[i]; Copy.BookName = LbBBookName[i]; Copy.DateOfBailment = LbBDate[i]; Copy.BailmentBookIsbn = LbBIsbn[i]; Form1.arrBookBailment.Add(Copy.BailmentBookIsbn, Copy); } }
private void btnSearchWN_Click(object sender, EventArgs e) { if (lstWriterName.SelectedIndex >= 0) { string bufferName = lstWriterName.SelectedItem.ToString(); foreach (BookInfo Read in Form1.arrBookInfo.Values) { if (bufferName == Read.WriterName) { txtDBookName.ForeColor = Color.Black; txtDBookName.Text = Read.BookName; txtDWriterName.ForeColor = Color.Black; txtDWriterName.Text = Read.WriterName; txtDTranslator.ForeColor = Color.Black; txtDTranslator.Text = Read.Translator; txtDPropagator.ForeColor = Color.Black; txtDPropagator.Text = Read.Propagator; txtDIsbn.ForeColor = Color.Black; txtDIsbn.Text = Read.Isbn; txtDDateOfBook.ForeColor = Color.Black; txtDDateOfBook.Text = Read.DateOfBook; txtDPrice.ForeColor = Color.Black; txtDPrice.Text = Read.Price; txtDNumberPage.ForeColor = Color.Black; txtDNumberPage.Text = Read.NumberPage; txtDHaveCD.ForeColor = Color.Black; txtDHaveCD.Text = Read.HaveCd; txtDBailment.ForeColor = Color.Black; if (string.Compare(Read.Bailment, "true", true) == 0) { BookBailment fillB = (BookBailment)Form1.arrBookBailment[Read.Isbn]; txtDBailment.Text = "Yes (By: " + fillB.BailmentName + ")"; } else { txtDBailment.Text = "No"; } break; } } } }
private void CancelToolStripMenuItem_Click(object sender, EventArgs e) { BtnEditClicked = false; txtDBookName.ReadOnly = true; txtDWriterName.ReadOnly = true; txtDPrice.ReadOnly = true; txtDPropagator.ReadOnly = true; txtDTranslator.ReadOnly = true; txtDDateOfBook.ReadOnly = true; txtDIsbn.ReadOnly = true; txtDNumberPage.ReadOnly = true; txtDHaveCD.ReadOnly = true; EditBookToolStripMenuItem.Text = "Edit &Book"; CancelToolStripMenuItem.Visible = false; // Refresh Info ============== BookInfo Read = (BookInfo)Form1.arrBookInfo[OldISBN]; txtDBookName.Text = Read.BookName; txtDWriterName.Text = Read.WriterName; txtDTranslator.Text = Read.Translator; txtDPropagator.Text = Read.Propagator; txtDIsbn.Text = Read.Isbn; txtDDateOfBook.Text = Read.DateOfBook; txtDPrice.Text = Read.Price; txtDNumberPage.Text = Read.NumberPage; txtDHaveCD.Text = Read.HaveCd; if (string.Compare(Read.Bailment, "true", true) == 0) { BookBailment fillB = (BookBailment)Form1.arrBookBailment[Read.Isbn]; txtDBailment.Text = "Yes (By: " + fillB.BailmentName + ")"; } else { txtDBailment.Text = "No"; } //============================ }
private void EditBookToolStripMenuItem_Click(object sender, EventArgs e) { if (BtnEditClicked == true) { BookInfo Change = (BookInfo)Form1.arrBookInfo[OldISBN]; if (Change.Bailment == "true") { BookBailment SaveBailment = (BookBailment)Form1.arrBookBailment[OldISBN]; Form1.arrBookBailment.Remove(OldISBN); Change.BookName = txtDBookName.Text; Change.WriterName = txtDWriterName.Text; Change.Price = txtDPrice.Text; Change.Propagator = txtDPropagator.Text; Change.Translator = txtDTranslator.Text; Change.DateOfBook = txtDDateOfBook.Text; Change.Isbn = txtDIsbn.Text; Change.NumberPage = txtDNumberPage.Text; Change.HaveCd = txtDHaveCD.Text; SaveBailment.BailmentBookIsbn = txtDIsbn.Text; SaveBailment.BookName = txtDBookName.Text; Form1.arrBookInfo.Remove(OldISBN); Form1.arrBookInfo.Add(Change.Isbn, Change); Form1.arrBookBailment.Add(Change.Isbn, SaveBailment); OldISBN = Change.Isbn; CancelToolStripMenuItem_Click(sender, e); BtnEditClicked = false; Form1.SavedBookInfo = false; StatusText = "Edit Book Complete Successfuly ..."; //------------------------------ Refresh Data -------------------- lstBookName.Items.Remove(OldBookName); lstBookName.Items.Add(Change.BookName); txtBookName.AutoCompleteCustomSource.Remove(OldBookName); txtBookName.AutoCompleteCustomSource.Add(Change.BookName); lstWriterName.Items.Remove(OldWriterName); lstWriterName.Items.Add(Change.WriterName); txtWriterName.AutoCompleteCustomSource.Remove(OldWriterName); txtWriterName.AutoCompleteCustomSource.Add(Change.WriterName); lstISBN.Items.Remove(OldISBN); lstISBN.Items.Add(Change.Isbn); txtIsbn.AutoCompleteCustomSource.Remove(OldISBN); txtIsbn.AutoCompleteCustomSource.Add(Change.Isbn); //---------------------------------------------------------------- MessageBox.Show("Edit Complete ...", "Successful Changed Data!"); } else { Change.BookName = txtDBookName.Text; Change.WriterName = txtDWriterName.Text; Change.Price = txtDPrice.Text; Change.Propagator = txtDPropagator.Text; Change.Translator = txtDTranslator.Text; Change.DateOfBook = txtDDateOfBook.Text; Change.Isbn = txtDIsbn.Text; Change.NumberPage = txtDNumberPage.Text; Change.HaveCd = txtDHaveCD.Text; Form1.arrBookInfo.Remove(OldISBN); Form1.arrBookInfo.Add(Change.Isbn, Change); OldISBN = Change.Isbn; CancelToolStripMenuItem_Click(sender, e); BtnEditClicked = false; Form1.SavedBookInfo = false; StatusText = "Edit Book Complete Successfuly ..."; //------------------------------ Refresh Data -------------------- lstBookName.Items.Remove(OldBookName); lstBookName.Items.Add(Change.BookName); txtBookName.AutoCompleteCustomSource.Remove(OldBookName); txtBookName.AutoCompleteCustomSource.Add(Change.BookName); lstWriterName.Items.Remove(OldWriterName); lstWriterName.Items.Add(Change.WriterName); txtWriterName.AutoCompleteCustomSource.Remove(OldWriterName); txtWriterName.AutoCompleteCustomSource.Add(Change.WriterName); lstISBN.Items.Remove(OldISBN); lstISBN.Items.Add(Change.Isbn); txtIsbn.AutoCompleteCustomSource.Remove(OldISBN); txtIsbn.AutoCompleteCustomSource.Add(Change.Isbn); //---------------------------------------------------------------- MessageBox.Show("Edit Complete ...", "Successful Changed Data!"); } } else if (BtnEditClicked == false) { if (txtDBookName.Text == "نام کتاب") { MessageBox.Show("Please Search One Book Then Edit It", "Empty TextBox!", MessageBoxButtons.OK , MessageBoxIcon.Information); txtBookName.Focus(); txtBookName.SelectAll(); } else { BtnEditClicked = true; CancelToolStripMenuItem.Visible = true; EditBookToolStripMenuItem.Text = "&Save Change"; // Save Old Data ----------------- OldISBN = txtDIsbn.Text; OldBookName = txtDBookName.Text; OldWriterName = txtDWriterName.Text; //-------------------------------- txtDBookName.ReadOnly = false; txtDWriterName.ReadOnly = false; txtDPrice.ReadOnly = false; txtDPropagator.ReadOnly = false; txtDTranslator.ReadOnly = false; txtDDateOfBook.ReadOnly = false; txtDIsbn.ReadOnly = false; txtDNumberPage.ReadOnly = false; txtDHaveCD.ReadOnly = false; } } }