private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { t_lcball t_Lcball = new t_lcball(); if (ISDataGridLoaded == true) { if (ItemIndx != int.Parse(dataGridView1.Rows[e.RowIndex].Cells["ItemIndex"].Value.ToString()) && (dataGridView1.Rows[e.RowIndex].Cells["ItemIndex"].Value.ToString() != "-1" || dataGridView1.Rows[e.RowIndex].Cells["ItemIndex"].Value.ToString() != "0")) { ItemIndx = int.Parse(dataGridView1.Rows[e.RowIndex].Cells["ItemIndex"].Value.ToString()); if (ISFinished != true) { //if the column value isnt equal to the list set true then give a image otherwise its false until true; ISFinished = true; dataGridView1.Rows[e.RowIndex].SetValues(new Bitmap(databaseHandle.IconFast(ItemIndx), 20, 20)); } else if (ISDataGridLoaded == true && ISFinished == true) { dataGridView1.Rows[e.RowIndex].SetValues(new Bitmap(databaseHandle.IconFast(ItemIndx), 20, 20)); } } } }
public void LoadDG(int LacaballItemidx) //dethunter12 add test lacaball code. { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); dataGridView1.Rows.Clear(); string str1 = "select a_item_order, a_tocken_index, a_course_code, a_order, a_item_index, a_item_count, a_item_max, a_item_remain from t_lcball WHERE a_tocken_index = " + LacaballItemidx + " order by a_course_code ASC, a_order ASC ;"; MySqlConnection mySqlConnection = new MySqlConnection("datasource=" + Host + ";port=3306;username="******";password="******";database=" + DB_Database); MySqlCommand command = mySqlConnection.CreateCommand(); command.CommandText = str1; mySqlConnection.Open(); MySqlDataReader mySqlDataReader = command.ExecuteReader(); if (mySqlDataReader.HasRows == false) //dethunter12 adjust 6/1/2020 { ISNullValue = true; } else { ISNullValue = false; } while (mySqlDataReader.Read()) { t_lcball t_Lcball = new t_lcball(); t_Lcball.a_item_order = Convert.ToInt32(mySqlDataReader.GetValue(0).ToString()); t_Lcball.a_tocken_index = Convert.ToInt32(mySqlDataReader.GetValue(1).ToString()); t_Lcball.a_course_code = Convert.ToInt32(mySqlDataReader.GetValue(2).ToString()); t_Lcball.a_order = Convert.ToInt32(mySqlDataReader.GetValue(3).ToString()); t_Lcball.a_item_index = Convert.ToInt32(mySqlDataReader.GetValue(4).ToString()); t_Lcball.a_item_count = Convert.ToInt32(mySqlDataReader.GetValue(5).ToString()); t_Lcball.a_item_max = Convert.ToInt32(mySqlDataReader.GetValue(6).ToString()); t_Lcball.a_item_remain = Convert.ToInt32(mySqlDataReader.GetValue(7).ToString()); LcBallList.Add(t_Lcball); string item_id = mySqlDataReader.GetValue(4).ToString(); int ItemIndx = t_Lcball.a_item_index; dataGridView1.Rows.Add(new Bitmap(databaseHandle.IconFast(Int32.Parse(item_id)), 20, 20), t_Lcball.a_item_order, t_Lcball.a_course_code, t_Lcball.a_order, t_Lcball.a_item_index, databaseHandle.ItemNameFast(Int32.Parse(item_id)), t_Lcball.a_item_count); tbItemMax.Text = t_Lcball.a_item_max.ToString(); tbItemRemain.Text = t_Lcball.a_item_remain.ToString(); } mySqlConnection.Close(); ISDataGridLoaded = true; stopwatch.Stop(); TimeSpan elapsed = stopwatch.Elapsed; string.Format("{0:00}:{1:00}:{2:00}.{3:00}", elapsed.Hours, elapsed.Minutes, elapsed.Seconds, (elapsed.Milliseconds / 10)); toolStripStatusLabel1.Text = "Ready"; toolStripStatusLabel1.ForeColor = Color.LimeGreen; }