private async void buttonX2_Click(object sender, EventArgs e) { ClassDataGridViewDo.ClumChekArray(NameCol, dataGridViewX1); /* * try{ * for (int i = 0; i < dataGridViewX1.Rows.Count; i++) * { * string fullname =Convert.ToString( dataGridViewX1.Rows[i].Cells[NameCol[0]].Value); * DateTime? date = ClassConvert.ConvDateTimeNull(dataGridViewX1.Rows[i].Cells[NameCol[1]].Value); * int year_sf =ClassConvert.ConvToStady( dataGridViewX1.Rows[i].Cells[NameCol[2]].Value); * int phone = ClassConvert.Convint(dataGridViewX1.Rows[i].Cells[NameCol[3]].Value); * string notes =Convert.ToString( dataGridViewX1.Rows[i].Cells[NameCol[4]].Value); * int nameArchev = ClassConvert.Convint(dataGridViewX1.Rows[i].Cells[NameCol[5]].Value); * int Id_Study =await CV_Study.CV_studyID(Convert.ToString(dataGridViewX1.Rows[i].Cells[NameCol[6]].Value)); * int id_team = ClassConvert.Convint(dataGridViewX1.Rows[i].Cells[NameCol[7]].Value); * * * CV_Info CV_Info = new CV_Info(0, fullname, notes, nameArchev, Id_Study, year_sf, phone, date, id_team, false , ); * await Sqldatabasethrding.SqlSaveVitl( CV_Info.adder()); * * } * }catch(NoColumnsException ec ) { * MegBox.Show(ec.Message); * }*/ }
private async void buttonX3_Click(object sender, EventArgs e) { try { dataGridViewX1.Enabled = false; ClassDataGridViewDo.ClumChekArray(NameCol, dataGridViewX1); int IdTheNameOfcoures = NameTeam.NameTeamStatic[comboBoxEx1.SelectedIndex].id; for (int i = 0; i < dataGridViewX1.Rows.Count; i++) { int id = ClassConvert.Convint(dataGridViewX1.Rows[i].Cells["id"].Value); DateTime?NuberOfDayes = ClassConvert.ConvDateTimeNull(dataGridViewX1.Rows[i].Cells["تاريخ تكليفه بالعمل"].Value); //أختبار هل الدورة مسجل عند الشخص + أنه تأكد من وجود ID if (id > 0) { Team CouresNew = new Team(0, NuberOfDayes, null, id, IdTheNameOfcoures, 1, 1); if (await Sqldatabasethrding.SqlSaveVitl(CouresNew.adder())) { dataGridViewX1.Rows[i].DefaultCellStyle.BackColor = Color.Green; } else { dataGridViewX1.Rows[i].DefaultCellStyle.BackColor = Color.Red; } } else { dataGridViewX1.Rows[i].DefaultCellStyle.BackColor = Color.Red; } } } catch (NoColumnsException ex) { ErrorClass.SaveErrorFile(ex); MessageBox.Show(string.Format(" لا يوجد عامود {0} ", ex.Message)); } catch (Exception ex) { ErrorClass.SaveErrorFile(ex); } buttonX3.Enabled = true; dataGridViewX1.Enabled = true; }
public async void ForRunThrading() { try { dataGridViewX1.Enabled = false; ClassDataGridViewDo.ClumChekArray(NameCol, dataGridViewX1); progressBarX1.Maximum = dataGridViewX1.Rows.Count; int IndexCombox = comboBoxEx1.SelectedIndex; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); for (int i = 0; i < dataGridViewX1.Rows.Count; i++) { stopwatch.Restart(); // إيقاف العمل في خلفية التزامن if (!Workin) { break; } //العداد progressBarX1.Value = i; // إنتظار بين الأمر والثاني await System.Threading.Tasks.Task.Delay(100); int id = ClassConvert.Convint(dataGridViewX1.Rows[i].Cells["id"].Value); int NumberOfCoures = ClassConvert.Convint(dataGridViewX1.Rows[i].Cells["رقم الدورة"].Value); int? NuberOfDayes = ClassConvert.ConvintNull(dataGridViewX1.Rows[i].Cells["عدد الأيام"].Value); float?float1 = ClassConvert.ConvFloatNull(dataGridViewX1.Rows[i].Cells["النتيجة"].Value); //أختبار هل الدورة مسجل عند الشخص + أنه تأكد من وجود ID if (!await Couress.GetIsItHaveCouresByIdInformation(id, IndexCombox)) { if (id > 0 && NumberOfCoures > 0 && NuberOfDayes != null && float1 != null) { int IdTheNameOfcoures = NameOfCouress.SerchByListStaticRetId(TypeofCouress.TypeofCouressList[IndexCombox].id, NumberOfCoures); if (IdTheNameOfcoures == -1) { DevComponents.DotNetBar.MessageBoxEx.Show("رقم الدورة غير مضاف:" + NumberOfCoures); break; } Couress CouresNew = new Couress(0, IdTheNameOfcoures, id, (int)NuberOfDayes, (float)float1); await Sqldatabasethrding.SqlSaveVitl(CouresNew.adder()); dataGridViewX1.Rows[i].DefaultCellStyle.BackColor = Color.Green; } else { dataGridViewX1.Rows[i].DefaultCellStyle.BackColor = Color.Red; } } else { dataGridViewX1.Rows[i].DefaultCellStyle.BackColor = Color.Yellow; } labelX2.Text = ((stopwatch.ElapsedMilliseconds * (dataGridViewX1.Rows.Count - i)) / 1000).ToString(); } } catch (NoColumnsException ex) { ErrorClass.SaveErrorFile(ex); MessageBox.Show(string.Format(" لا يوجد عامود {0} ", ex.Message)); } catch (Exception ex) { ErrorClass.SaveErrorFile(ex); } buttonX3.Enabled = true; Workin = false; dataGridViewX1.Enabled = true; }