Ejemplo n.º 1
0
        public mainForm()
        {
            try
            {
                //Microsoft.
                InitializeComponent();
                settingsData = new settingsData();
                settingsData.getSettings();

                string CommandText = "select * from `ads_paper`.`catalogitems` order by R1,R2,R3,R4";
                string Connect = "Database=" + settingsData.dbname + ";Data Source=" + settingsData.server + ";User Id="+ settingsData.dbuser +";Password="******";Port=" + settingsData.dbPort;
                //Переменная Connect - это строка подключения в которой:
                //БАЗА - Имя базы в MySQL
                //ХОСТ - Имя или IP-адрес сервера (если локально то можно и localhost)
                //ПОЛЬЗОВАТЕЛЬ - Имя пользователя MySQL
                //ПАРОЛЬ - говорит само за себя - пароль пользователя БД MySQL
                MySqlConnection myConnection = new MySqlConnection(Connect);
                MySqlCommand myCommand = new MySqlCommand(CommandText, myConnection);
                myConnection.Open(); //Устанавливаем соединение с базой данных.
                MySqlDataReader MyDataReader;
                MyDataReader = myCommand.ExecuteReader();
                int i = -1;
                catalogList.BackColor = System.Drawing.Color.DarkGray;
                while (MyDataReader.Read())
                {
                    int id = MyDataReader.GetInt32(0); //Получаем строку
                    string R1 = MyDataReader.GetString(2); //Получаем строку
                    string R2 = MyDataReader.GetString(3); //Получаем строку
                    string R3 = MyDataReader.GetString(4); //Получаем строку
                    string R4 = MyDataReader.GetString(5); //Получаем строку
                    string name = MyDataReader.GetString(1); //Получаем строку

                    catalogList.Rows.Add(id, R1, R2, R3, R4, name);
                    i++;
                    catalogList.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(192, 192, 192);
                    if (R1 == "0")
                    {
                        catalogList.Rows[i].DefaultCellStyle.BackColor= System.Drawing.Color.DarkCyan;
                        continue;

                    }
                    if (R2 == "0")
                    {
                        catalogList.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(0,128,128);
                        continue;
                    }
                    if (R3 == "0")
                    {
                        catalogList.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(166, 202, 240);
                        continue;
                    }
                    if (R4 == "0")
                    {
                        catalogList.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(128, 128, 128);
                        continue;
                    }
                }
                MyDataReader.Close();
                myConnection.Close(); //Обязательно закрываем соединение!
                //добавляем первую карточку
                EditControl card = new EditControl();
                card.Name = "cardPane" + cardsCount.ToString();
                selectedCard = card.Name;
                card.Top = startHeight;
                card.Left = startWidth;
                cardsCount++;
                card.Show();
                card.Enter += this.cardName;
                selectedCard = card.Name;
                listOfCards.Controls.Add(card);
                //listOfCards.Height += card.Height + 10;

            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Ejemplo n.º 2
0
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         if (catalogList.CurrentRow.Cells[1].Value.ToString() != "18")
         {
             EditControl card = new EditControl();
             card.Name = "cardPane" + cardsCount.ToString();
             selectedCard = card.Name;
             card.Top = startHeight;
             card.Left = startWidth;
             cardsCount++;
             card.Show();
             card.Enter += this.cardName;
             selectedCard = card.Name;
             listOfCards.Controls.Add(card);
             //listOfCards.Height += card.Height + 10;
         }
         else
         {
             //EditControlJob card = new EditControlJob();
             //card.Name = "cardPane" + cardsCount.ToString();
             //card.Top = cardsView.Height;
             //card.BackColor = Color.DarkGray;
             //cardsCount++;
             //selectedCard = card.Name;
             //cardsView.Controls.Add(card);
             //cardsView.Width = 615;
             //cardsView.Height += card.Height;
         }
     }
     catch (Exception except)
     {
         MessageBox.Show(except.Message);
     }
 }