public string GetAnalysesList(GmConnection conn)
        {
            StringBuilder sb  = new StringBuilder();
            GmCommand     cmd = conn.CreateCommand(
                @"select RequestDate, Name from Analyses 
left join AnalysisTypes on AnalysisTypes.Id=AnalysisTypeId
where PatientId=@Id");

            cmd.AddInt("Id", id);
            using (DbDataReader dr = cmd.ExecuteReader())
            {
                while (dr.Read())
                {
                    int      i    = 0;
                    DateTime dt   = dr.GetDateTime(i++);
                    string   name = dr.GetString(i++);
                    if (sb.Length > 0)
                    {
                        sb.Append("; ");
                    }
                    sb.AppendFormat("{0:dd.MM} {1}", dt, name);
                }
            }
            if (sb.Length > 0)
            {
                sb.Append(".");
            }
            return(sb.ToString());
        }
Exemple #2
0
        public void Load(Context context)
        {
            if (ranges != null)
            {
                throw new Exception("Ranges already loaded.");
            }
            GmCommand cmd = context.Conn.CreateCommandById("selectCountFromGisRangesWhereTypeId");

            cmd.AddInt("TypeId", id);
            int count = (int)cmd.ExecuteScalar();

            ranges = new List <GRange>(count);
            if (count > 0)
            {
                cmd = context.Conn.CreateCommandById("selectAllFromGisRangesWhereTypeId");
                cmd.AddInt("TypeId", id);
                using (IDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        GRange range = new GRange(context, this, dr);
                    }
                }
            }
        }
Exemple #3
0
        void LoadLib(Context context)
        {
            int[]     indexerCode;
            GmCommand cmd = context.Conn.CreateCommandById("selectAllFromGisLibWhereId");

            cmd.AddInt("Id", Constants.currentLib);
            using (IDataReader dr = cmd.ExecuteReader())
            {
                if (!dr.Read())
                {
                    throw new GeoLibException("Lib record not found.");
                }
                attr = dr.GetInt32((int)LibField.Attr);
                name = dr.GetString((int)LibField.Name);
//      DZ  16.01.09
//                context.SetStyle(dr.GetString((int)LibField.Style),ref styleStr,ref style);
                context.SetStyle(dr.IsDBNull((int)LibField.Style) ? "" : dr.GetString((int)LibField.Style), ref styleStr, ref style);
//				context.SetStyle(dr.GetString((int)LibField.DefaultStyle),ref defaultStyleStr,ref defaultStyle.style);
                context.SetStyle(dr.IsDBNull((int)LibField.DefaultStyle) ? "" : dr.GetString((int)LibField.DefaultStyle), ref defaultStyleStr, ref defaultStyle);
                smin          = dr.GetInt32((int)LibField.SMin);
                smax          = dr.GetInt32((int)LibField.SMax);
                bounds        = context.Buf.GetRect(dr, (int)LibField.Code);
                indexerCode   = context.Buf.GetIntArray(dr, (int)LibField.IndexerCode);
                scales.Values = context.Buf.GetIntArray(dr, (int)LibField.Scales);
            }
            if (scales.Count == 0)
            {
                scales.InitScales();
            }
            id      = Constants.currentLib;
            indexer = new Indexer(indexerCode);
        }
        public static string GetTreatment(GmConnection conn, int patientId)
        {
/*			string cmdText = @"select Medicaments.Name from Prescriptions
 * left join StoreProducts on StoreProducts.Id=StoreProductId
 * left join Products on Products.Id=ProductId
 * left join Medicaments on Medicaments.Id=MedicamentId
 * where PatientId=@PatientId";*/
            string    cmdText = @"select MedicamentGroups.Name from Prescriptions 
left join StoreProducts on StoreProducts.Id=StoreProductId
left join Products on Products.Id=ProductId
left join MedicamentGroupTies on MedicamentGroupTies.MedicamentId=Products.MedicamentId
left join MedicamentGroups on MedicamentGroups.Id=MedicamentGroupId
where PatientId=@PatientId";
            GmCommand cmd     = conn.CreateCommand(cmdText);

            cmd.AddInt("PatientId", patientId);
            List <string> list = new List <string>();

            using (DbDataReader dr = cmd.ExecuteReader())
            {
                while (dr.Read())
                {
                    string s = dr.GetString(0);
                    if (!list.Contains(s))
                    {
                        list.Add(s);
                    }
                }
            }
            list.Sort();
            return(Geomethod.CollectionUtils.GetCommaSeparatedList <string>(list));
        }
Exemple #5
0
 public void Load(Context context)
 {
     if (objects != null)
     {
         return;
     }
     lock (this)
     {
         if (objects != null)
         {
             return;
         }
         GmCommand cmd = context.Conn.CreateCommandById("selectCountFromGisObjectsWhereRangeId");
         cmd.AddInt("RangeId", id);
         int count = (int)cmd.ExecuteScalar();
         objects = new List <GObject>(count);
         if (count > 0)
         {
             cmd = context.Conn.CreateCommandById("selectAllFromGisObjectsWhereRangeId");
             cmd.AddInt("RangeId", id);
             using (IDataReader dr = cmd.ExecuteReader())
             {
                 while (dr.Read())
                 {
                     GObject.Create(context, this, dr, true);
                 }
             }
         }
     }
 }
Exemple #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        log = MainMasterPage.InitPage(this);
        int forumTopicId = RequestUtils.GetForumTopicId(this);

        this.SqlDataSource1.SelectParameters["ForumTopicId"].DefaultValue = forumTopicId.ToString();
        try
        {
            string cmdText = "SELECT Forums.Id AS ForumId, Forums.Name AS ForumName, ForumTopics.Name AS ForumTopicName FROM Forums INNER JOIN   ForumTopics ON Forums.Id = ForumTopics.ForumId WHERE (ForumTopics.Id = @ForumTopicId)";
            using (GmConnection conn = Global.CreateConnection())
            {
                GmCommand cmd = conn.CreateCommand(cmdText);
                cmd.AddInt("ForumTopicId", forumTopicId);
                using (GmDataReader dr = cmd.ExecuteReader())
                {
                    if (dr.Read())
                    {
                        forumId        = dr.GetInt();
                        forumName      = dr.GetString();
                        forumTopicName = dr.GetString();
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }
        catch (Exception ex)
        {
            log.Exception(ex);
        }
    }
        public bool IsMultyLoginDenied()
        {
            bool denied = false;

            if (UserId != 0)
            {
                using (GmConnection conn = App.ConnectionFactory.CreateConnection())
                {
                    GmCommand cmd = conn.CreateCommand("select MultiLoginFlag, lastupdate, GETDATE() from [User] where UserCode=@UserCode");
                    cmd.AddInt("UserCode", UserId);
                    using (IDataReader dr = cmd.ExecuteReader())
                    {
                        if (dr.Read())
                        {
                            int  i = 0;
                            bool multiLoginFlag = dr.GetBoolean(i++);
                            if (multiLoginFlag)
                            {
                                DateTime lastUpdate = dr.GetDateTime(i++);
                                DateTime curTime    = dr.GetDateTime(i++);
                                TimeSpan ts         = curTime - lastUpdate;
                                denied = ts.TotalMilliseconds < this.config.PollTime * 2;                           //+config.CommandTimeout*1000
                            }
                        }
                    }
                }
            }
            return(denied);
        }
        public static List <Analysis> GetAnalyses(GmConnection conn, int patientId)
        {
            List <Analysis> list = new List <Analysis>();
            GmCommand       cmd  = conn.CreateCommand("select * from Analyses where PatientId=@PatientId");

            cmd.AddInt("PatientId", patientId);
            using (DbDataReader dr = cmd.ExecuteReader())
            {
                list.Add(new Analysis(dr));
            }
            return(list);
        }
Exemple #9
0
        public static void GetPrescriptionTypes(GmConnection conn, List <PrescriptionType> list)
        {
            GmCommand cmd = conn.CreateCommand("select * from PrescriptionTypes");

            using (DbDataReader dr = cmd.ExecuteReader())
            {
                while (dr.Read())
                {
                    list.Add(new PrescriptionType(dr));
                }
            }
        }
Exemple #10
0
        public static void GetRoles(GmConnection conn, Dictionary <int, Role> roles)
        {
            GmCommand cmd = conn.CreateCommand("select * from Roles");

            using (DbDataReader dr = cmd.ExecuteReader())
            {
                while (dr.Read())
                {
                    Role role = new Role(dr);
                    roles.Add(role.id, role);
                }
            }
        }
        public static ConfigRecord GetLastConfigRecord(GmConnection conn)
        {
            GmCommand cmd = conn.CreateCommand("select top 1 * from ConfigRecords order by Id desc");

            using (DbDataReader dr = cmd.ExecuteReader())
            {
                if (dr.Read())
                {
                    return(new ConfigRecord(dr));
                }
            }
            return(null);
        }
        public static void GetUsers(GmConnection conn, Dictionary <int, User> users)
        {
            GmCommand cmd = conn.CreateCommand("select * from Users");

            using (DbDataReader dr = cmd.ExecuteReader())
            {
                while (dr.Read())
                {
                    User user = new User(dr);
                    users.Add(user.Id, user);
                }
            }
        }
Exemple #13
0
        public string GetInsuranceCompanyName(GmConnection conn)
        {
            GmCommand cmd = conn.CreateCommand("select Name from InsuranceCompanies where Id=@Id");

            cmd.AddInt("Id", insuranceCompanyId);
            using (DbDataReader dr = cmd.ExecuteReader())
            {
                if (dr.Read())
                {
                    return(dr.GetString(0));
                }
            }
            return("");
        }
        public static User GetUser(GmConnection conn, string login)
        {
            GmCommand cmd = conn.CreateCommand("select * from Users where Login=@Login");

            cmd.AddString("Login", login);
            using (DbDataReader dr = cmd.ExecuteReader())
            {
                if (dr.Read())
                {
                    return(new User(dr));
                }
            }
            return(null);
        }
    public static Article GetArticle(GmConnection conn, string tag)
    {
        GmCommand cmd = conn.CreateCommand("select * from Articles where Tag=@Tag");

        cmd.AddString("Tag", tag);
        using (GmDataReader dr = cmd.ExecuteReader())
        {
            if (dr.Read())
            {
                return(new Article(dr));
            }
        }
        return(null);
    }
Exemple #16
0
        public static Watching GetLastTakingWatching(GmConnection conn, int userId)
        {
            GmCommand cmd = conn.CreateCommand("select top 1 * from Watching where UserId=@UserId and EndTime is null");

            cmd.AddInt("UserId", userId);
            using (DbDataReader dr = cmd.ExecuteReader())
            {
                if (dr.Read())
                {
                    return(new Watching(dr));
                }
            }
            return(null);
        }
Exemple #17
0
        public static Employee GetEmployee(GmConnection conn, int id)
        {
            GmCommand cmd = conn.CreateCommand("select * from Employees where Id=@Id");

            cmd.AddInt("Id", id);
            using (DbDataReader dr = cmd.ExecuteReader())
            {
                if (dr.Read())
                {
                    return(new Employee(dr));
                }
            }
            return(null);
        }
Exemple #18
0
    public static void GetArticleParams(GmConnection conn, int articleId, System.Collections.Specialized.StringDictionary sd)
    {
        GmCommand cmd = conn.CreateCommand("select [Key], [Value] from ArticleParams where ArticleId=@ArticleId");

        cmd.AddInt("ArticleId", articleId);
        using (GmDataReader dr = cmd.ExecuteReader())
        {
            while (dr.Read())
            {
                var key = dr.GetString();
                var val = dr.GetString();
                sd[key] = val;
            }
        }
    }
Exemple #19
0
        public static Employee GetEmployee(GmConnection conn, string login, string password)
        {
            GmCommand cmd = conn.CreateCommand("select * from Employees where Login=@Login and Password=@Password");

            cmd.AddString("Login", login);
            cmd.AddString("Password", password);
            using (DbDataReader dr = cmd.ExecuteReader())
            {
                if (dr.Read())
                {
                    return(new Employee(dr));
                }
            }
            return(null);
        }
Exemple #20
0
        public static int GetDiagnoses(GmConnection conn, Dictionary <int, Diagnosis> diagnoses)
        {
            GmCommand cmd = conn.CreateCommand("select * from Diagnoses");

//            cmd.AddInt("Id", id);
            using (DbDataReader dr = cmd.ExecuteReader())
            {
                while (dr.Read())
                {
                    Diagnosis diagnosis = new Diagnosis(dr);
                    diagnoses.Add(diagnosis.Id, diagnosis);
                }
            }
            return(diagnoses.Count);
        }
        public static int GetMedicaments(GmConnection conn, List <Medicament> medicaments)
        {
            GmCommand cmd   = conn.CreateCommand("select * from Medicaments");
            int       count = 0;

            using (DbDataReader dr = cmd.ExecuteReader())
            {
                while (dr.Read())
                {
                    Medicament med = new Medicament(dr);
                    medicaments.Add(med);
                    count++;
                }
            }
            return(count);
        }
Exemple #22
0
        public static PrescriptionType GetPrescriptionType(GmConnection conn, int id)
        {
            if (id == 0)
            {
                return(null);
            }
            GmCommand cmd = conn.CreateCommand("select * from PrescriptionTypes where Id=@Id");

            cmd.AddInt("Id", id);
            using (DbDataReader dr = cmd.ExecuteReader())
            {
                if (dr.Read())
                {
                    return(new PrescriptionType(dr));
                }
            }
            return(null);
        }
Exemple #23
0
    public static LinkExchangePage GetLinkExchangePage(GmConnection conn, int id)
    {
        if (id == 0)
        {
            return(null);
        }
        GmCommand cmd = conn.CreateCommand("select * from LinkExchange where Id=@Id");

        cmd.AddInt("Id", id);
        using (DbDataReader dr = cmd.ExecuteReader())
        {
            if (dr.Read())
            {
                return(new LinkExchangePage(dr));
            }
        }
        return(null);
    }
        public static Medicament GetMedicament(GmConnection conn, int id)
        {
            if (id == 0)
            {
                return(null);
            }
            GmCommand cmd = conn.CreateCommand("select * from Medicaments where Id=@Id");

            cmd.AddInt("Id", id);
            using (DbDataReader dr = cmd.ExecuteReader())
            {
                if (dr.Read())
                {
                    return(new Medicament(dr));
                }
            }
            return(null);
        }
Exemple #25
0
    public static Candidate GetCandidate(GmConnection conn, int id)
    {
        if (id == 0)
        {
            return(null);
        }
        GmCommand cmd = conn.CreateCommand("select * from Candidates where Id=@Id");

        cmd.AddInt("Id", id);
        using (GmDataReader dr = cmd.ExecuteReader())
        {
            if (dr.Read())
            {
                return(new Candidate(dr));
            }
        }
        return(null);
    }
Exemple #26
0
        public static ExpertBoard GetExpertBoard(GmConnection conn, int id)
        {
            if (id == 0)
            {
                return(null);
            }
            GmCommand cmd = conn.CreateCommand("select * from ExpertBoards where Id=@Id");

            cmd.AddInt("Id", id);
            using (DbDataReader dr = cmd.ExecuteReader())
            {
                if (dr.Read())
                {
                    return(new ExpertBoard(dr));
                }
            }
            return(null);
        }
Exemple #27
0
    public static Gallery GetGallery(GmConnection conn, int id)
    {
        if (id == 0)
        {
            return(null);
        }
        GmCommand cmd = conn.CreateCommand("select * from Galleries where Id=@Id");

        cmd.AddInt("Id", id);
        using (DbDataReader dr = cmd.ExecuteReader())
        {
            if (dr.Read())
            {
                return(new Gallery(dr));
            }
        }
        return(null);
    }
Exemple #28
0
    public static UserInfo GetUserInfo(GmConnection conn, int id)
    {
        if (id == 0)
        {
            return(null);
        }
        GmCommand cmd = conn.CreateCommand("select * from UserInfo where Id=@Id");

        cmd.AddInt("Id", id);
        using (DbDataReader dr = cmd.ExecuteReader())
        {
            if (dr.Read())
            {
                return(new UserInfo(dr));
            }
        }
        return(null);
    }
//		public int Age { get { return birthday != DateTime.MinValue ? DateTimeUtils.Age(birthday) : -1; } }

        #region Construction
        public static PatientIdentification GetPatientIdentification(GmConnection conn, int id)
        {
            if (id == 0)
            {
                return(null);
            }
            GmCommand cmd = conn.CreateCommand("select * from PatientIdentifications where Id=@Id");

            cmd.AddInt("Id", id);
            using (DbDataReader dr = cmd.ExecuteReader())
            {
                if (dr.Read())
                {
                    return(new PatientIdentification(dr));
                }
            }
            return(null);
        }
Exemple #30
0
    public static ArticleParam GetArticleParam(GmConnection conn, int id)
    {
        if (id == 0)
        {
            return(null);
        }
        GmCommand cmd = conn.CreateCommand("select * from ArticleParams where Id=@Id");

        cmd.AddInt("Id", id);
        using (GmDataReader dr = cmd.ExecuteReader())
        {
            if (dr.Read())
            {
                return(new ArticleParam(dr));
            }
        }
        return(null);
    }