private void objList_CellEditFinishing(object sender, CellEditEventArgs e) { if (e.ListViewItem.Index == objList.Items.Count - 1 && !string.IsNullOrWhiteSpace(e.NewValue.ToString())) { KeyWordMD obj = (KeyWordMD)objList.AddEmptyRow(); int maxIdInDb = BusinessObject.GetBONextID(BOIDEnum.KeyWord); int maxIdOfUi = objList.Objects.Cast <KeyWordMD>().ToList().Max(x => x.ID); obj.ID = Math.Max(maxIdInDb, maxIdOfUi) + 1; } }
private void LoadGridData() { m_kwBo = (BOKeyWord)BOFactory.GetBO(BOIDEnum.KeyWord); List <KeyWordMD> listObj = Utilities.ConvertList <KeyWordMD>(m_kwBo.GetDataList()); objList.SetObjects(listObj); objList.DataSourceType = typeof(KeyWordMD); KeyWordMD newKw = (KeyWordMD)objList.AddEmptyRow(); newKw.ID = BusinessObject.GetBONextID(BOIDEnum.KeyWord); }
private bool ValidateData() { bool result = true; IList objs = (IList)objList.Objects; IEnumerator iter = objs.GetEnumerator(); while (iter.MoveNext()) { KeyWordMD md = (KeyWordMD)iter.Current; if (!objList.IsEmptyRow(md) && string.IsNullOrWhiteSpace(md.Name)) { GetStatusBar().DisplayMessage(MessageType.Error, "名称不能为空!"); result = false; break; } } return(result); }
private void objList_CellEditValidating(object sender, CellEditEventArgs e) { if (string.IsNullOrWhiteSpace(e.NewValue.ToString())) { if (e.ListViewItem.Index == objList.Items.Count - 1) { return; } if (e.ListViewItem.Index < objList.Items.Count - 1) { GetStatusBar().DisplayMessage(MessageType.Error, "关键字不能为空!"); e.Cancel = true; return; } } KeyWordMD md = objList.Objects.Cast <KeyWordMD>().ToList().Find(x => x.Name == e.NewValue.ToString()); if (md != null && e.ListViewItem.Index != objList.ModelToItem(md).Index) { GetStatusBar().DisplayMessage(MessageType.Warming, "关键字 \"" + e.NewValue.ToString() + "\" 已存在!"); e.Cancel = true; return; } }
private bool btnOk_Clicking(object sender, EventArgs e) { if (this.FormMode == NanCrm.FormMode.Ok) { return(true); } IList obj = (IList)objList.Objects; if (!ValidateData()) { return(false); } if (objList.EmptyObject != null) { KeyWordMD temp = (KeyWordMD)objList.EmptyObject; if (string.IsNullOrWhiteSpace(temp.Name)) { obj.Remove(objList.EmptyObject); } } m_kwBo.SetDataList(obj, objList.RemovedObjects); return(m_kwBo.UpdateBatch()); }