private void barButtonItem_SaveType_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { TreeListNode selTreeLNode = TreeList_Event.FocusedNode; g_eventType.EVENTTYPE_CODE = this.textEdit_Code.EditValue.ToString(); g_eventType.EVENTTYPE_NAME = this.textEdit_Name.EditValue.ToString(); if (this.DBOperType == "I") { g_eventType.EVENTTYPE_CREATETIME = System.DateTime.Now.ToString(); g_eventType.EVENTTYPE_LASTMODIFIEDTIME = System.DateTime.Now.ToString(); g_eventType.EVENTTYPE_MODIFICATIONTIMES = "1"; if (this.memoEdit_Note.EditValue == null) { MessageBox.Show("请写NOTE"); return; } g_eventType.EVENTTYPE_NOTE = this.memoEdit_Note.EditValue.ToString(); //新增直接插入 this.eventTypeList.Add(g_eventType); } else if (this.DBOperType == "U") { //update的时候,不需要!!!将类型下的属性全部赋值一遍,因为只需要update修改的这些 g_eventType.EVENTTYPE_ID = selTreeLNode.GetValue("EVENTTYPE_ID").ToString(); g_eventType.EVENTTYPE_LASTMODIFIEDTIME = System.DateTime.Now.ToString(); g_eventType.EVENTTYPE_MODIFICATIONTIMES = Convert.ToString(Convert.ToInt32(this.textEdit_ModificationTimes.EditValue) + 1); if (this.memoEdit_Note.EditValue == null) { MessageBox.Show("请写NOTE"); return; } g_eventType.EVENTTYPE_NOTE = this.memoEdit_Note.EditValue.ToString(); //编辑类型的时候,应该先删除再添加 foreach (MyEventType item in eventTypeList) { if (item.EVENTTYPE_ID == g_eventType.EVENTTYPE_ID) { eventTypeList.Remove(item); break; } } this.eventTypeList.Add(g_eventType); } //这个地方是不是需要添加判断?如果是类型那么就保存如果不是那就提示? eventClient.SaveEventType(this.DBOperType, g_eventType); //修改显示 this.BindTree(TreeList_Event, eventTypeList); ChangeCardState(false); }