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); }
private async Task readFromDataReader(TNDMetaEntity metaEntity, List <TNDEntityItem> result, System.Data.SqlClient.SqlDataReader sqlDataReader) { // loop over NextResult bool next = true; while (next) { var fieldCount = sqlDataReader.FieldCount; string[] names = new string[fieldCount]; Type[] types = new Type[fieldCount]; TNDPropertyCache[] caches = new TNDPropertyCache[fieldCount]; object[] values = new object[fieldCount]; int idxMetaEntityName = -1; for (int idx = 0; idx < fieldCount; idx++) { names[idx] = sqlDataReader.GetName(idx); types[idx] = sqlDataReader.GetFieldType(idx); caches[idx] = new TNDPropertyCache(); if (string.Equals(names[idx], "MetaEntityName", StringComparison.Ordinal)) { idxMetaEntityName = idx; } } // loop over Read bool read = true; while (read) { var taskReadAsync = sqlDataReader.ReadAsync(); try { read = await taskReadAsync; } catch (Exception exception) { throw; } if (read) { sqlDataReader.GetValues(values); var item = new TNDEntityItem(); for (int idx = 0; idx < fieldCount; idx++) { if (idx == idxMetaEntityName) { item.MetaEntityName = values[idx] as string; } else { var property = new TNDProperty(names[idx], types[idx], values[idx]); if (caches[idx] != null) { property = caches[idx].GetOrCreate(property); } item.Property.Add(property); } } if (item.MetaEntityName != null) { item.MetaEntity = this._ApplicationBuis.ApplicationModel.Configuration.FindMetaEntity(item.MetaEntityName); } if (item.MetaEntity == null) { item.MetaEntity = metaEntity; item.MetaEntityName = metaEntity.MetaEntityName; } result.Add(item); } } var taskNextResult = sqlDataReader.NextResultAsync(); try { next = await taskNextResult; } catch (Exception exception) { throw; } } }
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); } }