Esempio n. 1
0
        /// <summary>
        /// submit the loan to the db
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SubmitLoan_Click(object sender, EventArgs e)
        {
            const int max = 1000000;

            if (!(Utils.AllowOnlyInRange(0, 1000000, CodeMemberTxt, $"נא הכנס מספר עד {max}")) || !(Utils.AllowOnlyInRange(0, 1000000, BookCodeTxt, $"נא הכנס מספר עד {max}")))
            {
                return;
            }

            int MemberID = Convert.ToInt32(CodeMemberTxt.Text);
            int CopyID   = Convert.ToInt32(BookCodeTxt.Text);

            //if (DataManager.IfItemExist(CopyID, "BooksCopies", "BooksCopyID"))

            if (DataManager.ifHadBeenLoanBefore(CopyID, MemberID))
            {
                DialogResult dialogResult = MessageBox.Show("ספר זה הושאל בעבר, האם תרצה להשאיל אותו שוב?", "השאלת ספר", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
            }
            string err = DataManager.CreateLoan(MemberID, CopyID);

            //because its a try the message will not show if there were an error on CreateLoan
            if (err == "")
            {
                MessageBox.Show("השאלה בוצעה בהצלחה");
                Utils.SwitchBetweenWindows(this, MemberForm.Instance(MemberID));
            }
            else
            {
                MessageBox.Show(err);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// submit the form and opens the Member window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            if (
                (fullNameTextBox.Text != "") &&
                (PersonIDTextBox.Text != "") &&
                (phoneNumberTextBox.Text != "") &&
                (AdressTextBox.Text != "")
                )
            {
                if (member == null)
                {
                    Member NewMember = DataManager.AddMember
                                       (
                        fullNameTextBox.Text,
                        PersonIDTextBox.Text,
                        phoneNumberTextBox.Text,
                        AdressTextBox.Text,
                        out bool isAdded,
                        EmailtextBox.Text

                                       );
                    if (isAdded)
                    {
                        MessageBox.Show("המנוי נוסף בהצלחה");
                        Utils.SwitchBetweenWindows(this, MemberForm.Instance(NewMember));
                    }
                    else
                    {
                        MessageBox.Show("מנוי זה כבר קיים");
                        AdressTextBox.Text      = "";
                        PersonIDTextBox.Text    = "";
                        phoneNumberTextBox.Text = "";
                        fullNameTextBox.Text    = "";
                        EmailtextBox.Text       = "";
                    }
                }
                else
                {
                    Member UpdatedMember = null;
                    UpdatedMember = DataManager.EditMember(member, fullNameTextBox.Text,
                                                           Convert.ToInt64(PersonIDTextBox.Text),
                                                           phoneNumberTextBox.Text,
                                                           AdressTextBox.Text, EmailtextBox.Text, out bool isUpdate);
                    if (isUpdate)
                    {
                        MessageBox.Show("פרטי המנוי נערכו בהצלחה");
                        Utils.SwitchBetweenWindows(this, MemberForm.Instance(UpdatedMember));
                    }
                    else
                    {
                        MessageBox.Show("שגיאה בעדכון פרטי המנוי");
                        Utils.SwitchBetweenWindows(this, MemberForm.Instance(member));
                    }
                }
            }
            else
            {
                MessageBox.Show("נא למלא את כל הפרטים");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// search and display Members on member form, if user given PersonID or memberID loan window will auto open
        /// /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SearchAndDisplayMember(object sender = null, EventArgs e = null)
        {
            if (searchTextBox.Text != "")
            {
                List <Member> Li        = null;
                bool          isNumeric = long.TryParse(searchTextBox.Text, out long n);
                if (isNumeric)
                {
                    Li = DataManager.GetMembersByID(n);
                }
                else
                {
                    Li = DataManager.GetMembersFromDb(searchTextBox.Text);
                }

                if (Li.Count == 1)
                {
                    Utils.SwitchBetweenWindows(this, MemberForm.Instance(Li[0]));
                }
                else
                {
                    MemberGrid.DataSource = Li;
                }
            }
        }
Esempio n. 4
0
 private void BackButton_Click(object sender, EventArgs e)
 {
     if (member == null)
     {
         Utils.SwitchBetweenWindows(this, MembersForm.Instance());
     }
     else
     {
         Utils.SwitchBetweenWindows(this, MemberForm.Instance(member));
     }
 }
Esempio n. 5
0
        private void MemberGrid_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            Member       member       = (Member)this.MemberGrid.CurrentRow.DataBoundItem;
            DialogResult dialogResult = MessageBox.Show($"מעבר ל: {member.memberName} ?", "מעבר לפרטי מנוי", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                Utils.SwitchBetweenWindows(this, MemberForm.Instance(member));
            }
            else if (dialogResult == DialogResult.No)
            {
                return;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// check if the book is on the shelf, if not return it and switch to member loan of the one who loaned it.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SubmitReturn_Click(object sender, EventArgs e)
        {
            if (!Utils.AllowOnlyInRange(0, 1000000, BookCodeTxt, "נא להכניס מספר עותק  עד 1000000"))
            {
                return;
            }
            var  BoocCopyID = Convert.ToInt32(BookCodeTxt.Text);
            bool IsReturned = DataManager.returnCopyToShelf(BoocCopyID, out string bookName);

            if (IsReturned)
            {
                Member member = DataManager.getLastUserUseTheBook(BoocCopyID);
                MessageBox.Show($"הספר {bookName} הוחזר למדף");
                Utils.SwitchBetweenWindows(this, MemberForm.Instance(member));
            }
            else
            {
                MessageBox.Show("שגיאה בהחזרת הספר");
                BookCodeTxt.Text = "";
            }
        }