메뉴 건너뛰기

Programing

C# 게시판

일기장 구현하기

관리자2 2018.12.26 18:59 조회 수 : 270

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

using Microsoft.VisualBasic;

 

 

namespace ts11

{

    public partial class Form1 : Form

    {

        string[] i = new string[365];

        public Form1()

        {

            InitializeComponent();

        }

 

        private void Form1_Load(object sender, EventArgs e)

        {

 

        }

 

        private void btnSave_Click(object sender, EventArgs e)

        {

            var datTim1 = Convert.ToDateTime("#1/1/2008#");

            DateTime datTim2 = this.dtbTime.Value;

            int wD = Convert.ToInt32(DateAndTime.DateDiff(DateInterval.Day, datTim1, datTim2, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1));

            i[wD] = this.txtMemo.Text;

            if (i[wD].Length > 0)

            {

                MessageBox.Show("일기가 정상적으로 저장되었습니다.", "알림", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                this.txtMemo.Clear();

            }

            else

            {

                MessageBox.Show("일기가 저장되지 못 했습니다.", "경고", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }

        }

 

        private void dtbTime_ValueChanged(object sender, EventArgs e)

        {

            DateTime datTim1 = Convert.ToDateTime("#1/1/2008#");

            DateTime datTim2 = this.dtbTime.Value;

            int wD = Convert.ToInt32(DateAndTime.DateDiff(DateInterval.Day, datTim1, datTim2, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1));

            this.txtMemo.Text = i[wD];

        }

    }

}

일기장 모듈 구현
위로