- 精品下载 | 实用查询 | 词典查询 | 桌面壁纸 | 网址 | 笑话 | FLASH频道 | 天气文章资讯 | 站长工具 | 证件办理 | 闪字生成 | 广告代码 | 在线手册 | 有问必答
您现在的位置: 蓝派网 >> 文章中心 >> 网络编程 >> .NET >> WinForm >> 正文
站内文章搜索:           

用C#制作有提示窗体的日程管理器

作者:佚名    文章来源:网络转载    更新时间 :2007-11-25 13:34:56
tChanged(object sender, System.EventArgs e)
  {
  
  }
  private void select()
  {
   DateTime dn=DateTime.Now;
   DateTime datetime;
   Myconn.Open();
   dr=Mycmd.ExecuteReader();
   string title,id;
   da=DateTime.Parse("3000-1-1 01:01:01");//设一个大点的值
   while(dr.Read())//读取数据库
   {
    datetime=DateTime.Parse(dr["datetime"].ToString());
    id=dr["id"].ToString();
    title=dr["title"].ToString();
    this.checkedListBox1.Items.Add(id+"    "+datetime.ToString()+"    "+title);
    if(datetime>dn&&datetime<da)
    {
     da=datetime;//取值
     info=dr["info"].ToString();
     
    }
   }
   dr.Close();
   Myconn.Close();//关闭数据库
   
            this.textBox5.Text="Next:"+da.ToString();//显示最近的一次提示的时间

  }
  private void button1_Click_1(object sender, System.EventArgs e)
  {
      this.Hide();//主窗体隐藏
  }
       
  private void timer1_Tick(object sender, System.EventArgs e)
  {
   //接收当前日期和时间,用于即时显示
   string CurrTime=System.DateTime.Now.ToString();
   this.textBox4.Text="当前时间:"+CurrTime;
    if(DateTime.Parse(CurrTime)==da)
    {
     clew clew1=new clew();//设置提示窗体的属性
     clew1.HeightMax=150;
     clew1.WidthMax=180;
     clew1.Info=info;
     clew1.ScrollShow();
     select();
    }
  
     
   
  }

  private void button4_Click(object sender, System.EventArgs e)
  {
   this.textBox1.Text="";
   this.textBox2.Text="";
   this.textBox3.Text="";
   this.textBox6.Text="";
  }

  private void button3_Click(object sender, System.EventArgs e)
  {
   if(this.textBox1.Text!=""&&this.textBox2.Text!=""&&this.textBox3.Text!=""&&this.textBox6.Text!="")
   {
    string indate=this.textBox1+" "+this.textBox2.Text;
    insertcmd.CommandText="insert into calendar(datetime,info,title) values('"+indate+"','"+this.textBox3.ToString()+"','"+this.textBox6.ToString()+"')";
                Myconn.Open();
    insertcmd.ExecuteNonQuery();
    Myconn.Close();
    select();
    MessageBox.Show("添加成功!!");
   }
   else
   {
    MessageBox.Show("请按指定格式填写并且各项不能为空!!");
   }
  }

  
 }
}
以下为提示窗体代码:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace Calendar
{
 /// <summary>
 /// clew 的摘要说明。
 /// </summary>
 public class clew : System.Windows.Forms.Form
 {
  private System.Windows.Forms.Timer timer1;
  private System.Windows.Forms.Timer timer2;
  private System.Windows.Forms.Timer timer3;
  private System.Windows.Forms.Label label1;
  private System.Windows.Forms.Label label2;
  private System.ComponentModel.IContainer components;

  public clew()
  {
   //
   // 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.components = new System.ComponentModel.Container();
   this.timer1 = new System.Windows.Forms.Timer(this.components);
   this.timer2 = new System.Windows.Forms.Timer(this.components);
   this.timer3 = new System.Windows.Forms.Timer(this.components);
   this.label1 = new System.Windows.Forms.Label();
   this.label2 = new System.Windows.Forms.Label();
   this.SuspendLayout();
   //
   // timer1
   //
   this.timer1.Interval = 10;
   this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
   //
   // timer2
   //
   this.timer2.Interval = 10;
   this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
   //
   // timer3
   //
   this.timer3.Interval = 10;
   this.timer3.Tick += new System.EventHandler(this.timer3_Tick);
   //
   // label1
   //
   this.label1.Location = new System.Drawing.Point(24, 40);
   this.label1.Name = "label1";
   this.label1.Size = new System.Drawing.Size(152, 96);
   this.label1.TabIndex = 0;
   //
   // label2
   //
   this.label2.Location = new System.Drawing.Point(0, 0);
   this.label2.Name = "label2";
   this.label2.Size = new System.Drawing.Size(192, 24);
   this.label2.TabIndex = 1;
   //
   // clew
   //
   this.AutoScaleBaseSize = new System.Drawing.Size(7, 15);
   this.BackColor = System.Drawing.SystemColors.InactiveCaption;
   this.ClientSize = new System.Drawing.Size(194, 150);
   this.Controls.Add(this.label2);
   this.Controls.Add(this.label1);
   this.Cursor = System.Windows.Forms.Cursors.Hand;
   this.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
   this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
   this.MaximizeBox = false;
   this.MinimizeBox = false;
   this.Name = "clew";
   this.ShowInTaskbar = false;
   this.Text = "提示……";
   this.TopMost = true;
   this.Load += new System.EventHandler(this.clew_Load);
   this.ResumeLayout(false);

  }
  #endregion
  private string info;//设置提示窗体的内容;
  public string Info
  {
   set
   {
    info=value;
   }
   get
   {
    return info;
   }
  }
  private int heightMax, widthMax;//设置窗体显示的大小的属性
  public int HeightMax
  {
   set
   {
    heightMax = value; 
   }
   get
   {
    return heightMax;
   }
  }

  public int WidthMax
  {
   set
   {
    widthMax = value;
   }
   get
   {
    return widthMax;
   }
  }
  public void ScrollShow()
  {
   this.Width = widthMax;
   this.Height = 0;
   this.Show();
   this.timer1.Enabled = true;
  }


  public int StayTime = 5000;//窗体的停留时间
  //窗体的滚出与滚入方法
  private void ScrollUp()
  {
   if(Height < heightMax)
   {
    this.Height += 3;
    this.Location = new Point(this.Location.X, this.Location.Y - 3);
   }
   else
   {
    this.timer1.Enabled = false;
    this.timer2.Enabled = true;
   }
  }

  private void ScrollDown()
  {
   if(Height > 3)
   {
    this.Height -= 3;
    this.Location = new Point(this.Location.X, this.Location.Y + 3);
   }
   else
   {
    this.timer3.Enabled = false;
    this.Close();
   }
  }

      

  private void clew_Load(object sender, System.EventArgs e)
  {
     string dNow;
   dNow=DateTime.Now.ToShortTimeString().ToString();
  
            this.label2.Text="现在时刻是:"+dNow;
   this.label1.Text=info;
   Screen[] screens = Screen.AllScreens;
   Screen screen = screens[0];//获取屏幕变量
   this.Location = new Point(screen.WorkingArea.Width - widthMax - 20, screen.WorkingArea.Height - 34);//WorkingArea为Windows桌面的工作区
   this.timer2.Interval = StayTime;

  
  }

  private void timer1_Tick(object sender, System.EventArgs e)
  {
   ScrollUp();

  }

  private void timer2_Tick(object sender, System.EventArgs e)
  {
   timer2.Enabled = false;
   timer3.Enabled = true;

  }

  private void timer3_Tick(object sender, System.EventArgs e)
  {
   ScrollDown();

  }
 }
}
//由于是从VS2003下编的所以这些代码不能直接运行,但可以提供一个思路,另外还可以加个托盘图标或,其他小功能。

上一页  [1] [2] 

 
【相关文章:】
没有相关文章

发表评论】【打印此文】【关闭窗口】【点击数:
★好玩的休闲小游戏★
网友评论:
数据载入中,请稍后……