Exemple #1
0
        private void FrmEditSong_Load(object sender, EventArgs e)
        {
            //绑定组合框
            db.BindComboBox(cmbSongType, "select * from song_type", "songtype_name", "songtype_id");
            if (song_id == 0)
            {
                return;
            }
            //添加信息到文本框中
            btnSave.Text = "保存修改";
            string  sql = string.Format("select song_name,song_ab,song_word_count,songtype_id,song_url,singer_name from dbo.song_info,singer_info where song_id = '{0}' and singer_info.singer_id = song_info.singer_id", song_id);
            DataSet ds  = db.GetDataSet(sql);

            txtSongName.Text = ds.Tables["temp"].Rows[0][0].ToString();

            txtPinYin.Text = ds.Tables["temp"].Rows[0][1].ToString();

            nudWordCount.Value = Convert.ToInt32(ds.Tables["temp"].Rows[0][2]);

            cmbSongType.SelectedValue = Convert.ToInt32(ds.Tables["temp"].Rows[0][3]);

            txtSongFileName.Text = ds.Tables["temp"].Rows[0][4].ToString();

            txtSinger.Text = ds.Tables["temp"].Rows[0][5].ToString();
        }
Exemple #2
0
        /// <summary>
        /// 保存修改按钮单击事件
        /// </summary>
        /// <param name="sender">事件源</param>
        /// <param name="e">事件参数</param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            ////如果歌曲路径字符串为空则更改歌手写真路径
            //sql = song_path == string.Empty ? string.Format("update singer_info set singer_photo_url = '{0}'", txtNewPath.Text) : string.Format("update song_info set song_url = '{0}'", txtNewPath.Text);
            //if (db.ExecuteNonQuery(sql)>0)
            //{
            //    HintMessageBox.Information_hint("修改路径成功!!");
            //    this.Close();
            //}
            //else
            //{
            //    HintMessageBox.Information_hint("修改路径失败!!");
            //}
            //需要将数据库中所有的记录查询出来,然后截取路径到文件名。
            //显示修改进度条
            pnlJinDu.Visible = true;
            //清空listview视图
            lvInfo.Items.Clear();
            //sql语句-->查询
            string sql = string.Empty;

            sql = song_path == null?string.Format("select singer_id,singer_photo_url from singer_info", txtNewPath.Text) : string.Format("select song_id,song_url from song_info", txtNewPath.Text);

            DataSet ds = db.GetDataSet(sql);//获得DataSet对象

            //修改每条记录的绝对路径
            for (int i = 0; i < ds.Tables["temp"].Rows.Count; i++)
            {
                string path     = ds.Tables["temp"].Rows[i][1].ToString();                                                                                                                                                                                                                       //获取记录的路径
                string fileName = path.Substring(path.LastIndexOf("\\") + 1);                                                                                                                                                                                                                    //获取文件名
                int    id       = Convert.ToInt32(ds.Tables["temp"].Rows[i][0]);                                                                                                                                                                                                                 //记录的id
                //sql语句 -->更新数据
                string sql_ = singer_photo_path == null?string.Format("update song_info set song_url = '{0}' where song_id = '{1}'", txtNewPath.Text + fileName, id) : string.Format("update singer_info set singer_photo_url = '{0}' where singer_id = '{1}'", txtNewPath.Text + fileName, id); //更新进行更新操作的sql语句

                //修改数据到数据库
                ListViewItem item = new ListViewItem();
                item.Text = path;                              //修改前的路径
                item.SubItems.Add("-->");
                item.SubItems.Add(txtNewPath.Text + fileName); //修改后的路径
                int result = db.ExecuteNonQuery(sql_);
                item.SubItems.Add(result > 0 ? "修改成功!": "修改失败!!");
                lvInfo.Items.Add(item);
            }
        }
Exemple #3
0
        private void rdoCombination_Load(object sender, EventArgs e)
        {
            //性别默认选中男
            rdoMale.Checked = true;
            //绑定组合框
            db.BindComboBox(cmbSingerType, "select * from singer_type", "singertype_name", "singertype_id");
            //如果不是通过修改歌手信息启动的该窗体,就提前结束该方法
            if (singer_id == 0)
            {
                return;
            }
            btnAdd.Text = "修改";
            string sql = string.Format("select singer_name,singertype_id,singer_sex,singer_photo_url,singer_Describe from dbo.singer_info where singer_id = '{0}'", singer_id);
            //添加歌手信息到信息编辑框内
            DataSet ds = db.GetDataSet(sql);

            txtName.Text = ds.Tables["temp"].Rows[0][0].ToString();
            cmbSingerType.SelectedValue = Convert.ToInt32(ds.Tables["temp"].Rows[0][1]);
            switch (ds.Tables["temp"].Rows[0][2].ToString())
            {
            case "男":
                rdoMale.Checked = true;
                break;

            case "女":
                rdoFemale.Checked = true;
                break;

            case "组合":
                rdoCom.Checked = true;
                break;
            }
            photoPath = ds.Tables["temp"].Rows[0][3].ToString(); //写真图片的储存路径
            if (photoPath != string.Empty)                       //当路径不为空时
            {
                picSingerPhoto.Image = Image.FromFile(photoPath);
            }
            txtDescribe.Text = ds.Tables["temp"].Rows[0][4].ToString();
        }