Пример #1
0
        private void YesButton_Click(object sender, EventArgs e)
        {
            try
            {
                string name = NameTextBox.Text.Trim();
                string filepath = folderBrowserDialog1.SelectedPath;
                string updatetime = SharedMethod.GetLastWriteTime(folderBrowserDialog1.SelectedPath).ToString();
                string isnewtime = IsNewTimeCheckBox.Checked.ToString();
                Access ac = new Access();
                ac.Open();
                if (this.Text == "添加")
                {
                    DataTable dt = ac.Select("select * from game where name = '" + name + "'");
                    if (dt.Rows.Count != 0)
                    {
                        MessageBox.Show("提示", "该游戏名称已存在");
                        return;
                    }
                    ac.Command("insert into game(name,updatetime,filepath,isnewtime) values('" + name + "','" + updatetime + "','" + filepath + "','" + isnewtime + "')");
                    if (SharedMethod.SelectFiles(name) != 0)
                    {
                        if (MessageBox.Show("当前游戏有曾备份的存档文件,是否还原?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                        {

                            RestoreForm rf = new RestoreForm(name,filepath);
                            rf.StartPosition = FormStartPosition.CenterParent;
                            this.Opacity = 0;
                            rf.ShowDialog();
                        }
                    }
                }
                else if (this.Text == "修改")
                {
                    ac.Command("update game set filepath = '" + filepath + "' ,updatetime = '" + updatetime + "' ,isnewtime = '" + isnewtime + "' where name = '" + name + "'");
                }
                ac.Close();
            }
            catch
            {

            }
        }
Пример #2
0
 private void RestoreButton_Click(object sender, EventArgs e)
 {
     if (NameComboBox.Text != "")
     {
         if (SaveFilesS.Text != "" || SaveFilesS.Text != "0")
         {
             string GameName = NameComboBox.Text;
             RestoreForm rf = new RestoreForm(NameComboBox.Text, FilePath2.Text + FilePath3.Text + FilePath4.Text + FilePath5.Text);
             rf.StartPosition = FormStartPosition.CenterParent;
             if (rf.ShowDialog() == System.Windows.Forms.DialogResult.Yes)
             {
                 updateDGV();
                 NameComboBox.SelectedIndex = NameComboBox.Items.IndexOf(GameName);
             }
         }
     }
 }