Ejemplo n.º 1
0
 private void btnCancel_Click(object sender, System.EventArgs e)
 {
     this.Close();
     this.Dispose();
     Actions act = new Actions();
     act.ShowDialog();
 }
Ejemplo n.º 2
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            if(txtOld.Text.Equals("") || txtNew.Text.Equals("") || txtConfirm.Text.Equals(""))
            {
                MessageBox.Show("All required data is not entered by you.","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            if(txtOld.Text != Globals.Password)
            {
                MessageBox.Show("Old password entered is not correct","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            if(txtNew.Text != txtConfirm.Text)
            {
                MessageBox.Show("Password confirmation is not correct","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            bool isSuccess = false;
            try
            {
                isSuccess = Globals.ChangePassword(Globals.UserName,txtNew.Text);

            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(),"Library Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
                this.Close();
                this.Dispose();
                Application.Exit();
                return;

            }
            if(isSuccess)
            {
                Globals.Password = txtNew.Text;
                MessageBox.Show("Password Changed","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                this.Close();
                this.Dispose();
                Actions act = new Actions();
                act.ShowDialog();
            }
        }
Ejemplo n.º 3
0
        private void btnLogin_Click(object sender, System.EventArgs e)
        {
            if(txtuser.Text.Equals(""))
            {
                MessageBox.Show("Please Enter User Name","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            if(txtpwd.Text.Equals(""))
            {
                MessageBox.Show("Please Enter Password","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            bool IsSuccesfulLogin = false;
            try
            {
                // Validates User
                IsSuccesfulLogin = Globals.ValidateId(txtuser.Text,txtpwd.Text);

            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(),"Library Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
                this.Close();
                this.Dispose();
                Application.Exit();
                return;
            }
            if(!IsSuccesfulLogin)
            {
                MessageBox.Show("Please Enter Valid User Name/Password Combination","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                txtpwd.Text = "";
                txtuser.Text = "";
                txtuser.Focus();
                return;
            }
            else
            {
                Globals.UserName = txtuser.Text;
                Globals.Password = txtpwd.Text;
                // Launch Action Form
                this.Close();
                this.Dispose();
                Actions act = new Actions();
                act.ShowDialog();
            }
        }
Ejemplo n.º 4
0
        private void btnRegister_Click(object sender, System.EventArgs e)
        {
            if(txtuser.Text.Equals(""))
            {
                MessageBox.Show("Please Enter User Name","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            if(txtpwd.Text.Equals(""))
            {
                MessageBox.Show("Please Enter Password","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            if(txtConfirm.Text.Equals(""))
            {
                MessageBox.Show("Please Confirm Password","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            if(!txtConfirm.Text.Equals(txtpwd.Text))
            {
                MessageBox.Show("Password not confirmed","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            bool IsSuccesfulRegister = false;
            try
            {
                IsSuccesfulRegister = Globals.RegisterUser(txtuser.Text,txtpwd.Text);;

            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(),"Library Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
                this.Close();
                this.Dispose();
                Application.Exit();
                return;
            }
            if(!IsSuccesfulRegister)
            {
                MessageBox.Show("This user already exists. Please enter some other user name","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                txtuser.Text = "";
                txtpwd.Text = "";
                txtConfirm.Text = "";
                txtuser.Focus();
                return;
            }
            else
            {
                MessageBox.Show("User succesfully registered.","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                Globals.UsersList.Add(txtuser.Text,0);
                Globals.UserName = txtuser.Text;
                Globals.Password = txtpwd.Text;
                Globals.isSystemUser = false;
                this.Close();
                this.Dispose();
                Actions act = new Actions();
                act.ShowDialog();

            }
        }
Ejemplo n.º 5
0
 private void btnAdd_Click(object sender, System.EventArgs e)
 {
     if(txtCatName.Text.Equals(""))
     {
         MessageBox.Show("Please Enter a category ","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
         return;
     }
     bool isSuccesfulAddition = false;
     try
     {
         isSuccesfulAddition = Globals.AddCategory(txtCatName.Text);
     }
     catch(Exception ex)
     {
         MessageBox.Show(ex.Message.ToString(),"Library Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
         this.Close();
         this.Dispose();
         Application.Exit();
         return;
     }
     if(!isSuccesfulAddition)
     {
         MessageBox.Show("This category already exists. Please enter some other category","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
         return;
     }
     else
     {
         MessageBox.Show("Category succesfully entered.","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
         Globals.CategoryList.Add(Globals.CategoryList.Count + 1, txtCatName.Text);
         this.Close();
         this.Dispose();
         Actions act = new Actions();
         act.ShowDialog();
     }
 }
Ejemplo n.º 6
0
        private void btnRemove_Click(object sender, System.EventArgs e)
        {
            if(cmbRemoveBook.Items.Count == 0)
            {
                MessageBox.Show("No books available to be removed","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            if(txtRemQty.Text.Equals(""))
            {
                MessageBox.Show("Please Enter Quantity of books in numeric format","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            else
            {
                bool isNumber = isNumeric(txtRemQty.Text, System.Globalization.NumberStyles.Integer);
                if(!isNumber)
                {
                    MessageBox.Show("Please Enter Quantity of books in numeric format","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                    return;
                }
            }
            if(Convert.ToInt32(txtRemQty.Text) > Convert.ToInt32(txtAvailQty.Text))
            {
                MessageBox.Show("Quantity of books to be removed should be less than available quantity","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            bool IsSucessFulRemove = false;
            try
            {
                IsSucessFulRemove = Globals.RemoveBook(cmbRemoveBook.SelectedItem.ToString(),Convert.ToInt32(txtRemQty.Text),txtViewAuthor.Text,txtViewCat.Text);
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(),"Library Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
                this.Close();
                this.Dispose();
                Application.Exit();
                return;
            }
            if(!IsSucessFulRemove)
            {
                MessageBox.Show("Please check the book data entered","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            else
            {
                MessageBox.Show("Book(s) succesfully removed.","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                // Launch Action Form
                int BooksLeft = Convert.ToInt32(txtAvailQty.Text) - Convert.ToInt32(txtRemQty.Text);
                if(BooksLeft == 0)
                    Globals.BookList.Remove(cmbRemoveBook.SelectedItem.ToString() + "~" + txtViewAuthor.Text + "#" + txtViewCat.Text);
                else
                    Globals.BookList[cmbRemoveBook.SelectedItem.ToString() + "~" + txtViewAuthor.Text + "#" + txtViewCat.Text] = BooksLeft;

                this.Close();
                this.Dispose();
                Actions act = new Actions();
                act.ShowDialog();
            }
        }
Ejemplo n.º 7
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            if(txtTitle.Text.Equals(""))
            {
                MessageBox.Show("Please Enter Book Title","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            if(txtAuthor.Text.Equals(""))
            {
                MessageBox.Show("Please Enter Author Name","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            if(txtQty.Text.Equals(""))
            {
                MessageBox.Show("Please Enter Quantity of books in numeric format","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            else
            {
                bool isNumber = isNumeric(txtQty.Text, System.Globalization.NumberStyles.Integer);
                if(!isNumber)
                {
                    MessageBox.Show("Please Enter Quantity of books in numeric format","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                    return;
                }
            }
            bool IsSuccesfulAdd = false;
            bool isNewEntry = true;
            try
            {
                int iCatId = 0;
                if(Globals.CategoryList!=null && Globals.CategoryList.Count > 0)
                {
                    IDictionaryEnumerator myEnumerator = Globals.CategoryList.GetEnumerator();
                    while ( myEnumerator.MoveNext() )
                    {
                        if(cmbCat.SelectedItem.Equals(myEnumerator.Value))
                        {
                            iCatId = Convert.ToInt32(myEnumerator.Key);
                            break;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Please add a category first","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                    return;
                }

                IsSuccesfulAdd = Globals.AddBook(txtTitle.Text,txtAuthor.Text,iCatId,Convert.ToInt32(txtQty.Text),ref isNewEntry);

            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(),"Library Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
                this.Close();
                this.Dispose();
                Application.Exit();
                return;
            }
            if(!IsSuccesfulAdd)
            {
                MessageBox.Show("Please check the book data entered","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            else
            {
                MessageBox.Show("Book(s) succesfully added.","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                // Launch Action Form
                if(Globals.BookList.ContainsKey(txtTitle.Text + "~" + txtAuthor.Text + "#" + cmbCat.SelectedItem.ToString()))
                    Globals.BookList[txtTitle.Text + "~" + txtAuthor.Text + "#" + cmbCat.SelectedItem.ToString()] = Convert.ToInt32(Globals.BookList[txtTitle.Text + "~" + txtAuthor.Text + "#" + cmbCat.SelectedItem.ToString()]) + Convert.ToInt32(txtQty.Text);
                else
                {
                    Globals.BookList.Add(txtTitle.Text + "~" + txtAuthor.Text + "#" + cmbCat.SelectedItem.ToString(),txtQty.Text);
                }

                this.Close();
                this.Dispose();
                Actions act = new Actions();
                act.ShowDialog();
            }
        }
Ejemplo n.º 8
0
        private void btnreturn_Click(object sender, System.EventArgs e)
        {
            bool IsSuccess=false;
            try
            {
                string selIndex = cmbreturn.SelectedIndex.ToString();
                string BookIssueId=	"";
                string BookId=	"";
                string SelectedIds= "";
                int Bookindex = -1;
                IDictionaryEnumerator myEnumerator = IDTable.GetEnumerator();
                while(myEnumerator.MoveNext())
                {
                    if (selIndex.Equals(myEnumerator.Key.ToString()))
                    {
                        SelectedIds = myEnumerator.Value.ToString();
                        break;
                    }
                }
                Bookindex = SelectedIds.IndexOf("~");
                if(Bookindex!=-1)
                {
                    BookId = SelectedIds.Substring(0,Bookindex);
                    BookIssueId = SelectedIds.Substring(Bookindex + 1, SelectedIds.Length - (Bookindex + 1));
                }
                IsSuccess = Globals.ReturnBook(Convert.ToInt32(BookId),Convert.ToInt32(BookIssueId));

            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(),"Library Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
                this.Close();
                this.Dispose();
                Application.Exit();
                return;
            }
            if(!IsSuccess)
            {
                MessageBox.Show("Some error has occured","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            else
            {
                MessageBox.Show("Book Returned Succesfully.","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                Globals.UsersList[Globals.UserName] = Convert.ToInt32(Globals.UsersList[Globals.UserName]) - 1;
                Globals.BookList[cmbreturn.SelectedItem.ToString() + "~" + txtAuthor.Text + "#" + txtCat.Text] =
                    Convert.ToInt32(Globals.BookList[cmbreturn.SelectedItem.ToString() + "~" + txtAuthor.Text + "#" + txtCat.Text]) + 1;

                this.Close();
                this.Dispose();
                Actions act = new Actions();
                act.ShowDialog();

            }
        }
Ejemplo n.º 9
0
        private void btnIssue_Click(object sender, System.EventArgs e)
        {
            if(Convert.ToInt32(Globals.UsersList[Globals.UserName]) == Globals.NUMBER_OF_BOOKS_ALLOWED)
            {
                MessageBox.Show("You already have 3 books issued. Please return one of them to get requested book issued" ,"Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            DialogResult dr = MessageBox.Show("You have requested for book " + dataGrid1[SelecetedBook,0] + " authored by " + dataGrid1[SelecetedBook,1] + ". Are you sure you want this book?","Library Management",MessageBoxButtons.YesNo);
            if(dr == DialogResult.No)
                return;
            bool IsSuccess = false;
            try
            {
                if(!Globals.ValidateBook(dataGrid1[SelecetedBook,0].ToString(),dataGrid1[SelecetedBook,1].ToString(),dataGrid1[SelecetedBook,3].ToString()))
                {
                    MessageBox.Show("Selected book is already issued to you","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                    return;
                }
                IsSuccess = Globals.IssueBook(dataGrid1[SelecetedBook,0].ToString(),dataGrid1[SelecetedBook,1].ToString(),dataGrid1[SelecetedBook,3].ToString());

            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(),"Library Management",MessageBoxButtons.OK,MessageBoxIcon.Error);
                this.Close();
                this.Dispose();
                Application.Exit();
                return;
            }
            if(!IsSuccess)
            {
                MessageBox.Show("Some error has occured","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return;
            }
            else
            {
                MessageBox.Show("Book Issued Succesfully.","Library Management",MessageBoxButtons.OK,MessageBoxIcon.Information);
                Globals.UsersList[Globals.UserName] = Convert.ToInt32(Globals.UsersList[Globals.UserName]) + 1;
                Globals.BookList[dataGrid1[SelecetedBook,0].ToString() + "~" + dataGrid1[SelecetedBook,1].ToString() + "#" + dataGrid1[SelecetedBook,3].ToString()] =
                    Convert.ToInt32(Globals.BookList[dataGrid1[SelecetedBook,0].ToString() + "~" + dataGrid1[SelecetedBook,1].ToString() + "#" + dataGrid1[SelecetedBook,3].ToString()]) - 1;

                this.Close();
                this.Dispose();
                Actions act = new Actions();
                act.ShowDialog();

            }
        }