예제 #1
0
        private static bool udtFile(AccDbConnection con, Files file)
        {
            bool ret = false;

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                StringBuilder udtSQL = new StringBuilder();
                udtSQL.Append("UPDATE");
                udtSQL.Append(" Files");
                udtSQL.Append(" SET");
                udtSQL.Append(" order_id=" + cmd.Add(file.OrderID).ParameterName);
                udtSQL.Append(",seq=" + cmd.Add(file.Seq).ParameterName);
                udtSQL.Append(",isorigin=" + cmd.Add(file.IsOrigin).ParameterName);
                udtSQL.Append(",name=" + cmd.Add(file.Name).ParameterName);
                udtSQL.Append(" WHERE");
                udtSQL.Append(" id=");
                udtSQL.Append(cmd.Add(file.FileID).ParameterName);

                cmd.CommandText = udtSQL.ToString();

                var retcnt = cmd.ExecuteNonQuery();
                if (retcnt > 0)
                {
                    ret = true;
                }
            }

            return(ret);
        }
예제 #2
0
        private static bool udtPatient(AccDbConnection con, Patient patient)
        {
            bool ret = false;

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                StringBuilder udtSQL = new StringBuilder();
                udtSQL.Append("UPDATE");
                udtSQL.Append(" Patient");
                udtSQL.Append(" SET");
                udtSQL.Append(" hospid=" + cmd.Add(patient.HospID).ParameterName);
                udtSQL.Append(",patid=" + cmd.Add(patient.PatID).ParameterName);
                udtSQL.Append(",patname=" + cmd.Add(patient.PatName).ParameterName);
                udtSQL.Append(",patname_h=" + cmd.Add(patient.PatName_H).ParameterName);
                udtSQL.Append(",patname_r=" + cmd.Add(patient.PatName_R).ParameterName);
                udtSQL.Append(",patsex=" + cmd.Add(patient.Sex).ParameterName);
                udtSQL.Append(",patbirth=" + cmd.Add(patient.BirthDay).ParameterName);
                udtSQL.Append(" WHERE");
                udtSQL.Append(" key=");
                udtSQL.Append(cmd.Add(patient.Key).ParameterName);

                cmd.CommandText = udtSQL.ToString();

                var retcnt = cmd.ExecuteNonQuery();
                if (retcnt > 0)
                {
                    ret = true;
                }
            }

            return(ret);
        }
예제 #3
0
        private static HospMst getHosp(AccDbConnection con, int id)
        {
            HospMst ret = new HospMst();

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                // SQL生成
                // ----------------------------
                // SELECT H.id, H.name, H.cd, H.seq
                // FROM M_Hosp As H
                // INNER JOIN HospUser HU
                // ON H.id = HU.hosp_id
                // WHERE user_id=id
                // ORDER BY H.seq ASC
                // ----------------------------
                StringBuilder selSQL = new StringBuilder();
                selSQL.Append("SELECT");
                selSQL.Append(" H.id");
                selSQL.Append(",H.name");
                selSQL.Append(",H.cd");
                selSQL.Append(",H.seq");
                selSQL.Append(",H.visible");
                selSQL.Append(" FROM");
                selSQL.Append(" M_Hosp As H");
                selSQL.Append(" INNER JOIN");
                selSQL.Append(" HospUser HU");
                selSQL.Append(" ON");
                selSQL.Append(" H.id = HU.hosp_id");
                selSQL.Append(" WHERE");
                selSQL.Append(" user_id=");
                selSQL.Append(cmd.Add(id).ParameterName);
                selSQL.Append(" ORDER BY");
                selSQL.Append(" H.seq");
                selSQL.Append(" ASC");

                cmd.CommandText = selSQL.ToString();

                // SQL実行
                using (var dr = cmd.ExecuteReader())
                    // 該当データがある場合、返却値を設定
                    if (dr.Read())
                    {
                        ret.HospID = Convert.ToInt32(dr["id"]);
                        ret.CD     = dr["cd"].ToString();
                        if (dr["name"] != DBNull.Value)
                        {
                            ret.Name = dr["name"].ToString();
                        }
                        ret.Seq     = Convert.ToInt32(dr["seq"]);
                        ret.Visible = Convert.ToInt32(dr["visible"]);
                    }
            }

            return(ret);
        }
예제 #4
0
        private static int setPatient(AccDbConnection con, Patient patient)
        {
            int ret = 0;

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                StringBuilder insSQL = new StringBuilder();
                insSQL.Append("INSERT");
                insSQL.Append(" INTO");
                insSQL.Append(" Patient");

                insSQL.Append(" (");
                insSQL.Append(" hospid");
                insSQL.Append(",patid");
                insSQL.Append(",patname");
                insSQL.Append(",patname_h");
                insSQL.Append(",patname_r");
                insSQL.Append(",patsex");
                insSQL.Append(",patbirth");
                insSQL.Append(" )");

                insSQL.Append(" VALUES");

                insSQL.Append(" (");
                insSQL.Append(cmd.Add(patient.HospID).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(patient.PatID).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(patient.PatName).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(patient.PatName_H).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(patient.PatName_R).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(patient.Sex).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(patient.BirthDay).ParameterName);
                insSQL.Append(" )");

                insSQL.Append(" RETURNING");
                insSQL.Append(" key");

                cmd.CommandText = insSQL.ToString();

                // SQL実行
                using (var dr = cmd.ExecuteReader())
                    // 該当データがある場合、返却値を設定
                    if (dr.Read())
                    {
                        ret = Convert.ToInt32(dr["key"]);
                    }
            }

            return(ret);
        }
예제 #5
0
        private static UserMst[] getUserList(AccDbConnection con, int hosp_id)
        {
            List <UserMst> ret = new List <UserMst>();

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                // SQL生成
                // ----------------------------
                // SELECT U.id, U.login_id, U.name, U.permission
                // FROM M_User As U
                // INNER JOIN HospUser HU
                // ON U.id = HU.user_id
                // WHERE hosp_id=hosp_id
                // ----------------------------
                StringBuilder selSQL = new StringBuilder();
                selSQL.Append("SELECT");
                selSQL.Append(" U.id");
                selSQL.Append(",U.login_id");
                selSQL.Append(",U.name");
                selSQL.Append(",U.permission");
                selSQL.Append(" FROM");
                selSQL.Append(" M_User As U");
                selSQL.Append(" INNER JOIN");
                selSQL.Append(" HospUser HU");
                selSQL.Append(" ON");
                selSQL.Append(" U.id = HU.user_id");
                selSQL.Append(" WHERE");
                selSQL.Append(" hosp_id=");
                selSQL.Append(cmd.Add(hosp_id).ParameterName);

                cmd.CommandText = selSQL.ToString();

                // SQL実行
                using (var dr = cmd.ExecuteReader())
                    // 該当データがある場合、返却値を設定
                    while (dr.Read())
                    {
                        UserMst tmpUser = new UserMst();
                        tmpUser.UserID  = Convert.ToInt32(dr["user_id"]);
                        tmpUser.LoginID = dr["login_id"].ToString();
                        if (dr["name"] != DBNull.Value)
                        {
                            tmpUser.UserName = dr["name"].ToString();
                        }
                        tmpUser.Permission = Convert.ToInt32(dr["permission"]);

                        ret.Add(tmpUser);
                    }
            }

            return(ret.ToArray());
        }
예제 #6
0
        private static HospMst[] getHospList(AccDbConnection con)
        {
            List <HospMst> ret = new List <HospMst>();

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                // SQL生成
                // ----------------------------
                // SELECT H.id, H.name, H.cd, H.seq
                // FROM M_Hosp As H
                // INNER JOIN HospUser HU
                // ON H.id = HU.hosp_id
                // WHERE user_id=id
                // ORDER BY H.seq ASC
                // ----------------------------
                StringBuilder selSQL = new StringBuilder();
                selSQL.Append("SELECT");
                selSQL.Append(" H.id");
                selSQL.Append(",H.name");
                selSQL.Append(",H.cd");
                selSQL.Append(",H.seq");
                selSQL.Append(",H.visible");
                selSQL.Append(" FROM");
                selSQL.Append(" M_Hosp As H");
                selSQL.Append(" ORDER BY");
                selSQL.Append(" H.seq");
                selSQL.Append(" ASC");

                cmd.CommandText = selSQL.ToString();

                // SQL実行
                using (var dr = cmd.ExecuteReader())
                    // 該当データがある場合、返却値を設定
                    while (dr.Read())
                    {
                        HospMst tmp = new HospMst();
                        tmp.HospID = Convert.ToInt32(dr["id"]);
                        tmp.CD     = dr["cd"].ToString();
                        if (dr["name"] != DBNull.Value)
                        {
                            tmp.Name = dr["name"].ToString();
                        }
                        tmp.Seq     = Convert.ToInt32(dr["seq"]);
                        tmp.Visible = Convert.ToInt32(dr["visible"]);

                        ret.Add(tmp);
                    }
            }

            return(ret.ToArray());
        }
예제 #7
0
        private static Files[] getFileList(AccDbConnection con, int id)
        {
            List <Files> ret = new List <Files>();

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                // SQL生成
                // ----------------------------
                // ----------------------------
                StringBuilder selSQL = new StringBuilder();
                selSQL.Append("SELECT");
                selSQL.Append(" id");
                selSQL.Append(",order_id");
                selSQL.Append(",seq");
                selSQL.Append(",isorigin");
                selSQL.Append(",name");
                selSQL.Append(" FROM");
                selSQL.Append(" Files");
                selSQL.Append(" WHERE");
                selSQL.Append(" order_id=");
                selSQL.Append(cmd.Add(id).ParameterName);
                selSQL.Append(" ORDER BY");
                selSQL.Append(" seq");


                cmd.CommandText = selSQL.ToString();

                // SQL実行
                using (var dr = cmd.ExecuteReader())
                    // 該当データがある場合、返却値を設定
                    while (dr.Read())
                    {
                        Files tmpFile = new Files();

                        tmpFile.FileID = Convert.ToInt32(dr["id"]);

                        tmpFile.OrderID = Convert.ToInt32(dr["order_id"]);

                        tmpFile.IsOrigin = Convert.ToInt32(dr["isorigin"]);

                        tmpFile.Seq = Convert.ToInt32(dr["seq"]);

                        tmpFile.Name = dr["name"].ToString();

                        ret.Add(tmpFile);
                    }
            }

            return(ret.ToArray());
        }
예제 #8
0
        private static HospitalTemplate[] getHospTemplate(AccDbConnection con, int id)
        {
            List <HospitalTemplate> ret = new List <HospitalTemplate>();

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                // SQL生成
                // ----------------------------
                // SELECT key,value,index
                // FROM HospTemplate
                // WHERE hosp_id=id
                // ----------------------------
                StringBuilder selSQL = new StringBuilder();
                selSQL.Append("SELECT");
                selSQL.Append(" key");
                selSQL.Append(",value");
                selSQL.Append(",index");
                selSQL.Append(" FROM");
                selSQL.Append(" HospTemplate");
                selSQL.Append(" WHERE");
                selSQL.Append(" hosp_id=");
                selSQL.Append(cmd.Add(id).ParameterName);
                selSQL.Append(" ORDER BY");
                selSQL.Append(" key");
                selSQL.Append(" ASC");
                selSQL.Append(",index");
                selSQL.Append(" ASC");

                cmd.CommandText = selSQL.ToString();

                // SQL実行
                using (var dr = cmd.ExecuteReader())
                    // 該当データがある場合、返却値を設定
                    while (dr.Read())
                    {
                        HospitalTemplate tmpTemp = new HospitalTemplate();
                        tmpTemp.Key = dr["key"].ToString();
                        if (dr["value"] != DBNull.Value)
                        {
                            tmpTemp.Value = dr["value"].ToString();
                        }
                        tmpTemp.Index = Convert.ToInt32(dr["index"]);

                        ret.Add(tmpTemp);
                    }
            }

            return(ret.ToArray());
        }
예제 #9
0
        private static bool setUser(AccDbConnection con, UserMst user)
        {
            bool ret = false;

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                // SQL生成
                // ----------------------------
                // INSERT
                // INTO M_User
                // (login_id, login_pw, name, permission)
                // VALUES
                // (user.LoginID, user.LoginPW, user.UserName, user.Permission)
                // ----------------------------
                StringBuilder insSQL = new StringBuilder();
                insSQL.Append("INSERT");
                insSQL.Append(" INTO");
                insSQL.Append(" M_User");
                insSQL.Append(" (");
                insSQL.Append(" login_id");
                insSQL.Append(",login_pw");
                insSQL.Append(",name");
                insSQL.Append(",permission");
                insSQL.Append(" )");
                insSQL.Append(" VALUES");
                insSQL.Append(" (");
                insSQL.Append(cmd.Add(user.LoginID).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(user.LoginPW).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(user.UserName).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(user.Permission).ParameterName);
                insSQL.Append(" )");

                cmd.CommandText = insSQL.ToString();

                var retcnt = cmd.ExecuteNonQuery();
                if (retcnt > 0)
                {
                    ret = true;
                }
            }

            return(ret);
        }
예제 #10
0
        private static UserMst[] getUserList(AccDbConnection con)
        {
            List <UserMst> ret = new List <UserMst>();

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                // SQL生成
                // ----------------------------
                // SELECT id,login_id,name,permission
                // FROM M_User
                // ----------------------------
                StringBuilder selSQL = new StringBuilder();
                selSQL.Append("SELECT");
                selSQL.Append(" id");
                selSQL.Append(",name");
                selSQL.Append(",cd");
                selSQL.Append(",seq");
                selSQL.Append(",permission");
                selSQL.Append(" FROM");
                selSQL.Append(" M_User");
                selSQL.Append(" ORDER BY");
                selSQL.Append(" seq");

                cmd.CommandText = selSQL.ToString();

                // SQL実行
                using (var dr = cmd.ExecuteReader())
                    // 該当データがある場合、返却値を設定
                    while (dr.Read())
                    {
                        UserMst tmpUser = new UserMst();
                        tmpUser.UserID = Convert.ToInt32(dr["id"]);
                        tmpUser.CD     = dr["cd"].ToString();
                        if (dr["name"] != DBNull.Value)
                        {
                            tmpUser.Name = dr["name"].ToString();
                        }
                        tmpUser.Seq        = Convert.ToInt32(dr["seq"]);
                        tmpUser.Permission = Convert.ToInt32(dr["permission"]);

                        ret.Add(tmpUser);
                    }
            }

            return(ret.ToArray());
        }
예제 #11
0
        private static UserMst getUser(AccDbConnection con, int id)
        {
            UserMst ret = new UserMst();

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                // SQL生成
                // ----------------------------
                // SELECT id,name,permission
                // FROM M_User
                // WHERE login_id=id
                // AND id=id
                // ----------------------------
                StringBuilder selSQL = new StringBuilder();
                selSQL.Append("SELECT");
                selSQL.Append(" id");
                selSQL.Append(",name");
                selSQL.Append(",cd");
                selSQL.Append(",seq");
                selSQL.Append(",permission");
                selSQL.Append(" FROM");
                selSQL.Append(" M_User");
                selSQL.Append(" WHERE");
                selSQL.Append(" id=");
                selSQL.Append(cmd.Add(id).ParameterName);

                cmd.CommandText = selSQL.ToString();

                // SQL実行
                using (var dr = cmd.ExecuteReader())
                    // 該当データがある場合、返却値を設定
                    if (dr.Read())
                    {
                        ret.UserID = id;
                        ret.CD     = dr["cd"].ToString();
                        if (dr["name"] != DBNull.Value)
                        {
                            ret.Name = dr["name"].ToString();
                        }
                        ret.Seq        = Convert.ToInt32(dr["seq"]);
                        ret.Permission = Convert.ToInt32(dr["permission"]);
                    }
            }

            return(ret);
        }
예제 #12
0
        private static UserConfig getUserConfig(AccDbConnection con, int id)
        {
            UserConfig    ret   = new UserConfig();
            List <Config> confs = new List <Config>();

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                // SQL生成
                // ----------------------------
                // SELECT key,value
                // FROM UserConfig
                // WHERE user_id=id
                // ----------------------------
                StringBuilder selSQL = new StringBuilder();
                selSQL.Append("SELECT");
                selSQL.Append(" key");
                selSQL.Append(",value");
                selSQL.Append(" FROM");
                selSQL.Append(" UserConfig");
                selSQL.Append(" WHERE");
                selSQL.Append(" user_id=");
                selSQL.Append(cmd.Add(id).ParameterName);

                cmd.CommandText = selSQL.ToString();

                // SQL実行
                using (var dr = cmd.ExecuteReader())
                    // 該当データがある場合、返却値を設定
                    while (dr.Read())
                    {
                        Config tmpConf = new Config();
                        tmpConf.Key = dr["key"].ToString();
                        if (dr["value"] != DBNull.Value)
                        {
                            tmpConf.Value = dr["value"].ToString();
                        }

                        confs.Add(tmpConf);
                    }
            }

            ret.Conf = confs.ToArray();

            return(ret);
        }
예제 #13
0
        public UserMst2[] GetUserList()
        {
            List <UserMst2> ret = new List <UserMst2>();

            try
            {
                using (var con = new AccDbConnection(DBRemote))
                {
                    using (var cmd = con.CreateCommand())
                    {
                        // SQL
                        StringBuilder sql = new StringBuilder();
                        sql.Append("SELECT ");
                        sql.Append(" UserCD");
                        sql.Append(",UserName");
                        sql.Append(" FROM");
                        sql.Append(" UserMst");
                        sql.Append(" WHERE");
                        sql.Append(" ViewType=1");
                        sql.Append(" AND");
                        sql.Append(" GroupCD NOT IN (999,1000)");
                        sql.Append(" ORDER BY SeqNo");

                        cmd.CommandText = sql.ToString();

                        using (var dr = cmd.ExecuteReader())
                            while (dr.Read())
                            {
                                UserMst2 mst = new UserMst2();
                                mst.UserCD   = Convert.ToInt32(dr["UserCD"]);
                                mst.UserName = dr["UserName"].ToString();

                                ret.Add(mst);
                            }
                    }
                }
            }
            catch (Exception ex)
            {
                LogControl.WriteLog(LogType.ERR, "S:GetUserList", ex.Message);
                LogControl.WriteLog(LogType.ERR, "S:GetUserList", ex.StackTrace);
            }

            return(ret.ToArray());
        }
예제 #14
0
        private static bool udtOrder(AccDbConnection con, Order order)
        {
            bool ret = false;

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                StringBuilder udtSQL = new StringBuilder();
                udtSQL.Append("UPDATE");
                udtSQL.Append(" Orders");
                udtSQL.Append(" SET");
                udtSQL.Append(" hospid=" + cmd.Add(order.HospID).ParameterName);
                udtSQL.Append(",orderno=" + cmd.Add(order.OrderNo).ParameterName);
                udtSQL.Append(",patkey=" + cmd.Add(order.Key).ParameterName);
                udtSQL.Append(",patage=" + cmd.Add(order.PatAge).ParameterName);
                udtSQL.Append(",modality=" + cmd.Add(order.Modality).ParameterName);
                udtSQL.Append(",studydate=" + cmd.Add(order.Date).ParameterName);
                udtSQL.Append(",studytime=" + cmd.Add(order.Time).ParameterName);
                udtSQL.Append(",bodypart=" + cmd.Add(order.BodyPart).ParameterName);
                udtSQL.Append(",studytype=" + cmd.Add(order.Type).ParameterName);
                udtSQL.Append(",isvisit=" + cmd.Add(order.IsVisit).ParameterName);
                udtSQL.Append(",department=" + cmd.Add(order.Department).ParameterName);
                udtSQL.Append(",orderdoctor=" + cmd.Add(order.Doctor).ParameterName);
                udtSQL.Append(",isemergency=" + cmd.Add(order.IsEmergency).ParameterName);
                udtSQL.Append(",ismail=" + cmd.Add(order.IsMail).ParameterName);
                udtSQL.Append(",comment=" + cmd.Add(order.Comment).ParameterName);
                udtSQL.Append(",contact=" + cmd.Add(order.Contact).ParameterName);
                udtSQL.Append(",recept=" + cmd.Add(order.Recept).ParameterName);
                udtSQL.Append(",status=" + cmd.Add(order.Status).ParameterName);
                udtSQL.Append(" WHERE");
                udtSQL.Append(" id=");
                udtSQL.Append(cmd.Add(order.OrderID).ParameterName);

                cmd.CommandText = udtSQL.ToString();

                var retcnt = cmd.ExecuteNonQuery();
                if (retcnt > 0)
                {
                    ret = true;
                }
            }

            return(ret);
        }
예제 #15
0
        private static bool setFile(AccDbConnection con, Files file)
        {
            bool ret = false;

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                StringBuilder insSQL = new StringBuilder();
                insSQL.Append("INSERT");
                insSQL.Append(" INTO");
                insSQL.Append(" Files");

                insSQL.Append(" (");
                insSQL.Append(" order_id");
                insSQL.Append(",seq");
                insSQL.Append(",isorigin");
                insSQL.Append(",name");
                insSQL.Append(" )");

                insSQL.Append(" VALUES");

                insSQL.Append(" (");
                insSQL.Append(cmd.Add(file.OrderID).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(file.Seq).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(file.IsOrigin).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(file.Name).ParameterName);
                insSQL.Append(" )");

                cmd.CommandText = insSQL.ToString();

                var retcnt = cmd.ExecuteNonQuery();
                if (retcnt > 0)
                {
                    ret = true;
                }
            }

            return(ret);
        }
예제 #16
0
        private static bool udtUser(AccDbConnection con, UserMst user)
        {
            bool ret = false;

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                // SQL生成
                // ----------------------------
                // UPDATE
                // M_User
                // SET
                //  login_id=user.LoginID
                // ,login_pw=user.LoginPW
                // ,name=user.UserName
                // ,permission=user.Permission
                // WHERE
                // id=user.UserID
                // ----------------------------
                StringBuilder udtSQL = new StringBuilder();
                udtSQL.Append("UPDATE");
                udtSQL.Append(" M_User");
                udtSQL.Append(" SET");
                udtSQL.Append(" login_id=" + cmd.Add(user.LoginID).ParameterName);
                udtSQL.Append(",login_pw=" + cmd.Add(user.LoginPW).ParameterName);
                udtSQL.Append(",name=" + cmd.Add(user.UserName).ParameterName);
                udtSQL.Append(",permission=" + cmd.Add(user.Permission).ParameterName);
                udtSQL.Append(" WHERE");
                udtSQL.Append(" id=");
                udtSQL.Append(cmd.Add(user.UserID).ParameterName);

                cmd.CommandText = udtSQL.ToString();

                var retcnt = cmd.ExecuteNonQuery();
                if (retcnt > 0)
                {
                    ret = true;
                }
            }

            return(ret);
        }
예제 #17
0
        private static int getUserID(AccDbConnection con, string id, string pw)
        {
            int ret = 0;

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                // SQL生成
                // ----------------------------
                // SELECT id
                // FROM M_User
                // WHERE login_id=id
                // AND login_pw=pw
                // ----------------------------
                StringBuilder selSQL = new StringBuilder();
                selSQL.Append("SELECT");
                selSQL.Append(" id");
                selSQL.Append(" FROM");
                selSQL.Append(" M_User");
                selSQL.Append(" WHERE");
                selSQL.Append(" login_id=");
                selSQL.Append(cmd.Add(id).ParameterName);
                selSQL.Append(" AND");
                selSQL.Append(" login_pw=");
                selSQL.Append(cmd.Add(pw).ParameterName);

                cmd.CommandText = selSQL.ToString();

                // SQL実行
                using (var dr = cmd.ExecuteReader())
                    // 該当データがある場合、返却値を設定
                    if (dr.Read())
                    {
                        ret = Convert.ToInt32(dr["id"]);
                    }
            }

            return(ret);
        }
예제 #18
0
        private static bool delFile(AccDbConnection con, int orderid)
        {
            bool ret = false;

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                StringBuilder delSQL = new StringBuilder();
                delSQL.Append("DELETE");
                delSQL.Append(" FROM");
                delSQL.Append(" Files");
                delSQL.Append(" WHERE");
                delSQL.Append(" order_id=");
                delSQL.Append(cmd.Add(orderid).ParameterName);

                cmd.CommandText = delSQL.ToString();

                cmd.ExecuteNonQuery();
                ret = true;
            }

            return(ret);
        }
예제 #19
0
        public bool DeleteSentence(string scd)
        {
            bool ret = false;

            try
            {
                using (var con = new AccDbConnection(DBRemote))
                {
                    using (var cmd = con.CreateCommand())
                    {
                        StringBuilder sql = new StringBuilder();

                        sql.Append("DELETE ");
                        sql.Append(" FROM");
                        sql.Append(" SentenceMst");
                        sql.Append(" WHERE");
                        sql.Append(" SentenceCD = " + cmd.Add(scd).ParameterName);

                        cmd.CommandText = sql.ToString();

                        var retDB = cmd.ExecuteNonQuery();

                        if (retDB > -1)
                        {
                            ret = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogControl.WriteLog(LogType.ERR, "S:saveReportImage", ex.Message);
                LogControl.WriteLog(LogType.ERR, "S:saveReportImage", ex.StackTrace);
            }

            return(ret);
        }
예제 #20
0
        private static string getSessionKey(AccDbConnection con, int id)
        {
            string ret = "";

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                // SQL生成
                // ----------------------------
                // SELECT id
                // FROM M_User
                // WHERE login_id=id
                // AND login_pw=pw
                // ----------------------------
                StringBuilder selSQL = new StringBuilder();
                selSQL.Append("SELECT");
                selSQL.Append(" key");
                selSQL.Append(" FROM");
                selSQL.Append(" Login");
                selSQL.Append(" WHERE");
                selSQL.Append(" user_id=");
                selSQL.Append(cmd.Add(id).ParameterName);

                cmd.CommandText = selSQL.ToString();

                // SQL実行
                using (var dr = cmd.ExecuteReader())
                    // 該当データがある場合、返却値を設定
                    if (dr.Read())
                    {
                        ret = dr["key"].ToString();
                    }
            }

            return(ret);
        }
예제 #21
0
        private static bool setHospTemplate(AccDbConnection con, int id, string key, string[] tempList)
        {
            bool ret = false;

            using (var cmd = con.CreateCommand())
            {
                StringBuilder delSQL = new StringBuilder();
                delSQL.Append("DELETE");
                delSQL.Append(" FROM");
                delSQL.Append(" HospTemplate");

                delSQL.Append(" WHERE");
                delSQL.Append(" hosp_id=");
                delSQL.Append(cmd.Add(id).ParameterName);
                delSQL.Append(" AND");
                delSQL.Append(" key=");
                delSQL.Append(cmd.Add(key).ParameterName);

                cmd.CommandText = delSQL.ToString();

                cmd.ExecuteNonQuery();
            }

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                StringBuilder insSQL = new StringBuilder();
                insSQL.Append("INSERT");
                insSQL.Append(" INTO");
                insSQL.Append(" HospTemplate");

                insSQL.Append(" (");
                insSQL.Append(" hosp_id");
                insSQL.Append(",key");
                insSQL.Append(",value");
                insSQL.Append(",index");
                insSQL.Append(" )");

                insSQL.Append(" VALUES");

                for (int i = 0; i < tempList.Length; i++)
                {
                    if (i > 0)
                    {
                        insSQL.Append(",");
                    }

                    insSQL.Append(" (");
                    insSQL.Append(cmd.Add(id).ParameterName);
                    insSQL.Append(",");
                    insSQL.Append(cmd.Add(key).ParameterName);
                    insSQL.Append(",");
                    insSQL.Append(cmd.Add(tempList[i]).ParameterName);
                    insSQL.Append(",");
                    insSQL.Append(cmd.Add(i + 1).ParameterName);
                    insSQL.Append(" )");
                }

                cmd.CommandText = insSQL.ToString();

                var retcnt = cmd.ExecuteNonQuery();
                if (retcnt > 0)
                {
                    ret = true;
                }
            }

            return(ret);
        }
예제 #22
0
        private static int setOrder_RetId(AccDbConnection con, Order order)
        {
            int ret = 0;

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                StringBuilder insSQL = new StringBuilder();
                insSQL.Append("INSERT");
                insSQL.Append(" INTO");
                insSQL.Append(" Orders");

                insSQL.Append(" (");
                insSQL.Append(" hospid");
                insSQL.Append(",orderno");
                insSQL.Append(",patkey");
                insSQL.Append(",patage");
                insSQL.Append(",modality");
                insSQL.Append(",studydate");
                insSQL.Append(",studytime");
                insSQL.Append(",bodypart");
                insSQL.Append(",studytype");
                insSQL.Append(",isvisit");
                insSQL.Append(",department");
                insSQL.Append(",orderdoctor");
                insSQL.Append(",imgcnt");
                insSQL.Append(",isemergency");
                insSQL.Append(",ismail");
                insSQL.Append(",comment");
                insSQL.Append(",contact");
                insSQL.Append(",recept");
                insSQL.Append(",status");
                insSQL.Append(",pre_id");
                insSQL.Append(",pastcnt");
                insSQL.Append(" )");

                insSQL.Append(" VALUES");

                insSQL.Append(" (");
                insSQL.Append(cmd.Add(order.HospID).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.OrderNo).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Key).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.PatAge).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Modality).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Date).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Time).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.BodyPart).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Type).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.IsVisit).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Department).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Doctor).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.ImgCnt).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.IsEmergency).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.IsMail).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Comment).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Contact).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Recept).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Status).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.PreID).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.PastCnt).ParameterName);
                insSQL.Append(" )");

                cmd.CommandText = insSQL.ToString();

                insSQL.Append(" RETURNING");
                insSQL.Append(" id");

                cmd.CommandText = insSQL.ToString();

                // SQL実行
                using (var dr = cmd.ExecuteReader())
                    // 該当データがある場合、返却値を設定
                    if (dr.Read())
                    {
                        ret = Convert.ToInt32(dr["id"]);
                    }
            }

            return(ret);
        }
예제 #23
0
        private static Order[] getOrderList(AccDbConnection con, Search search)
        {
            List <Order> ret = new List <Order>();

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                // SQL生成
                // ----------------------------
                // ----------------------------
                StringBuilder selSQL = new StringBuilder();
                selSQL.Append("SELECT");
                selSQL.Append(" O.id");
                selSQL.Append(",O.hospid");
                selSQL.Append(",O.orderno");
                selSQL.Append(",O.patkey");
                selSQL.Append(",O.patage");
                selSQL.Append(",O.modality");
                selSQL.Append(",O.studydate");
                selSQL.Append(",O.studytime");
                selSQL.Append(",O.bodypart");
                selSQL.Append(",O.studytype");
                selSQL.Append(",O.isvisit");
                selSQL.Append(",O.department");
                selSQL.Append(",O.orderdoctor");
                selSQL.Append(",O.imgcnt");
                selSQL.Append(",O.isemergency");
                selSQL.Append(",O.ismail");
                selSQL.Append(",O.comment");
                selSQL.Append(",O.contact");
                selSQL.Append(",O.recept");
                selSQL.Append(",O.status");
                selSQL.Append(",O.pre_id");
                selSQL.Append(",O.pastcnt");
                selSQL.Append(",O.updatedate");
                selSQL.Append(",P.key");
                selSQL.Append(",P.patid");
                selSQL.Append(",P.patname");
                selSQL.Append(",P.patname_h");
                selSQL.Append(",P.patname_r");
                selSQL.Append(",P.patsex");
                selSQL.Append(",P.patbirth");
                selSQL.Append(" FROM");
                selSQL.Append(" Orders As O");
                selSQL.Append(" INNER JOIN");
                selSQL.Append(" Patient As P");
                selSQL.Append(" ON");
                selSQL.Append(" O.patkey=P.Key");

                string strWhere = " WHERE";

                if (search.HospID > 0)
                {
                    selSQL.Append(strWhere);
                    selSQL.Append(" O.hospid=");
                    selSQL.Append(cmd.Add(search.HospID).ParameterName);

                    strWhere = " AND";
                }

                if (search.OrderID > 0)
                {
                    selSQL.Append(strWhere);
                    selSQL.Append(" O.id=");
                    selSQL.Append(cmd.Add(search.OrderID).ParameterName);

                    strWhere = " AND";
                }

                if (!string.IsNullOrEmpty(search.OrderNo))
                {
                    selSQL.Append(strWhere);
                    selSQL.Append(" O.orderno=");
                    selSQL.Append(cmd.Add(search.OrderNo).ParameterName);

                    strWhere = " AND";
                }

                if (!string.IsNullOrEmpty(search.PatID))
                {
                    selSQL.Append(strWhere);
                    selSQL.Append(" P.patid=");
                    selSQL.Append(cmd.Add(search.PatID).ParameterName);

                    strWhere = " AND";
                }

                if (!string.IsNullOrEmpty(search.Modality))
                {
                    selSQL.Append(strWhere);
                    selSQL.Append(" O.modality=");
                    selSQL.Append(cmd.Add(search.Modality).ParameterName);

                    strWhere = " AND";
                }

                if (!string.IsNullOrEmpty(search.Date_F))
                {
                    selSQL.Append(strWhere);
                    selSQL.Append(" O.studydate >= ");
                    selSQL.Append(cmd.Add(search.Date_F).ParameterName);

                    strWhere = " AND";
                }

                if (!string.IsNullOrEmpty(search.Date_T))
                {
                    selSQL.Append(strWhere);
                    selSQL.Append(" O.studydate <= ");
                    selSQL.Append(cmd.Add(search.Date_T).ParameterName);

                    strWhere = " AND";
                }

                if (search.Status != -2)
                {
                    selSQL.Append(strWhere);
                    selSQL.Append(" O.status=");
                    selSQL.Append(cmd.Add(search.Status).ParameterName);

                    strWhere = " AND";
                }
                if (search.AreaStatus != -2)
                {
                    selSQL.Append(strWhere);
                    selSQL.Append(" O.status <=");
                    selSQL.Append(cmd.Add(search.AreaStatus).ParameterName);

                    strWhere = " AND";
                }

                selSQL.Append(" ORDER BY");
                selSQL.Append(" (");
                selSQL.Append(" CASE o.status WHEN 1 THEN 1 ELSE 2 END");
                selSQL.Append(",CASE o.status WHEN 0 THEN 1 ELSE 2 END");
                selSQL.Append(",CASE o.status WHEN 2 THEN 1 ELSE 2 END");
                selSQL.Append(" )");
                selSQL.Append(",O.isemergency");
                selSQL.Append(" DESC");
                selSQL.Append(",O.updatedate");
                selSQL.Append(" ASC");

                cmd.CommandText = selSQL.ToString();

                // SQL実行
                using (var dr = cmd.ExecuteReader())
                    // 該当データがある場合、返却値を設定
                    while (dr.Read())
                    {
                        Order tmpOrder = new Order();

                        tmpOrder.OrderID = Convert.ToInt32(dr["id"]);

                        tmpOrder.HospID = Convert.ToInt32(dr["hospid"]);


                        tmpOrder.Key = Convert.ToInt32(dr["key"]);

                        tmpOrder.OrderNo = dr["orderno"].ToString();

                        tmpOrder.PatID = dr["patid"].ToString();

                        if (dr["patname"] != DBNull.Value)
                        {
                            tmpOrder.PatName = dr["patname"].ToString();
                        }

                        if (dr["patname_h"] != DBNull.Value)
                        {
                            tmpOrder.PatName_H = dr["patname_h"].ToString();
                        }

                        if (dr["patname_r"] != DBNull.Value)
                        {
                            tmpOrder.PatName_R = dr["patname_r"].ToString();
                        }

                        tmpOrder.Sex = Convert.ToInt32(dr["patsex"]);

                        if (dr["patbirth"] != DBNull.Value)
                        {
                            tmpOrder.BirthDay = dr["patbirth"].ToString();
                        }

                        if (dr["patage"] != DBNull.Value)
                        {
                            tmpOrder.PatAge = Convert.ToInt32(dr["patage"]);
                        }

                        tmpOrder.Modality = dr["modality"].ToString();

                        tmpOrder.Date = dr["studydate"].ToString();

                        if (dr["studytime"] != DBNull.Value)
                        {
                            tmpOrder.Time = dr["studytime"].ToString();
                        }

                        if (dr["bodypart"] != DBNull.Value)
                        {
                            tmpOrder.BodyPart = dr["bodypart"].ToString();
                        }

                        if (dr["studytype"] != DBNull.Value)
                        {
                            tmpOrder.Type = dr["studytype"].ToString();
                        }

                        if (dr["isvisit"] != DBNull.Value)
                        {
                            tmpOrder.IsVisit = dr["isvisit"].ToString();
                        }

                        if (dr["department"] != DBNull.Value)
                        {
                            tmpOrder.Department = dr["department"].ToString();
                        }

                        if (dr["orderdoctor"] != DBNull.Value)
                        {
                            tmpOrder.Doctor = dr["orderdoctor"].ToString();
                        }

                        if (dr["imgcnt"] != DBNull.Value)
                        {
                            tmpOrder.ImgCnt = Convert.ToInt32(dr["imgcnt"]);
                        }

                        tmpOrder.IsEmergency = Convert.ToInt32(dr["isemergency"]);

                        tmpOrder.IsMail = Convert.ToInt32(dr["ismail"]);

                        if (dr["comment"] != DBNull.Value)
                        {
                            tmpOrder.Comment = dr["comment"].ToString();
                        }

                        if (dr["contact"] != DBNull.Value)
                        {
                            tmpOrder.Contact = dr["contact"].ToString();
                        }

                        if (dr["recept"] != DBNull.Value)
                        {
                            tmpOrder.Recept = dr["recept"].ToString();
                        }

                        if (dr["status"] != DBNull.Value)
                        {
                            tmpOrder.Status = Convert.ToInt32(dr["status"]);
                        }

                        if (dr["pre_id"] != DBNull.Value)
                        {
                            tmpOrder.PreID = Convert.ToInt32(dr["pre_id"]);
                        }

                        tmpOrder.PastCnt = dr["pastcnt"].ToString();


                        ret.Add(tmpOrder);
                    }
            }

            return(ret.ToArray());
        }
예제 #24
0
        private static bool setSessionKey(AccDbConnection con, int id, string key)
        {
            bool ret = false;

            // コマンドオブジェクト生成(DELETE用)
            using (var cmd = con.CreateCommand())
            {
                // SQL生成
                // ----------------------------
                // DELETE
                // FROM Login
                // WHERE
                // user_id=id
                // ----------------------------
                StringBuilder delSQL = new StringBuilder();
                delSQL.Append("DELETE");
                delSQL.Append(" FROM");
                delSQL.Append(" Login");
                delSQL.Append(" WHERE");
                delSQL.Append(" user_id=");
                delSQL.Append(cmd.Add(id).ParameterName);

                cmd.CommandText = delSQL.ToString();

                cmd.ExecuteNonQuery();
            }

            // コマンドオブジェクト生成(INSERT用)
            using (var cmd = con.CreateCommand())
            {
                // SQL生成
                // ----------------------------
                // INSERT
                // INTO Login
                // (user_id, key)
                // VALUES
                // (id, key)
                // ----------------------------
                StringBuilder insSQL = new StringBuilder();
                insSQL.Append("INSERT");
                insSQL.Append(" INTO");
                insSQL.Append(" Login");
                insSQL.Append(" (");
                insSQL.Append(" user_id");
                insSQL.Append(",key");
                insSQL.Append(" )");
                insSQL.Append(" VALUES");
                insSQL.Append(" (");
                insSQL.Append(cmd.Add(id).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(key).ParameterName);
                insSQL.Append(" )");

                cmd.CommandText = insSQL.ToString();

                var retcnt = cmd.ExecuteNonQuery();
                if (retcnt > 0)
                {
                    ret = true;
                }
            }

            return(ret);
        }
예제 #25
0
        public string[] GetImageExt(int userCd, string serialNo, string imagePath)
        {
            List <string> ret = new List <string>();

            try
            {
                int history = 0;
                List <ReportImage> lstImage = new List <ReportImage>();

                using (var con = new AccDbConnection(DBRemote))
                {
                    using (var cmd = con.CreateCommand())
                    {
                        // SQL
                        StringBuilder sql = new StringBuilder();
                        sql.Append("SELECT ");
                        sql.Append(" HistoryNo");
                        sql.Append(" FROM");
                        sql.Append(" ReportTbl");
                        sql.Append(" WHERE");
                        sql.Append(" SerialNo = " + cmd.Add(serialNo).ParameterName);

                        cmd.CommandText = sql.ToString();

                        using (var dr = cmd.ExecuteReader())
                            if (dr.Read())
                            {
                                history = Convert.ToInt32(dr["HistoryNo"]);
                            }
                    }

                    using (var cmd = con.CreateCommand())
                    {
                        // SQL
                        StringBuilder sql = new StringBuilder();
                        sql.Append(" HistoryNo");
                        sql.Append(" FROM");
                        sql.Append(" ReportTbl");
                        sql.Append(" WHERE");
                        sql.Append(" SerialNo = " + cmd.Add(serialNo).ParameterName);

                        cmd.CommandText = sql.ToString();
                    }


                    using (var cmd = con.CreateCommand())
                    {
                        // SQL
                        StringBuilder sql = new StringBuilder();
                        sql.Append("SELECT ");
                        sql.Append(" ImageData");
                        sql.Append(",ImageExt");
                        sql.Append(" FROM");
                        sql.Append(" ImageTbl");
                        sql.Append(" WHERE");
                        sql.Append(" SerialNo = " + cmd.Add(serialNo).ParameterName);
                        sql.Append(" AND");
                        sql.Append(" HistoryNo = " + cmd.Add(history).ParameterName);
                        sql.Append(" ORDER BY SeqNo ASC");

                        cmd.CommandText = sql.ToString();

                        using (var dr = cmd.ExecuteReader())
                            while (dr.Read())
                            {
                                ReportImage tmpImage = new ReportImage();
                                tmpImage.ImageData = (byte[])dr["ImageData"];
                                tmpImage.ImageExt  = (string)dr["ImageExt"];

                                lstImage.Add(tmpImage);
                            }
                    }
                }

                outputReportImage(userCd, Convert.ToInt32(serialNo), imagePath, lstImage, ref ret);
            }
            catch (Exception ex)
            {
                LogControl.WriteLog(LogType.ERR, "S:GetImageExt", ex.Message);
                LogControl.WriteLog(LogType.ERR, "S:GetImageExt", ex.StackTrace);
            }

            return(ret.ToArray());
        }
예제 #26
0
        public bool UpdateSentence(string scd, string name, string val1, string val2, string pcd, string usercd)
        {
            bool ret = false;

            try
            {
                using (var con = new AccDbConnection(DBRemote))
                {
                    using (var cmd = con.CreateCommand())
                    {
                        StringBuilder sql = new StringBuilder();

                        if (string.IsNullOrEmpty(scd))
                        {
                            sql.Append("INSERT ");
                            sql.Append(" INTO");
                            sql.Append(" SentenceMst");
                            sql.Append(" (");
                            sql.Append(" SentenceName");
                            sql.Append(",SentenceValue1");
                            sql.Append(",SentenceValue2");
                            sql.Append(",PublicCD");
                            sql.Append(",UserCD");
                            sql.Append(" )");
                            sql.Append(" VALUES");

                            sql.Append(" (");
                            sql.Append(cmd.Add(name).ParameterName);
                            sql.Append(",");
                            sql.Append(cmd.Add(val1).ParameterName);
                            sql.Append(",");
                            sql.Append(cmd.Add(val2).ParameterName);
                            sql.Append(",");
                            sql.Append(cmd.Add(pcd).ParameterName);
                            sql.Append(",");
                            sql.Append(cmd.Add(usercd).ParameterName);
                            sql.Append(" )");
                        }
                        else
                        {
                            sql.Append("UPDATE ");
                            sql.Append(" SentenceMst");
                            sql.Append(" SET");
                            sql.Append(" SentenceName = " + cmd.Add(name).ParameterName);
                            sql.Append(",SentenceValue1 = " + cmd.Add(val1).ParameterName);
                            sql.Append(",SentenceValue2 = " + cmd.Add(val2).ParameterName);
                            sql.Append(",PublicCD = " + cmd.Add(pcd).ParameterName);
                            sql.Append(",UserCD = " + cmd.Add(usercd).ParameterName);
                            sql.Append(" WHERE");
                            sql.Append(" SentenceCD = " + cmd.Add(scd).ParameterName);
                        }

                        cmd.CommandText = sql.ToString();

                        var retDB = cmd.ExecuteNonQuery();

                        if (retDB > -1)
                        {
                            ret = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogControl.WriteLog(LogType.ERR, "S:saveReportImage", ex.Message);
                LogControl.WriteLog(LogType.ERR, "S:saveReportImage", ex.StackTrace);
            }

            return(ret);
        }
예제 #27
0
        public bool SaveReportImage(string serialNo, string[] images)
        {
            bool ret = false;

            try
            {
                int history = 0;

                using (var con = new AccDbConnection(DBRemote))
                {
                    using (var cmd = con.CreateCommand())
                    {
                        // SQL
                        StringBuilder sql = new StringBuilder();
                        sql.Append("SELECT ");
                        sql.Append(" HistoryNo");
                        sql.Append(" FROM");
                        sql.Append(" ReportTbl");
                        sql.Append(" WHERE");
                        sql.Append(" SerialNo = " + cmd.Add(serialNo).ParameterName);

                        cmd.CommandText = sql.ToString();

                        using (var dr = cmd.ExecuteReader())
                            if (dr.Read())
                            {
                                history = Convert.ToInt32(dr["HistoryNo"]);
                            }
                    }

                    using (var cmd = con.CreateCommand())
                    {
                        // SQL
                        StringBuilder sql = new StringBuilder();
                        sql.Append("DELETE ");
                        sql.Append(" FROM");
                        sql.Append(" ImageTbl");
                        sql.Append(" WHERE");
                        sql.Append(" SerialNo = " + cmd.Add(serialNo).ParameterName);
                        sql.Append(" AND");
                        sql.Append(" HistoryNo = " + cmd.Add(history).ParameterName);

                        cmd.CommandText = sql.ToString();

                        cmd.ExecuteNonQuery();
                    }

                    using (var cmd = con.CreateCommand())
                    {
                        // SQL
                        StringBuilder sql = new StringBuilder();
                        sql.Append("INSERT ");
                        sql.Append(" INTO");
                        sql.Append(" ImageTbl");
                        sql.Append(" (");
                        sql.Append(" SerialNo");
                        sql.Append(",HistoryNo");
                        sql.Append(",SeqNo");
                        sql.Append(",ImageData");
                        sql.Append(",ImageExt");
                        sql.Append(" )");
                        sql.Append(" VALUES");

                        for (int i = 0; i < images.Length; i++)
                        {
                            if (i != 0)
                            {
                                sql.Append(",");
                            }

                            byte[] tmpByte;

                            using (Image img = Image.FromFile(images[i]))
                            {
                                //LogControl.WriteLog(LogType.ORE, "S:saveReportImage", images[i]);
                                ImageConverter imgconv = new ImageConverter();
                                tmpByte = (byte[])imgconv.ConvertTo(img, typeof(byte[]));
                            }
                            sql.Append(" (");
                            sql.Append(cmd.Add(serialNo).ParameterName);
                            sql.Append(",");
                            sql.Append(cmd.Add(history).ParameterName);
                            sql.Append(",");
                            sql.Append(cmd.Add(i).ParameterName);
                            sql.Append(",");
                            //LogControl.WriteLog(LogType.ORE, "S:saveReportImage", Convert.ToBase64String(tmpByte));
                            sql.Append(cmd.Add(tmpByte).ParameterName);
                            sql.Append(",");
                            sql.Append(cmd.Add("jpg").ParameterName);
                            sql.Append(" )");
                        }

                        cmd.CommandText = sql.ToString();

                        var retDB = cmd.ExecuteNonQuery();

                        if (retDB > -1)
                        {
                            ret = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogControl.WriteLog(LogType.ERR, "S:saveReportImage", ex.Message);
                LogControl.WriteLog(LogType.ERR, "S:saveReportImage", ex.StackTrace);
            }

            return(ret);
        }
예제 #28
0
        public bool SaveReport(int userCd, int serialNo, string finding, string diagnosing, int imgCnt)
        {
            bool ret = false;

            try
            {
                string userName = "";
                int    history  = 0;
                int    status   = 0;

                using (var con = new AccDbConnection(DBRemote))
                {
                    using (var cmd = con.CreateCommand())
                    {
                        // SQL
                        StringBuilder sql = new StringBuilder();
                        sql.Append("SELECT ");
                        sql.Append(" UserName");
                        sql.Append(" FROM");
                        sql.Append(" UserMst");
                        sql.Append(" WHERE");
                        sql.Append(" UserCD = " + cmd.Add(userCd).ParameterName);

                        cmd.CommandText = sql.ToString();

                        using (var dr = cmd.ExecuteReader())
                            if (dr.Read())
                            {
                                userName = dr["UserName"].ToString();
                            }
                    }

                    using (var cmd = con.CreateCommand())
                    {
                        // SQL
                        StringBuilder sql = new StringBuilder();
                        sql.Append("SELECT ");
                        sql.Append(" HistoryNo");
                        sql.Append(",ReadingStatus");
                        sql.Append(" FROM");
                        sql.Append(" ReportTbl");
                        sql.Append(" WHERE");
                        sql.Append(" SerialNo = " + cmd.Add(serialNo).ParameterName);

                        cmd.CommandText = sql.ToString();

                        using (var dr = cmd.ExecuteReader())
                            if (dr.Read())
                            {
                                history = Convert.ToInt32(dr["HistoryNo"]);
                                status  = Convert.ToInt32(dr["ReadingStatus"]);
                            }
                    }

                    if (status == 0)
                    {
                        // HistoryNo をインクリメント
                        history++;
                        status = 1;
                    }

                    using (var cmd = con.CreateCommand())
                    {
                        // SQL
                        StringBuilder sql = new StringBuilder();
                        sql.Append("UPDATE ");
                        sql.Append(" ReportTbl");
                        sql.Append(" SET");
                        sql.Append(" ReadingStatus = " + cmd.Add(status).ParameterName);
                        sql.Append(",ReadPhysicianName = " + cmd.Add(userName).ParameterName);
                        sql.Append(",HistoryNo = " + cmd.Add(history).ParameterName);
                        sql.Append(",Finding = " + cmd.Add(finding).ParameterName);
                        sql.Append(",Diagnosing = " + cmd.Add(diagnosing).ParameterName);
                        sql.Append(",ImageUmu = " + cmd.Add(imgCnt).ParameterName);
                        sql.Append(" WHERE");
                        sql.Append(" SerialNo = " + cmd.Add(serialNo).ParameterName);

                        cmd.CommandText = sql.ToString();

                        var retDB = cmd.ExecuteNonQuery();

                        if (retDB > -1)
                        {
                            ret = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogControl.WriteLog(LogType.ERR, "S:saveReport", ex.Message);
                LogControl.WriteLog(LogType.ERR, "S:saveReport", ex.StackTrace);
            }

            return(ret);
        }
예제 #29
0
        private static bool setOrder(AccDbConnection con, Order order)
        {
            bool ret = false;

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                StringBuilder insSQL = new StringBuilder();
                insSQL.Append("INSERT");
                insSQL.Append(" INTO");
                insSQL.Append(" Orders");

                insSQL.Append(" (");
                insSQL.Append(" hospid");
                insSQL.Append(",orderno");
                insSQL.Append(",patkey");
                insSQL.Append(",patage");
                insSQL.Append(",modality");
                insSQL.Append(",studydate");
                insSQL.Append(",studytime");
                insSQL.Append(",bodypart");
                insSQL.Append(",studytype");
                insSQL.Append(",isvisit");
                insSQL.Append(",department");
                insSQL.Append(",orderdoctor");
                insSQL.Append(",imgcnt");
                insSQL.Append(",isemergency");
                insSQL.Append(",ismail");
                insSQL.Append(",comment");
                insSQL.Append(",contact");
                insSQL.Append(",recept");
                insSQL.Append(",status");
                insSQL.Append(",pre_id");
                insSQL.Append(",pastcnt");
                insSQL.Append(" )");

                insSQL.Append(" VALUES");

                insSQL.Append(" (");
                insSQL.Append(cmd.Add(order.HospID).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.OrderNo).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Key).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.PatAge).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Modality).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Date).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Time).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.BodyPart).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Type).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.IsVisit).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Department).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Doctor).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.ImgCnt).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.IsEmergency).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.IsMail).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Comment).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Contact).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Recept).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.Status).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.PreID).ParameterName);
                insSQL.Append(",");
                insSQL.Append(cmd.Add(order.PastCnt).ParameterName);
                insSQL.Append(" )");

                cmd.CommandText = insSQL.ToString();

                var retcnt = cmd.ExecuteNonQuery();
                if (retcnt > 0)
                {
                    ret = true;
                }
            }

            return(ret);
        }
예제 #30
0
        private static bool setHospConfig(AccDbConnection con, HospitalConfig hospconf)
        {
            bool ret = false;

            Config[] conf = hospconf.Conf;

            using (var cmd = con.CreateCommand())
            {
                StringBuilder delSQL = new StringBuilder();
                delSQL.Append("DELETE");
                delSQL.Append(" FROM");
                delSQL.Append(" HospConfig");

                delSQL.Append(" WHERE");
                delSQL.Append(" hosp_id=");
                delSQL.Append(cmd.Add(hospconf.HospID).ParameterName);
                delSQL.Append(" AND");
                delSQL.Append(" key IN (");

                for (int i = 0; i < conf.Length; i++)
                {
                    if (i > 0)
                    {
                        delSQL.Append(',');
                    }

                    delSQL.Append(cmd.Add(conf[i].Key).ParameterName);
                }

                delSQL.Append(")");

                cmd.CommandText = delSQL.ToString();

                cmd.ExecuteNonQuery();
            }

            // コマンドオブジェクト生成
            using (var cmd = con.CreateCommand())
            {
                StringBuilder insSQL = new StringBuilder();
                insSQL.Append("INSERT");
                insSQL.Append(" INTO");
                insSQL.Append(" HospConfig");

                insSQL.Append(" (");
                insSQL.Append(" hosp_id");
                insSQL.Append(",key");
                insSQL.Append(",value");
                insSQL.Append(" )");

                insSQL.Append(" VALUES");

                for (int i = 0; i < conf.Length; i++)
                {
                    if (i > 0)
                    {
                        insSQL.Append(",");
                    }

                    insSQL.Append(" (");
                    insSQL.Append(cmd.Add(hospconf.HospID).ParameterName);
                    insSQL.Append(",");
                    insSQL.Append(cmd.Add(conf[i].Key).ParameterName);
                    insSQL.Append(",");
                    insSQL.Append(cmd.Add(conf[i].Value).ParameterName);
                    insSQL.Append(" )");
                }

                cmd.CommandText = insSQL.ToString();

                var retcnt = cmd.ExecuteNonQuery();
                if (retcnt > 0)
                {
                    ret = true;
                }
            }

            return(ret);
        }