Exemple #1
0
        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";
            }
            //============================
        }
Exemple #2
0
 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;
         }
     }
 }
Exemple #3
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     progressBar1.Visible = true;
     Thread.Sleep(100);
     if (txtBookName.Text == "نام کتاب" || txtWriterName.Text == "نام نویسنده کتاب" ||
         txtTranslator.Text == "مترجم" || txtPrice.Text == "قیمت کتاب" ||
         txtPropagator.Text == "انتشارات" || txtIsbn.Text == "شابک" ||
         txtNumberPage.Text == "تعداد صفحات" || txtDateOfBook.Text == "تاریخ انتشار")
     {
         progressBar1.Value = 100;
         MessageBox.Show("Please Fill the All Textbox", "TextBox Empty Error", MessageBoxButtons.OK
                         , MessageBoxIcon.Error);
         StatusText = "TextBox Empty Error";
     }
     else
     {
         if (Form1.arrBookInfo.Contains(txtIsbn.Text) == true)
         {
             MessageBox.Show("This Book Already Exist in library", "Exist Book Warning", MessageBoxButtons.OK
                             , MessageBoxIcon.Warning);
             ClearText();
             StatusText           = "The Book Already Exist in library!";
             progressBar1.Visible = false;
             return;
         }
         Thread.Sleep(60);
         progressBar1.Value = 1;
         BookInfo Fill = new BookInfo();
         Thread.Sleep(60);
         progressBar1.Value = 10;
         // Search Repeat Book Name ---------------------------------------
         string re = txtBookName.Text;
         if (Form1.arrBookInfo.Count != 0)
         {
             Boolean Find = true;
             while (Find == true)
             {
                 foreach (BookInfo Repeat in Form1.arrBookInfo.Values)
                 {
                     if (string.Compare(Repeat.BookName, re, true) == 0)
                     {
                         re  += " ";
                         Find = true;
                         break;
                     }
                     else
                     {
                         Find = false;
                     }
                 }
             }
         }
         Fill.BookName = re;
         //----------------------------------------------------------------
         Thread.Sleep(50);
         progressBar1.Value = 20;
         // Search Repeat Book Name ---------------------------------------
         string re2 = txtWriterName.Text;
         if (Form1.arrBookInfo.Count != 0)
         {
             Boolean Find = true;
             while (Find == true)
             {
                 foreach (BookInfo Repeat in Form1.arrBookInfo.Values)
                 {
                     if (string.Compare(Repeat.WriterName, re2, true) == 0)
                     {
                         re2 += " ";
                         Find = true;
                         break;
                     }
                     else
                     {
                         Find = false;
                     }
                 }
             }
         }
         Fill.WriterName = re2;
         //----------------------------------------------------------------
         Thread.Sleep(50);
         progressBar1.Value = 30;
         Fill.Translator    = txtTranslator.Text;
         progressBar1.Value = 40;
         // Convert Price (Exmple : 0001234 --> 1,234)
         int p = int.Parse(txtPrice.Text);
         if (p != 0)
         {
             Fill.Price = price(p, comboBoxUnit.Text);
         }
         else
         {
             Fill.Price = "0  " + comboBoxUnit.Text;
         }
         Thread.Sleep(60);
         progressBar1.Value = 55;
         Fill.Propagator    = txtPropagator.Text;
         progressBar1.Value = 60;
         Thread.Sleep(60);
         Fill.Isbn          = txtIsbn.Text;
         progressBar1.Value = 65;
         // Conver Number Page (Exmple : 00123  -->  123)
         int number = int.Parse(txtNumberPage.Text);
         Fill.NumberPage    = number.ToString();
         progressBar1.Value = 70;
         Fill.DateOfBook    = txtDateOfBook.Text;
         Thread.Sleep(60);
         progressBar1.Value = 75;
         Fill.Bailment      = "false";
         Thread.Sleep(60);
         progressBar1.Value = 80;
         if (chbCD.Checked == true)
         {
             Fill.HaveCd = "true";
         }
         else if (chbCD.Checked == false)
         {
             Fill.HaveCd = "false";
         }
         // Display in ListBox
         Thread.Sleep(60);
         progressBar1.Value = 85;
         lstAdd.Items.Add(Fill);
         Thread.Sleep(60);
         progressBar1.Value  = 90;
         Form1.SavedBookInfo = false;
         Thread.Sleep(60);
         progressBar1.Value = 95;
         Fill.Bailment      = "false";
         Form1.arrBookInfo.Add(Fill.Isbn, Fill);
         txtPropagator.AutoCompleteCustomSource.Add(txtPropagator.Text);
         txtWriterName.AutoCompleteCustomSource.Add(txtWriterName.Text);
         txtTranslator.AutoCompleteCustomSource.Add(txtTranslator.Text);
         ClearText();
         Thread.Sleep(100);
         progressBar1.Value = 100;
         StatusText         = "The new book added to Library";
     }
     Thread.Sleep(100);
     progressBar1.Visible = false;
 }