public bool AddShortitems(ShortItem sitem) { //if (FindShortitem(sitem)) if (SelectShortitems(sitem.StartDateTime, sitem.Itemall) == null) { shortitems.Add(sitem); return true; } return false; }
private void UpdateList(UpdateForm updateForm, string type) { int subjectcount = Encoding.GetEncoding("Shift_JIS").GetByteCount(updateForm.subjectTextBox.Text); if (subjectcount > 20) { MessageBox.Show("件名を短くしてください", "予定登録エラー"); return; } string subject = updateForm.subjectTextBox.Text + new String(' ', 20 - subjectcount); if (type == "short") { ShortItem shortitem = new ShortItem(updateForm.startdateTextBox.Text, updateForm.starttimeDomainUpDown.Text, updateForm.endtimeDomainUpDown.Text, subject, updateForm.contentTextBox.Text); if (listitem.AddShortitems(shortitem)) { //listitem.DeleteShortitems(scheduleListBox.SelectedIndex); listitem.DeleteShortitems(startdate, scheduleListBox.SelectedItem.ToString()); scheduleListBox.Items.Clear(); //foreach (ShortItem shorts in listitem.Shortitems) foreach (ShortItem shorts in listitem.GetCurrentShortitems(startdate)) { scheduleListBox.Items.Add(shorts.Itemall); } } else { MessageBox.Show("既に存在する予定です", "その日の予定エラー"); } } else { LongItem longitem = new LongItem(updateForm.startdateTextBox.Text, updateForm.enddateTextBox.Text, subject, updateForm.contentTextBox.Text); if (listitem.AddLongitems(longitem)) { //listitem.DeleteLongitems(scheduleListBox.SelectedIndex); listitem.DeleteLongitems(scheduleListBox.SelectedItem.ToString()); scheduleListBox.Items.Clear(); //foreach (LongItem longs in listitem.Longitems) foreach (LongItem longs in listitem.GetCurrentLongitems(startdate)) { scheduleListBox.Items.Add(longs.Itemall); } } else { MessageBox.Show("既に存在する予定です", "長期の予定エラー"); } } }
private void inputButton_Click(object sender, EventArgs e) { //string record; if (subjectTextBox.Text != "" && contentTextBox.Text != "") { int subjectcount = Encoding.GetEncoding("Shift_JIS"). GetByteCount(subjectTextBox.Text); if (subjectcount > 20) { MessageBox.Show("件名を短くしてください。", "予定登録エラー"); return; } string subject = subjectTextBox.Text + new String(' ', 20 - subjectcount); string contents = TrimNewLine(contentTextBox.Text); // その日の予定 if (startTextBox.Text == endTextBox.Text) { label5.Text = "時間 件名 内容"; /* record = starttimeDomainUpDown.Text + "~" + endtimeDomainUpDown.Text + " " + subject + ":" + contentTextBox.Text; scheduleListBox.Items.Add(record); ClearSubject(); */ ShortItem shortitem = new ShortItem( startTextBox.Text, starttimeDomainUpDown.Text, endtimeDomainUpDown.Text, subject, contents ); if (listitem.AddShortitems(shortitem)) { scheduleListBox.Items.Clear(); //foreach (ShortItem shorts in listitem.Shortitems) foreach(ShortItem shorts in listitem.GetCurrentShortitems(startdate)) { scheduleListBox.Items.Add(shorts.Itemall); } } else { MessageBox.Show("既に存在する予定です。","その日の予定エラー"); } } // 長期の予定 else { label5.Text = "期間 件名 内容"; /* record = startTextBox.Text.Substring(5) + "~" + endTextBox.Text.Substring(5) + " " + subject + ":" + contentTextBox.Text; scheduleListBox.Items.Add(record); ClearSubject(); */ LongItem longitem = new LongItem( startTextBox.Text, endTextBox.Text, subject, contents ); if (listitem.AddLongitems(longitem)) { scheduleListBox.Items.Clear(); //foreach (LongItem longs in listitem.Longitems) foreach (LongItem longs in listitem.GetCurrentLongitems(startdate)) { scheduleListBox.Items.Add(longs.Itemall); } } else { MessageBox.Show("既に存在する予定です。","長期の予定エラー"); } } ClearSubject(); } else { MessageBox.Show("件名と内容を入力してください。","予定登録エラー"); } }