コード例 #1
0
ファイル: YoUpdate.cs プロジェクト: muxiujh/YoERP
        public bool Update(JObject uiDict)
        {
            var result = false;

            while (true)
            {
                m_uiDict = uiDict;
                if (m_uiDict == null)
                {
                    break;
                }

                if (!m_uiDict.ContainsKey(ID))
                {
                    break;
                }

                if (!Find(m_uiDict[ID]))
                {
                    break;
                }

                if (!checkUptime())
                {
                    m_errorDict[DB] = "dirty data";
                    break;
                }

                if (!parseSqlSet())
                {
                    break;
                }

                var sql = string.Format("UPDATE `{0}` SET {1} WHERE `id`='{2}';", m_table, string.Join(",", m_sqlSetDict.Values), m_uiDict[ID]);
                if (!runSql(sql))
                {
                    break;
                }

                // remove cache
                var yoRefer = new YoCacheRefer(m_table, (table, id) => {
                    // create cache
                    var selectone = new YoSelectOne(table, m_trans);
                    selectone.GetRowTitleDisplay(id);
                });
                if (yoRefer.CheckDisplayChange(m_sqlSetDict))
                {
                    yoRefer.ReferRow(m_uiDict[ID]);
                }

                result = true;
                break;
            }

            return(result);
        }
コード例 #2
0
ファイル: YoInsert.cs プロジェクト: muxiujh/YoERP
        public bool Insert(JObject uiDict)
        {
            var result = false;

            while (true)
            {
                m_id     = null;
                m_uiDict = uiDict;
                if (m_uiDict == null)
                {
                    break;
                }

                if (m_uiDict.Count <= 0)
                {
                    break;
                }

                if (!parseSqlValues())
                {
                    break;
                }

                var sql = string.Format("INSERT INTO `{0}` ({1}) VALUES ({2});", m_table, string.Join(",", m_listSqlColumn), string.Join(",", m_listSqlValue));
                sql += "SELECT last_insert_id();";
                m_id = getFirst(sql);
                if (m_id == null)
                {
                    break;
                }

                // create cache
                var selectone = new YoSelectOne(m_table, m_trans);
                selectone.GetRowTitleDisplay(m_id);

                result = true;
                break;
            }

            return(result);
        }