コード例 #1
0
ファイル: License.cs プロジェクト: ridvankuntug/StockTracker
 private void button1_Click(object sender, EventArgs e)
 {
     if (checkBox1.Checked)
     {
         if (textBox1.Text != null && textBox2.Text != null)
         {
             if (MethodsClass.LicenseCheck(MethodsClass.CreateKey(textBox1.Text), textBox2.Text))
             {
                 Regedit.Write(textBox1.Text, textBox2.Text);
                 MessageBox.Show("Thank you for your purchase.");
                 Application.Restart();
             }
             else
             {
                 MessageBox.Show("The license is not valid, check it and if it still doesn't work, contact the developer.");
             }
         }
         else
         {
             MessageBox.Show("Be sure to fill in all the fields.");
         }
     }
     else
     {
         MessageBox.Show("You must accept EULA first.");
     }
 }
コード例 #2
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(
             "Are you sure delete this datas?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk
             ) == DialogResult.Yes)
     {
         if (MethodsClass.ExportDatabase())
         {
             if (DatabaseClass.DropHistoryStockLocation())
             {
                 label3.ForeColor = Color.Green;
                 label3.Text      = "Backed up and delete.";
                 label3.Visible   = true;
             }
             else
             {
                 label3.ForeColor = Color.Red;
                 label3.Text      = "Cant delete datas.";
                 label3.Visible   = true;
             }
         }
         else
         {
             label3.ForeColor = Color.Red;
             label3.Text      = "Not backed up.";
             label3.Visible   = true;
         }
     }
 }
コード例 #3
0
 private void button5_Click(object sender, EventArgs e)
 {
     if (MethodsClass.ExportDatabase())
     {
         if (MethodsClass.ImportDatabase())
         {
             label5.ForeColor = Color.Green;
             label5.Text      = "Imported.";
             label5.Visible   = true;
             Application.Restart();
         }
         else
         {
             label5.ForeColor = Color.Red;
             label5.Text      = "Not implemented.";
             label5.Visible   = true;
         }
     }
     else
     {
         label5.ForeColor = Color.Red;
         label5.Text      = "Not implemented.";
         label5.Visible   = true;
     }
 }
コード例 #4
0
        private void ParentForm_Load(object sender, EventArgs e)
        {
            this.Text = this.Text + " v" + Assembly.GetExecutingAssembly().GetName().Version.ToString();



            DatabaseClass.CreateDB();
            DatabaseClass.CreateTable();
            string[] LicenseKey = new string[2];
            LicenseKey = Regedit.Read();

            DatabaseClass.DeleteOlderThen(Settings.Default.DeletePeriod.ToString());

            if (LicenseKey == null)
            {
                menuStrip1.Enabled = false;
                Form License = new License();
                License.MdiParent = this;
                License.Show();
            }
            else if (!MethodsClass.LicenseCheck(MethodsClass.CreateKey(LicenseKey[0]), LicenseKey[1]))
            {
                menuStrip1.Enabled = false;
                Form License = new License();
                License.MdiParent = this;
                License.Show();
            }
            else if (!DatabaseClass.LocationTableCheck())
            {
                menuStrip1.Enabled = false;
                if (!DatabaseClass.ProductsTableCheck())
                {
                    if (MessageBox.Show(
                            "Do you have a database created and backed up with this program that you want to add to the system? \nIf you choose a wrong file, you may need to uninstall and reinstall the program.", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk
                            ) == DialogResult.Yes)
                    {
                        Form ImportDatabaseFile = new ImportDatabaseFile();
                        ImportDatabaseFile.ShowDialog();
                    }
                    else
                    {
                        Form AddLocation = new AddLocation();
                        AddLocation.ShowDialog();
                    }
                }
                else
                {
                    Form AddLocation = new AddLocation();
                    AddLocation.ShowDialog();
                }
            }
            else
            {
                Form HomeForm = new Home();
                HomeForm.MdiParent = this;
                HomeForm.Show();
            }
        }
コード例 #5
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (MethodsClass.ExportToExcel(dataGridView1))
     {
         MessageBox.Show("Saved");
     }
     else
     {
         MessageBox.Show("Can't saved!");
     }
 }
コード例 #6
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (MethodsClass.ExportDatabase())
     {
         label1.ForeColor = Color.Green;
         label1.Text      = "Backed up to the desktop.";
         label1.Visible   = true;
     }
     else
     {
         label1.ForeColor = Color.Red;
         label1.Text      = "Not backed up.";
         label1.Visible   = true;
     }
 }
コード例 #7
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(
             "Are you sure you want to delete all the data? \nThe program will be restarted.", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk
             ) == DialogResult.Yes)
     {
         if (MethodsClass.ExportDatabase())
         {
             if (File.Exists(@"Databases/Stock.db"))
             {
                 File.Delete(@"Databases/Stock.db");
                 Settings.Default.DeletePeriod = 2;
                 Settings.Default.Save();
                 Application.Restart();
             }
             else
             {
                 label4.ForeColor = Color.Red;
                 label4.Text      = "Database not deleted.";
                 label4.Visible   = true;
             }
         }
         else
         {
             label4.ForeColor = Color.Red;
             label4.Text      = "Database not deleted.";
             label4.Visible   = true;
         }
     }
     else
     {
         label4.ForeColor = Color.Red;
         label4.Text      = "Database not deleted.";
         label4.Visible   = true;
     }
 }