📄 diarywrite.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace personal
{
/// <summary>
/// diarywrite 的摘要说明。
/// </summary>
public class diarywrite : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txttitle;
private System.Windows.Forms.RadioButton btnweather1;
private System.Windows.Forms.RadioButton btnweather2;
private System.Windows.Forms.RadioButton btnweather3;
private System.Windows.Forms.RadioButton btnweather4;
private System.Windows.Forms.RadioButton btnweather5;
private System.Windows.Forms.RadioButton btnweather6;
private System.Windows.Forms.ComboBox btnmood;
private System.Windows.Forms.RichTextBox rtbdiary;
private System.Windows.Forms.Button btnsubmit;
private System.Windows.Forms.Button btnreset;
private System.Windows.Forms.DateTimePicker dateTimediary;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public diarywrite()
{
//
// 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()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(diarywrite));
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.dateTimediary = new System.Windows.Forms.DateTimePicker();
this.txttitle = new System.Windows.Forms.TextBox();
this.btnweather1 = new System.Windows.Forms.RadioButton();
this.btnweather2 = new System.Windows.Forms.RadioButton();
this.btnweather3 = new System.Windows.Forms.RadioButton();
this.btnweather4 = new System.Windows.Forms.RadioButton();
this.btnweather5 = new System.Windows.Forms.RadioButton();
this.btnweather6 = new System.Windows.Forms.RadioButton();
this.btnmood = new System.Windows.Forms.ComboBox();
this.rtbdiary = new System.Windows.Forms.RichTextBox();
this.btnsubmit = new System.Windows.Forms.Button();
this.btnreset = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.BackgroundImage")));
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(352, 50);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// label1
//
this.label1.Location = new System.Drawing.Point(40, 80);
this.label1.Name = "label1";
this.label1.TabIndex = 1;
this.label1.Text = "时间";
//
// label2
//
this.label2.Location = new System.Drawing.Point(40, 128);
this.label2.Name = "label2";
this.label2.TabIndex = 1;
this.label2.Text = "题目 ";
//
// label3
//
this.label3.Location = new System.Drawing.Point(40, 176);
this.label3.Name = "label3";
this.label3.TabIndex = 1;
this.label3.Text = "天气";
//
// label4
//
this.label4.Location = new System.Drawing.Point(40, 216);
this.label4.Name = "label4";
this.label4.TabIndex = 1;
this.label4.Text = "心情";
//
// label5
//
this.label5.Location = new System.Drawing.Point(40, 264);
this.label5.Name = "label5";
this.label5.TabIndex = 1;
this.label5.Text = "内容";
//
// dateTimediary
//
this.dateTimediary.Location = new System.Drawing.Point(120, 80);
this.dateTimediary.Name = "dateTimediary";
this.dateTimediary.Size = new System.Drawing.Size(168, 21);
this.dateTimediary.TabIndex = 2;
//
// txttitle
//
this.txttitle.Location = new System.Drawing.Point(120, 128);
this.txttitle.Name = "txttitle";
this.txttitle.Size = new System.Drawing.Size(168, 21);
this.txttitle.TabIndex = 3;
this.txttitle.Text = "";
//
// btnweather1
//
this.btnweather1.Checked = true;
this.btnweather1.Image = ((System.Drawing.Image)(resources.GetObject("btnweather1.Image")));
this.btnweather1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnweather1.Location = new System.Drawing.Point(120, 176);
this.btnweather1.Name = "btnweather1";
this.btnweather1.Size = new System.Drawing.Size(40, 24);
this.btnweather1.TabIndex = 4;
this.btnweather1.TabStop = true;
//
// btnweather2
//
this.btnweather2.Image = ((System.Drawing.Image)(resources.GetObject("btnweather2.Image")));
this.btnweather2.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnweather2.Location = new System.Drawing.Point(168, 176);
this.btnweather2.Name = "btnweather2";
this.btnweather2.Size = new System.Drawing.Size(32, 24);
this.btnweather2.TabIndex = 4;
//
// btnweather3
//
this.btnweather3.Image = ((System.Drawing.Image)(resources.GetObject("btnweather3.Image")));
this.btnweather3.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnweather3.Location = new System.Drawing.Point(200, 176);
this.btnweather3.Name = "btnweather3";
this.btnweather3.Size = new System.Drawing.Size(32, 24);
this.btnweather3.TabIndex = 4;
//
// btnweather4
//
this.btnweather4.Image = ((System.Drawing.Image)(resources.GetObject("btnweather4.Image")));
this.btnweather4.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnweather4.Location = new System.Drawing.Point(240, 176);
this.btnweather4.Name = "btnweather4";
this.btnweather4.Size = new System.Drawing.Size(40, 24);
this.btnweather4.TabIndex = 4;
//
// btnweather5
//
this.btnweather5.Image = ((System.Drawing.Image)(resources.GetObject("btnweather5.Image")));
this.btnweather5.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnweather5.Location = new System.Drawing.Point(280, 176);
this.btnweather5.Name = "btnweather5";
this.btnweather5.Size = new System.Drawing.Size(32, 24);
this.btnweather5.TabIndex = 4;
//
// btnweather6
//
this.btnweather6.Image = ((System.Drawing.Image)(resources.GetObject("btnweather6.Image")));
this.btnweather6.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnweather6.Location = new System.Drawing.Point(320, 176);
this.btnweather6.Name = "btnweather6";
this.btnweather6.Size = new System.Drawing.Size(40, 24);
this.btnweather6.TabIndex = 4;
//
// btnmood
//
this.btnmood.Items.AddRange(new object[] {
"1",
"2",
"3",
"4",
"5"});
this.btnmood.Location = new System.Drawing.Point(120, 216);
this.btnmood.Name = "btnmood";
this.btnmood.Size = new System.Drawing.Size(121, 20);
this.btnmood.TabIndex = 5;
this.btnmood.Text = "心情指数";
//
// rtbdiary
//
this.rtbdiary.Location = new System.Drawing.Point(120, 256);
this.rtbdiary.Name = "rtbdiary";
this.rtbdiary.Size = new System.Drawing.Size(224, 128);
this.rtbdiary.TabIndex = 6;
this.rtbdiary.Text = "";
//
// btnsubmit
//
this.btnsubmit.Location = new System.Drawing.Point(56, 408);
this.btnsubmit.Name = "btnsubmit";
this.btnsubmit.TabIndex = 7;
this.btnsubmit.Text = "提交";
this.btnsubmit.Click += new System.EventHandler(this.btnsubmit_Click);
//
// btnreset
//
this.btnreset.Location = new System.Drawing.Point(232, 408);
this.btnreset.Name = "btnreset";
this.btnreset.TabIndex = 7;
this.btnreset.Text = "退出";
this.btnreset.Click += new System.EventHandler(this.btnreset_Click);
//
// diarywrite
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(235)), ((System.Byte)(246)), ((System.Byte)(255)));
this.ClientSize = new System.Drawing.Size(352, 460);
this.Controls.Add(this.btnsubmit);
this.Controls.Add(this.rtbdiary);
this.Controls.Add(this.btnmood);
this.Controls.Add(this.btnweather1);
this.Controls.Add(this.txttitle);
this.Controls.Add(this.dateTimediary);
this.Controls.Add(this.label1);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label3);
this.Controls.Add(this.label4);
this.Controls.Add(this.label5);
this.Controls.Add(this.btnweather2);
this.Controls.Add(this.btnweather3);
this.Controls.Add(this.btnweather4);
this.Controls.Add(this.btnweather5);
this.Controls.Add(this.btnweather6);
this.Controls.Add(this.btnreset);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "diarywrite";
this.ShowInTaskbar = false;
this.Text = "个人信息管理系统";
this.ResumeLayout(false);
}
#endregion
private void btnreset_ContextMenuChanged(object sender, System.EventArgs e)
{
Application.Exit();
}
private void btnsubmit_Click(object sender, System.EventArgs e)
{
if(txttitle.Text==""||rtbdiary.Text=="")
MessageBox.Show("请填写完整信息!");
else
{
datalink mydl=new datalink();
string weather="";
if(btnweather1.Checked==true) weather="images/weather1.gif";
if(btnweather2.Checked==true) weather="images/weather2.gif";
if(btnweather3.Checked==true) weather="images/weather3.gif";
if(btnweather4.Checked==true) weather="images/weather4.gif";
if(btnweather5.Checked==true) weather="images/weather5.gif";
if(btnweather6.Checked==true) weather="images/weather6.gif";
string sql="insert into diary(diary_time,diary_weather,diary_mood,diary_content,diary_title) values('"+dateTimediary.Text+"','"+weather+"','"+btnmood.SelectedItem.ToString()+"','"+rtbdiary.Text+"','"+ txttitle.Text+"')";
if(mydl.executesql(sql))
{
MessageBox.Show("信息录入成功!");
rtbdiary.Text="";
txttitle.Text="";
}
else
MessageBox.Show("信息录入失败!");
}
}
private void btnreset_Click(object sender, System.EventArgs e)
{
this.Close();;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -