/// <summary> /// /// </summary> public static async Task <List <object> > GetvitlByid(System.Data.SqlClient.SqlCommand SqlCommand1) { List <object> object1 = new List <object>(); await openConction(); SqlCommand1.Connection = Sqldatabasethrding.SqlConnection1; SqlDataReader SqlDataReader1 = SqlCommand1.ExecuteReader(); try { if (SqlDataReader1.Read()) { for (int i = 0; i < SqlDataReader1.FieldCount; i++) { object1.Add(SqlDataReader1.GetValue(i)); } } } catch (Exception e) { ErrorClass.SaveErrorFile(e); } finally { SqlDataReader1.Close(); } return(object1); }
public static async Task <bool> RetHaveVitelACtiv(int ID_informtion) { System.Data.SqlClient.SqlCommand Sqlcom = new System.Data.SqlClient.SqlCommand("SELECT [Id] FROM [HR_SARC].[dbo].[Team_ta] where [ID_informtion] = @ID_informtion and [Delete] = 0 and Date_End is null"); Sqlcom.Parameters.AddWithValue("ID_informtion", ID_informtion); await Sqldatabasethrding.openConction(); Sqlcom.Connection = Sqldatabasethrding.SqlConnection1; System.Data.SqlClient.SqlDataReader Rader = await Sqlcom.ExecuteReaderAsync(); try { while (await Rader.ReadAsync()) { return(true); } } catch (Exception e) { ErrorClass.SaveErrorFile(e); } finally { Rader.Close(); } return(false); }
public static async Task <bool> SqlSaveVitl(SqlCommand Sqlcommand1) { if (await openConction()) { try { Sqlcommand1.Connection = Sqldatabasethrding.SqlConnection1; await Sqlcommand1.ExecuteNonQueryAsync(); return(true); } catch (Exception e) { ErrorClass.SaveErrorFile(e); MessageBox.Show(e.ToString()); return(false); } } else { ErrorClass.SaveErrorFile(new Exception("لا يوجد إتصال")); MessageBox.Show("لا يوجد إتصال"); return(false); } }
public static async System.Threading.Tasks.Task <int> Serch(string ByIdArchev) { ByIdArchev = ClassDataGridViewDo.Trimall(ByIdArchev); System.Data.SqlClient.SqlCommand Sqlcom = new System.Data.SqlClient.SqlCommand(""); Sqlcom.CommandText = "SELECT [HR_SARC]. dbo.CV_Info.id , [HR_SARC].dbo.CV_Info.NmuberOfArchev , [HR_SARC]. dbo.CV_Study.Sampl FROM [HR_SARC].dbo.CV_Info INNER JOIN [HR_SARC].dbo.CV_Study on [HR_SARC].[dbo].CV_Info.Id_Study = [HR_SARC].[dbo].CV_Study.id WHERE [HR_SARC].dbo.CV_Study.Sampl + CAST( [HR_SARC].dbo.CV_Info.NmuberOfArchev as nvarchar) like @ByIdArchev "; Sqlcom.Parameters.AddWithValue("@ByIdArchev", ByIdArchev); List <CV_Info> Ve = new List <CV_Info>(); List <List <object> > Ob = await Sqldatabasethrding.GetSql(Sqlcom); for (int i = 0; i < Ob.Count; i++) { if (Ob[i].Count != 0) { try { return(Convert.ToInt32(Ob[i][0])); } catch (Exception e) { ErrorClass.SaveErrorFile(e); } } } return(-1); }
public AssingDateGetWebSite() { InitializeComponent(); try { DownloadDataFromWebCliend.LoginSet("m5524512", "m5524512"); } catch (Exception e) { ErrorClass.SaveErrorFile(e, true); } }
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; }
private void UserAndNameAdderingToWebSite_Load(object sender, EventArgs e) { try { DownloadDataFromWebCliend.LoginSet("m5524512", "m5524512"); } catch (Exception ex) { ErrorClass.SaveErrorFile(ex, true); this.Close(); } UserNameGetWebSite1 = DownloadDataFromWebCliend.GetInfrmationofdateGet(); ClassDataGridViewDo.DataGridAddVuleComBoxEx(comboBoxEx2, Valuationname.Valuationnamelist); ClassDataGridViewDo.DataGridAddVuleComBoxEx(comboBoxEx1, UserNameGetWebSite1); }
/// <summary> /// إرسال أمر SQl /// وإرجعه على شكل مصفوفتين كائنات /// </summary> /// <param name="SqlCommand1">أمر SQL</param> /// <returns>ليست بداخل ليست Object</returns> public static async Task <List <List <object> > > GetSql(System.Data.SqlClient.SqlCommand SqlCommand1) { List <object> object1 = new List <object>(); List <List <object> > object2 = new List <List <object> >(); if (await openConction()) { SqlCommand1.Connection = Sqldatabasethrding.SqlConnection1; SqlDataReader SqlDataReader1 = null; try { SqlDataReader1 = SqlCommand1.ExecuteReader(); while (await SqlDataReader1.ReadAsync()) { for (int i = 0; i < SqlDataReader1.FieldCount; i++) { object1.Add(SqlDataReader1.GetValue(i)); } object2.Add(object1); object1 = new List <object>(); } } catch (Exception e) { ErrorClass.SaveErrorFile(e); } finally { SqlDataReader1.Close(); SqlDataReader1.Dispose(); } return(object2); } else { return(object2); } }
public static async Task <bool> openConction() { try { if (Sqldatabasethrding.SqlConnection1.State != System.Data.ConnectionState.Open) { SqlConnection1.Close(); SqlConnection1.ConnectionString = sqlconction; await Sqldatabasethrding.SqlConnection1.OpenAsync(); } else { } } catch (Exception e) { ErrorClass.SaveErrorFile(e); return(false); } return(true); }
public static async Task SqlupdataVitl(SqlCommand Sqlcommand1) { await openConction(); try { // IAsyncResult result = Sqlcommand1.BeginExecuteNonQuery(); Sqlcommand1.Connection = Sqldatabasethrding.SqlConnection1; Sqlcommand1.ExecuteNonQuery(); } catch (Exception e) { ErrorClass.SaveErrorFile(e); MessageBox.Show(e.ToString()); } finally { } }
public static async Task <int> SqlSaveAdderAndBack(SqlCommand Vitl) { await openConction(); try { // IAsyncResult result = Sqlcommand1.BeginExecuteNonQuery(); Vitl.Connection = Sqldatabasethrding.SqlConnection1; return((int)Vitl.ExecuteScalar()); } catch (Exception e) { ErrorClass.SaveErrorFile(e); MessageBox.Show(e.ToString()); } finally { } return(0); }
public static async Task <bool> SaveOrUpdeataDataBase(SqlCommand Sqlcommand1) { await openConction(); try { Sqlcommand1.Connection = Sqldatabasethrding.SqlConnection1; Sqlcommand1.ExecuteNonQuery(); } catch (Exception e) { ErrorClass.SaveErrorFile(e); return(false); } finally { } return(true); }
public static async Task SaveNewAssing(Valuationname valuationname1) { SqlCommand Sqlcommand1 = valuationname1.adder(); await openConction(); try { // IAsyncResult result = Sqlcommand1.BeginExecuteNonQuery(); Sqlcommand1.Connection = Sqldatabasethrding.SqlConnection1; valuationname1.id = ((int)await Sqlcommand1.ExecuteScalarAsync()); } catch (Exception e) { ErrorClass.SaveErrorFile(e); MessageBox.Show(e.ToString()); } finally { } }
public static async void SqlSaveAdderAndBack(Vitl Vitl) { SqlCommand Sqlcommand1 = Vitl.adder(); await openConction(); try { // IAsyncResult result = Sqlcommand1.BeginExecuteNonQuery(); Sqlcommand1.Connection = Sqldatabasethrding.SqlConnection1; Vitl.ChanId((int)Sqlcommand1.ExecuteScalar()); } catch (Exception e) { ErrorClass.SaveErrorFile(e); MessageBox.Show(e.ToString()); } finally { } }
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; }
public static async System.Threading.Tasks.Task <List <CV_Info> > Serch(string Fullname, string Notes, int Id_Study, int Year_sutr, int ID_TemaNeed, bool Chek, int NumberPhone, string CodeForCV, int SelectTeamOut, string NotesOut) { String Where = ""; List <CV_Info> Ve = new List <CV_Info>(); Fullname = ClassDataGridViewDo.LograthemChangEverAleffToAll(Fullname, true); System.Data.SqlClient.SqlCommand Sqlcom = new System.Data.SqlClient.SqlCommand("SELECT [id] ,[FullName] ,[Notes] ,[NmuberOfArchev] ,[Id_Study] ,[Year_sutr],[Numberphone] ,[Date],[ID_TemaNeed] ,[Bit] ,[ToOutTeam] , [ToOutDate] , [Notesout],[Delete] FROM [HR_SARC].[dbo].[CV_Info] where [Delete] =0 and [FullName] = @FullName " + Where); if (Notes.Trim() != "") { Where += " and [Notes] like @Notes"; Sqlcom.Parameters.AddWithValue("@Notes", "%" + ClassDataGridViewDo.LograthemChangEverAleffToAll(Notes) + "%"); } if (Id_Study != -1) { Where += " and [Id_Study] = @Id_Study"; Sqlcom.Parameters.AddWithValue("Id_Study", Id_Study); } if (Year_sutr != -1) { Where += " and [Year_sutr] = @Year_sutr"; Sqlcom.Parameters.AddWithValue("Year_sutr", Year_sutr); } if (ID_TemaNeed != -1) { Where += " and [ID_TemaNeed] = @ID_TemaNeed"; Sqlcom.Parameters.AddWithValue("ID_TemaNeed", ID_TemaNeed); } if (Chek) { Where += " and [Bit] = @Bit"; Sqlcom.Parameters.AddWithValue("Bit", !Chek); } if (NumberPhone != 0) { Where += " and [Numberphone] = @Numberphone"; Sqlcom.Parameters.AddWithValue("Numberphone", NumberPhone); } if (SelectTeamOut != -1) { Where += " and [ToOutTeam] = @ToOutTeam"; Sqlcom.Parameters.AddWithValue("ToOutTeam", SelectTeamOut); } if (NotesOut.Trim() != "") { Where += " and [Notesout] like @Notesout"; Sqlcom.Parameters.AddWithValue("Notesout", "%" + ClassDataGridViewDo.LograthemChangEverAleffToAll(NotesOut, true) + "%"); } Sqlcom.CommandText = "SELECT [id] ,[FullName] ,[Notes] ,[NmuberOfArchev] ,[Id_Study] ,[Year_sutr],[Numberphone] ,[Date],[ID_TemaNeed] ,[Bit] ,[ToOutTeam] , [ToOutDate] , [Notesout],[Delete] FROM [HR_SARC].[dbo].[CV_Info] where [Delete] =0 and [FullName] like @FullName " + Where; Sqlcom.Parameters.AddWithValue("@FullName", "%" + Fullname + "%"); if (CodeForCV != "") { Sqlcom.CommandText = "SELECT [id] ,[FullName] ,[Notes] ,[NmuberOfArchev] ,[Id_Study] ,[Year_sutr],[Numberphone] ,[Date],[ID_TemaNeed] ,[Bit] ,[ToOutTeam] , [ToOutDate] , [Notesout],[Delete] FROM [HR_SARC].[dbo].[CV_Info] where [Delete] =0 and [id] = @id "; Sqlcom.Parameters.AddWithValue("id", await CV_Info.Serch(CodeForCV)); } List <List <object> > Ob = await Sqldatabasethrding.GetSql(Sqlcom); for (int i = 0; i < Ob.Count; i++) { if (Ob[i].Count != 0) { try { Ve.Add(new CV_Info( Convert.ToInt32(Ob[i][0]), Convert.ToString(Ob[i][1]), Convert.ToString(Ob[i][2]), Convert.ToInt32(Ob[i][3]), Convert.ToInt32(Ob[i][4]), Convert.ToInt32(Ob[i][5]), Convert.ToInt32(Ob[i][6]), ClassConvert.ConvDateTimeNull(Ob[i][7]), Convert.ToInt32(Ob[i][8]), Convert.ToBoolean(Ob[i][9]), -1, null, null )); } catch (Exception e) { ErrorClass.SaveErrorFile(e); } } } return(Ve); }
public static async Task <bool> GetIsItHaveCouresByIdInformation(int idinformation, int idCoures, bool IsId = false, bool DotHave = false) { if (idinformation <= 0) { return(false); } string Op = ""; foreach (NameOfCouress Name in NameOfCouress.NameOfCouresslist) { if (IsId) { if (Name.Id_TypeofCouress_ta == idCoures) { Op += " id_NameOfCouress = " + Name.id.ToString() + " Or"; } } else { if (Name.Id_TypeofCouress_ta == TypeofCouress.TypeofCouressList[idCoures].id) { Op += " id_NameOfCouress = " + Name.id.ToString() + " Or"; } } } Op = Op.Remove(Op.Length - 3, 3); StringSelect = Op; System.Data.SqlClient.SqlCommand SqlCommand1 = new System.Data.SqlClient.SqlCommand(String.Format("SELECT id FROM [HR_SARC].[dbo].[Couress_ta] where [Id_Information]= @Id_Information and {0} and ({1}) {2} ", "[Delete] = 0 ", Op, "and [Result] > " + RetultSect)); SqlCommand1.Parameters.AddWithValue("Id_Information", idinformation); SqlCommand1.Connection = Sqldatabasethrding.SqlConnection1; System.Data.SqlClient.SqlDataReader Reader = await SqlCommand1.ExecuteReaderAsync(); try{ if (await Reader.ReadAsync()) { if (!DotHave) { return(true); } else { return(false); } } else { if (!DotHave) { return(false); } else { return(true); } } }catch (Exception e) { ErrorClass.SaveErrorFile(e); } finally{ Reader.Close(); } if (!DotHave) { return(false); } else { return(true); } }