bool getMonth() { int month; DateTime Time1, Time2; TimeSpan time; var k = dataGridView1.SelectedRows[0].Cells[0].Value; SqlConnection cnn = Kn(); cnn.Open(); string sql = "SELECT NgayGui FROM TheTietKiem WHERE ID = '" + k + "'"; SqlCommand cm = new SqlCommand(sql, cnn); SqlDataReader dr = cm.ExecuteReader();; if (dr.Read()) { Time1 = Convert.ToDateTime(dr[0].ToString()); int a = Time1.Month; Time2 = Convert.ToDateTime(DateTime.Now.ToString()); time = Time2.Subtract(Time1); int day = time.Days; month = day / 30; if (month < a) { return(false); } } cnn.Close(); return(true); }
IEnumerator ResumeGame() { Debug.Log("reset"); PropsController.Instance.Restart(); ResetPlayer(myPlayer, initMyPosition); ResetPlayer(oppoPlayer, initOppoPosition); footBall.SendMessage("Reset", initBallPosition, SendMessageOptions.DontRequireReceiver); mainCamera.SendMessage("CameraReset"); Time.timeScale = 1f; Time3.Hide(false); yield return(new WaitForSeconds(1.0f)); Time3.Hide(true); Time2.Hide(false); yield return(new WaitForSeconds(1.0f)); Time2.Hide(true); Time1.Hide(false); yield return(new WaitForSeconds(1.0f)); Time1.Hide(true); TexGo.Hide(false); StartGame(); yield return(new WaitForSeconds(1.0f)); TexGo.Hide(true); }
bool getMonth() { int month; DateTime Time1, Time2; TimeSpan nowtime; SqlConnection cnn = Kn(); cnn.Open(); string sql = "SELECT NgayGui FROM TheTietKiem WHERE ID = '" + lbnKey.Text + "'"; SqlCommand cm = new SqlCommand(sql, cnn); SqlDataReader dr = cm.ExecuteReader();; if (dr.Read()) { Time1 = Convert.ToDateTime(dr[0].ToString()); int a = Time1.Month; Time2 = Convert.ToDateTime(DateTime.Now.ToString()); nowtime = Time2.Subtract(Time1); month = nowtime.Days / 30; if (month < int.Parse(lbnIntKyHan.Text)) { return(false); } } cnn.Close(); return(true); }
public int gMonth(string GKey1) { DateTime Time1, Time2; TimeSpan time; SqlConnection cnn = Kn(); cnn.Open(); string sql = "SELECT NgayGui FROM TheTietKiem WHERE ID = '" + GKey1 + "'"; SqlCommand cm = new SqlCommand(sql, cnn); SqlDataReader dr = cm.ExecuteReader();; if (dr.Read()) { Time1 = Convert.ToDateTime(dr[0].ToString()); int a = Time1.Month; Time2 = Convert.ToDateTime(DateTime.Now.ToString()); time = Time2.Subtract(Time1); int day = time.Days; int thang = day / 30; { return(thang); } } cnn.Close(); return(0); }
private void Odszyfruj_click(object sender, RoutedEventArgs e) { Time2.Clear(); Stopwatch zegar = Stopwatch.StartNew(); Szyfruj.IsEnabled = true; Deszyfruj.IsEnabled = false; TekstOdszyfrowany.Clear(); string wyjsciowy; string TekstZaszyfrowanyLocal = TekstZaszyfrowany.Text.Replace(System.Environment.NewLine, ""); int[] t = StringtoArray.StoA(Klucz.Text, Convert.ToInt32(KeyLength.Text)); int NumOfColumns = TekstZaszyfrowanyLocal.Length / Convert.ToInt32(KeyLength.Text); string blockOfText; string restOfText = TekstZaszyfrowanyLocal.ToString(); for (int i = 0; i < NumOfColumns; i++) { blockOfText = restOfText.Substring(0, Convert.ToInt32(KeyLength.Text)); restOfText = restOfText.Substring(Convert.ToInt32(KeyLength.Text)); wyjsciowy = string.Concat(ReverseEncrypt(blockOfText, t)); TekstOdszyfrowany.Text = TekstOdszyfrowany.Text + wyjsciowy; wyjsciowy = string.Empty; } TekstOdszyfrowany.Text = TekstOdszyfrowany.Text + restOfText; zegar.Stop(); Time2.Text = zegar.ElapsedMilliseconds.ToString() + " ms"; }
public void ShouldClassVariableChangeAppliesToAllVariable() { Time2 t21 = new Time2(9, 30); Time2 t22 = t21; t21.minutes = 100; Assert.Equal(100, t22.minutes); }
public void TestMethodToStringAM() { Time2 myTime = new Time2(11, 4, 5); //NUnit string expResult = "11:04:05 AM"; Assert.AreEqual(expResult, myTime.ToString()); }
public void TestMethodToStringPM() { Time2 myTime = new Time2(14, 4, 5); string expResult = "2:04:05 PM"; //NUnit Assert.AreEqual(expResult, myTime.ToString()); }
public void TestMethodObj4() { Time2 myTime = new Time2(11, 12, 30); //NUnit Assert.AreEqual(11, myTime.Hour); Assert.AreEqual(12, myTime.Minute); Assert.AreEqual(30, myTime.Second); }
public void TestMethodObj2() { Time2 myTime = new Time2(2); //NUnit Assert.AreEqual(2, myTime.Hour); Assert.AreEqual(0, myTime.Minute); Assert.AreEqual(0, myTime.Second); }
} // end Time2 three-argument overloaded method // Time2 constructor: another Time2 object supplied as an argument public void addtime(Time2 atime) { //atime.SetTime(Hour, Minute, Second); //atime.addTime(Hour, Minute, Second); atime.Hour2 = atime.Hour + atime.Hour; atime.Minute2 += atime.Minute + atime.Minute; atime.Second2 = atime.Second + atime.Second; }
public void TestMethodToUniversalString() { Time2 myTime = new Time2(11, 4, 5); string expResult = "11:04:05"; //NUnit Assert.AreEqual(expResult, myTime.ToUniversalString()); }
public void TestMethodObj5() { Time2 myTime = new Time2(); Time2 myTime55 = new Time2(myTime); //NUnit Assert.AreEqual(0, myTime55.Hour); Assert.AreEqual(0, myTime55.Minute); Assert.AreEqual(0, myTime55.Second); }
private void setTimeButton_Click(object sender, EventArgs e) { usingCustomTime = true; Int32.TryParse(hourTextBox.Text, out hours); Int32.TryParse(minuteTextBox.Text, out minutes); Int32.TryParse(secondTextBox.Text, out seconds); currentTimeCustom = new Time2(hours, minutes, seconds); }
public static bool operator !=(Time Time1, Time Time2) { if ((object)Time1 == null && (object)Time2 == null) { return(false); } else if ((object)Time1 == null ^ (object)Time2 == null) { return(true); } return(Time1.ToDateTime() != Time2.ToDateTime()); }
// add the specified number of hours to the time // and return a new Time2 object public static Time2 AddHours(this Time2 aTime, int hours) { // create a new Time object var newTime = new Time2() { Minute = aTime.Minute, Second = aTime.Second }; // add the specified number of hours to the given time newTime.Hour = (aTime.Hour + hours) % 24; return(newTime); // return the new Time2 object }
public Time2 ToHoursMinutesSeconds(int second) { Hour = second / 60 / 60; second = second - (Hour * 60 * 60); Minute = second / 60; second = second - (Minute * 60); Second = second; Time2 time2 = new Time2(Hour, Minute, Second); return(time2); }
//动画 private void Time1_Tick(object sender, EventArgs e) { if (this.Left + this.Width > 0) { this.Left -= ScriptTime; } else { Time1.Stop(); Init(); this.Left = this.Parent.Width; Time2.Start(); } }
private void Time2_Tick(object sender, EventArgs e) {//有点小问题哦 if (this.Left > aleft + ScriptTime) { this.Left -= ScriptTime; } else if (this.Left > aleft) { this.Left -= 5; } else { Time2.Stop(); } }
private void Wyczysc_Click(object sender, RoutedEventArgs e) { KeyLength.IsEnabled = true; Szyfruj.IsEnabled = false; Deszyfruj.IsEnabled = false; TekstJawny.IsEnabled = true; GenerujKlucz.IsEnabled = true; TekstJawny.Clear(); TekstZaszyfrowany.Clear(); TekstOdszyfrowany.Clear(); Key = string.Empty; Klucz.Clear(); Time1.Clear(); Time2.Clear(); }
public static void Main(string[] args) { Time2 t1 = new Time2(); // 00:00:00 Time2 t2 = new Time2(2); // 02:00:00 Time2 t3 = new Time2(21, 34); // 21:34:00 Time2 t4 = new Time2(12, 25, 42); // 12:25:42 Time2 t5 = new Time2(t4); // 12:25:42 Time2 t6; // initialized later in the program Console.WriteLine("Constructed with:\n"); Console.WriteLine("t1: all arguments defaulted"); Console.WriteLine(" {0}", t1.ToUniversalString()); // 00:00:00 Console.WriteLine(" {0}\n", t1.ToString()); // 12:00:00 AM Console.WriteLine("t2: hour specified; minute and second defaulted"); Console.WriteLine(" {0}", t2.ToUniversalString()); // 02:00:00 Console.WriteLine(" {0}\n", t2.ToString()); // 2:00:00 AM Console.WriteLine("t3: hour and minute specified; second defaulted"); Console.WriteLine(" {0}", t3.ToUniversalString()); // 21:34:00 Console.WriteLine(" {0}\n", t3.ToString()); // 9:34:00 PM Console.WriteLine("t4: hour, minute and second specified"); Console.WriteLine(" {0}", t4.ToUniversalString()); // 12:25:42 Console.WriteLine(" {0}\n", t4.ToString()); // 12:25:42 PM Console.WriteLine("t5: Time2 object t4 specified"); Console.WriteLine(" {0}", t5.ToUniversalString()); // 12:25:42 Console.WriteLine(" {0}", t5.ToString()); // 12:25:42 PM // attempt to initialize t6 with invalid values try { t6 = new Time2(27, 74, 99); // invalid values } // end try catch (ArgumentOutOfRangeException ex) { Console.WriteLine("\nException while initializing t6:"); Console.WriteLine(ex.Message); } // end catch Console.WriteLine("\nTecle qualquer tecla para finalizar..."); Console.ReadKey(); } // end Main
static void Main() { var t1 = new Time2(); var t2 = new Time2(2); var t3 = new Time2(21, 34); var t4 = new Time2(12, 25, 42); var t5 = new Time2(t4); Console.WriteLine("Constructed with:\n"); Console.WriteLine("t1: all arguments defaulted"); Console.WriteLine($"{t1.ToUniversalString()}"); Console.WriteLine($"{t1.ToString()}\n"); Console.WriteLine("t2: hour specified; minute and second defaulted"); Console.WriteLine($"{t2.ToUniversalString()}"); Console.WriteLine($"{t2.ToString()}\n"); Console.WriteLine("t3: hour and minute specified; second defaulted"); Console.WriteLine($"{t3.ToUniversalString()}"); Console.WriteLine($"{t3.ToString()}\n"); Console.WriteLine("t4: hour, minute and second defaulted"); Console.WriteLine($"{t4.ToUniversalString()}"); Console.WriteLine($"{t4.ToString()}\n"); Console.WriteLine("t5: Time2 object t4 specified"); Console.WriteLine($"{t5.ToUniversalString()}"); Console.WriteLine($"{t5.ToString()}"); try { var t6 = new Time2(27, 74, 99); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine("\nException while initializing t6:"); Console.WriteLine(ex.Message); } Console.ReadLine(); }
static void Main() { var t1 = new Time2(); // 00:00:00 var t2 = new Time2(2); // 02:00:00 var t3 = new Time2(21, 34); // 21:34:00 var t4 = new Time2(12, 25, 42); // 12:25:42 var t5 = new Time2(t4); // 12:25:42 Console.WriteLine("Constructed with:\n"); Console.WriteLine("t1: all arguments defaulted"); Console.WriteLine($" {t1.ToUniversalString()}"); // 00:00:00 Console.WriteLine($" {t1.ToString()}\n"); // 12:00:00 AM Console.WriteLine( "t2: hour specified; minute and second defaulted"); Console.WriteLine($" {t2.ToUniversalString()}"); // 02:00:00 Console.WriteLine($" {t2.ToString()}\n"); // 2:00:00 AM Console.WriteLine( "t3: hour and minute specified; second defaulted"); Console.WriteLine($" {t3.ToUniversalString()}"); // 21:34:00 Console.WriteLine($" {t3.ToString()}\n"); // 9:34:00 PM Console.WriteLine("t4: hour, minute and second specified"); Console.WriteLine($" {t4.ToUniversalString()}"); // 12:25:42 Console.WriteLine($" {t4.ToString()}\n"); // 12:25:42 PM Console.WriteLine("t5: Time2 object t4 specified"); Console.WriteLine($" {t5.ToUniversalString()}"); // 12:25:42 Console.WriteLine($" {t5.ToString()}"); // 12:25:42 PM // attempt to initialize t6 with invalid values try { var t6 = new Time2(27, 74, 99); // invalid values } catch (ArgumentOutOfRangeException ex) { Console.WriteLine("\nException while initializing t6:"); Console.WriteLine(ex.Message); } }
//Update the current time label using Time2 object private void timer1_Tick(object sender, EventArgs e) { if (sender == timer1) { if (!usingCustomTime) { //capture current time in DateTime object currentTime = DateTime.Now; currentTimeConverted = ConvertDateTime(currentTime); //Update time label on form currentTimeLabel.Text = currentTimeConverted.ToString(); } else { currentTimeCustom.Second++; currentTimeLabel.Text = currentTimeCustom.ToString(); } //Loop through alarms and see if one needs to be triggered. foreach (AlarmTime a in alarmsListBox.Items) { if (!usingCustomTime) { if ((currentTimeConverted.ToString()).Equals(a.ToString())) { currentAlarm = a; alarmTriggered(currentAlarm); } } else { if ((currentTimeCustom.ToString()).Equals(a.ToString())) { currentAlarm = a; alarmTriggered(currentAlarm); } } } } }
public override object Convert(object value, Type type) { if (value == null) { return(TypeHelper.GetDefault(type)); } type = TypeHelper.GetNonNullableType(type); if (type == typeof(Time)) { return(Time.Parse(value.ToString())); } if (type == typeof(Time2)) { return(Time2.Parse(value.ToString())); } Type vtype = value.GetType(); if (type != vtype) { if (type.IsEnum) { if (vtype == typeof(string)) { return(Enum.Parse(type, (string)value)); } else { Type utype = Enum.GetUnderlyingType(type); if (utype != vtype) { value = System.Convert.ChangeType(value, utype); } return(Enum.ToObject(type, value)); } } return(System.Convert.ChangeType(value, type)); } return(value); }
public static void Main() { Time2 t1 = new Time2(); // 00:00:00 Time2 t2 = new Time2(2); // 02:00:00 Time2 t3 = new Time2(21, 34); // 21:34:00 Time2 t4 = new Time2(12, 25, 42); // 12:25:42 Time2 t5 = new Time2(27, 74, 99); // 00:00:00 Time2 t6 = new Time2(t4); // 12:25:42 Console.WriteLine("Constructed with :\n"); Console.WriteLine("t1: all arguments defaulted"); Console.WriteLine(" {0}", t1.ToUniversalString()); Console.WriteLine(" {0}\n", t1.ToString()); Console.WriteLine("t2: hour specified"); Console.WriteLine(" {0}", t2.ToUniversalString()); Console.WriteLine(" {0}\n", t2.ToString()); Console.WriteLine("t3: hour & minute specified"); Console.WriteLine(" {0}", t3.ToUniversalString()); Console.WriteLine(" {0}\n", t3.ToString()); Console.WriteLine("t4: hour & minute & seconde specified"); Console.WriteLine(" {0}", t4.ToUniversalString()); Console.WriteLine(" {0}\n", t4.ToString()); Console.WriteLine("t5: all invalid arguments"); Console.WriteLine(" {0}", t5.ToUniversalString()); Console.WriteLine(" {0}\n", t5.ToString()); Console.WriteLine("t6: Time2 object t4 specified"); Console.WriteLine(" {0}", t6.ToUniversalString()); Console.WriteLine(" {0}\n", t6.ToString()); Console.ReadLine(); } // end Main
static void Main() { var myTime = new Time2(); // call Time constructor myTime.SetTime(11, 34, 15); // set the time to 11:34:15 // test the DisplayTime extension method Console.Write("Use the DisplayTime extension method: "); myTime.DisplayTime(); // test the AddHours extension method Console.Write("Add 5 hours with the AddHours extension method: "); var timeAdded = myTime.AddHours(5); // add five hours timeAdded.DisplayTime(); // display the new Time2 object // add hours and display the time in one statement Console.Write("Add 15 hours with the AddHours extension method: "); myTime.AddHours(15).DisplayTime(); // add hours and display time // use fully qualified extension-method name to display the time Console.Write("Use fully qualified extension-method name: "); TimeExtensions.DisplayTime(myTime); }
public static void Main( string[] args ) { Time2 t1 = new Time2(); // 00:00:00 Time2 t2 = new Time2( 2 ); // 02:00:00 Time2 t3 = new Time2( 21, 34 ); // 21:34:00 Time2 t4 = new Time2( 12, 25, 42 ); // 12:25:42 Time2 t5 = new Time2( 27, 74, 99 ); // 00:00:00 Time2 t6 = new Time2( t4 ); // 12:25:42 Console.WriteLine( "Constructed with:\n" ); Console.WriteLine( "t1: all arguments defaulted" ); Console.WriteLine( " {0}", t1.ToUniversalString() ); // 00:00:00 Console.WriteLine( " {0}\n", t1.ToString() ); // 12:00:00 AM Console.WriteLine( "t2: hour specified; minute and second defaulted" ); Console.WriteLine( " {0}", t2.ToUniversalString() ); // 02:00:00 Console.WriteLine( " {0}\n", t2.ToString() ); // 2:00:00 AM Console.WriteLine( "t3: hour and minute specified; second defaulted" ); Console.WriteLine( " {0}", t3.ToUniversalString() ); // 21:34:00 Console.WriteLine( " {0}\n", t3.ToString() ); // 9:34:00 PM Console.WriteLine( "t4: hour, minute and second specified" ); Console.WriteLine( " {0}", t4.ToUniversalString() ); // 12:25:42 Console.WriteLine( " {0}\n", t4.ToString() ); // 12:25:42 PM Console.WriteLine( "t5: all invalid values specified" ); Console.WriteLine( " {0}", t5.ToUniversalString() ); // 00:00:00 Console.WriteLine( " {0}\n", t5.ToString() ); // 12:00:00 AM Console.WriteLine( "t6: Time2 object t4 specified" ); Console.WriteLine( " {0}", t6.ToUniversalString() ); // 12:25:42 Console.WriteLine( " {0}", t6.ToString() ); // 12:25:42 PM }
} // end Time2 three-argument overloaded method // Time2 constructor: another Time2 object supplied as an argument public void addtime(Time2 atime) { atime.SetTime(Hour, Minute, Second); atime.addTime(Hour, Minute, Second); }
} // end Time2 three-argument constructor // Time2 constructor: another Time2 object supplied as an argument public Time2(Time2 time) : this(time.Hour, time.Minute, time.Second) { addtime(time); }
public static void Main(string[] args) { Time2 t1 = new Time2(); // 00:00:00 Time2 t2 = new Time2(2); // 02:00:00 Time2 t3 = new Time2(21, 34); // 21:34:00 Time2 t4 = new Time2(12, 25, 42); // 12:25:42 Time2 t5 = new Time2(t4); // 12:25:42 Time2 t6; // initialized later in the program Time2 t44 = new Time2(12, 25, 42); Time2 t41 = t4; if (t4.Equals(t44)) { Console.WriteLine("No way"); } else { Console.WriteLine("t4 and t44 point to different objects"); } if (t4.Equals(t41)) { Console.WriteLine("t4 and t41 point to the same object"); } Console.WriteLine("Constructed with:\n"); Console.WriteLine("t1: all arguments defaulted"); Console.WriteLine(" {0}", t1.ToUniversalString()); // 00:00:00 Console.WriteLine(" {0}\n", t1.ToString()); // 12:00:00 AM Console.WriteLine( "t2: hour specified; minute and second defaulted"); Console.WriteLine(" {0}", t2.ToUniversalString()); // 02:00:00 Console.WriteLine(" {0}\n", t2.ToString()); // 2:00:00 AM Console.WriteLine( "t3: hour and minute specified; second defaulted"); Console.WriteLine(" {0}", t3.ToUniversalString()); // 21:34:00 Console.WriteLine(" {0}\n", t3.ToString()); // 9:34:00 PM Console.WriteLine("t4: hour, minute and second specified"); Console.WriteLine(" {0}", t4.ToUniversalString()); // 12:25:42 Console.WriteLine(" {0}\n", t4.ToString()); // 12:25:42 PM Console.WriteLine("t5: Time2 object t4 specified"); Console.WriteLine(" {0}", t5.ToUniversalString()); // 12:25:42 Console.WriteLine(" {0}", t5.ToString()); // 12:25:42 PM // attempt to initialize t6 with invalid values try { t6 = new Time2(27, 74, 99); // invalid values } // end try catch (ArgumentOutOfRangeException ex) { Console.WriteLine("\nException while initializing t6:"); Console.WriteLine(ex.Message); } // end catch Console.WriteLine("Push Enter to end the program"); string s = Console.ReadLine(); } // end Main
// Time2 constructor: another Time2 object supplied public Time2( Time2 time ) : this(time.Hour, time.Minute, time.Second) { }