private void buttonChart_Click(object sender, EventArgs e) { CigReaderDataBase.CigDataBase Cig = new CigReaderDataBase.CigDataBase(); CigRead = new List <String>(); Cig.CigRead(ref dataGridViewCig, ref CigRead); pictureBox1_Paint(sender, new System.Windows.Forms.PaintEventArgs(g, new System.Drawing.Rectangle(0, 0, this.pictureBox1.Width, pictureBox1.Height))); }
private void FormCigRemove_Load(object sender, System.EventArgs e) { try { CigReaderDataBase.CigDataBase Cig = new CigReaderDataBase.CigDataBase(); CigRead = new List <String>(); Cig.CigRead(ref dataGridViewCig, ref CigRead); DateTime S = System.Convert.ToDateTime(CigRead[0]); DateTime Now = DateTime.Now; if (S.Year != Now.Year || S.Month != Now.Month || S.Day != Now.Day) { Directory.CreateDirectory(S.Year.ToString() + S.Month.ToString() + S.Day.ToString()); File.Copy("CigRemove.accdb", S.Year.ToString() + S.Month.ToString() + S.Day.ToString() + "\\CigRemove.accdb"); (new CigReaderDataBase.CigDataBase()).CigDelete(); } CigRead.Clear(); CigRead = null; } catch (Exception t) { Log(t); } }
private void button1CigIndicator_Click(object sender, EventArgs e) { try { CigReaderDataBase.CigDataBase Cig = new CigReaderDataBase.CigDataBase(); Cig.CigInsert(DateTime.Now.ToString()); CigRead = new List <String>(); Cig.CigRead(ref dataGridViewCig, ref CigRead); List <Double> SL = new List <Double>(); if (CigRead != null) { double CigReadL = 0; int CigL = 999999999; int iL = 0; for (int i = 0; i < CigRead.Count - 1; i++) { DateTime S = System.Convert.ToDateTime(CigRead[i]); DateTime A = System.Convert.ToDateTime(CigRead[i + 1]); double SS = S.Hour * 60 * 60 * 1000 + S.Minute * 60 * 1000 + S.Second * 1000 + S.Millisecond; double AA = A.Hour * 60 * 60 * 1000 + A.Minute * 60 * 1000 + A.Second * 1000 + A.Millisecond; String D = S.ToString().Substring(S.ToString().Length - 2, 2); // if (D == "PM" && S.Hour != 12) // SS += 12 * 60 * 60 * 1000; String H = A.ToString().Substring(A.ToString().Length - 2, 2); // if (H == "PM" && A.Hour != 12) // AA += 12 * 60 * 60 * 1000; if (CigReadL < (AA - SS)) { CigReadL = (AA - SS); iL = i; } if (CigL > (AA - SS)) { CigL = (int)(AA - SS); } } if (CigRead != null) { for (int i = 0; i < CigRead.Count; i++) { DateTime S = System.Convert.ToDateTime(CigRead[i]); String D = S.ToString().Substring(S.ToString().Length - 2, 2); double SS = S.Hour * 60 * 60 * 1000 + S.Minute * 60 * 1000 + S.Second * 1000 + S.Millisecond; // if (D == "PM" && S.Hour != 12) // SS += 12 * 60 * 60 * 1000; SL.Add(SS); } } } int SA = SL.Count - 1; double AD = SL[SA] - SL[SA - 1]; DateTime ASA = DateTime.Now; double ASS = ASA.Hour * 60 * 60 * 1000 + ASA.Minute * 60 * 1000 + ASA.Second * 1000 + ASA.Millisecond; String HHY = ASA.ToString().Substring(ASA.ToString().Length - 2, 2); // if (HHY == "PM" && ASA.Hour != 12) // ASS += 12 * 60 * 60 * 1000; double AZ = ASS - SL[SA]; if (File.Exists("Time.tm")) { File.Delete("Time.tm"); } File.WriteAllText("Time.tm", (AD - AZ).ToString()); } catch (Exception t) { MessageBox.Show(t.ToString()); } }