コード例 #1
0
ファイル: TermDetail.xaml.cs プロジェクト: JakeLin/glossary
        private void ApplicationBarIconButton_Save_Click(object sender, EventArgs e)
        {
            string term        = TermTextBox.Text.Trim();
            string description = DescriptionTextBox.Text.Trim();

            if (term.Length == 0)
            {
                TermTextBox.Focus();
                //ToastPromptHelper.ShowToastPrompt("Term shouldn't be empty.", 3000);
                MessageBox.Show("Term shouldn't be empty.");
                return;
            }

            if (description.Length == 0)
            {
                DescriptionTextBox.Focus();
                //ToastPromptHelper.ShowToastPrompt("Description shouldn't be empty.", 3000);
                MessageBox.Show("Description shouldn't be empty.");
                return;
            }

            if (detailAction == DetailAction.Add)
            {
                if (app.Glossary.CheckNewTermName(term))
                {
                    TermTextBox.SelectAll();
                    TermTextBox.Focus();
                    MessageBox.Show("Term name exists. Please input another term. Please notice Term name is case insensitive.");
                    return;
                }
                app.Glossary.Add(term, description);
                NavigationService.GoBack();
            }
            else if (detailAction == DetailAction.Edit)
            {
                editingTermItem.Term        = term;
                editingTermItem.Description = description;
                if (app.Glossary.CheckEditTermName(editingTermItem))
                {
                    TermTextBox.SelectAll();
                    TermTextBox.Focus();
                    MessageBox.Show("Term name exists. Please input another term. Please notice Term name is case insensitive.");
                    return;
                }
                app.Glossary.Edit(editingTermItem);
                NavigationService.GoBack();
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: NiranjanKumbhar/VisualC-
        /*
         * Event handler for Proceed Button
         * -Generating Membership ID
         * -Enabling user input fields such as Email and Full Name
         * -Calculating Total Fees for provided input in Client Confirmed Textbox
         */
        private void ProceedButton_Click(object sender, EventArgs e)
        {
            Random RandomNumberGenerator = new Random();

            if (ClientConfirmedTextBox.Text == "")
            {
                MessageBox.Show("Term can not be Blank. Please enter input in months", "Blank Entry not allowed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ClientConfirmedTextBox.Focus();
                ClientConfirmedTextBox.SelectAll();
            }
            else
            {
                try
                {
                    ConfirmedTerm = int.Parse(ClientConfirmedTextBox.Text);
                    if (ConfirmedTerm < 0)
                    {
                        MessageBox.Show("Please Enter Positive Number", "Negative Number not Allowed in Terms", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        ClientConfirmedTextBox.Focus();
                        ClientConfirmedTextBox.SelectAll();
                    }
                    else if (ConfirmedTerm == 0)
                    {
                        MessageBox.Show("Term can not be Zero. Please enter valid input", "Zero Terms not allowed in Terms", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        ClientConfirmedTextBox.Focus();
                        ClientConfirmedTextBox.SelectAll();
                    }
                    else
                    {
                        SearchButton.Enabled  = false;
                        SummaryButton.Enabled = false;
                        ProceedButton.Enabled = false;

                        //Checking if user has provided details from mentioned results
                        if (ConfirmedTerm.ToString() == TermTextBox.Text)
                        {
                            ConfirmedTermTotal = EnquiredPrice;
                        }
                        else if (ConfirmedTerm == NextMonth)
                        {
                            ConfirmedTermTotal = SuggestedPrice;
                        }
                        else
                        {
                            //Calculating Final Term Total based on user input
                            ConfirmedTermTotal = CalculateTotalFees(ConfirmedTerm);
                        }


                        int MembershipNumber = RandomNumberGenerator.Next(1, 999999);

                        //Randomly generating Membership ID until we get unique
                        //-Comparing it with file to check if generated ID exists in file
                        while (MembershipIdExists(MembershipNumber.ToString("D6"), false, false))
                        {
                            MembershipNumber = RandomNumberGenerator.Next(1, 999999);
                        }

                        MembershipIDLabel.Text = MembershipNumber.ToString("D6");
                        JoinDayLabel.Text      = DateTime.Now.ToShortDateString();

                        MembershipDetailsGroupBox.Visible = true;
                        FullNameTextBox.Focus();
                    }
                }
                catch
                {
                    MessageBox.Show("Invalid input provided for Terms. Please provide number", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TermTextBox.Focus();
                    TermTextBox.SelectAll();
                }
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: NiranjanKumbhar/VisualC-
        /*
         * Event Handler for Display Button
         * It will Calculate Fees based on User provided Term input
         * Also It will validate Term provided
         */
        private void DisplayButton_Click(object sender, EventArgs e)
        {
            decimal PerMonthPrice, TotalPrice;
            int     TermInput;

            if (TermTextBox.Text == "")
            {
                MessageBox.Show("Term can not be blank. Please enter input in months", "Blank Entry Not allowed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TermTextBox.Focus();
                TermTextBox.SelectAll();
            }
            else
            {
                try
                {
                    TermInput = int.Parse(TermTextBox.Text);
                    if (TermInput < 0)
                    {
                        MessageBox.Show("Please Enter Positive Number", "Negative Number not Allowed in Terms", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        TermTextBox.Focus();
                        TermTextBox.SelectAll();
                    }
                    else if (TermInput == 0)
                    {
                        MessageBox.Show("Term can not be Zero. Please enter valid input", "Zero Terms not allowed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        TermTextBox.Focus();
                        TermTextBox.SelectAll();
                    }
                    else
                    {
                        //Fetching Per Month price
                        PerMonthPrice = CalculatePerMonth(TermInput);
                        //Fetching Total Fees
                        TotalPrice = CalculateTotalFees(TermInput);

                        //Assigning Details of fees
                        PricePerMonthLabel.Text = "€ " + PerMonthPrice.ToString("N2");
                        PriceFullTermLabel.Text = "€ " + TotalPrice.ToString("N2");
                        EnquiredPrice           = TotalPrice;

                        //Fetching Next Term based on current Term
                        NextMonth = NextTermMonth(TermInput);
                        //If Next month is more than limit
                        if (TermInput > MONTH12)
                        {
                            NextTermLabel.Text      = NEXTTERMTEXT;
                            PriceNextTermLabel.Text = "N.A.";
                            PitchLabel.Text         = "Kudos! You are about to avail maximum Discount of 66.66%! Confirm Soon!!";
                        }
                        else
                        {
                            TotalPrice              = CalculateTotalFees(NextMonth);
                            SuggestedPrice          = TotalPrice;
                            NextTermLabel.Text      = NEXTTERMTEXT + " for " + NextMonth.ToString() + " Month(s)";
                            PriceNextTermLabel.Text = "€ " + TotalPrice.ToString("N2");
                            if (GetDiscount(NextMonth) == DISCOUNT7)
                            {
                                PitchLabel.Text = "Pay €" + (SuggestedPrice).ToString() + " to get  " + (NextMonth - TermInput).ToString() + " Month(s) at whooping " + GetDiscount(NextMonth).ToString() + "% Discount";
                            }
                            else
                            {
                                PitchLabel.Text = "Pay additional €" + (SuggestedPrice - EnquiredPrice).ToString() + " to get extra " + (NextMonth - TermInput).ToString() + " Month(s) at whooping " + GetDiscount(NextMonth).ToString() + "% Discount";
                            }
                        }



                        ClientConfirmedTextBox.Focus();
                    }
                }
                catch
                {
                    MessageBox.Show("Invalid input provided for Terms. Please provide number", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TermTextBox.Focus();
                    TermTextBox.SelectAll();
                }
            }
        }