예제 #1
0
파일: MainForm.cs 프로젝트: i-e-b/DBSS
        /// <summary>
        /// Update in-memory grid and database
        /// </summary>
        protected void UpdateCell(GridCell gc, int x, int y)
        {
            bigGrid1.Items[x,y] = (gc.IsEmpty()) ? (null) : (gc);

            ulong key = bigGrid1.Items.GetUniqueKey(x, y);

            // Send changes to DB
            var adapter = new SheetDataTableAdapters.SheetAdapter();
            var cache = new SheetDataTableAdapters.CachesAdapter();
            if (gc.IsEmpty()) {
                adapter.DeleteCellByHash((long)key);
                cache.DeleteCacheByHash((long)key);
            } else {
                adapter.SetCellByHash((long)key, x, y, gc.Name, gc.Formula);
                cache.SetCacheByHash((long)key, gc.RPN, gc.Value);
            }
        }
예제 #2
0
파일: MainForm.cs 프로젝트: i-e-b/DBSS
        protected void LoadFromDB()
        {
            var adapter = new SheetDataTableAdapters.SheetAdapter();
            var cache = new SheetDataTableAdapters.CachesAdapter();

            bigGrid1.Items.Clear();
            var table = adapter.GetSheet();
            foreach (var cell in table) {
                var gc = new GridCell {Formula = cell.Formula, Name = cell.Name};
                int x = cell.x;
                int y = cell.y;

                var ctab = cache.GetCacheByHash((long)bigGrid1.Items.GetUniqueKey(x, y));
                if (ctab.Count > 0) {
                    gc.Value = ctab[0].Value;
                    gc.RPN = ctab[0].RPN;
                }

                bigGrid1.Items[x, y] = gc;
            }
        }