Advertisement
Guest User

ZCalulator

a guest
Oct 30th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 12.22 KB | None | 0 0
  1. using Microsoft.VisualBasic;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12.  
  13. namespace Printer_Calc
  14. {
  15.     public partial class Form1 : Form
  16.     {
  17.         public Form1()
  18.         {
  19.             InitializeComponent();
  20.         }
  21.  
  22.         public string SELECTED_PRINTER = "Normal Printer";
  23.         public double OverallTotal;
  24.         public double SELECTED_MULTIPLIER = 1;
  25.         public double SELECTED_PRINTER_PROFIT = 35928;
  26.         public double EARNINGS;
  27.  
  28.         private void timer1_Tick(object sender, EventArgs e)
  29.         {
  30.             if (OverallTotal <= 0 )
  31.             {
  32.                 label2.Text = "No Printers";
  33.             }
  34.             else
  35.             {
  36.                 label2.Text = OverallTotal.ToString() + "$/h";
  37.             }
  38.         }
  39.  
  40.         private void button1_Click(object sender, EventArgs e)
  41.         {
  42.             OverallTotal = 0;
  43.             dataGridView1.Rows.Clear();
  44.         }
  45.  
  46.         private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  47.         {
  48.             if (comboBox1.SelectedIndex == 0)
  49.             {
  50.                 SELECTED_PRINTER = "=Normal Printer=";
  51.                 SELECTED_PRINTER_PROFIT = 0;
  52.             }
  53.             else if (comboBox1.SelectedIndex == 1)
  54.             {
  55.                 SELECTED_PRINTER = "Topaz Printer";
  56.                 SELECTED_PRINTER_PROFIT = 18000;
  57.             }
  58.             else if (comboBox1.SelectedIndex == 2)
  59.             {
  60.                 SELECTED_PRINTER = "Amethyst Printer";
  61.                 SELECTED_PRINTER_PROFIT = 27000;
  62.             }
  63.             else if (comboBox1.SelectedIndex == 3)
  64.             {
  65.                 SELECTED_PRINTER = "Emerald Printer";
  66.                 SELECTED_PRINTER_PROFIT = 45000;
  67.             }
  68.             else if (comboBox1.SelectedIndex == 4)
  69.             {
  70.                 SELECTED_PRINTER = "Sapphire Printer";
  71.                 SELECTED_PRINTER_PROFIT = 135000;
  72.             }
  73.             else if (comboBox1.SelectedIndex == 5)
  74.             {
  75.                 SELECTED_PRINTER = "Uranium Printer";
  76.                 SELECTED_PRINTER_PROFIT = 133;
  77.             }
  78.             else if (comboBox1.SelectedIndex == 6)
  79.             {
  80.                 SELECTED_PRINTER = "=VIP Printers=";
  81.                 SELECTED_PRINTER_PROFIT = 0;
  82.             }
  83.             else if (comboBox1.SelectedIndex == 7)
  84.             {
  85.                 SELECTED_PRINTER = "Normal Printer";
  86.                 SELECTED_PRINTER_PROFIT = 36000;
  87.             }
  88.             else if (comboBox1.SelectedIndex == 8)
  89.             {
  90.                 SELECTED_PRINTER = "Ruby Printer";
  91.                 SELECTED_PRINTER_PROFIT = 72000;
  92.             }
  93.             else if (comboBox1.SelectedIndex == 9)
  94.             {
  95.                 SELECTED_PRINTER = "Gold Printer";
  96.                 SELECTED_PRINTER_PROFIT = 144000;
  97.             }
  98.             else if (comboBox1.SelectedIndex == 10)
  99.             {
  100.                 SELECTED_PRINTER = "Nuclear Printer";
  101.                 SELECTED_PRINTER_PROFIT = 324000;
  102.             }
  103.             else if (comboBox1.SelectedIndex == 11)
  104.             {
  105.                 SELECTED_PRINTER = "=Special Printers=";
  106.                 SELECTED_PRINTER_PROFIT = 0;
  107.             }
  108.             else if (comboBox1.SelectedIndex == 12)
  109.             {
  110.                 SELECTED_PRINTER = "Diamond Printer";
  111.                 SELECTED_PRINTER_PROFIT = 720000;
  112.             }
  113.             else if (comboBox1.SelectedIndex == 13)
  114.             {
  115.                 SELECTED_PRINTER = "Black Diamond Printer";
  116.                 SELECTED_PRINTER_PROFIT = 1200000;
  117.             }
  118.             else if (comboBox1.SelectedIndex == 14)
  119.             {
  120.                 SELECTED_PRINTER = "Golden Plated Printer";
  121.                 SELECTED_PRINTER_PROFIT = 27000000;
  122.             }
  123.             else if (comboBox1.SelectedIndex == 15)
  124.             {
  125.                 SELECTED_PRINTER = "GenCorp Printer";
  126.                 SELECTED_PRINTER_PROFIT = 1800000;
  127.             }
  128.             else if (comboBox1.SelectedIndex == 16)
  129.             {
  130.                 SELECTED_PRINTER = "Magik Printer";
  131.                 SELECTED_PRINTER_PROFIT = 2400012;
  132.             }
  133.             else if (comboBox1.SelectedIndex == 17)
  134.             {
  135.                 SELECTED_PRINTER = "Festive Printer";
  136.                 SELECTED_PRINTER_PROFIT = 1800000;
  137.             }
  138.             else if (comboBox1.SelectedIndex == 18)
  139.             {
  140.                 SELECTED_PRINTER = "Iridium Printer";
  141.                 SELECTED_PRINTER_PROFIT = 2250000;
  142.             }
  143.             else if (comboBox1.SelectedIndex == 19)
  144.             {
  145.                 SELECTED_PRINTER = "Ice Printer";
  146.                 SELECTED_PRINTER_PROFIT = 27000000;
  147.             }
  148.             else if (comboBox1.SelectedIndex == 20)
  149.             {
  150.                 SELECTED_PRINTER = "Skull Printer";
  151.                 SELECTED_PRINTER_PROFIT = 27000000;
  152.             }
  153.             else if (comboBox1.SelectedIndex == 21)
  154.             {
  155.                 SELECTED_PRINTER = "XMAS Printer";
  156.                 SELECTED_PRINTER_PROFIT = 2772000;
  157.             }
  158.             else if (comboBox1.SelectedIndex == 22)
  159.             {
  160.                 SELECTED_PRINTER = "Summer Printer";
  161.                 SELECTED_PRINTER_PROFIT = 2880000;
  162.             }
  163.             else if (comboBox1.SelectedIndex == 23)
  164.             {
  165.                 SELECTED_PRINTER = "Hell Printer";
  166.                 SELECTED_PRINTER_PROFIT = 2889000;
  167.             }
  168.             else if (comboBox1.SelectedIndex == 24)
  169.             {
  170.                 SELECTED_PRINTER = "Santa Printer";
  171.                 SELECTED_PRINTER_PROFIT = 2520000;
  172.             }
  173.             else if (comboBox1.SelectedIndex == 25)
  174.             {
  175.                 SELECTED_PRINTER = "Easter Printer";
  176.                 SELECTED_PRINTER_PROFIT = 2790000;
  177.             }
  178.         }
  179.  
  180.  
  181.  
  182.         private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
  183.         {
  184.             if (comboBox2.SelectedIndex == 0)
  185.             {
  186.                 SELECTED_MULTIPLIER = 1;
  187.             }
  188.             else if (comboBox2.SelectedIndex == 1)
  189.             {
  190.                 SELECTED_MULTIPLIER = 2;
  191.             }
  192.             else if (comboBox2.SelectedIndex == 2)
  193.             {
  194.                 SELECTED_MULTIPLIER = 3;
  195.             }
  196.             else if (comboBox2.SelectedIndex == 3)
  197.             {
  198.                 SELECTED_MULTIPLIER = 4;
  199.             }
  200.             else if (comboBox2.SelectedIndex == 4)
  201.             {
  202.                 SELECTED_MULTIPLIER = 5;
  203.             }
  204.         }
  205.  
  206.         private void button2_Click(object sender, EventArgs e)
  207.         {
  208.             EARNINGS = SELECTED_PRINTER_PROFIT * SELECTED_MULTIPLIER;
  209.  
  210.             dataGridView1.Rows.Add(SELECTED_PRINTER, SELECTED_MULTIPLIER.ToString(), EARNINGS.ToString());
  211.             OverallTotal += EARNINGS;
  212.         }
  213.  
  214.         private void button3_Click(object sender, EventArgs e)
  215.         {
  216.             if (dataGridView1.SelectedRows.Count > 0 && dataGridView1.SelectedRows[0].Index != dataGridView1.Rows.Count - 1)
  217.             {
  218.                 dataGridView1.Rows.RemoveAt(dataGridView1.SelectedRows[0].Index);
  219.             }
  220.         }
  221.  
  222.         private void button3_Click_1(object sender, EventArgs e)
  223.         {
  224.             string defaultResponse = "Your Config";
  225.             string input = Interaction.InputBox("Enter your Config name below", "Enter Name", defaultResponse, -1, -1);
  226.             if (input.Length == 0)
  227.             {
  228.                 MessageBox.Show("Input can't be empty!!", "Error");
  229.             }
  230.             else
  231.             {
  232.                 MessageBox.Show("Will save printer config with the name: " + input);
  233.  
  234.                 string file = Application.StartupPath + "/" + input + "_calcsave.bin";
  235.                 using (BinaryWriter bw = new BinaryWriter(File.Open(file, FileMode.Create)))
  236.                 {
  237.                     bw.Write(dataGridView1.Columns.Count);
  238.                     bw.Write(dataGridView1.Rows.Count);
  239.                     foreach (DataGridViewRow dgvR in dataGridView1.Rows)
  240.                     {
  241.                         for (int j = 0; j < dataGridView1.Columns.Count; ++j)
  242.                         {
  243.                             object val = dgvR.Cells[j].Value;
  244.                             if (val == null)
  245.                             {
  246.                                 bw.Write(false);
  247.                                 bw.Write(false);
  248.                             }
  249.                             else
  250.                             {
  251.                                 bw.Write(true);
  252.                                 bw.Write(val.ToString());
  253.                             }
  254.                         }
  255.                     }
  256.                 }
  257.             }
  258.         }
  259.  
  260.         private void button4_Click(object sender, EventArgs e)
  261.         {
  262.             try
  263.             {
  264.                 string defaultResponse = "Your Config";
  265.                 string input = Interaction.InputBox("Enter your Config name below", "Enter Name", defaultResponse, -1, -1);
  266.                 if (input.Length == 0)
  267.                 {
  268.                     MessageBox.Show("Input can't be empty!!", "Error");
  269.                 }
  270.                 else
  271.                 {
  272.                     MessageBox.Show("Will load printer config with the name: " + input);
  273.  
  274.                     dataGridView1.Rows.Clear();
  275.                     string file = Application.StartupPath + "/" + input + "_calcsave.bin";
  276.                     using (BinaryReader bw = new BinaryReader(File.Open(file, FileMode.Open)))
  277.                     {
  278.                         int n = bw.ReadInt32();
  279.                         int m = bw.ReadInt32();
  280.                         for (int i = 0; i < m; ++i)
  281.                         {
  282.                             dataGridView1.Rows.Add();
  283.                             for (int j = 0; j < n; ++j)
  284.                             {
  285.                                 if (bw.ReadBoolean())
  286.                                 {
  287.                                     dataGridView1.Rows[i].Cells[j].Value = bw.ReadString();
  288.                                 }
  289.                                 else bw.ReadBoolean();
  290.                             }
  291.                         }
  292.                     }
  293.                 }
  294.             }
  295.             catch
  296.             {
  297.                 MessageBox.Show("Config does not exist!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  298.             }
  299.         }
  300.  
  301.         private void Form1_Load(object sender, EventArgs e)
  302.         {
  303.  
  304.         }
  305.  
  306.         private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
  307.         {
  308.  
  309.         }
  310.  
  311.         private void quicknonprinterload_Click(object sender, EventArgs e)
  312.         {
  313.  
  314.             if (comboBox1.SelectedIndex == 0)
  315.             {
  316.                 SELECTED_PRINTER = "=Normal Printer=";
  317.                 SELECTED_PRINTER_PROFIT = 0;
  318.             }
  319.             else if (comboBox1.SelectedIndex == 1)
  320.             {
  321.                 SELECTED_PRINTER = "Topaz Printer";
  322.                 SELECTED_PRINTER_PROFIT = 18000;
  323.             }
  324.             else if (comboBox1.SelectedIndex == 2)
  325.             {
  326.                 SELECTED_PRINTER = "Amethyst Printer";
  327.                 SELECTED_PRINTER_PROFIT = 27000;
  328.             }
  329.             else if (comboBox1.SelectedIndex == 3)
  330.             {
  331.                 SELECTED_PRINTER = "Emerald Printer";
  332.                 SELECTED_PRINTER_PROFIT = 45000;
  333.             }
  334.             else if (comboBox1.SelectedIndex == 4)
  335.             {
  336.                 SELECTED_PRINTER = "Sapphire Printer";
  337.                 SELECTED_PRINTER_PROFIT = 135000;
  338.             }
  339.             else if (comboBox1.SelectedIndex == 5)
  340.             {
  341.                 SELECTED_PRINTER = "Uranium Printer";
  342.                 SELECTED_PRINTER_PROFIT = 133;
  343.             }
  344.             else if (comboBox1.SelectedIndex == 6)
  345.  
  346.  
  347.                 EARNINGS = SELECTED_PRINTER_PROFIT * SELECTED_MULTIPLIER;
  348.  
  349.             dataGridView1.Rows.Add(SELECTED_PRINTER, SELECTED_MULTIPLIER.ToString(), EARNINGS.ToString());
  350.             OverallTotal += EARNINGS;
  351.         }
  352.     }
  353. }
  354.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement