Beispiel #1
0
        public static SInstance ReadertoInst(SQLiteDataReader reader)
        {
            string[] jm = new string[6];
            string[] js = new string[6];

            for (int i = 0; i < jm.Length; i++)
            {
                jm[i] = reader[(i + 1) + "JoMember"].ToString();
            }
            for (int i = 0; i < js.Length; i++)
            {
                js[i] = reader[(i + 1) + "JoScore"].ToString();
            }

            SInstance inst = new SInstance(reader["Name"].ToString(), reader["Class"].ToString(), jm, js, reader["Date"].ToString());
            return inst;
        }
Beispiel #2
0
        /// <summary>
        /// 내역의 변경 사항을 저장합니다.
        /// </summary>
        /// <param name="instance"></param>
        /// <returns></returns>
        public static string SaveDB(SInstance instance, bool memberUpdate)
        {
            try
            {
                //if(instance.nonexists) throw new Exception("NO record found, use Insert instead.");
                if (con.State == System.Data.ConnectionState.Closed)
                    con.Open();
                if (memberUpdate)
                {
                    sqltext = string.Format(@"UPDATE " + YangpaConstants.DB_Tablename + @" SET
            `Name` = '{0}',
            `1JoMember` = '{1}',
            `2JoMember` = '{2}',
            `3JoMember` = '{3}',
            `4JoMember` = '{4}',
            `5JoMember` = '{5}',
            `6JoMember` = '{6}',
            `1JoScore` = '{7}',
            `2JoScore` = '{8}',
            `3JoScore` = '{9}',
            `4JoScore` = '{10}',
            `5JoScore` = '{11}',
            `6JoScore` = '{12}'
             WHERE  `ID` = '{13}'", instance.Name,
                    YangpaData.ConvertArrayToComma(instance.JoMember[0]), YangpaData.ConvertArrayToComma(instance.JoMember[1]),
                    YangpaData.ConvertArrayToComma(instance.JoMember[2]), YangpaData.ConvertArrayToComma(instance.JoMember[3]),
                    YangpaData.ConvertArrayToComma(instance.JoMember[4]), YangpaData.ConvertArrayToComma(instance.JoMember[5]),
                    instance.JoScoreToString(1), instance.JoScoreToString(2), instance.JoScoreToString(3),
                    instance.JoScoreToString(4), instance.JoScoreToString(5), instance.JoScoreToString(6), instance.Id);

                }
                else
                {
                    sqltext = string.Format(@"UPDATE " + YangpaConstants.DB_Tablename + @" SET
            `Name` = '{0}',
            `1JoScore` = '{1}',
            `2JoScore` = '{2}',
            `3JoScore` = '{3}',
            `4JoScore` = '{4}',
            `5JoScore` = '{5}',
            `6JoScore` = '{6}'
             WHERE `ID` = '{7}'", instance.Name, instance.JoScoreToString(1), instance.JoScoreToString(2), instance.JoScoreToString(3),
                    instance.JoScoreToString(4), instance.JoScoreToString(5), instance.JoScoreToString(6), instance.Id);
                }

                command = new SQLiteCommand(sqltext, con);
                return command.ExecuteNonQuery().ToString();
            }
            catch (SQLiteException e)
            {
                return e.Message;
            }
        }
Beispiel #3
0
        /// <summary>
        /// 새 조별활동 내역을 추가합니다.
        /// </summary>
        /// <param name="instance"></param>
        /// <returns></returns>
        public static string InsertDB(SInstance instance)
        {
            try
            {
                if (con.State == System.Data.ConnectionState.Closed)
                    con.Open();
                sqltext = string.Format(@"INSERT INTO `" + YangpaConstants.DB_Tablename + @"`
            (`ID`, `Name`, `Class`, `Date`, `1JoMember`, `2JoMember`, `3JoMember`, `4JoMember`, `5JoMember`, `6JoMember`, `1JoScore`, `2JoScore`, `3JoScore`, `4JoScore`, `5JoScore`, `6JoScore`)
            VALUES ('{15}', '{0}', '{1}', '{14}', '{2}',  '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}'
            )"
                , instance.Name, instance.Class,
                YangpaData.ConvertArrayToComma(instance.JoMember[0]), YangpaData.ConvertArrayToComma(instance.JoMember[1]),
                YangpaData.ConvertArrayToComma(instance.JoMember[2]), YangpaData.ConvertArrayToComma(instance.JoMember[3]),
                YangpaData.ConvertArrayToComma(instance.JoMember[4]), YangpaData.ConvertArrayToComma(instance.JoMember[5]),
                instance.JoScoreToString(1), instance.JoScoreToString(2), instance.JoScoreToString(3),
                instance.JoScoreToString(4), instance.JoScoreToString(5), instance.JoScoreToString(6), instance.Date, instance.Id);

                command = new SQLiteCommand(sqltext, con);
                command.ExecuteNonQuery();

                return string.Empty;
            }
            catch (SQLiteException e)
            {
                if (e.Message.Contains("unique")) return YangpaConstants.MSG_COL_IS_NOT_UNIQ;
                else return e.Message;
            }
        }