예제 #1
0
        private void List_control_Load(object sender, EventArgs e)
        {
            Company[] cpnList = new Company[30];
            Task.Run(() => {
                cpnList = Company.GenerateListOfCompanies(30);
                for (int i = 0; i < 30; i++)
                {
                    SQLiteCommands.LoadToDatabase(cpnList[i]);
                }
            });

            List <string> listOne = SQLiteCommands.LoadCompanies();

            for (int i = 0; i < listOne.Count; i++)
            {
                comboBox1.Items.Add(listOne[i]);
                comboBox2.Items.Add(listOne[i]);
            }

            cpn = SQLiteCommands.LoadInformation("DEREHAM SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ");
            List <List <string> > listTwo = cpn.PropertiesList(cpn);

            for (int i = 0; i < listTwo[0].Count; i++)
            {
                dataGridView3.Rows.Add(listTwo[0][i].ToString(), listTwo[1][i].ToString());
            }
        }
        private void convertBtn_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists("DatabasePatch"))
            {
                Directory.CreateDirectory("DatabasePatch");
            }
            List <string[]> updateCards = convertList.Items.OfType <string[]>().ToList();
            string          str         = Directory.GetCurrentDirectory();;
            string          str2        = Path.Combine(str, "cards.cdb");

            if (!File.Exists(str2))
            {
                MessageBox.Show("cards.cdb not found.");
                return;
            }

            var connection = new SQLiteConnection("Data Source=" + str2);

            connection.Open();
            foreach (var updateCard in updateCards)
            {
                string formatInt = updateCard[1] == "OCG" ? "1" : updateCard[1] == "TCG" ? "2" : updateCard[1] == "TCG/OCG" ? "3" : "???";
                if (formatInt == "???")
                {
                    MessageBox.Show("Error occured.", "Error!", MessageBoxButtons.OK);
                    return;
                }
                SQLiteCommands.UpdateCardOt(updateCard[0], formatInt, connection);
            }

            connection.Close();
            File.Copy(str2, "DatabasePatch\\cards.cdb", true);
            convertList.Items.Clear();
            MessageBox.Show("Complete.");
        }
예제 #3
0
        public static bool LoadCDB(string dir, bool overwrite, bool clearData = false)
        {
            if (!File.Exists(dir))
            {
                return(false);
            }

            if (clearData)
            {
                CardData.Clear();
            }

            SqliteConnection connection = new SqliteConnection("Data Source=" + dir);
            List <string[]>  datas      = new List <string[]>();
            List <string[]>  texts      = new List <string[]>();

            try
            {
                connection.Open();
                datas = SQLiteCommands.LoadData(connection);
                texts = SQLiteCommands.LoadText(connection);
                connection.Close();
            }
            catch (Exception ex)
            {
                connection.Close();
                return(false);
            }

            foreach (string[] row in datas)
            {
                if (overwrite)
                {
                    CardManager.UpdateOrAddCard(new CardInfos(row));
                }
                else
                {
                    if (!CardManager.ContainsCard(Int32.Parse(row[0])))
                    {
                        CardManager.UpdateOrAddCard(new CardInfos(row));
                    }
                }
            }
            foreach (string[] row in texts)
            {
                if (CardManager.ContainsCard(Int32.Parse(row[0])))
                {
                    CardManager.GetCard(Int32.Parse(row[0])).SetCardText(row);
                }
            }

            if (File.Exists("setname.txt"))
            {
                LoadSetCodesFromFile(CreateFileStreamFromString(File.ReadAllText("setname.txt")));
            }
            SetCodesStringInit();

            return(true);
        }
예제 #4
0
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            cpn = SQLiteCommands.LoadInformation(comboBox2.SelectedItem.ToString());
            List <List <string> > listTwo = cpn.PropertiesList(cpn);

            for (int i = 0; i < listTwo[0].Count; i++)
            {
                dataGridView2.Rows.Add(listTwo[0][i].ToString(), listTwo[1][i].ToString());
            }
        }
예제 #5
0
        private void Button1_Click(object sender, EventArgs e)
        {
            //
            // pobieram informacje o osobie
            //
            string mquery = "select distinct imieNazwisko || ' ' || kodMiasto || ' ' || UlicaNr as adres" +
                            " from osoba where osobaId=" + lblOsobaId.Text;

            SQLiteCommands myConnn = new SQLiteCommands(IniDataBaseFile.conPath, IniDataBaseFile.conFile);

            txtWynik.Text = myConnn.SqlReturnOneValue(mquery);


            string query = "select ksiazkiId from pierwszePozyczenie where osobaId = " + lblOsobaId.Text;


            lblKsiazkaId.Text      = myConnn.SqlReturnOneValue(query);
            lblKsiazkaOsobaId.Text = lblOsobaId.Text;
            wypelnijGrid2(lblOsobaId.Text);
        }
        public static bool LoadCDB(string dir, bool overwrite, bool clearData = false)
        {
            logger.Info("Start LOAD CDB {0}", dir);
            LoadPicsFile();

            if (!File.Exists(dir))
            {
                return(false);
            }

            if (clearData)
            {
                CardData.Clear();
            }

            SQLiteConnection connection = new SQLiteConnection("Data Source=" + dir);
            List <string[]>  datas      = new List <string[]>();
            List <string[]>  texts      = new List <string[]>();

            try
            {
                connection.Open();
                datas = SQLiteCommands.LoadData(connection);
                texts = SQLiteCommands.LoadText(connection);
                connection.Close();
            }
            catch (Exception ex)
            {
                logger.Error("LOADCDB :" + ex.ToString());
                connection.Close();
                return(false);
            }

            progress = 0;
            total    = datas.Count + texts.Count;
            foreach (string[] row in datas)
            {
                if (overwrite)
                {
                    CardManager.UpdateOrAddCard(new CardInfos(row));
                }
                else
                {
                    if (!CardManager.ContainsCard(int.Parse(row[0])))
                    {
                        CardManager.UpdateOrAddCard(new CardInfos(row));
                    }
                }

                if (!CheckPicsLoaded(Convert.ToInt32(row[0])))
                {
                    DownloadPics(row[0]);
                }
                else
                {
                    progress++;
                    Application.Current.Dispatcher.Invoke(() => LoadingProgress?.Invoke(progress, total));
                }
            }
            foreach (string[] row in texts)
            {
                progress++;
                Application.Current.Dispatcher.Invoke(() => LoadingProgress?.Invoke(progress, total));

                if (CardManager.ContainsCard(int.Parse(row[0])))
                {
                    CardManager.GetCard(int.Parse(row[0])).SetCardText(row);
                }
            }

            if (File.Exists(Path.Combine(FormExecution.path, "BattleCityAlpha", "strings.conf")))
            {
                LoadSetCodesFromFile(CreateFileStreamFromString(File.ReadAllText(Path.Combine(FormExecution.path, "BattleCityAlpha", "strings.conf"))));
            }
            SetCodesStringInit();

            while (progress != total)
            {
                Thread.Sleep(500);
            }
            Application.Current.Dispatcher.Invoke(() => LoadingFinished?.Invoke());

            return(true);
        }
예제 #7
0
        private void Chart_control_Load_1(object sender, EventArgs e)
        {
            List <string> listOne = SQLiteCommands.LoadCompanies();

            for (int i = 0; i < listOne.Count; i++)
            {
                comboBox1.Items.Add(listOne[i]);
                comboBox2.Items.Add(listOne[i]);
            }
            List <Label> Label_Left  = new List <Label>();
            List <Label> Label_Right = new List <Label>();



            Label_Right.Add(Label1_Right);



            Charts_Left.Add(Chart1_Left);
            Charts_Left.Add(Chart2_Left);
            Charts_Left.Add(Chart3_Left);
            Charts_Left.Add(Chart4_Left);


            Charts_Right.Add(Chart1_Right);
            Charts_Right.Add(Chart2_Right);
            Charts_Right.Add(Chart3_Right);
            Charts_Right.Add(Chart4_Right);



            Random rd = new Random();

            for (int i = 0; i < 4; i++)
            {
                Charts_array_left[i]  = rd.Next(1, 50000);
                Charts_array_right[i] = rd.Next(1, 50000);

                Color col = Color.FromArgb(rd.Next(255), rd.Next(255), rd.Next(255));
                Charts_Left[i].BackColor  = col;
                Charts_Right[i].BackColor = col;

                if (Charts_array_left[i] > Charts_array_right[i])
                {
                    Charts_Left[i].Location = new Point(Charts_Left[i].Location.X - (400 - Charts_Left[i].Width), Charts_Left[i].Location.Y);
                    Charts_Left[i].Width    = 400;
                    Charts_Left[i].Text     = Charts_array_left[i].ToString();
                    Charts_Right[i].Width   = (int)(400 * (Charts_array_right[i] / Charts_array_left[i]));
                    Charts_Right[i].Text    = Charts_array_right[i].ToString();
                }
                else
                {
                    Charts_Right[i].Width = 400;
                    Charts_Right[i].Text  = Charts_array_right[i].ToString();

                    Charts_Left[i].Location = new Point(Charts_Left[i].Location.X + (Charts_Left[i].Width - (int)(400 * (Charts_array_left[i] / Charts_array_right[i]))), Charts_Left[i].Location.Y);
                    Charts_Left[i].Width    = (int)(400 * (Charts_array_left[i] / Charts_array_right[i]));
                    Charts_Left[i].Text     = Charts_array_left[i].ToString();
                }
            }
        }