天子不跪吧 关注:8贴子:258
  • 14回复贴,共1

关于某一次坑爹的考试

只看楼主收藏回复

一楼献给我亲爱的度娘


IP属地:重庆1楼2012-06-27 23:41回复
    【音乐播放器】
    (mp31)
    using System;using System.Collections.Generic;using System.Text;using System.Runtime.InteropServices;namespace Musicar{ class API { public const int WM_SYSCOMMAND = 0x112; public const int SC_MOVE = 0xF010; public const int HTCAPTION = 0x2; [DllImportAttribute("user32.dll")] public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); [DllImportAttribute("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("kernel32.dll", CharSet = CharSet.Auto)] public static extern int GetShortPathName(string lpszLongPath, string shortFile, int cchBuffer); [DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)] public static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback); }}
    


    IP属地:重庆6楼2012-06-27 23:58
    回复
      (mp32)
      using System;using System.Collections.Generic;using System.Text;namespace Musicar{ class mp3Play { public static void OpenAndPlay(string strFileName, bool flagRepeat) { string strCommand = ""; string buf = ""; strCommand = "open \"" + strFileName + "\" alias music"; buf = buf.PadLeft(128, ' '); API.mciSendString(strCommand, buf, buf.Length, 0);
      if (flagRepeat) { strCommand = "play music repeat"; } else { strCommand = "play music"; } API.mciSendString(strCommand, buf, buf.Length, 0); } public static void Play(bool flagRepeat) { string strCommand = ""; if (flagRepeat) { strCommand = "play music repeat"; } else { strCommand = "play music"; } API.mciSendString(strCommand, "", 0, 0); } public static bool SetProcess(int nPosition) { bool success = false; string strCommand = string.Format("seek music to {0}", nPosition); if (API.mciSendString(strCommand, "", 0, 0) == 0) { success = true; } return success; }
      public static void StepN(int nStep) { API.mciSendString("step music by " + nStep.ToString(), "", 0, 0); } public static void Stop() //暂停播放 { API.mciSendString("stop music", "", 0, 0); } public static void Pause()//暂停 { API.mciSendString("pause music", "", 0, 0); } public static void Resume()//继续播放 { API.mciSendString("resume music", "", 0, 0); }
      public static int GetCurrentPosition() //获得当前播放位置 { string buf = ""; buf = buf.PadLeft(128, ' '); API.mciSendString("status music position", buf, buf.Length, 0); buf = buf.Trim().Replace("\0", ""); if (string.IsNullOrEmpty(buf)) { return 0; } else { return (int)(Convert.ToDouble(buf)) / 1000; } }
      public static void Forward()//快进 { int x = mp3Play.GetCurrentPosition();
      int y = 1000 * x + 2000; mp3Play.SetProcess(y);
      } public static void Backward() //后退 {
      int x = mp3Play.GetCurrentPosition();
      int y = 1000 * x - 2000; mp3Play.SetProcess(y);
      } public static bool SetVolume(int Valume) //设置音量大小 { bool success = false; string strCommand = string.Format("setaudio music volume to {0}", Valume); if (API.mciSendString(strCommand, "", 0, 0) == 0) { success = true; } return success; } public static int GetVolume() //获得当前音量 { string strVolume = ""; strVolume = strVolume.PadLeft(128, ' '); API.mciSendString("status music volume", strVolume, strVolume.Length, 0); int nVolume = 0; strVolume = strVolume.Trim().Replace("\0", ""); if (string.IsNullOrEmpty(strVolume)) { nVolume = 0; } else { nVolume = Convert.ToInt32(strVolume); } return nVolume; } public static void increase_voice()//加大音量 { SetVolume(GetVolume() + 250); } public static void decrease_voice()//减少音量 { SetVolume(GetVolume() - 250); } }}


      IP属地:重庆7楼2012-06-27 23:58
      回复
        (Mp3)
        using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using Musicar;namespace CandySure{ public partial class Mp3 : Form { public Mp3() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { OpenFileDialog x = new OpenFileDialog(); DialogResult y = x.ShowDialog(); if (y == DialogResult.OK) { textBox1.Text = x.FileName; }
        } private void button2_Click(object sender, EventArgs e) { mp3Play.OpenAndPlay(textBox1.Text, true); }
        private void button3_Click(object sender, EventArgs e) { mp3Play.Stop(); } private void MP3_Load(object sender, EventArgs e) { } private void MP3_Load_1(object sender, EventArgs e) { } }}
        


        IP属地:重庆8楼2012-06-27 23:59
        回复
          【视频播放器】
          using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;
          namespace CandySure{ public partial class Video : Form { public Video() { InitializeComponent(); }
          private void button2_Click(object sender, EventArgs e) { axWindowsMediaPlayer1.URL = textBox1.Text; axWindowsMediaPlayer1.Ctlcontrols.play(); }
          private void button1_Click(object sender, EventArgs e) { OpenFileDialog t = new OpenFileDialog(); DialogResult x = t.ShowDialog(); if (x == DialogResult.OK) { textBox1.Text = t.FileName; } }
          private void audio_Load(object sender, EventArgs e) {
          } }}


          IP属地:重庆9楼2012-06-28 00:00
          回复
            【光标回车ReturnEvent】
            using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;
            namespace CandySure{ public partial class ReturnEvent : Form { public ReturnEvent() { InitializeComponent(); }
            private void t1_KeyDown_1(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { t4.Focus(); } else if (e.KeyValue == 40) { t4.Focus(); } else if (e.KeyValue == 39) { t2.Focus(); } else if (e.KeyValue == 38) { t7.Focus(); } else if (e.KeyValue == 37) { t9.Focus(); } }
            private void t2_KeyDown_1(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { t4.Focus(); } else if (e.KeyValue == 40) { t5.Focus(); } else if (e.KeyValue == 39) { t3.Focus(); } else if (e.KeyValue == 38) { t8.Focus(); } else if (e.KeyValue == 37) { t1.Focus(); }
            }
            private void t3_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { t4.Focus(); } else if (e.KeyValue == 40) { t6.Focus(); } else if (e.KeyValue == 39) { t4.Focus(); } else if (e.KeyValue == 38) { t9.Focus(); } else if (e.KeyValue == 37) { t2.Focus(); } }
            private void t4_KeyDown_1(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { t7.Focus(); } else if (e.KeyValue == 40) { t7.Focus(); } else if (e.KeyValue == 39) { t5.Focus(); } else if (e.KeyValue == 38) { t1.Focus(); } else if (e.KeyValue == 37) { t3.Focus(); } }
            private void t5_KeyDown_1(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { t7.Focus(); } else if (e.KeyValue == 40) { t8.Focus(); } else if (e.KeyValue == 39) { t6.Focus(); } else if (e.KeyValue == 38) { t2.Focus(); } else if (e.KeyValue == 37) { t4.Focus(); } }
            private void t6_KeyDown_1(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { t7.Focus(); } else if (e.KeyValue == 40) { t9.Focus(); } else if (e.KeyValue == 39) { t7.Focus(); } else if (e.KeyValue == 38) { t3.Focus(); }
            


            IP属地:重庆10楼2012-06-28 00:01
            回复
              else if (e.KeyValue == 37) { t5.Focus(); } }
              private void t7_KeyDown_1(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { t1.Focus(); } else if (e.KeyValue == 40) { t1.Focus(); } else if (e.KeyValue == 39) { t8.Focus(); } else if (e.KeyValue == 38) { t4.Focus(); }
              else if (e.KeyValue == 37) { t6.Focus(); }
              }
              private void t8_KeyDown_1(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { t1.Focus(); } else if (e.KeyValue == 40) { t2.Focus(); } else if (e.KeyValue == 39) { t9.Focus(); } else if (e.KeyValue == 38) { t5.Focus(); }
              else if (e.KeyValue == 37) { t7.Focus(); } }
              private void t9_KeyDown_1(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { t1.Focus(); } else if (e.KeyValue == 40) { t3.Focus(); } else if (e.KeyValue == 39) { t1.Focus(); } else if (e.KeyValue == 38) { t6.Focus(); }
              else if (e.KeyValue == 37) { t8.Focus(); } }
              private void button1_Click_1(object sender, EventArgs e) { StringBuilder str = new StringBuilder(); str.AppendFormat("第一个输入值是:" + t1.Text); str.AppendFormat("\n第二个输入值是:" + t2.Text); str.AppendFormat("\n第三个输入值是:" + t3.Text); str.AppendFormat("\n第四个输入值是:" + t4.Text); str.AppendFormat("\n第五个输入值是:" + t5.Text); str.AppendFormat("\n第六个输入值是:" + t6.Text); str.AppendFormat("\n第七个输入值是:" + t7.Text); str.AppendFormat("\n第八个输入值是:" + t8.Text); str.AppendFormat("\n第九个输入值是:" + t9.Text); MessageBox.Show(str.ToString()); }
              private void button2_Click_1(object sender, EventArgs e) { this.Close(); }
              private void Form13_Load(object sender, EventArgs e) {
              }
              }}
              


              IP属地:重庆11楼2012-06-28 00:01
              回复
                【父窗体 MDIParent1 】
                using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;
                namespace CandySure{ public partial class MDIParent1 : Form { private int childFormNumber = 0;
                public MDIParent1() { InitializeComponent(); }
                private void 光标回车事件ToolStripMenuItem_Click(object sender, EventArgs e) { ReturnEvent t = new ReturnEvent(); t.MdiParent = this; t.Show(); }
                private void 音乐播放器ToolStripMenuItem_Click_1(object sender, EventArgs e) { Mp3 t = new Mp3(); t.MdiParent = this; t.Show(); }
                private void 视频播放器ToolStripMenuItem_Click_1(object sender, EventArgs e) { Video t = new Video(); t.MdiParent = this; t.Show(); }
                private void 播放器ToolStripMenuItem_Click(object sender, EventArgs e) {
                }
                }}
                


                IP属地:重庆12楼2012-06-28 00:02
                回复
                  【数据库】
                  (SQL1)
                  using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.OleDb;
                  namespace CandySure{ public partial class SQL1 : Form { public SQL1() { InitializeComponent(); }
                  //按条件查询并更新视图 OleDbCommand comm = new OleDbCommand(); OleDbConnection conn = new OleDbConnection(); OleDbDataAdapter adapt = new OleDbDataAdapter(); DataTable dt = new DataTable(); //查询 private void button1_Click(object sender, EventArgs e) { select(); } public void select() { String temp = "1=1"; if (textBox1.Text.Trim() != "") temp += " and 学号='" + textBox1.Text.Trim() + "'"; if (textBox2.Text.Trim() != "") temp += " and 姓名='" + textBox2.Text.Trim() + "'"; if (comboBox1.Text.Trim() != "") temp += " and 性别='" + comboBox1.Text.Trim() + "'"; if (textBox4.Text.Trim() != "") temp += " and 年级='" + textBox4.Text.Trim() + "'";
                  String SQL1 = "Select * from 学生信息表 where " + temp;
                  try { conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + Application.StartupPath + "\\student.mdb"; conn.Open(); comm.Connection = conn; comm.CommandType = CommandType.Text; comm.CommandText = SQL1; adapt.SelectCommand = comm; dt = new DataTable(); adapt.Fill(dt); dataGridView1.DataSource = dt; } catch (Exception x) { MessageBox.Show(x.Message); } finally { conn.Close(); } } //修改 private void button3_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count == 0) MessageBox.Show("请先指定一行数据"); else { update.data = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); update y = new update(); y.ShowDialog(); if (y.DialogResult == DialogResult.OK) { select(); label6.Text = "修改该记录成功!"; } } } public add b; //添加 private void button2_Click(object sender, EventArgs e) { add b = new add(); b.ShowDialog(); if (b.DialogResult == DialogResult.OK) { select(); label6.Text = "添加记录成功!"; } } //删除 private void button4_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count == 0) MessageBox.Show("请先指定一行数据"); else { try { String data = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + "student.mdb"; conn.Open();
                  comm.Connection = conn; comm.CommandType = CommandType.Text; comm.CommandText = "Delete from 学生信息表 where 学号='" + data + "'"; int x = comm.ExecuteNonQuery(); if (x == 1) label6.Text = "删除该记录成功!"; } catch (Exception x) { MessageBox.Show(x.Message); } finally { conn.Close(); } select(); } }
                  private void SQL1_Load(object sender, EventArgs e) {
                  }
                  }}


                  IP属地:重庆13楼2012-06-28 00:04
                  回复
                    (add)
                    using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.OleDb;
                    namespace CandySure{ public partial class add : Form { public add() { InitializeComponent();
                    }
                    OleDbConnection conn = new OleDbConnection(); OleDbCommand comm = new OleDbCommand(); DialogResult result;
                    private void add_Load(object sender, EventArgs e) {
                    }
                    private void button1_Click_1(object sender, EventArgs e) { StringBuilder sql = new StringBuilder(); sql.AppendFormat("insert into 学生信息表 values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')" , t1.Text, t2.Text, comboBox1.SelectedItem.ToString(), t4.Text, t5.Text, t6.Text, t7.Text, t8.Text, t9.Text, t10.Text ); try { conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb"; conn.Open(); comm.Connection = conn; comm.CommandType = CommandType.Text; comm.CommandText = sql.ToString(); int x = comm.ExecuteNonQuery(); if (x == 1) { result = DialogResult.OK; this.DialogResult = result; MessageBox.Show("插入新记录成功"); this.Close(); } } catch (Exception x) { MessageBox.Show(x.Message); } finally { conn.Close(); } } }}
                    


                    IP属地:重庆14楼2012-06-28 00:04
                    回复
                      (update)
                      using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.OleDb;
                      namespace CandySure{ public partial class update : Form { public update() { InitializeComponent(); } public static String data; OleDbConnection conn = new OleDbConnection(); OleDbCommand comm = new OleDbCommand(); OleDbDataAdapter adapt = new OleDbDataAdapter(); DataTable dt = new DataTable(); DataRow dr; DialogResult result; private void update_Load(object sender, EventArgs e) { try { conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Student.mdb"; conn.Open(); comm.Connection = conn; comm.CommandType = CommandType.Text; comm.CommandText = "select * from 学生信息表 where 学号='" + data + "'"; adapt.SelectCommand = comm; adapt.Fill(dt); dr = dt.Rows[0]; t1.Text = dr[0].ToString(); t2.Text = dr[1].ToString(); comboBox1.SelectedItem = dr[2].ToString(); t4.Text = dr[3].ToString(); t5.Text = dr[4].ToString(); t6.Text = dr[5].ToString(); t7.Text = dr[6].ToString(); t8.Text = dr[7].ToString(); t9.Text = dr[8].ToString(); t10.Text = dr[9].ToString(); } catch (Exception x) { MessageBox.Show(x.Message); } finally { conn.Close(); } }
                      private void button1_Click(object sender, EventArgs e) { StringBuilder sql = new StringBuilder(); sql.AppendFormat("update 学生信息表 set 姓名='{1}',性别='{2}',年级='{3}',班级='{4}',家庭地址='{5}',邮编='{6}',电话='{7}',电子邮件='{8}',年龄='{9}' where 学号='{0}'" , t1.Text, t2.Text, comboBox1.SelectedItem.ToString(), t4.Text, t5.Text, t6.Text, t7.Text, t8.Text, t9.Text, t10.Text ); try { conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb"; conn.Open(); comm.Connection = conn; comm.CommandType = CommandType.Text; comm.CommandText = sql.ToString(); int x = comm.ExecuteNonQuery(); if (x == 1) { result = DialogResult.OK; this.DialogResult = result; MessageBox.Show("修改记录成功"); this.Close(); } } catch (Exception x) { MessageBox.Show(x.Message); } finally { conn.Close(); } } }}
                      


                      IP属地:重庆15楼2012-06-28 00:06
                      回复
                        【Program】
                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        Application.Run(new MDIParent1());


                        IP属地:重庆16楼2012-06-28 00:07
                        回复
                          我来挖坟……


                          IP属地:河北来自Android客户端17楼2013-04-11 19:09
                          收起回复