Advertisement
Kulas_Code20

Renting System

Mar 19th, 2022
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Text.RegularExpressions;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11.  
  12.  
  13. namespace StudioRentingSystem
  14. {
  15.     public partial class Renting_System : Form
  16.     {
  17.         public Renting_System()
  18.         {
  19.             InitializeComponent();
  20.         }
  21.  
  22.         private void btnCalculate_Click(object sender, EventArgs e)
  23.         {
  24.             //Variables
  25.             double totalCustomerOwe = 0;
  26.             double noMinUsed = 0;
  27.             double charged = 0;
  28.             const int RATE_PER_HOUR = 350;
  29.            
  30.             //Covert string to number
  31.             noMinUsed = Convert.ToInt32(noMinUsedField.Text);
  32.  
  33.             //Calculation
  34.             charged = RATE_PER_HOUR / 60;
  35.             double minRate = Math.Round(charged);
  36.             totalCustomerOwe = minRate * noMinUsed;
  37.  
  38.             //Result Display
  39.             //Side Summary display
  40.             lblStudioNameResult.Text = studioNameField.Text;
  41.             lblStudioNameResult.Text = studioNameField.Text;
  42.             lblFixRatePerHour.Text = lblFixRatePerHour.Text + RATE_PER_HOUR.ToString("N2");
  43.             lblRatePerMinutes.Text = lblRatePerMinutes.Text + minRate.ToString("N2");
  44.  
  45.             //Total Summary Display
  46.             lblStudioName.Text = lblStudioName.Text + studioNameField.Text;
  47.             lblNoMinUsed.Text = lblNoMinUsed.Text + noMinUsed.ToString();
  48.             lblRatePerHour.Text = lblRatePerHour.Text + "PHP " + RATE_PER_HOUR.ToString("N2");
  49.             lblRatePerMin.Text = lblRatePerMin.Text + "PHP " + minRate.ToString("N2");
  50.             lblTotalCustomerOwe.Text = lblTotalCustomerOwe.Text + "PHP " + totalCustomerOwe.ToString("N2");
  51.         }
  52.  
  53.         private void btnClear_Click(object sender, EventArgs e)
  54.         {
  55.             studioNameField.Text = "";
  56.             noMinUsedField.Text = "";
  57.             lblStudioName.Text = "STUDIO NAME: ";
  58.             lblNoMinUsed.Text = "NO. MINUTES USED: ";
  59.             lblRatePerHour.Text = "RATE PER HOUR: ";
  60.             lblRatePerMin.Text = "RATE PER MIN: ";
  61.             lblTotalCustomerOwe.Text = "TOTAL CUSTOMER OWE: ";
  62.  
  63.             lblStudioNameResult.Text = "STUDIO NAME";
  64.             lblFixRatePerHour.Text = "FIXED RATE/HOUR: ";
  65.             lblRatePerMinutes.Text = "RATE/MIN: ";
  66.         }
  67.  
  68.         private void btnExit_Click(object sender, EventArgs e)
  69.         {
  70.             this.Close();
  71.         }
  72.  
  73.         private void noMinUsedField_KeyPress(object sender, KeyPressEventArgs e)
  74.         {
  75.             // allows only numbers
  76.             if (!char.IsNumber(e.KeyChar) & (Keys)e.KeyChar != Keys.Back & e.KeyChar != '.')
  77.             {
  78.                 e.Handled = true;
  79.                 MessageBox.Show("Input should not be letters/characters!");
  80.             }
  81.         }
  82.     }
  83. }
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement