Windows 10 1 2 3 4 5 Visual Studio 2008LINQ MySchedule
242 Microsoft Visual C# 2008
10 Windows 243 1 LINQIEnumerableXML LINQ to Object q Form1.cs w RefreshListBox private void RefreshListBox() schedulelistbox.items.clear(); if (listitem.shortflg) label5.text = ""; var sortshortitems = from shorttable in listitem.getcurrentshortitems(startdate) orderby shorttable.startdatetime, shorttable.enddatetime select shorttable; foreach (ShortItem s in sortshortitems) schedulelistbox.items.add(s.itemall); else label5.text = ""; var sortlongitems = from longtable in listitem.getcurrentlongitems(startdate) orderby longtable.startdatetime, longtable.enddatetime select longtable; foreach (LongItem l in sortlongitems) schedulelistbox.items.add(l.itemall); //
244 Microsoft Visual C# 2008 e MainForm r inputbutton_click t inputbutton_click RefreshListBox w //Click private void inputbutton_click(object sender, EventArgs e) // if (subjecttextbox.text!= "" && contenttextbox.text!= "") // // if (starttextbox.text == endtextbox.text) listitem.shortflg = true; shortmenu.checked = true; longmenu.checked = false; label5.text = ""; ShortItem shortitem = new ShortItem(startTextBox.Text, starttimedomainupdown.text, endtimedomainupdown.text, subject, contents); if (listitem.addshortitems(shortitem)) schedulelistbox.items.clear(); var sortshortitems = from shorttable in listitem.getcurrentshortitems(startdate) orderby shorttable.startdatetime, shorttable.enddatetime select shorttable; foreach (ShortItem shorts in sortshortitems) schedulelistbox.items.add(shorts.itemall); else MessageBox.Show("", ""); // else listitem.shortflg = false; shortmenu.checked = false; longmenu.checked = true; label5.text = ""; LongItem longitem = new LongItem(startTextBox.Text, endtextbox.text, subject, contents); if (listitem.addlongitems(longitem))
10 Windows 245 schedulelistbox.items.clear(); var sortlongitems = from longtable in listitem.getcurrentlongitems(startdate) orderby longtable.startdatetime, longtable.enddatetime select longtable; foreach (LongItem longs in sortlongitems) schedulelistbox.items.add(longs.itemall); else MessageBox.Show("", ""); ClearSubject(); // else MessageBox.Show("", ""); y u i 13:0013:30 test2 o 10:0013:00 test1 test1test2
246 Microsoft Visual C# 2008!0!1!2 test1 13:3014:30 OK test2test1
10 Windows 247 var sortshortitems = from shorttable in listitem.getcurrentshortitems(startdate) orderby shorttable.startdatetime, shorttable.enddatetime select shorttable; LINQ sortshortitems var sortshortitemsienumerable<shortitem> sortshortitems LINQ var = from in where orderby select foreach (ShortItem s in sortshortitems) schedulelistbox.items.add(s.itemall); foreachz var sortlongitems = from longtable in listitem.getcurrentlongitems(startdate) orderby longtable.startdatetime, longtable.enddatetime select longtable; sortlongitems foreach (LongItem l in sortlongitems) schedulelistbox.items.add(l.itemall); foreachc
248 Microsoft Visual C# 2008 2 myinit.txt LINQ to SQLLINQ to SQLSQL Server myinit.txt q myinit.txtuse=database DISP=SHORT SHORT=shortfile.csv LONG=longfile.csv HELP=myschedule.chm USE=DATABASE w FileIO.cs e FileIOInitRead class FileIO public static string shortfile; public static string longfile; public static string myhelp; public static bool databaseflg = false; // public static void InitRead(ScheduleList list) if (File.Exists("myinit.txt")) try StreamReader reader = new StreamReader("myinit.txt", Encoding.GetEncoding("Shift_JIS")); while(reader.peek()!= -1) string[] field=reader.readline().split('='); if (field[0] == "DISP") if (field[1] == "SHORT") list.shortflg = true; else list.shortflg = false;
10 Windows 249 // if (field[0] == "USE") databaseflg = true; shortfile = null; longfile = null; if (field[0] == "SHORT") shortfile=field[1]; if (field[0] == "LONG") longfile = field[1]; if (field[0] == "HELP") myhelp = field[1]; reader.close(); catch (FileNotFoundException) // r MySchedule t y MySchedule
250 Microsoft Visual C# 2008 u MySchedule.mdf i MySchedule.mdf o!0 Null Null STARTDATE char(10) STARTTIME char(5) ENDTIME char(5) SUBJECT nchar(20) CONTENTS nvarchar(50)!1 SHORTTABLE!2 LONGTABLE Null STARTDATE char(10) ENDDATE char(10) SUBJECT nchar(20) CONTENTS nvarchar(50)!3 LONGTABLESHORTTABLE
10 Windows 251 public static bool databaseflg = false; databaseflgfalse if (field[0] == "USE") databaseflg = true; shortfile = null; longfile = null; field0usedatabaseflgtrue shortfilelongfilenull Table ColumnLINQ to SQL SQL q MySchedule w LINQ to SQL e ScheduleSQL ScheduleSQL.dbml
252 Microsoft Visual C# 2008 r LONGTABLE SHORTTABLEScheduleSQL.dbml DataContext t r LINQ to SQL q FileIO.cs w FileIORead // public static void FileIORead(ScheduleList list) // try // if(shortfile!=null) // // if(longfile!=null) // // if (databaseflg) var db = new ScheduleSQLDataContext();
10 Windows 253 var shorttable = from sfield in db.shorttable select sfield; foreach (var sfield in shorttable) ShortItem s = new ShortItem(sfield.STARTDATE, sfield.starttime, sfield.endtime, sfield.subject, sfield.contents); list.addshortitems(s); var longtable = from lfield in db.longtable select lfield; foreach (var lfield in longtable) LongItem l = new LongItem(lfield.STARTDATE, lfield.enddate, lfield.subject, lfield.contents); list.addlongitems(l); catch (FileNotFoundException) // e FileIOWrite using System.Data.Sqlclient; // // public static void FileIOWrite(ScheduleList list) try // // // // // if (databaseflg) string basedir = AppDomain.CurrentDomain.BaseDirectory; string ConnectionString = "Data Source=. SQLEXPRESS;AttachDbFilename= "" + basedir + "MySchedule.mdf ";Integrated Security=True;User Instance=True"; SqlConnection hconnection = ( new SqlConnection(ConnectionString)); hconnection.open(); // string SQL = "DELETE FROM SHORTTABLE"; SqlCommand cmd = new SqlCommand(SQL, hconnection); cmd.executenonquery(); // SQL = "DELETE FROM LONGTABLE";
254 Microsoft Visual C# 2008 cmd = new SqlCommand(SQL, hconnection); cmd.executenonquery(); // foreach (ShortItem s in list.shortitems) string[] field = s.getfield(); SQL = "INSERT INTO SHORTTABLE VALUES('" + field[0] + "'," + "'" + field[1] + "','" + field[2] + "','" + s.subject + "','" +s.contents + "')"; cmd = new SqlCommand(SQL, hconnection); cmd.executenonquery(); // foreach (LongItem l in list.longitems) string[] field = l.getfield(); SQL = "INSERT INTO LONGTABLE VALUES('" + field[0] + "','" + field[1] + "','" + l.subject + "','" + l.contents + "')"; cmd = new SqlCommand(SQL, hconnection); cmd.executenonquery(); hconnection.close(); hconnection.dispose(); catch (FileNotFoundException) // r InitWrite // public static void InitWrite(ScheduleList list) try string[] files = new string[3]; // StreamReader reader = new StreamReader("myinit.txt", Encoding.GetEncoding("Shift_JIS")); while (reader.peek()!= -1) string[] field = reader.readline().split('='); if(field[0] == "SHORT") files[0] = field[1]; if (field[0] == "LONG") files[1] = field[1]; if (field[0] == "HELP") files[2] = field[1]; reader.close(); // StreamWriter writer = new StreamWriter("myinit.txt", false,
10 Windows 255 Encoding.GetEncoding("Shift_JIS")); if(list.shortflg) writer.writeline("disp=short"); else writer.writeline("disp=long"); if (files[0]!= null) writer.writeline("short=" + files[0]); if (files[1]!= null) writer.writeline("long=" + files[1]); if (files[2]!= null) writer.writeline("help=" + files[2]); if(databaseflg) writer.writeline("use=database"); writer.close(); catch (FileNotFoundException) // var db = new ScheduleSQLDataContext(); ScheduleSQLDataContextDataContext ScheduleSQLDataContext var shorttable = from sfield in db.shorttable select sfield; SHORTTABLEshorttable foreach (var sfield in shorttable) ShortItem s = new ShortItem(sfield.STARTDATE, sfield.starttime,sfield.endtime, sfield.subject, sfield.contents); list.addshortitems(s); x1 var longtable = from lfield in db.longtable select lfield; LONGTABLElongtable
256 Microsoft Visual C# 2008 foreach (var lfield in longtable) LongItem l = new LongItem(lfield.STARTDATE, lfield.enddate, lfield.subject, lfield.contents); list.addlongitems(l); v1 string basedir = AppDomain.CurrentDomain.BaseDirectory; string ConnectionString = "Data Source=. SQLEXPRESS;AttachDbFilename= "" + basedir + "MySchedule.mdf ";Integrated Security=True;User Instance=True"; basedir ConnectionString SqlConnection hconnection = ( new SqlConnection(ConnectionString)); SqlConnection hconnection.open(); SqlCommand cmd = new SqlCommand(SQL, hconnection); SQLSQL SQLcmd cmd.executenonquery();.sql foreach (ShortItem s in list.shortitems) string[] field = s.getfield(); SQL = "INSERT INTO SHORTTABLE VALUES('" + field[0] +"'," + "'" + field[1] + "','" + field[2] + "','" + s.subject + "','" + s.contents + "')"; cmd = new SqlCommand(SQL, hconnection); cmd.executenonquery(); 1
10 Windows 257 hconnection.close(); hconnection.dispose(); StreamReader reader = new StreamReader("myinit.txt", Encoding.GetEncoding("Shift_JIS")); myinit.txt null if (files[0]!= null) writer.writeline("short=" + files[0]); if (files[1]!= null) writer.writeline("long=" + files[1]); if (files[2]!= null) writer.writeline("help=" + files[2]); if(databaseflg) writer.writeline("use=database"); stringfiles012 trueuse=database
258 Microsoft Visual C# 2008 3 MySchedule MySchedule q w MySchedule e r Visual C# t Icon1.ico y Icon1.ico
10 Windows 259 u Icon1.ico161632322 32321616 1616 3232 q 32324BMP 3232 w 16164BMP 1616 e Icon1.ico
260 Microsoft Visual C# 2008 MyScheduleIcon1.ico MySchedule.exe q MySchedule w Icon1.ico e Icon1.ico r t MySchedule bin Debug MySchedule.exeIcon1.ico w t
10 Windows 261 MySchedule Icon1.ico q MainForm MainForm w Icon... e Icon1.icoMySchedule Icon r DisplayForm UpdateFormIcon t MainForm y d
262 Microsoft Visual C# 2008 4 VersionForm q MySchedule w e r Bitmap1.bmp t Bitmap1.bmp y u Bitmap1.bmp
10 Windows 263 VersionFormBitmap1.bmp q VersionForm w PictureBox picturebox1 e Image... r t y Bitmap1.bmp MySchedule u OK PictureBoxBitmap1.bmp
264 Microsoft Visual C# 2008 i SizeModeAutoSize PictureBox o!0!1!2 PictureBox r
10 Windows 265 5 MySchedule MyScheduleMySchedule bin DebugMySchedule.exe MySchedule q DebugRelease w Release e MySchedule MySchedule bin Release MySchedule.exe
1 Visual Studio 2008 15 C var var x = 1; var y = 1.0; var z = "abcde"; zx1int x1.064double cabcdestring static class Extensions public static string IndexString(this string s) string str = "Hello C#"; string s1 = str.indexstring(); zindexstringthis xzindexstringextensions. IndexString(str)
16 Microsoft Visual C# 2008 Func<int, bool> result = n => n > 0; MessageBox.Show(result(-1) + ""); z0true0false xz1false LINQ var = newnew=1,="", new=2,="", new=3,="", ; var = from p in where p.==2 select p.; foreach (var in ) MessageBox.Show();
1 Visual Studio 2008 17 z x 2 c public int number get; set; number=12345; MessageBox.Show(number+""); znumber xnumber12345 cnumber
186 Microsoft Visual C# 2008 C StringDateTime.NET Framework ConsoleMath Console Math Random Console ReadLine WriteLine 1 Math Abs Ceiling Floor Max Min PI Pow Sign Sqrt 2 2 12-1100
7 187 Random Random Next 0 DirectoryFile StreamReaderStreamWriter 8 Directory CreateDirectory Delete GetDirectories GetFiles Move 12 File Copy Create Delete Exists Move 12 12
188 Microsoft Visual C# 2008 System.TextEncodingUnicode System.Collections ArrayList HashTable System.DrawingGDI+ System.Drawing.Drawing2DSystem.Drawing.ImagingSystem.Drawing.Text System.Windows.FormsMicrosoft Windows Windows