КАПУСТА: почитай,обсуди,отдохни!

Информация о пользователе

Привет, Гость! Войдите или зарегистрируйтесь.


Вы здесь » КАПУСТА: почитай,обсуди,отдохни! » С# » Примеры программ


Примеры программ

Сообщений 1 страница 5 из 5

1

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

namespace Planyvalnuk
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
    private System.Windows.Forms.MainMenu mainMenu1;
    private System.Windows.Forms.MenuItem menuItem1;
    private System.Windows.Forms.MenuItem menuItem2;
    private System.Windows.Forms.MenuItem menuItem3;
    private System.Windows.Forms.ListBox listBox1;
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.DateTimePicker dateTimePicker1;
    private System.Windows.Forms.NumericUpDown numericUpDown1;
    private System.Windows.Forms.NumericUpDown numericUpDown2;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.Label label3;
    private System.Windows.Forms.TextBox textBox1;
    private System.Windows.Forms.Label label4;
    private System.Windows.Forms.DateTimePicker dateTimePicker2;
    private System.Windows.Forms.Timer timer1;
    private System.Windows.Forms.Button button2;
    private System.Windows.Forms.Label label5;
    private System.Windows.Forms.TextBox textBox2;
    private System.Windows.Forms.ContextMenu contextMenu1;
    private System.Windows.Forms.MenuItem menuItem4;
    private System.Windows.Forms.MenuItem menuItem5;
    public System.Windows.Forms.NotifyIcon notifyIcon1;
    private System.Windows.Forms.Button button3;
    private System.Windows.Forms.MenuItem menuItem7;
    private System.Windows.Forms.MenuItem menuItem6;
    private System.Windows.Forms.MenuItem menuItem8;
    private System.ComponentModel.IContainer components;

    public Form1()
    {
    //
    // Required for Windows Form Designer support
    //
    InitializeComponent();

    //
    // TODO: Add any constructor code after InitializeComponent call
    //
    }

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
        if (components != null)
        {
        components.Dispose();
        }
    }
    base.Dispose( disposing );
    }

    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    this.components = new System.ComponentModel.Container();
    System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
    this.mainMenu1 = new System.Windows.Forms.MainMenu();
    this.menuItem1 = new System.Windows.Forms.MenuItem();
    this.menuItem2 = new System.Windows.Forms.MenuItem();
    this.menuItem3 = new System.Windows.Forms.MenuItem();
    this.menuItem7 = new System.Windows.Forms.MenuItem();
    this.menuItem6 = new System.Windows.Forms.MenuItem();
    this.listBox1 = new System.Windows.Forms.ListBox();
    this.button1 = new System.Windows.Forms.Button();
    this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
    this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
    this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
    this.label1 = new System.Windows.Forms.Label();
    this.label2 = new System.Windows.Forms.Label();
    this.label3 = new System.Windows.Forms.Label();
    this.textBox1 = new System.Windows.Forms.TextBox();
    this.label4 = new System.Windows.Forms.Label();
    this.dateTimePicker2 = new System.Windows.Forms.DateTimePicker();
    this.timer1 = new System.Windows.Forms.Timer(this.components);
    this.button2 = new System.Windows.Forms.Button();
    this.label5 = new System.Windows.Forms.Label();
    this.textBox2 = new System.Windows.Forms.TextBox();
    this.contextMenu1 = new System.Windows.Forms.ContextMenu();
    this.menuItem4 = new System.Windows.Forms.MenuItem();
    this.menuItem5 = new System.Windows.Forms.MenuItem();
    this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
    this.button3 = new System.Windows.Forms.Button();
    this.menuItem8 = new System.Windows.Forms.MenuItem();
    ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
    ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
    this.SuspendLayout();
    //
    // mainMenu1
    //
    this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                          this.menuItem1,
                                          this.menuItem7,
                                          this.menuItem6,
                                          this.menuItem8});
    //
    // menuItem1
    //
    this.menuItem1.Index = 0;
    this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                          this.menuItem2,
                                          this.menuItem3});
    this.menuItem1.Text = "Записи";
    //
    // menuItem2
    //
    this.menuItem2.Index = 0;
    this.menuItem2.Text = "Продивитись";
    this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
    //
    // menuItem3
    //
    this.menuItem3.Index = 1;
    this.menuItem3.Text = "Створити";
    this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
    //
    // menuItem7
    //
    this.menuItem7.Index = 1;
    this.menuItem7.Text = "Закрити всі меню";
    this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
    //
    // menuItem6
    //
    this.menuItem6.Index = 2;
    this.menuItem6.Text = "Нотатник";
    this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
    //
    // listBox1
    //
    this.listBox1.BackColor = System.Drawing.SystemColors.InactiveBorder;
    this.listBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
    this.listBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
    this.listBox1.ForeColor = System.Drawing.SystemColors.InfoText;
    this.listBox1.ItemHeight = 16;
    this.listBox1.Location = new System.Drawing.Point(0, 0);
    this.listBox1.Name = "listBox1";
    this.listBox1.Size = new System.Drawing.Size(496, 288);
    this.listBox1.TabIndex = 0;
    this.listBox1.Visible = false;
    //
    // button1
    //
    this.button1.Cursor = System.Windows.Forms.Cursors.Hand;
    this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
    this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image")));
    this.button1.Location = new System.Drawing.Point(520, 336);
    this.button1.Name = "button1";
    this.button1.Size = new System.Drawing.Size(248, 56);
    this.button1.TabIndex = 1;
    this.button1.Visible = false;
    this.button1.Click += new System.EventHandler(this.button1_Click);
    this.button1.MouseEnter += new System.EventHandler(this.button1_MouseEnter);
    this.button1.MouseLeave += new System.EventHandler(this.button1_MouseLeave);
    //
    // dateTimePicker1
    //
    this.dateTimePicker1.Location = new System.Drawing.Point(552, 56);
    this.dateTimePicker1.Name = "dateTimePicker1";
    this.dateTimePicker1.Size = new System.Drawing.Size(176, 20);
    this.dateTimePicker1.TabIndex = 2;
    this.dateTimePicker1.Visible = false;
    //
    // numericUpDown1
    //
    this.numericUpDown1.BackColor = System.Drawing.SystemColors.Control;
    this.numericUpDown1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
    this.numericUpDown1.ForeColor = System.Drawing.SystemColors.ControlText;
    this.numericUpDown1.Location = new System.Drawing.Point(528, 104);
    this.numericUpDown1.Maximum = new System.Decimal(new int[] {
                                       23,
                                       0,
                                       0,
                                       0});
    this.numericUpDown1.Name = "numericUpDown1";
    this.numericUpDown1.Size = new System.Drawing.Size(40, 22);
    this.numericUpDown1.TabIndex = 3;
    this.numericUpDown1.Visible = false;
    //
    // numericUpDown2
    //
    this.numericUpDown2.BackColor = System.Drawing.SystemColors.Control;
    this.numericUpDown2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
    this.numericUpDown2.ForeColor = System.Drawing.SystemColors.ControlText;
    this.numericUpDown2.Location = new System.Drawing.Point(632, 104);
    this.numericUpDown2.Maximum = new System.Decimal(new int[] {
                                       59,
                                       0,
                                       0,
                                       0});
    this.numericUpDown2.Name = "numericUpDown2";
    this.numericUpDown2.Size = new System.Drawing.Size(48, 22);
    this.numericUpDown2.TabIndex = 4;
    this.numericUpDown2.Visible = false;
    //
    // label1
    //
    this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
    this.label1.Location = new System.Drawing.Point(568, 104);
    this.label1.Name = "label1";
    this.label1.Size = new System.Drawing.Size(56, 24);
    this.label1.TabIndex = 5;
    this.label1.Text = "Годин";
    this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
    this.label1.Visible = false;
    //
    // label2
    //
    this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
    this.label2.Location = new System.Drawing.Point(688, 104);
    this.label2.Name = "label2";
    this.label2.Size = new System.Drawing.Size(56, 24);
    this.label2.TabIndex = 6;
    this.label2.Text = "Хвилин";
    this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
    this.label2.Visible = false;
    //
    // label3
    //
    this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
    this.label3.Location = new System.Drawing.Point(536, 8);
    this.label3.Name = "label3";
    this.label3.Size = new System.Drawing.Size(168, 32);
    this.label3.TabIndex = 7;
    this.label3.Text = "Виберіть число і час для                 нагадування";
    this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    this.label3.Visible = false;
    //
    // textBox1
    //
    this.textBox1.BackColor = System.Drawing.SystemColors.Info;
    this.textBox1.Location = new System.Drawing.Point(520, 192);
    this.textBox1.Multiline = true;
    this.textBox1.Name = "textBox1";
    this.textBox1.Size = new System.Drawing.Size(248, 120);
    this.textBox1.TabIndex = 8;
    this.textBox1.Text = "";
    this.textBox1.Visible = false;
    //
    // label4
    //
    this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
    this.label4.Location = new System.Drawing.Point(528, 144);
    this.label4.Name = "label4";
    this.label4.Size = new System.Drawing.Size(216, 40);
    this.label4.TabIndex = 9;
    this.label4.Text = "Введіть текст";
    this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    this.label4.Visible = false;
    //
    // dateTimePicker2
    //
    this.dateTimePicker2.Location = new System.Drawing.Point(80, 344);
    this.dateTimePicker2.Name = "dateTimePicker2";
    this.dateTimePicker2.Size = new System.Drawing.Size(160, 20);
    this.dateTimePicker2.TabIndex = 10;
    this.dateTimePicker2.Visible = false;
    //
    // timer1
    //
    this.timer1.Enabled = true;
    this.timer1.Interval = 1000;
    this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
    //
    // button2
    //
    this.button2.Cursor = System.Windows.Forms.Cursors.Hand;
    this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
    this.button2.Image = ((System.Drawing.Image)(resources.GetObject("button2.Image")));
    this.button2.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
    this.button2.Location = new System.Drawing.Point(8, 352);
    this.button2.Name = "button2";
    this.button2.Size = new System.Drawing.Size(472, 48);
    this.button2.TabIndex = 12;
    this.button2.Visible = false;
    this.button2.Click += new System.EventHandler(this.button2_Click);
    this.button2.MouseEnter += new System.EventHandler(this.button2_MouseEnter);
    this.button2.MouseLeave += new System.EventHandler(this.button2_MouseLeave);
    //
    // label5
    //
    this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
    this.label5.Location = new System.Drawing.Point(536, 8);
    this.label5.Name = "label5";
    this.label5.Size = new System.Drawing.Size(208, 32);
    this.label5.TabIndex = 13;
    this.label5.Text = "Текст повідомлення";
    this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    this.label5.Visible = false;
    //
    // textBox2
    //
    this.textBox2.BackColor = System.Drawing.SystemColors.Info;
    this.textBox2.Location = new System.Drawing.Point(512, 40);
    this.textBox2.Multiline = true;
    this.textBox2.Name = "textBox2";
    this.textBox2.Size = new System.Drawing.Size(256, 248);
    this.textBox2.TabIndex = 14;
    this.textBox2.Text = "";
    this.textBox2.Visible = false;
    //
    // contextMenu1
    //
    this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                             this.menuItem4,
                                             this.menuItem5});
    //
    // menuItem4
    //
    this.menuItem4.Index = 0;
    this.menuItem4.Text = "Відновити";
    this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
    //
    // menuItem5
    //
    this.menuItem5.Index = 1;
    this.menuItem5.Text = "Вийти з програми";
    this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
    //
    // notifyIcon1
    //
    this.notifyIcon1.ContextMenu = this.contextMenu1;
    this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
    this.notifyIcon1.Text = "notifyIcon1";
    this.notifyIcon1.Visible = true;
    //
    // button3
    //
    this.button3.Cursor = System.Windows.Forms.Cursors.Hand;
    this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
    this.button3.Image = ((System.Drawing.Image)(resources.GetObject("button3.Image")));
    this.button3.Location = new System.Drawing.Point(8, 296);
    this.button3.Name = "button3";
    this.button3.Size = new System.Drawing.Size(472, 48);
    this.button3.TabIndex = 16;
    this.button3.Visible = false;
    this.button3.Click += new System.EventHandler(this.button3_Click);
    this.button3.MouseEnter += new System.EventHandler(this.button3_MouseEnter);
    this.button3.MouseLeave += new System.EventHandler(this.button3_MouseLeave);
    //
    // menuItem8
    //
    this.menuItem8.Index = 3;
    this.menuItem8.Text = "Допомога";
    this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);
    //
    // Form1
    //
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.BackColor = System.Drawing.Color.DarkSeaGreen;
    this.ClientSize = new System.Drawing.Size(786, 408);
    this.Controls.Add(this.button3);
    this.Controls.Add(this.textBox2);
    this.Controls.Add(this.label5);
    this.Controls.Add(this.button2);
    this.Controls.Add(this.dateTimePicker2);
    this.Controls.Add(this.label4);
    this.Controls.Add(this.textBox1);
    this.Controls.Add(this.label3);
    this.Controls.Add(this.label2);
    this.Controls.Add(this.label1);
    this.Controls.Add(this.numericUpDown2);
    this.Controls.Add(this.numericUpDown1);
    this.Controls.Add(this.dateTimePicker1);
    this.Controls.Add(this.button1);
    this.Controls.Add(this.listBox1);
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
    this.MaximizeBox = false;
    this.Menu = this.mainMenu1;
    this.Name = "Form1";
    this.Text = "Планувальник";
    this.TransparencyKey = System.Drawing.Color.Red;
    this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);
    this.Load += new System.EventHandler(this.Form1_Load);
    ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
    ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
    this.ResumeLayout(false);

    }
    #endregion

    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
    Application.Run(new Form1());
    }

    private void Form1_Load(object sender, System.EventArgs e)
    {
    string[] all=Directory.GetFiles("DATA/");
    for(int i=0;i<all.Length;i++)
    {
        StreamReader sr=new StreamReader(all[i]);
        string sqr=sr.ReadToEnd();
        string del2=all[i];
        sr.Close();
        all[i]=all[i].Replace("DATA/","");
        all[i]=all[i].Replace(".txt","");
        string[] spl=all[i].Split(new char[] {'.'});
        listBox1.Items.AddRange(new object[1] {spl[0]+" хвилин(а) "+spl[1]+" годин(а) "+spl[2]+" день "+spl[3]+" місяць "+spl[4]+" рік "+" текст повідомлення: "+sqr});
        if(Convert.ToInt32(spl[4])<dateTimePicker2.Value.Year)
        {
        MessageBox.Show("Пропущене повідомлення: "+sqr);
        File.Delete(del2);
        listBox1.Items.Remove(spl[0]+" хвилин(а) "+spl[1]+" годин(а) "+spl[2]+" день "+spl[3]+" місяць "+spl[4]+" рік "+" текст повідомлення: "+sqr);
        }
        else if(Convert.ToInt32(spl[4])==dateTimePicker2.Value.Year)
        {
        if(Convert.ToInt32(spl[3])<dateTimePicker2.Value.Month)
        {
            MessageBox.Show("Пропущене повідомлення: "+sqr);
            File.Delete(del2);
            listBox1.Items.Remove(spl[0]+" хвилин(а) "+spl[1]+" годин(а) "+spl[2]+" день "+spl[3]+" місяць "+spl[4]+" рік "+" текст повідомлення: "+sqr);
        }
        else if(Convert.ToInt32(spl[3])==dateTimePicker2.Value.Month)
        {
            if(Convert.ToInt32(spl[2])<dateTimePicker2.Value.Day)
            {
            MessageBox.Show("Пропущене повідомлення: "+sqr);
            File.Delete(del2);
            listBox1.Items.Remove(spl[0]+" хвилин(а) "+spl[1]+" годин(а) "+spl[2]+" день "+spl[3]+" місяць "+spl[4]+" рік "+" текст повідомлення: "+sqr);
            }
            else if(Convert.ToInt32(spl[2])==dateTimePicker2.Value.Day)
            {
            if(Convert.ToInt32(spl[1])<dateTimePicker2.Value.Hour)
            {
                MessageBox.Show("Пропущене повідомлення: "+sqr);
                File.Delete(del2);
                listBox1.Items.Remove(spl[0]+" хвилин(а) "+spl[1]+" годин(а) "+spl[2]+" день "+spl[3]+" місяць "+spl[4]+" рік "+" текст повідомлення: "+sqr);
            }
            else if(Convert.ToInt32(spl[1])==dateTimePicker2.Value.Hour)
            {
                if(Convert.ToInt32(spl[0])<dateTimePicker2.Value.Minute)
                {
                MessageBox.Show("Пропущене повідомлення: "+sqr);
                File.Delete(del2);
                listBox1.Items.Remove(spl[0]+" хвилин(а) "+spl[1]+" годин(а) "+spl[2]+" день "+spl[3]+" місяць "+spl[4]+" рік "+" текст повідомлення: "+sqr);
                }
            }
            }
        }
        }
    }
    }

    private void button1_Click(object sender, System.EventArgs e)
    {
    try
    {
        string s="DATA/"+numericUpDown2.Value.ToString()+"."+numericUpDown1.Value.ToString()+"."+dateTimePicker1.Value.Day.ToString()+"."+dateTimePicker1.Value.Month.ToString()+"."+dateTimePicker1.Value.Year.ToString();
        StreamWriter zapus=new StreamWriter(s+".txt");
        zapus.Write(textBox1.Text);
        zapus.Close();
        listBox1.Items.AddRange(new object[1] {numericUpDown2.Value.ToString()+" хвилин(а) "+numericUpDown1.Value.ToString()+" годин(а) "+dateTimePicker1.Value.Day.ToString()+" день "+dateTimePicker1.Value.Month.ToString()+" місяць "+dateTimePicker1.Value.Year.ToString()+" рік "+" текст повідомлення: "+textBox1.Text});
        numericUpDown2.Value=0;
        numericUpDown1.Value=0;
        MessageBox.Show("Збереженно");
    }
    catch
    {
        MessageBox.Show("Нажаль такий час вже існує - задайте інший час");   
    }
    }

    private void menuItem2_Click(object sender, System.EventArgs e)
    {
    listBox1.Visible=true;
    button2.Visible=true;
    textBox1.Visible=false;
    label4.Visible=false;
    button1.Visible=false;
    numericUpDown1.Visible=false;
    numericUpDown2.Visible=false;
    label1.Visible=false;
    label2.Visible=false;
    label3.Visible=false;
    label5.Visible=true;
    textBox2.Visible=true;
    dateTimePicker1.Visible=false;
    button3.Visible=true;
    }

    private void menuItem3_Click(object sender, System.EventArgs e)
    {
    listBox1.Visible=true;
    textBox1.Visible=true;
    label4.Visible=true;
    button1.Visible=true;
    numericUpDown1.Visible=true;
    numericUpDown2.Visible=true;
    label1.Visible=true;
    label2.Visible=true;
    label3.Visible=true;
    dateTimePicker1.Visible=true;
    label5.Visible=false;
    textBox2.Visible=false;
    button2.Visible=false;
    button3.Visible=false;
    }

    private void timer1_Tick(object sender, System.EventArgs e)
    {
    string[] all=Directory.GetFiles("DATA/");
    for(int i=0;i<all.Length;i++)
    {
        string del=all[i];
        StreamReader sr=new StreamReader(all[i]);
        string sqr=sr.ReadToEnd();
        sr.Close();
        all[i]=all[i].Replace("DATA/","");
        all[i]=all[i].Replace(".txt","");
        string[] spl=all[i].Split(new char[] {'.'});
        if((spl[0]==dateTimePicker2.Value.Minute.ToString())&&(spl[1]==dateTimePicker2.Value.Hour.ToString())&&(spl[2]==dateTimePicker2.Value.Day.ToString())&&(spl[3]==dateTimePicker2.Value.Month.ToString())&&(spl[4]==dateTimePicker2.Value.Year.ToString()))
        {       
        File.Delete(del);
        MessageBox.Show(sqr);
        listBox1.Items.Remove(spl[0]+" хвилин(а) "+spl[1]+" годин(а) "+spl[2]+" день "+spl[3]+" місяць "+spl[4]+" рік "+" текст повідомлення: "+sqr);
        break;
        }
    }
    }

    private void button2_Click(object sender, System.EventArgs e)
    {
    try
    {
        listBox1.Items.Remove(listBox1.SelectedItem);
        string ss=textBox2.Text;
        ss=ss.Remove(0,1);
        textBox2.Text="";
        string[] ss1=Directory.GetFiles("DATA/");
        for(int i=0;i<ss1.Length;i++)
        {
        StreamReader sr=new StreamReader(ss1[i]);
        if(ss==sr.ReadLine())
        {
            sr.Close();
            File.Delete(ss1[i]);
            break;
        }
        }
    }
    catch
    {
        MessageBox.Show("повідомленнь немає");
    }
    }

    private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
    {
    e.Cancel=true;
    this.Visible=false;
    }

    private void menuItem5_Click(object sender, System.EventArgs e)
    {
    Application.Exit();
    }

    private void menuItem4_Click(object sender, System.EventArgs e)
    {
    this.Visible=true;
    }

    private void button3_Click(object sender, System.EventArgs e)
    {
    try
    {
        string si=listBox1.SelectedItem.ToString();
        int ir=si.IndexOf(":");
        si=si.Remove(0,ir+1);
        textBox2.Text=si;
    }
    catch
    {
        MessageBox.Show("повідомленнь немає");
    }
    }

    private void menuItem7_Click(object sender, System.EventArgs e)
    {
    label1.Visible=false;
    label2.Visible=false;
    label3.Visible=false;
    label4.Visible=false;
    label5.Visible=false;
    button1.Visible=false;
    button2.Visible=false;
    button3.Visible=false;
    textBox1.Visible=false;
    textBox2.Visible=false;
    numericUpDown1.Visible=false;
    numericUpDown2.Visible=false;
    dateTimePicker1.Visible=false;
    listBox1.Visible=false;
    }

    private void menuItem6_Click(object sender, System.EventArgs e)
    {
    System.Diagnostics.Process.Start("WindowsApplication1.exe");
    }

    private void button2_MouseEnter(object sender, System.EventArgs e)
    {
    button2.FlatStyle=FlatStyle.Popup;
    }

    private void button2_MouseLeave(object sender, System.EventArgs e)
    {
    button2.FlatStyle=FlatStyle.Standard;
    }

    private void button3_MouseEnter(object sender, System.EventArgs e)
    {
    button3.FlatStyle=FlatStyle.Popup;
    }

    private void button3_MouseLeave(object sender, System.EventArgs e)
    {
    button3.FlatStyle=FlatStyle.Standard;
    }

    private void button1_MouseEnter(object sender, System.EventArgs e)
    {
    button1.FlatStyle=FlatStyle.Popup;
    }

    private void button1_MouseLeave(object sender, System.EventArgs e)
    {
    button1.FlatStyle=FlatStyle.Standard;
    }

    private void menuItem8_Click(object sender, System.EventArgs e)
    {
    System.Diagnostics.Process.Start("HELP/Текстовый документ.html");
    }
}
}

0

2

Эта программа - планировщик. Она отлсеживает время каждую секунду и проверяет не запланировано ли на это время каких-либо сообщений. Делается за 7-8 часов

0

3

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

namespace WindowsApplication1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
    private System.Windows.Forms.MainMenu mainMenu1;
    private System.Windows.Forms.MenuItem menuItem1;
    private System.Windows.Forms.MenuItem menuItem4;
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.RichTextBox richTextBox1;
    private System.Windows.Forms.RichTextBox richTextBox2;
    private System.Windows.Forms.TextBox textBox1;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.Button button2;
    private System.Windows.Forms.ContextMenu contextMenu1;
    private System.Windows.Forms.MenuItem menuItem2;
    private System.Windows.Forms.ComboBox comboBox1;
    private System.Windows.Forms.Button button3;
    private System.Windows.Forms.Button button4;
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null;

    public Form1()
    {
    //
    // Required for Windows Form Designer support
    //
    InitializeComponent();

    //
    // TODO: Add any constructor code after InitializeComponent call
    //
    }

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
        if (components != null)
        {
        components.Dispose();
        }
    }
    base.Dispose( disposing );
    }

    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    this.mainMenu1 = new System.Windows.Forms.MainMenu();
    this.menuItem1 = new System.Windows.Forms.MenuItem();
    this.menuItem4 = new System.Windows.Forms.MenuItem();
    this.button1 = new System.Windows.Forms.Button();
    this.richTextBox1 = new System.Windows.Forms.RichTextBox();
    this.richTextBox2 = new System.Windows.Forms.RichTextBox();
    this.textBox1 = new System.Windows.Forms.TextBox();
    this.label1 = new System.Windows.Forms.Label();
    this.button2 = new System.Windows.Forms.Button();
    this.contextMenu1 = new System.Windows.Forms.ContextMenu();
    this.menuItem2 = new System.Windows.Forms.MenuItem();
    this.comboBox1 = new System.Windows.Forms.ComboBox();
    this.button3 = new System.Windows.Forms.Button();
    this.button4 = new System.Windows.Forms.Button();
    this.SuspendLayout();
    //
    // mainMenu1
    //
    this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                          this.menuItem1});
    //
    // menuItem1
    //
    this.menuItem1.Index = 0;
    this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                          this.menuItem4});
    this.menuItem1.Text = "Створити";
    //
    // menuItem4
    //
    this.menuItem4.Index = 0;
    this.menuItem4.Text = "Нова замітка";
    this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
    //
    // button1
    //
    this.button1.Location = new System.Drawing.Point(416, 224);
    this.button1.Name = "button1";
    this.button1.Size = new System.Drawing.Size(312, 48);
    this.button1.TabIndex = 3;
    this.button1.Text = "Зберігти запис";
    this.button1.Visible = false;
    this.button1.Click += new System.EventHandler(this.button1_Click);
    //
    // richTextBox1
    //
    this.richTextBox1.BackColor = System.Drawing.SystemColors.Info;
    this.richTextBox1.Location = new System.Drawing.Point(408, 8);
    this.richTextBox1.Name = "richTextBox1";
    this.richTextBox1.Size = new System.Drawing.Size(328, 216);
    this.richTextBox1.TabIndex = 4;
    this.richTextBox1.Text = "richTextBox1";
    this.richTextBox1.Visible = false;
    //
    // richTextBox2
    //
    this.richTextBox2.BackColor = System.Drawing.SystemColors.Info;
    this.richTextBox2.Location = new System.Drawing.Point(408, 8);
    this.richTextBox2.Name = "richTextBox2";
    this.richTextBox2.Size = new System.Drawing.Size(328, 208);
    this.richTextBox2.TabIndex = 5;
    this.richTextBox2.Text = "richTextBox2";
    this.richTextBox2.Visible = false;
    //
    // textBox1
    //
    this.textBox1.BackColor = System.Drawing.SystemColors.ScrollBar;
    this.textBox1.Location = new System.Drawing.Point(504, 224);
    this.textBox1.Name = "textBox1";
    this.textBox1.Size = new System.Drawing.Size(160, 20);
    this.textBox1.TabIndex = 6;
    this.textBox1.Text = "";
    this.textBox1.Visible = false;
    //
    // label1
    //
    this.label1.BackColor = System.Drawing.Color.Gold;
    this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
    this.label1.Location = new System.Drawing.Point(504, 176);
    this.label1.Name = "label1";
    this.label1.Size = new System.Drawing.Size(160, 32);
    this.label1.TabIndex = 7;
    this.label1.Text = "Введіть назву замітки";
    this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    this.label1.Visible = false;
    //
    // button2
    //
    this.button2.BackColor = System.Drawing.Color.RoyalBlue;
    this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
    this.button2.Location = new System.Drawing.Point(504, 256);
    this.button2.Name = "button2";
    this.button2.Size = new System.Drawing.Size(160, 40);
    this.button2.TabIndex = 8;
    this.button2.Text = "Далі";
    this.button2.Visible = false;
    this.button2.Click += new System.EventHandler(this.button2_Click);
    //
    // contextMenu1
    //
    this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                             this.menuItem2});
    //
    // menuItem2
    //
    this.menuItem2.Index = 0;
    this.menuItem2.Text = "uoy";
    //
    // comboBox1
    //
    this.comboBox1.BackColor = System.Drawing.SystemColors.ScrollBar;
    this.comboBox1.Font = new System.Drawing.Font("Times New Roman", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
    this.comboBox1.ItemHeight = 21;
    this.comboBox1.Location = new System.Drawing.Point(8, 24);
    this.comboBox1.Name = "comboBox1";
    this.comboBox1.Size = new System.Drawing.Size(384, 29);
    this.comboBox1.TabIndex = 9;
    this.comboBox1.Text = "виберіть запис";
    this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
    //
    // button3
    //
    this.button3.BackColor = System.Drawing.Color.RoyalBlue;
    this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
    this.button3.Location = new System.Drawing.Point(408, 232);
    this.button3.Name = "button3";
    this.button3.Size = new System.Drawing.Size(328, 40);
    this.button3.TabIndex = 10;
    this.button3.Text = "Видалити запис";
    this.button3.Visible = false;
    this.button3.Click += new System.EventHandler(this.button3_Click);
    //
    // button4
    //
    this.button4.BackColor = System.Drawing.Color.RoyalBlue;
    this.button4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
    this.button4.Location = new System.Drawing.Point(408, 280);
    this.button4.Name = "button4";
    this.button4.Size = new System.Drawing.Size(328, 40);
    this.button4.TabIndex = 11;
    this.button4.Text = "Редагувати замітку";
    this.button4.Visible = false;
    this.button4.Click += new System.EventHandler(this.button4_Click);
    //
    // Form1
    //
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.BackColor = System.Drawing.Color.DarkSeaGreen;
    this.ClientSize = new System.Drawing.Size(752, 321);
    this.Controls.Add(this.button4);
    this.Controls.Add(this.button3);
    this.Controls.Add(this.comboBox1);
    this.Controls.Add(this.button2);
    this.Controls.Add(this.label1);
    this.Controls.Add(this.textBox1);
    this.Controls.Add(this.richTextBox2);
    this.Controls.Add(this.richTextBox1);
    this.Controls.Add(this.button1);
    this.Menu = this.mainMenu1;
    this.Name = "Form1";
    this.Text = "Нотатник";
    this.Load += new System.EventHandler(this.Form1_Load);
    this.ResumeLayout(false);

    }
    #endregion

    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
    Application.Run(new Form1());
    }

    private void Form1_Load(object sender, System.EventArgs e)
    {
    string [] a=new string[ ] {};
    a= Directory.GetFiles("DTA1");
    for(int i1=0;i1<a.Length;i1++)
    {
        string ss="";
        for(int k1=5;k1<a[i1].Length-4;k1++)
        {
        ss+=a[i1][k1];
        }
        comboBox1.Items.AddRange(new object[] {ss});
    }
    }

    private void menuItem4_Click(object sender, System.EventArgs e)
    {
    label1.Visible=true;
    richTextBox1.Visible=false;
    textBox1.Text="";
    richTextBox1.Text="";
    textBox1.Visible=true;
    button2.Visible=true;
    button3.Visible=false;
    button4.Visible=false;
    }

    private void button1_Click(object sender, System.EventArgs e)
    {
    StreamWriter sr=new StreamWriter("DTA1/"+textBox1.Text+".txt");
    sr.Write(richTextBox2.Text);
    sr.Close();
    button1.Visible=false;
    richTextBox2.Visible=false;
    MessageBox.Show("Замітка збережена");
    }

    private void button2_Click(object sender, System.EventArgs e)
    {
    button3.Visible=false;
    richTextBox2.Text="";
    try
    {
        richTextBox1.Visible=false;
        comboBox1.Items.AddRange(new object[] {textBox1.Text});
        richTextBox2.Visible=true;
        button1.Visible=true;
        label1.Visible=false;
        textBox1.Visible=false;
        button2.Visible=false;
    }
    catch
    {
        MessageBox.Show("помилка");
    }
    }

    private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
    button3.Visible=true;
    button4.Visible=true;
    try
    {
        StreamReader sR=new StreamReader("DTA1/"+comboBox1.SelectedItem+".txt");
        richTextBox1.Text=sR.ReadToEnd();
        sR.Close();
        richTextBox1.Visible=true;
    }
    catch
    {
        MessageBox.Show("помилка");
    }
    }

    private void button3_Click(object sender, System.EventArgs e)
    {
    File.Delete("DTA1/"+comboBox1.SelectedItem+".txt");
    comboBox1.Items.Remove(comboBox1.SelectedItem);
    richTextBox1.Visible=false;
    button4.Visible=false;
    button3.Visible=false;
    }

    private void button4_Click(object sender, System.EventArgs e)
    {
    StreamWriter swr1=new StreamWriter("DTA1/"+comboBox1.SelectedItem+".txt");
    swr1.Write(richTextBox1.Text);
    button4.Visible=false;
    richTextBox1.Visible=false;
    button3.Visible=false;
    swr1.Close();
    }
}
}

0

4

Это просто блокнот. Название сообщения, и само сообщение. Потом просто по названию находим нужное сообщение и просматриваем его. Или редактируем

0

5

Если будет время - выложу обе проги в работающем виде

0


Вы здесь » КАПУСТА: почитай,обсуди,отдохни! » С# » Примеры программ