📄 form1.cs
字号:
/************************************************************************/
/*
* 利用word的书签功能实现家长通知书的打印。
*
* 原理很简单,替换文档中的书签对象就可以了。
* 下学期来就要做个J2EE的项目,可能要三四个月的时间
* .net要放下一阵子了
*
* 此程序在 windows2003 + visual.net 2003 + office 2003 下调试通过
* 如果要修改word模板,只要保留书签名不变即可
*
* 李志杰 2005.1.28于桂林电子工业学院
* QQ: 3263262
* Email/MSN: wuChang@gliet.edu.cn
* */
/************************************************************************/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.Office.Interop.Word;
using Microsoft;
namespace WindowsApplication1
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
#region xx 这些不想看,折起来
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox 课本费;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox 学费;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox 住宿费;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.DateTimePicker 放假日期;
private System.Windows.Forms.DateTimePicker 开学日期;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox 班主任姓名;
private System.Windows.Forms.TextBox 班主任电话;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.OpenFileDialog ofd;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TextBox 模板;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.DateTimePicker 打印日期;
private System.Data.OleDb.OleDbConnection conn;
private System.Data.OleDb.OleDbCommand cmd;
private System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter();
private System.Windows.Forms.DateTimePicker 注册日期;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.TextBox 数据库;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
#endregion
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button3 = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.label12 = new System.Windows.Forms.Label();
this.班主任电话 = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.班主任姓名 = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.放假日期 = new System.Windows.Forms.DateTimePicker();
this.课本费 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.学费 = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.住宿费 = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.开学日期 = new System.Windows.Forms.DateTimePicker();
this.label11 = new System.Windows.Forms.Label();
this.打印日期 = new System.Windows.Forms.DateTimePicker();
this.模板 = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.注册日期 = new System.Windows.Forms.DateTimePicker();
this.label13 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
this.数据库 = new System.Windows.Forms.TextBox();
this.ofd = new System.Windows.Forms.OpenFileDialog();
this.button2 = new System.Windows.Forms.Button();
this.conn = new System.Data.OleDb.OleDbConnection();
this.cmd = new System.Data.OleDb.OleDbCommand();
this.da = new System.Data.OleDb.OleDbDataAdapter();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.button3);
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.label12);
this.groupBox1.Controls.Add(this.班主任电话);
this.groupBox1.Controls.Add(this.label10);
this.groupBox1.Controls.Add(this.班主任姓名);
this.groupBox1.Controls.Add(this.label9);
this.groupBox1.Controls.Add(this.放假日期);
this.groupBox1.Controls.Add(this.课本费);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.学费);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.住宿费);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.开学日期);
this.groupBox1.Controls.Add(this.label11);
this.groupBox1.Controls.Add(this.打印日期);
this.groupBox1.Controls.Add(this.模板);
this.groupBox1.Controls.Add(this.label7);
this.groupBox1.Controls.Add(this.label8);
this.groupBox1.Controls.Add(this.注册日期);
this.groupBox1.Controls.Add(this.label13);
this.groupBox1.Controls.Add(this.label14);
this.groupBox1.Controls.Add(this.数据库);
this.groupBox1.Location = new System.Drawing.Point(8, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(544, 240);
this.groupBox1.TabIndex = 4;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "基本信息";
//
// button3
//
this.button3.Location = new System.Drawing.Point(488, 192);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(40, 23);
this.button3.TabIndex = 19;
this.button3.Text = "浏览";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// label6
//
this.label6.Location = new System.Drawing.Point(176, 96);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(16, 23);
this.label6.TabIndex = 18;
this.label6.Text = "元";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// button1
//
this.button1.Location = new System.Drawing.Point(488, 160);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(40, 23);
this.button1.TabIndex = 17;
this.button1.Text = "浏览";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label12
//
this.label12.Location = new System.Drawing.Point(216, 160);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(88, 24);
this.label12.TabIndex = 16;
this.label12.Text = "模板:";
this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// 班主任电话
//
this.班主任电话.Location = new System.Drawing.Point(312, 64);
this.班主任电话.MaxLength = 20;
this.班主任电话.Name = "班主任电话";
this.班主任电话.Size = new System.Drawing.Size(120, 23);
this.班主任电话.TabIndex = 15;
this.班主任电话.Text = "139773277749";
//
// label10
//
this.label10.Location = new System.Drawing.Point(224, 64);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(88, 24);
this.label10.TabIndex = 14;
this.label10.Text = "班主任电话:";
this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// 班主任姓名
//
this.班主任姓名.Location = new System.Drawing.Point(312, 32);
this.班主任姓名.MaxLength = 6;
this.班主任姓名.Name = "班主任姓名";
this.班主任姓名.Size = new System.Drawing.Size(88, 23);
this.班主任姓名.TabIndex = 13;
this.班主任姓名.Text = "李志杰";
//
// label9
//
this.label9.Location = new System.Drawing.Point(224, 32);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(88, 24);
this.label9.TabIndex = 12;
this.label9.Text = "班主任姓名:";
this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// 放假日期
//
this.放假日期.CustomFormat = "M月d日";
this.放假日期.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.放假日期.Location = new System.Drawing.Point(104, 32);
this.放假日期.Name = "放假日期";
this.放假日期.Size = new System.Drawing.Size(104, 23);
this.放假日期.TabIndex = 11;
//
// 课本费
//
this.课本费.Location = new System.Drawing.Point(104, 96);
this.课本费.MaxLength = 4;
this.课本费.Name = "课本费";
this.课本费.Size = new System.Drawing.Size(64, 23);
this.课本费.TabIndex = 9;
this.课本费.Text = "200";
//
// label3
//
this.label3.Location = new System.Drawing.Point(16, 96);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(88, 24);
this.label3.TabIndex = 8;
this.label3.Text = "课本费:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 64);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(88, 24);
this.label2.TabIndex = 6;
this.label2.Text = "开学日期:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(88, 24);
this.label1.TabIndex = 4;
this.label1.Text = "放假日期:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// 学费
//
this.学费.Location = new System.Drawing.Point(104, 128);
this.学费.MaxLength = 5;
this.学费.Name = "学费";
this.学费.Size = new System.Drawing.Size(64, 23);
this.学费.TabIndex = 9;
this.学费.Text = "7000";
//
// label4
//
this.label4.Location = new System.Drawing.Point(16, 128);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(88, 24);
this.label4.TabIndex = 8;
this.label4.Text = "学费:";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// 住宿费
//
this.住宿费.Location = new System.Drawing.Point(104, 160);
this.住宿费.MaxLength = 4;
this.住宿费.Name = "住宿费";
this.住宿费.Size = new System.Drawing.Size(64, 23);
this.住宿费.TabIndex = 9;
this.住宿费.Text = "500";
//
// label5
//
this.label5.Location = new System.Drawing.Point(16, 160);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(88, 24);
this.label5.TabIndex = 8;
this.label5.Text = "住宿费:";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// 开学日期
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -