using Microsoft.Data.SqlClient; using Microsoft.Data.Sqlite; using System.Drawing; using TimeTable.controll; using TimeTable.model; namespace TimeTable { partial class Main { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { btnPanel = new Panel(); btnTaskStop = new Button(); btnTaskStart = new Button(); btnStopResume = new Button(); btnStart = new Button(); tableView = new Panel(); taskTimeGridView = new DataGridView(); btnPanel.SuspendLayout(); tableView.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)taskTimeGridView).BeginInit(); SuspendLayout(); sqlConnectionString = "Data Source=" + Directory.GetCurrentDirectory() + "\\sqllite.db"; SqliteCommands.CreateTableIfNotExists(sqlConnectionString); dataAdapter = new SqlDataAdapter("SELECT * from timetable", sqlConnectionString); // // btnPanel // btnPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; btnPanel.Controls.Add(btnTaskStop); btnPanel.Controls.Add(btnTaskStart); btnPanel.Controls.Add(btnStopResume); btnPanel.Controls.Add(btnStart); btnPanel.Dock = DockStyle.Left; btnPanel.Location = new Point(0, 0); btnPanel.Name = "btnPanel"; btnPanel.Size = new Size(233, 171); btnPanel.TabIndex = 0; // // btnTaskStop // btnTaskStop.Location = new Point(103, 38); btnTaskStop.Name = "btnTaskStop"; btnTaskStop.Size = new Size(114, 29); btnTaskStop.TabIndex = 3; btnTaskStop.Text = "Task Stop"; btnTaskStop.UseVisualStyleBackColor = true; btnTaskStart.Click += this.btnTaskStopClick; // // btnTaskStart // btnTaskStart.Location = new Point(3, 38); btnTaskStart.Name = "btnTaskStart"; btnTaskStart.Size = new Size(94, 29); btnTaskStart.TabIndex = 2; btnTaskStart.Text = "Task Start"; btnTaskStart.UseVisualStyleBackColor = true; btnTaskStart.Click += this.btnTaskStartClick; // // btnStopResume // btnStopResume.Location = new Point(103, 3); btnStopResume.Name = "btnStopResume"; btnStopResume.Size = new Size(114, 29); btnStopResume.TabIndex = 1; btnStopResume.Text = "Stop/Resume"; btnStopResume.UseVisualStyleBackColor = true; btnTaskStart.Click += this.btnStopResumeClick; // // btnStart // btnStart.Location = new Point(3, 3); btnStart.Name = "btnStart"; btnStart.Size = new Size(94, 29); btnStart.TabIndex = 0; btnStart.Text = "Start"; btnStart.UseVisualStyleBackColor = true; btnStart.Click += this.btnStartClick; // // tableView // tableView.AutoSizeMode = AutoSizeMode.GrowAndShrink; tableView.Controls.Add(taskTimeGridView); tableView.Dock = DockStyle.Right; tableView.Location = new Point(239, 0); tableView.Name = "tableView"; tableView.Size = new Size(477, 171); tableView.TabIndex = 1; // // taskTimeGridView // taskTimeGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; taskTimeGridView.Dock = DockStyle.Fill; taskTimeGridView.Location = new Point(0, 0); taskTimeGridView.Name = "taskTimeGridView"; taskTimeGridView.RowHeadersWidth = 51; taskTimeGridView.Size = new Size(477, 171); taskTimeGridView.TabIndex = 0; taskTimeGridView.DataSource = dataAdapter; // // Main // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(716, 171); Controls.Add(tableView); Controls.Add(btnPanel); Name = "Main"; Text = "TimeTable"; btnPanel.ResumeLayout(false); tableView.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)taskTimeGridView).EndInit(); ResumeLayout(false); } private void executeSql(string command) { SqliteConnection con = new SqliteConnection(sqlConnectionString); SqliteCommand sqliteCmd = con.CreateCommand(); sqliteCmd.CommandText = command; con.Open(); sqliteCmd.ExecuteNonQuery(); con.Close(); } private void btnStartClick(object sender, EventArgs e) { UidCommand uidCmd = SqliteCommands.InsertCmd(DateTime.Now); uid = uidCmd.uid; executeSql(uidCmd.command); } private void btnTaskStartClick(object sender, EventArgs e) { } private void btnStopResumeClick(object sender, EventArgs e) { String cmd = SqliteCommands.UpdateEndCmd(uid, DateTime.Now); executeSql(cmd); taskTimeGridView.DataSource = dataAdapter; } private void btnTaskStopClick(object sender, EventArgs e) { } #endregion private Panel btnPanel; private Button btnTaskStop; private Button btnTaskStart; private Button btnStopResume; private Button btnStart; private Panel tableView; private DataGridView taskTimeGridView; private string uid; string sqlConnectionString; private SqlDataAdapter dataAdapter; } }