private void btnSave_Click(object sender, EventArgs e) { if (DateTimeParse()) { if (!Compare()) { //刪掉原有資料 UDTTransfer.UDTEnrolmntExcessInputDateDelete(_EnrolmentExcessInputDateList); List <UDT_EnrolmentExcessInputDate> list = new List <UDT_EnrolmentExcessInputDate>(); UDT_EnrolmentExcessInputDate each = new UDT_EnrolmentExcessInputDate(); each.StartDate = DateTime.Parse(tbStartDateTime.Text); each.EndDate = DateTime.Parse(tbEndDateTime.Text); list.Add(each); // 新增資料 UDTTransfer.UDTEnrolmentExcessInputDateInsert(list); MsgBox.Show("儲存成功!!"); this.Close(); } else { MsgBox.Show("[結束時間]不可小於[開始時間]!!"); return; } } else { MsgBox.Show("請輸入正確資料\n再進行儲存動作!!"); return; } }
private void FillTimes() { _EnrolmentExcessInputDateList = UDTTransfer.UDTEnrolmentExcessInputDateSelect(); if (_EnrolmentExcessInputDateList.Count >= 1) { UDT_EnrolmentExcessInputDate each = _EnrolmentExcessInputDateList[0]; string startTime = each.StartDate.HasValue ? each.StartDate.Value.ToString(DateTimeFormat) : ""; string endTime = each.EndDate.HasValue ? each.EndDate.Value.ToString(DateTimeFormat) : ""; tbStartDateTime.Text = startTime; tbEndDateTime.Text = endTime; } }