private void btnLogin_Click(object sender, EventArgs e) { //非空验证 if (txtUserName.Text == "") { HintMessageBox.Warning_hint("请输入账户姓名!!"); return; } else if (txtPwd.Text == "") { HintMessageBox.Warning_hint("请输入账户密码!!"); return; } //sql语句 string sql = string.Format("select COUNT(*) from admin_info where admin_name = '{0}' and admin_pwd = '{1}'", txtUserName.Text.Trim(), txtPwd.Text.Trim()); if (db.ExecuteScalar(sql) == null) { return; } if ((int)db.ExecuteScalar(sql) > 0) { HintMessageBox.Information_hint("登录成功!!"); FrmAdmin admin = new FrmAdmin(); admin.Show(); //显示后台管理主窗体 this.Hide(); //隐藏登录窗体 } else { HintMessageBox.Information_hint("用户名或密码错误!!"); } }
private void btnSave_Click(object sender, EventArgs e) { //非空验证 if (txtSongName.Text == "" || txtPinYin.Text == "" || Convert.ToInt32(cmbSongType.SelectedValue) == -1 || txtSongFileName.Text == "") { HintMessageBox.Information_hint("请填写完整带 * 的项!!"); return; } //获取用户输入的值 string songName = txtSongName.Text; string pinYin = txtPinYin.Text; string songFileName = txtSongFileName.Text; int singer = Convert.ToInt32(db.ExecuteScalar(string.Format("select singer_id from dbo.singer_info where singer_Name = '{0}'", txtSinger.Text))); int songtype = Convert.ToInt32(cmbSongType.SelectedValue); int wordNum = Convert.ToInt32(nudWordCount.Value); string sql = ""; switch (btnSave.Text) { case "保存": sql = string.Format("insert dbo.song_info values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", songName, pinYin, wordNum, songtype, singer, songFileName, 0); break; case "保存修改": sql = string.Format("UPDATE [MyKTV].[dbo].[song_info] SET [song_name] = '{0}',[song_ab] ='{1}',[song_word_count] = '{2}',[songtype_id] = '{3}',[singer_id] = '{4}',[song_url] = '{5}' WHERE song_id='{6}'", songName, pinYin, wordNum, songtype, singer, songFileName, song_id); break; } if (db.ExecuteNonQuery(sql) > 0) { HintMessageBox.Information_hint(btnSave.Text + "歌曲成功!!"); } else { HintMessageBox.Warning_hint(btnSave.Text + "歌曲失败!!"); } }