Beispiel #1
0
        public static bool xiugai(string path, string type, int id)
        {
            string sql = new StringBuilder().AppendFormat("{0} {1}", DBHelper.FormatUpdateOneTable("resource_path", new string[] { "resource_path" }, new string[] { path + @"\" }), DBHelper.FormatWHERE(new string[] { "resource_type", "resource_id" }, new string[] { type, id.ToString() }, new DBHelper.WHERE[] { DBHelper.WHERE.OR }, new DBHelper.Relation[] { DBHelper.Relation.Like, DBHelper.Relation.Like })).ToString();
            int i = new DBHelper().UpdateDB(sql);
            if (i > 0)
            {
                DialogResult moveFiles = MessageBox.Show("路径修改成功,是否要移动原文件夹下所有文件到新文件夹?", "移动文件?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (moveFiles == DialogResult.Yes)
                {
                    int movedFilesCount = 0;
                    if (id == 1)
                    {
                        movedFilesCount = MoveFiles(KTVUtil.singerPhotoPath, path);
                    }
                    else if (id == 2)
                    {
                        movedFilesCount = MoveFiles(KTVUtil.songPath, path);
                    }

                    MessageBox.Show("移动了" + movedFilesCount + "个文件");

                }
                FrmAdmin.SetPath();
                return true;
            }
            else
            {
                MessageBox.Show("路径修改失败");
                return false;
            }
        }
Beispiel #2
0
 private void xiugai()
 {
     string sql =  DBHelper.FormatUpdateOneTable("song_info",
               new string[] { "song_name", "song_ab", "song_word_count", "songtype_id", "singer_id", "song_url" },
               new string[] { tbgequmingcheng.Text.Trim(), tbsouxie.Text.Trim(), tbgequmingcheng.Text.Trim().Length.ToString(), GetId(tbleixing), GetId(tbgeshou), tbwenjianming.Text.Trim() }
               );
     sql += DBHelper.FormatWHERE(new string[]{"song_id"},new string[]{SongID},new DBHelper.WHERE[0],new DBHelper.Relation[]{DBHelper.Relation.Equal});
        int i = new DBHelper().UpdateDB(sql);
        if (i>0)
        {
        MessageBox.Show("修改成功","提示框");
        fsl.chaxun(true);
        }
 }
Beispiel #3
0
 /// <summary>
 /// 获取id
 /// </summary>
 /// <param name="columnName">select 列名</param>
 /// <param name="whereColumnName">where 列名</param>
 /// <param name="whereValueName">where 值</param>
 /// <param name="tableName">表名</param>
 /// <returns></returns>
 private string GetOrCreateId(string columnName, string whereColumnName, string whereValueName, string tableName)
 {
     DataTable dt = new DBHelper().FillInDataSet
         (
         new StringBuilder("SELECT ")
         .AppendFormat("[{0}] FROM [{1}] WHERE [{2}] = '{3}'", columnName, tableName,whereColumnName,whereValueName)
         .ToString()
          , tableName).Tables[tableName];
     if (dt.Rows.Count>0)
     {
         return dt.Rows[0][columnName].ToString();
     }
     else
     {
         return CreateId(whereValueName,tableName,whereColumnName);
     }
 }