private void buttonSelectExcelOld_Click(object sender, EventArgs e) { dataGridViewOldFile.DataSource = ExcelOptions.SelectExcelFile(); dataGridViewOldFile.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; for (int i = 0; i < dataGridViewOldFile.ColumnCount; i++) { if (dataGridViewOldFile.Columns[i].HeaderText.Contains("قوم")) // الرقم القومي { for (int k = 0; k < dataGridViewOldFile.RowCount; k++) { try { long ID = long.Parse(dataGridViewOldFile[i, k].Value.ToString()); oldNationalId.Add(ID, 1); } catch { buttonSelectExcelNew.Enabled = true; buttonSelectExcelOld.Enabled = false; return; } } buttonSelectExcelNew.Enabled = true; buttonSelectExcelOld.Enabled = false; return; } } }
private void buttonSelectExcelNew_Click(object sender, EventArgs e) { dataGridViewNewFile.DataSource = ExcelOptions.SelectExcelFile(); dataGridViewNewFile.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; for (int i = 0; i < dataGridViewNewFile.ColumnCount; i++) { if (dataGridViewNewFile.Columns[i].HeaderText.Contains("قوم")) // الرقم القومي { for (int k = 0; k < dataGridViewNewFile.RowCount; k++) { try { long ID = long.Parse(dataGridViewNewFile[i, k].Value.ToString()); if (!oldNationalId.Contains(new KeyValuePair <long, byte>(ID, 1))) { oldNationalId.Add(ID, 3); } else { oldNationalId[ID] = 2; // to make remove true in the dictionary } } catch { buttonSelectExcelNew.Enabled = false; //return; } } buttonSelectExcelNew.Enabled = false; return; } } }
private void buttonSelectFile_Click(object sender, EventArgs e) { dataGridView1.DataSource = ExcelOptions.SelectExcelFile(); dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; for (int i = 0; i < dataGridView1.ColumnCount; i++) { columnsIndex[dataGridView1.Columns[i].HeaderText] = i; comboCoulms.Items.Add(dataGridView1.Columns[i].HeaderText); listView1.Items.Add(dataGridView1.Columns[i].HeaderText, "Data/boy.jpg"); } for (int i = 0; i < dataGridView1.ColumnCount; i++) { dataGridView1.Columns[i].Visible = false; } for (int i = 0; i < dataGridView1.RowCount; i++) { if ((i & 1) == 1) { dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.AliceBlue; } } }