⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inputdata.pas.~1~

📁 《Delphi 2005程序设计及其应用开发》源代码
💻 ~1~
字号:

unit InputData;

interface

uses
  System.Collections, System.ComponentModel,
  System.Data, System.Drawing, System.Web, System.Web.SessionState,
  System.Web.UI, System.Web.UI.WebControls, System.Web.UI.HtmlControls,
  System.Globalization, System.Data.SqlClient, Borland.Data.Web, 
  Borland.Data.Common, Borland.Data.Provider, System.Data.Common;
type
  TWebForm1 = class(System.Web.UI.Page)
  protected
  {$REGION 'Designer Managed Code'}
  strict private
    procedure InitializeComponent;
    procedure Button2_Click(sender: System.Object; e: System.EventArgs);
    procedure Button1_Click(sender: System.Object; e: System.EventArgs);
    procedure Button3_Click(sender: System.Object; e: System.EventArgs);
  {$ENDREGION}
  strict private
    procedure Page_Load(sender: System.Object; e: System.EventArgs);
  strict protected
    Repeater1: System.Web.UI.WebControls.Repeater;
    Label1: System.Web.UI.WebControls.Label;
    Label2: System.Web.UI.WebControls.Label;
    TextBox2: System.Web.UI.WebControls.TextBox;
    TextBox3: System.Web.UI.WebControls.TextBox;
    TextBox4: System.Web.UI.WebControls.TextBox;
    TextBox5: System.Web.UI.WebControls.TextBox;
    TextBox6: System.Web.UI.WebControls.TextBox;
    TextBox7: System.Web.UI.WebControls.TextBox;
    TextBox1: System.Web.UI.WebControls.TextBox;
    Label3: System.Web.UI.WebControls.Label;
    Label4: System.Web.UI.WebControls.Label;
    Label5: System.Web.UI.WebControls.Label;
    Label6: System.Web.UI.WebControls.Label;
    Label7: System.Web.UI.WebControls.Label;
    Label8: System.Web.UI.WebControls.Label;
    Button1: System.Web.UI.WebControls.Button;
    Button2: System.Web.UI.WebControls.Button;
    Button3: System.Web.UI.WebControls.Button;
    procedure OnInit(e: EventArgs); override;
  private
    { Private Declarations }
  public
    { Public Declarations }
  end;

implementation

{$REGION 'Designer Managed Code'}
/// <summary>
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure TWebForm1.InitializeComponent;
begin
  Include(Self.Button1.Click, Self.Button1_Click);
  Include(Self.Button2.Click, Self.Button2_Click);
  Include(Self.Button3.Click, Self.Button3_Click);
  Include(Self.Load, Self.Page_Load);
end;
{$ENDREGION}

procedure TWebForm1.Page_Load(sender: System.Object; e: System.EventArgs);
begin

  // TODO: Put user code to initialize the page here
 //BdpDataAdapter1.Fill(Dataset1.Tables[0]);
 //Self.dataGrid1.DataBind();
end;

procedure TWebForm1.OnInit(e: EventArgs);
begin
  //
  // Required for Designer support
  //
  InitializeComponent;
  inherited OnInit(e);
end;

procedure TWebForm1.Button3_Click(sender: System.Object; e: System.EventArgs);
begin
   Response.Redirect('Course.aspx');
end;

procedure TWebForm1.Button1_Click(sender: System.Object; e: System.EventArgs);
var
   Connection: SqlConnection;
   Command : SqlCommand;
   pCourseID,pCourseName, pStudentID, pStudentName, pClass, pScores, pOther : SqlParameter;
begin
      Connection := SqlConnection.Create('server =localhost; Database =StudentDB; uid = sa; pwd =; ');
      Command :=SqlCommand.Create( 'INSERT INTO ScoreInfo(CourseID, CourseName,StudentID, StudentName, Class, Other)' +
      'Values(@CourseID, @CourseName,@StudentID, @StudentName, @Class, @Other)', Connection);
      pCourseID := SqlParameter.Create('@CourseID', SqlDbType.Char, 10);
      pCourseID.Value := TextBox1.Text;
      Command.Parameters.Add(pCourseID);
      pCourseName := SqlParameter.Create('@CourseName', SqlDbType.Char, 20);
      pCourseName.Value := TextBox2.Text;
      Command.Parameters.Add(pCourseName);
      pStudentID := SqlParameter.Create('@StudentID', SqlDbType.Char, 10);
      pStudentID.Value := TextBox3.Text;
      Command.Parameters.Add(pStudentID);
      pStudentName := SqlParameter.Create('@StudentName', SqlDbType.Char, 10);
      pStudentName.Value := TextBox4.Text;
      Command.Parameters.Add(pStudentName);
      pClass := SqlParameter.Create('@Class', SqlDbType.Char,20);
      pClass.Value := TextBox5.Text;
      Command.Parameters.Add(pClass);
      pScores := SqlParameter.Create('@Scores', SqlDbType.int);
      pScores.Value := TextBox6.Text;
      Command.Parameters.Add(pScores);
      pOther := SqlParameter.Create('@Other', SqlDbType.Char, 30);
      pOther.Value := TextBox7.Text;
      Command.Parameters.Add(pOther);
      try
          Connection.Open();
          Command.ExecuteNonQuery();
          Connection.Close();
          Response.Write('<script>confirm("操作成功!")</script>');
      except
          Response.Write('<script>confirm("操作失败!")</script>');
      end;
      TextBox1.Text :='';
      TextBox2.Text :='';
      TextBox3.Text :='';
      TextBox4.Text :='';
      TextBox5.Text :='';
      TextBox6.Text :='';
      TextBox7.Text :='';
end;

procedure TWebForm1.Button2_Click(sender: System.Object; e: System.EventArgs);
begin
   Response.Redirect('Score.aspx');
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -