コード例 #1
0
 public Form1()
 {
     InitializeComponent();
     JsonController.ReadJson();
     fillTicketTable();
     dateTimePicker1.Format       = DateTimePickerFormat.Custom;
     dateTimePicker1.CustomFormat = "MM/dd/yyyy hh:mm:ss tt";
     dateTimePicker1.Value        = DateTime.Now;
     if (Environment.UserName.ToLower() == "vancef")
     {
         this.BackColor = Color.ForestGreen;
     }
     changeColor();
 }
コード例 #2
0
        internal static void ImportJson()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title  = "Select Ticket File to Import";
            ofd.Filter = "Tickets |*.tkt";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string path = ofd.FileName;
                if (Ticket.ticketArray.Count >= 1)
                {
                    var test = MessageBox.Show("Would you like to add on to your tickets? If not I would delete all existing tickets.", "Warning!", MessageBoxButtons.YesNo);
                    if (test == DialogResult.No)
                    {
                        Properties.Settings.Default.Json = "";
                        Ticket.ticketArray.Clear();
                    }
                }
                using (StreamReader sr = new StreamReader(path))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        Properties.Settings.Default.Json += Encrypt.DecryptString(line, "Password");
                    }
                    if (Properties.Settings.Default.Json.Contains("¼") && Properties.Settings.Default.Json.Contains("µ"))
                    {
                        JsonController.ReadJson();
                    }
                    else
                    {
                        MessageBox.Show("File is corrupted!", "Error: Corruption", MessageBoxButtons.OK);
                        Properties.Settings.Default.Json = "";
                        JsonController.ReadJson();
                    }
                }
            }
        }