/// <summary> /// Click event for Add buttom /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { MemoDetail newMemo = new MemoDetail(); newMemo._ID = (new Random(DateTime.Now.Millisecond)).Next(-999, 0).ToString(); newMemo.CreateTimeStamp = System.DateTime.Now; newMemo.EditTimeStamp = System.DateTime.Now; newMemo.ActionCode = ActionCode.New; MemoDetailForm newMemoDetailForm = new MemoDetailForm(newMemo, MemoDetailForm.FormState.NewMemo); if (newMemoDetailForm.ShowDialog(this) == DialogResult.OK) { MemoDetail[] newMemoArray = new MemoDetail[this._BatchDetail.Memos.Length + 1]; Array.Copy( this._BatchDetail.Memos, 0, newMemoArray, 0, this._BatchDetail.Memos.Length); newMemoArray[this._BatchDetail.Memos.Length] = newMemoDetailForm.MemoDetail; this.BatchDetail.Memos = newMemoArray; this.UpdateMemoList(); } }
private void EditMemo() { MemoDetail selectedMemo = (MemoDetail)lstMemos.SelectedItem; MemoDetailForm newMemoDetailForm = new MemoDetailForm(selectedMemo, MemoDetailForm.FormState.EditMemo); newMemoDetailForm.ShowDialog(); }
/// <summary> /// Add Memo /// </summary> private void AddMemo() { MemoDetail newMemo = new MemoDetail(); newMemo._ID = "-" + (new Random(DateTime.Now.Millisecond)).Next(1, 1000).ToString(); newMemo.CreateTimeStamp = System.DateTime.Now; newMemo.EditTimeStamp = newMemo.CreateTimeStamp; newMemo.Type = MemoTypes.Note; newMemo.ActionCode = ActionCode.New; MemoDetailForm newMemoDetailForm = new MemoDetailForm(newMemo, MemoDetailForm.FormState.NewMemo); if (newMemoDetailForm.ShowDialog(this) == DialogResult.OK) { this._DocumentInfo.ActionCode = this._DocumentInfo.ActionCode == ActionCode.New ? ActionCode.New : ActionCode.Edit; this.CurrentMemos.Add(newMemo); this._DocumentInfo.Memos = CurrentMemos.ToArray(); this.UpdateMemosList(); } }
/// <summary> /// Double Click method for ListBox /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lstMemos_DoubleClick(object sender, EventArgs e) { if (this._allowEdit) { if (this.lstMemos.SelectedItem == null) { MemoDetail newMemo = new MemoDetail(); newMemo._ID = (new Random(DateTime.Now.Millisecond)).Next(-999, 0).ToString(); newMemo.CreateTimeStamp = System.DateTime.Now; newMemo.EditTimeStamp = newMemo.CreateTimeStamp; newMemo.Type = MemoTypes.Note; newMemo.ActionCode = ActionCode.New; MemoDetailForm newMemoDetailForm = new MemoDetailForm(newMemo, MemoDetailForm.FormState.NewMemo); if (newMemoDetailForm.ShowDialog(this) == DialogResult.OK) { MemoDetail[] newMemoArray = new MemoDetail[this._BatchDetail.Memos.Length + 1]; Array.Copy(this._BatchDetail.Memos, 0, newMemoArray, 0, this._BatchDetail.Memos.Length); newMemoArray[this._BatchDetail.Memos.Length] = newMemoDetailForm.MemoDetail; this.BatchDetail.Memos = newMemoArray; this.UpdateMemoList(); } } else { MemoDetail selectedMemo = this._BatchDetail.Memos[this.lstMemos.SelectedIndex]; MemoDetailForm newMemoDetailForm = new MemoDetailForm(selectedMemo, MemoDetailForm.FormState.EditMemo); newMemoDetailForm.ShowDialog(this); } } else { if (this.lstMemos.SelectedItem != null) { MemoDetail selectedMemo = this._BatchDetail.Memos[this.lstMemos.SelectedIndex]; MemoDetailForm newMemoDetailForm = new MemoDetailForm(selectedMemo, MemoDetailForm.FormState.ViewMemo); newMemoDetailForm.ShowDialog(this); } } }
/// <summary> /// Open form to view selected memo /// </summary> private void ViewSelectedMemo() { MemoDetail selectedMemo = (MemoDetail)lstMemos.SelectedItem; MemoDetailForm newMemoDetailForm = new MemoDetailForm(selectedMemo, MemoDetailForm.FormState.ViewMemo); newMemoDetailForm.ShowDialog(); }