private void cmdDone_Click(object sender, EventArgs e) { uint?vid; //volunteerid try { vid = Program.vc.getVolunteerIDFromName(cboName.Text); }//get the volunteer id catch (DatabaseNotOpenException) { Program.forceQuit(); return; }//Return is required for compiler myTime //set time objects timeIn = new myTime((byte)nudInHour.Value, (byte)nudInMin.Value, lblInTP.Text == "AM"), timeOut = new myTime((byte)nudOutHour.Value, (byte)nudOutMin.Value, lblOutTP.Text == "AM"); if (vid != null && Program.current_taskid != null && Program.manual_path == true) //check validity { int tic = timeIn.compare(timeOut); //timeincompare if (tic == 0 || tic == 2) //Equal or less than { try { if (!Program.vc.insertLog(vid.Value, Program.current_taskid.Value, dtpDate.Value, timeIn, timeOut, txtComment.Text)) //insert log and warn if it doesn't work { MessageBox.Show("The transaction was not completed", "Warning"); } } catch (DatabaseNotOpenException) { Program.forceQuit(); } cmdCancel_Click(null, null);//clear cache and exit } else { MessageBox.Show("You left before you arrived?"); } } }
/// <summary> /// Compare this to another myTime /// </summary> /// <param name="compareto">The myTime object to compare to</param> /// <returns>0 if times are equal, 1 if this is > than compareto, or 2 if this is < than compareto</returns> public byte compare(myTime compareto) {// 0 is == 1 is > 2 is < if (this.hour > compareto.hour) { return(1); } else if (this.hour < compareto.hour) { return(2); } else if (this.hour == compareto.hour) { if (this.minute == compareto.minute) { return(0); } else if (this.minute > compareto.minute) { return(1); } else { return(2); } } else { return(0); } }
/*###*/ /*Built-In Functions*/ void Start() { timer = GameObject.Find("Timer").GetComponent <Timer>(); myTime = GameObject.Find("System/Time").GetComponent <myTime>(); prefForce = (GameObject)Resources.Load("Prefs/Force", typeof(GameObject)); phizMaterial = new PhysicsMaterial2D("DefMat"); phizMaterial.friction = 0; phizMaterial.bounciness = 0; rb.gravityScale = 0; PhizMaterial = phizMaterial; }
/// <summary> /// Insert a manual VolunteerLog entry, linking the task and volunteer /// </summary> /// <param name="VolunteerID">The VolunteerID</param> /// <param name="TaskID">The TaskID of the referenced task, one task may belong to many logs</param> /// <param name="Date">The date of the log</param> /// <param name="TimeIn">The time in of the log</param> /// <param name="TimeOut">The time out of the log</param> /// <param name="Comment">An optional comment, filtered for xss/sql injection</param> /// <returns>Success of the transaction</returns> public Boolean insertLog(uint VolunteerID,uint TaskID,DateTime Date,myTime TimeIn,myTime TimeOut,string Comment){ if (Comment.Length > TEXT_FIELD_MAX) throw new TextTooLargeException(String.Format("The Comment is too large({0}) max {1}!", Comment.Length, TEXT_FIELD_MAX)); try { return new MySQLCommand( String.Format("INSERT INTO VolunteerLog(LogID,VolunteerID,TaskID,Date,TimeIn,TimeOut,Comment) VALUES({0},{1},{2},'{3}','{4}','{5}','{6}');", getNewKey("VolunteerLog", "LogID"), VolunteerID, TaskID, MySQLSafeDate(Date), TimeIn.toString(), TimeOut.toString(), filterEscape(Comment)), vlcon) .ExecuteNonQuery() == 1; } catch (MySQLException) { throw new DatabaseNotOpenException(); } }
void awake() { instance = this; }
// Start is called before the first frame update void Start() { test = myTime.getInstance(); }