📄 settime.cs
字号:
// 程序:settime.cs
using System;
using System.WinForms;
using System.Drawing;
using System.IO;
using System.Data;
public class test:Form
{
private Label Name=null;
private TextBox Name1=null;
private Label Breakfast=null;
private TextBox Breakfast1=null;
private Label Lunch=null;
private TextBox Lunch1=null;
private Label Dinner=null;
private TextBox Dinner1=null;
private Button ok=null;
private Button Cancel=null;
private Button Clear=null;
private Label Note=null;
private Label Mail=null;
public static void Main()
{
Application.Run(new test());
}
public test()
{
Mail =new Label();
Mail.Text="mail me: caogjwj@sina.com \ncaogjwj@sina.com";
Mail.Size=new Size(200,30);
Mail.Location=new Point(20,230);
Mail.ForeColor=Color.Blue;
Note=new Label();
Note.Text="If that is after 1pm add 12 hrs.\nIf you want Enter 2:30pm please enter 14:30. \n12:00+2:30=14:30";
Note.Size=new Size(300,40);
Note.Location=new Point(5,5);
Note.Font=new Font("Arial",8,FontStyle.Bold);
Note.ForeColor=Color.Chocolate;
Name=new Label();
Name.Text="Name:";
Name.Size=new Size(50,20);
Name.Location=new Point(20,50);
Name1=new TextBox();
Name1.Location=new Point(100,50);
Name1.Size=new Size(100,1);
Name1.Text=" ";
Breakfast=new Label();
Breakfast.Size=new Size(80,20);
Breakfast.Location=new Point(20,80);
Breakfast.Text="BreakFast:";
Breakfast1=new TextBox();
Breakfast1.Location=new Point(100,80);
Breakfast1.Size=new Size(100,20);
Breakfast1.TabIndex=1;
Breakfast1.Text=" ";
Lunch=new Label();
Lunch.Size=new Size(80,20);
Lunch.Location=new Point(20,110);
Lunch.Text="Lunch:";
Lunch1=new TextBox();
Lunch1.Location=new Point(100,110);
Lunch1.Size=new Size(100,20);
Lunch1.TabIndex=2;
Lunch1.Text=" ";
Dinner=new Label();
Dinner.Size=new Size(80,20);
Dinner.Location=new Point(20,140);
Dinner.Text="Dinner:";
Dinner1=new TextBox();
Dinner1.Location=new Point(100,140);
Dinner1.Size=new Size(100,20);
Dinner1.TabIndex=3;
Dinner1.Text=" ";
ok=new Button();
Cancel=new Button();
Clear=new Button();
ok.Location=new Point(20,190);
ok.Size=new Size(50,20);
ok.TabIndex=4;
ok.Text="OK";
Cancel.Location=new Point(100,190);
Cancel.Size=new Size(60,20);
Cancel.TabIndex=5;
Cancel.Text="CANCEL";
Clear.Location=new Point(180,190);
Clear.Size=new Size(60,20);
Clear.TabIndex=6;
Clear.Text="CLEAR";
ok.Click+=new System.EventHandler(ok_click);
Cancel.Click+=new System.EventHandler(ok_click);
Clear.Click+=new System.EventHandler(ok_click);
this.MaximizeBox=false;
this.StartPosition=FormStartPosition.CenterScreen;
this.Controls.Add(Name);
this.Controls.Add(Name1);
this.Controls.Add(Breakfast);
this.Controls.Add(Breakfast1);
this.Controls.Add(Lunch);
this.Controls.Add(Lunch1);
this.Controls.Add(Dinner);
this.Controls.Add(Dinner1);
this.Controls.Add(ok);
this.Controls.Add(Cancel);
this.Controls.Add(Clear);
this.Controls.Add(Note);
this.Controls.Add(Mail);
this.Text="maaa";
}
public void ok_click(object sender,EventArgs arg)
{
if(sender.Equals(ok))
{
string s=null;
StreamWriter sw=null;
try
{
sw=new StreamWriter("storetime.txt",false);
s=Name1.Text+"\n"+Breakfast1.Text+"\n"+Lunch1.Text+"\n"+Dinner1.Text;
if(Name1.Text==" ")
MessageBox.Show("My Dear SweetHeart!! \n tell me your Name...","Dear child!!");
else if(Breakfast1.Text==" ")
MessageBox.Show("My Dear SweetHeart!! \n don't forget your Breakfast...","Dear child!!");
else if(Lunch1.Text==" ")
MessageBox.Show("My Dear SweetHeart!! \n don't forget your Lunch...","Dear child!!");
else if(Dinner1.Text==" ")
MessageBox.Show("My Dear SweetHeart!! \n don't forget your Dinner...","Dear child!!");
else
{
sw.WriteLine(s);
MessageBox.Show("My Dear SweetHeart!! \n I will call you on your timeings ...","Dear Child!!");
Application.Exit();
}
}catch(Exception e)
{
Console.WriteLine(e);
base.Dispose();
}finally{sw.Close();}
}
if(sender.Equals(Cancel))
{
base.Dispose();
Application.Exit();
}
if(sender.Equals(Clear))
{
Name1.Text="";
Breakfast1.Text="";
Lunch1.Text="";
Dinner1.Text="";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -