/// <summary> /// フォーマットに基づいて文字列を生成する /// </summary> /// <param name="format"> /// フォーマット /// %h 時 /// %m 分 /// %s 秒 /// %d 日 /// %w 週の文字(例:Mon) /// %S 秒の通算 /// %M 分の通算 /// %H 時の通算 /// %D 日の通算 /// %DI 日の通算(整数部のみ) /// </param> /// <returns></returns> // public string ToString(string format) { format = format.Replace("%h", Hour.ToString("00")); format = format.Replace("%m", Minute.ToString("00")); format = format.Replace("%s", Second.ToString("00")); format = format.Replace("%d", Day.ToString()); var day = Day; if (day < 0) { day = (day % DateTimeEx._dayStrings.Length) + 7; } format = format.Replace("%w", DateTimeEx._dayStrings[day % DateTimeEx._dayStrings.Length]); format = format.Replace("%H", TotalHours.ToString()); format = format.Replace("%S", TotalSeconds.ToString()); format = format.Replace("%M", TotalMinutes.ToString()); format = format.Replace("%DI", ((int)TotalDays).ToString()); // 日を整数化(切り捨て) format = format.Replace("%D", TotalDays.ToString()); return(format); }
/// <summary> /// This method is responsible for displaying the stats inside of the totals /// panel. /// </summary> private void DisplayStats() { BoxHoursLabel.Text = TotalHoursBoxes.ToString("#.##"); DrawerHoursLabel.Text = TotalHoursDrawers.ToString("#.##"); EdgeBandingHoursLabel.Text = TotalHoursEdgeBanding.ToString("#.##"); CuttingHoursLabel.Text = TotalHoursCutting.ToString("#.##"); TotalSheetsLabel.Text = NumSheetsCut.ToString("#.##"); EdgBardedLabel.Text = NumPartsEdgeBarded.ToString("#.##"); TotalDrawersLabel.Text = NumDrawersBuilt.ToString("#.##"); TotalFinishedPartsLabel.Text = NumFinishedParts.ToString("#.##"); TotalHoursLabel.Text = TotalHours.ToString("#.##"); if (Return > 0) { ReturnLabel.ForeColor = Color.LightGreen; } else { ReturnLabel.ForeColor = Color.Red; } ReturnLabel.Text = "$" + Return.ToString("#.##"); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) hashCode = hashCode * 59 + Years.GetHashCode(); hashCode = hashCode * 59 + Months.GetHashCode(); hashCode = hashCode * 59 + Days.GetHashCode(); hashCode = hashCode * 59 + Hours.GetHashCode(); hashCode = hashCode * 59 + Minutes.GetHashCode(); hashCode = hashCode * 59 + Milliseconds.GetHashCode(); hashCode = hashCode * 59 + TotalYears.GetHashCode(); hashCode = hashCode * 59 + TotalMonths.GetHashCode(); hashCode = hashCode * 59 + TotalDays.GetHashCode(); hashCode = hashCode * 59 + TotalHours.GetHashCode(); hashCode = hashCode * 59 + TotalMinutes.GetHashCode(); hashCode = hashCode * 59 + TotalSeconds.GetHashCode(); hashCode = hashCode * 59 + TotalMilliseconds.GetHashCode(); hashCode = hashCode * 59 + Ticks.GetHashCode(); return(hashCode); } }
private void BtnSumbit_Click(object sender, EventArgs e) { //declare variables decimal RegularRate = 15M; decimal OTRate = 22.50M; decimal RegularHours; decimal OTHours; decimal TotalHours; decimal RegularPay; decimal OTPay; decimal grossPay; // validate that there are no errors bool valitdateResults = validatedata(); if (valitdateResults == false) { return; } else { GrpBoxResults.Show(); } //list for day off checkboxs List <CheckBox> cb = new List <CheckBox>(); cb.Add(CbMon); cb.Add(CbTues); cb.Add(CbWed); cb.Add(CbThurs); cb.Add(CbFri); cb.Add(CbSat); cb.Add(CbSun); // Var for total hours. Days of the week added up TotalHours = NumUpDownMonday.Value + NumUpDownTuesday.Value + NumUpDownWednesday.Value + NumUpDownThursday.Value + NumUpDownFriday.Value + NumUpDownSaturday.Value + NumUpDownSunday.Value; // if hours are greater than 40 calculate overtime if (TotalHours > 40) { // math for regular/OT hours and pay OTHours = TotalHours - 40; RegularHours = TotalHours - OTHours; RegularPay = RegularHours * RegularRate; OTPay = OTHours * OTRate; grossPay = RegularPay + OTPay; //Display results TxtRegHours.Text = RegularHours.ToString(""); TxtRegRate.Text = RegularRate.ToString("c"); TxtRegPay.Text = RegularPay.ToString("c"); TxtOTHours.Text = OTHours.ToString(""); TxtOTRate.Text = OTRate.ToString("c"); TxtOTPay.Text = OTPay.ToString(""); TxtTotalHours.Text = TotalHours.ToString(""); TxtGrossPay.Text = grossPay.ToString("c"); } // if totalHours is less than 40 calculate Regular pay without OT else { //Math for pay RegularPay = TotalHours * RegularRate; grossPay = TotalHours * RegularRate; //Display output TxtRegHours.Text = TotalHours.ToString(""); TxtRegRate.Text = RegularRate.ToString("c"); TxtRegPay.Text = RegularPay.ToString("c"); TxtTotalHours.Text = TotalHours.ToString(""); TxtGrossPay.Text = grossPay.ToString("c"); } // loop to check how many checkboxes are checked var checkCbCount = cb.Where(s => s.Checked == true).Count(); //display results TxtOffDays.Text = checkCbCount.ToString(""); }
public override string ToString() { return(TotalHours.ToString().PadLeft(2, '0') + ":" + Minutes.ToString().PadLeft(2, '0') + ":" + Seconds.ToString().PadLeft(2, '0') + "." + Milliseconds.ToString().PadLeft(3, '0')); }
/// <summary> /// Returns true if OutputDateDifference instances are equal /// </summary> /// <param name="other">Instance of OutputDateDifference to be compared</param> /// <returns>Boolean</returns> public bool Equals(OutputDateDifference other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Years == other.Years || Years.Equals(other.Years) ) && ( Months == other.Months || Months.Equals(other.Months) ) && ( Days == other.Days || Days.Equals(other.Days) ) && ( Hours == other.Hours || Hours.Equals(other.Hours) ) && ( Minutes == other.Minutes || Minutes.Equals(other.Minutes) ) && ( Milliseconds == other.Milliseconds || Milliseconds.Equals(other.Milliseconds) ) && ( TotalYears == other.TotalYears || TotalYears.Equals(other.TotalYears) ) && ( TotalMonths == other.TotalMonths || TotalMonths.Equals(other.TotalMonths) ) && ( TotalDays == other.TotalDays || TotalDays.Equals(other.TotalDays) ) && ( TotalHours == other.TotalHours || TotalHours.Equals(other.TotalHours) ) && ( TotalMinutes == other.TotalMinutes || TotalMinutes.Equals(other.TotalMinutes) ) && ( TotalSeconds == other.TotalSeconds || TotalSeconds.Equals(other.TotalSeconds) ) && ( TotalMilliseconds == other.TotalMilliseconds || TotalMilliseconds.Equals(other.TotalMilliseconds) ) && ( Ticks == other.Ticks || Ticks.Equals(other.Ticks) )); }
public override string ToString() { return($"Oid={Oid.ToString()},Date={Date.ToString()}, ClockIn={ClockIn.ToString()}, ClockOut={ClockOut.ToString()} TotalHours={ TotalHours.ToString()}, HourlyRate={HourlyRate.ToString()} | "); }