private HandlingResult ValidateBeforeSave() { HandlingResult result = new HandlingResult(); result.Successed = true; DataDicDetailModel model = new DataDicDetailModel(); model.Code = textBoxSubName.Text.TrimStart().TrimEnd(); if (comboBoxMainType.SelectedValue != null) { DataRow dr = ((System.Data.DataRowView)comboBoxMainType.SelectedValue).Row; model.Source = Guid.Parse(dr["ID"].ToString()); } if (String.IsNullOrEmpty(model.Code)) { result.Message = "请录入名称"; result.Successed = false; } if (model.Source == null || model.Source == Guid.Empty) { result.Message = "请选择类别"; result.Successed = false; } model.Id = Guid.NewGuid(); result.Result = model; return(result); }
public HandlingResult Add(DataDicDetailModel model) { HandlingResult result = new HandlingResult(); result.Successed = false; if (model != null) { String sql = String.Format( "INSERT INTO BPSYS_DATADICDETAIL(ID, CODE, SOURCE, CREATOR, CREATORID, CREATEDTIME) VALUES ('{0}', '{1}','{2}' , '{3}','{4}','{5}')", model.Id, model.Code, model.Source, UserInformationContext.LoginName, UserInformationContext.ID, DateTime.Now.ToString(ConfigImformationContext.TIME_FORMAT_FULL)); using (DataBaseProcess process = new DataBaseProcess()) { result.MsgNumber = process.Exec(sql); } } result.Successed = result.MsgNumber > 0; result.Message = result.Successed ? "新增成功" : "新增失败"; return(result); }
private void Add() { HandlingResult result = ValidateBeforeSave(); if (result.Successed) { DataDicDetailModel model = (DataDicDetailModel)result.Result; result = _action.Add(model); if (result.Successed) { MessageHelper.ShowErrorNotify(this, result.Message); } else { MessageHelper.ShowErrorNotify(this, result.Message); } } else { MessageHelper.ShowErrorNotify(this, result.Message); } }