Ejemplo n.º 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (dgViewFileList.SelectedRows == null || dgViewFileList.SelectedCells.Count == 0)
            {
                return;
            }

            SyncFile syncFile;
            var      row = dgViewFileList.SelectedCells[0].OwningRow;
            int      id  = Convert.ToInt32(row.Cells["colID"].Value);

            if (SycerSQLiteHelper.GetSyncFile(_conn, id, out syncFile) && syncFile != null)
            {
                string   latestPath;
                DateTime updateTime;
                if (!FileSyncHelper.UpdateFilesToNewest(syncFile.ListFullName, out latestPath, out updateTime) ||
                    string.IsNullOrEmpty(latestPath))
                {
                    MessageBox.Show(@"同步数据失败!");
                }
                else                //更新数据库文件
                {
                    FileSyncHelper.FreshSyncFile(ref syncFile, latestPath, updateTime, 1);
                    if (!SycerSQLiteHelper.UpdateSyncFile(_conn, syncFile))
                    {
                        MessageBox.Show(@"文件已更新,但更新同步信息失败!");
                    }
                }
            }
            else
            {
                MessageBox.Show(@"读取同步文件信息失败!");
            }
            ReadDataBase();
        }
Ejemplo n.º 2
0
        private void dgViewFileList_DoubleClick(object sender, EventArgs e)
        {
            if (dgViewFileList.SelectedRows == null || dgViewFileList.SelectedCells.Count == 0)
            {
                return;
            }

            SyncFile syncFile;
            var      row = dgViewFileList.SelectedCells[0].OwningRow;
            int      id  = Convert.ToInt32(row.Cells["colID"].Value);

            if (SycerSQLiteHelper.GetSyncFile(_conn, id, out syncFile) && syncFile != null)
            {
                //打开添加数据窗体
                FrmFileSet frm = new FrmFileSet(syncFile.FileSetName, syncFile.ListFullName);
                frm.ShowDialog();
                //向数据库添加数据
                if (!SycerSQLiteHelper.UpdateSyncFile(_conn, frm.FileSetName, frm.ListFileInfo, id))
                {
                    MessageBox.Show(@"未能更新文件集!", @"文件集更新失败");
                }
                else
                {
                    ReadDataBase();
                }
            }
        }
Ejemplo n.º 3
0
        public FrmMain()
        {
            InitializeComponent();

            _conn = SycerSQLiteHelper.ConnectMainDb();
            System.Diagnostics.Debug.Assert(_conn != null);
            ReadDataBase();
        }
Ejemplo n.º 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //打开添加数据窗体
            FrmFileSet frm = new FrmFileSet(null);

            if (frm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            //向数据库添加数据
            if (!SycerSQLiteHelper.InsertSyncFile(_conn, frm.FileSetName, frm.ListFileInfo))
            {
                MessageBox.Show(@"未能添加新的文件集!", @"文件集添加失败");
            }
            else
            {
                ReadDataBase();
            }
        }