public ActionResult btnCreate_Click(BasicType model) { if (ModelState.IsValid) { try { if (!string.IsNullOrEmpty(model.Name)) { if (!CheckRepeat(model)) { Alert.Show("已有相同记录存在!", MessageBoxIcon.Warning); } else { var max = (int)(Rep.Max(t => t.Rid) ?? 0); model.Rid = max + 1; Rep.Add(model); // 关闭本窗体(触发窗体的关闭事件) PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } } else { Alert.Show("名称不能为空!", MessageBoxIcon.Warning); } } catch (Exception ex) { Alert.Show(ex.Message, MessageBoxIcon.Warning); } } return(UIHelper.Result()); }
public ActionResult AddOrEdit(PhysicalDevice model) { if (!ModelState.IsValid) { return(UIHelper.Result()); } try { if (model.Rid == 0) { if (!CheckRepeat(model)) { Alert.Show("已有相同记录存在!", MessageBoxIcon.Warning); } else { Rep.Add(model); // 关闭本窗体(触发窗体的关闭事件) PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } } else { Rep.Update(t => t.Rid == model.Rid, Builders <PhysicalDevice> .Update.Set(t => t.MachineName, model.MachineName) .Set(t => t.ModelNum, model.ModelNum) .Set(t => t.DeviceType, model.DeviceType) .Set(t => t.Owner, model.Owner) .Set(t => t.PublicIP, model.PublicIP) .Set(t => t.IntranetIP, model.IntranetIP) .Set(t => t.ManagementIP, model.ManagementIP) .Set(t => t.DomainIP, model.DomainIP) .Set(t => t.Cpu, model.Cpu) .Set(t => t.Memory, model.Memory) .Set(t => t.Storage, model.Storage) .Set(t => t.Locale, model.Locale) .Set(t => t.Date, model.Date) .Set(t => t.PurchaseDate, model.PurchaseDate) .Set(t => t.WarrantyExpiry, model.WarrantyExpiry) .Set(t => t.NetTpParam, model.NetTpParam) .Set(t => t.Remark, model.Remark)); // 关闭本窗体(触发窗体的关闭事件) PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } } catch (Exception ex) { Alert.Show(ex.Message, MessageBoxIcon.Warning); } return(UIHelper.Result()); }
public ActionResult AddOrEdit(ServiceList model) { if (!ModelState.IsValid) { return(UIHelper.Result()); } try { if (model._id == 0) { if (!CheckRepeat(model)) { Alert.Show("已有相同记录存在!", MessageBoxIcon.Warning); } else { model._id = (int)(Rep.Max(t => t._id) ?? 0) + 1; model.PrimaryId = (int)(Rep.Max(t => t.PrimaryId) ?? 0) + 1; model.SecondaryId = (int)(Rep.Max(t => t.SecondaryId) ?? 0) + 1; SetRegContent(model); Rep.Add(model); // 关闭本窗体(触发窗体的关闭事件) PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } } else { SetRegContent(model); Rep.Update(t => t._id == Convert.ToInt32(model._id), Builders <ServiceList> .Update.Set(t => t.ServiceName, model.ServiceName) .Set(t => t.SecondaryName, model.SecondaryName) .Set(t => t.Host, model.Host) .Set(t => t.Version, model.Version) .Set(t => t.Remark, model.Remark)); // 关闭本窗体(触发窗体的关闭事件) PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } } catch (Exception ex) { Alert.Show(ex.Message, MessageBoxIcon.Warning); } return(UIHelper.Result()); }
public ActionResult AddOrEdit(AppContacts model, bool isAdd = false) { if (!ModelState.IsValid) { return(UIHelper.Result()); } try { if (isAdd) { if (!CheckRepeat(model)) { Alert.Show("已有相同记录存在!", MessageBoxIcon.Warning); } else { Rep.Add(model); // 关闭本窗体(触发窗体的关闭事件) PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } } else { Rep.Update(t => t._id == model._id, Builders <AppContacts> .Update.Set(t => t.Tel, model.Tel) .Set(t => t.Email, model.Email) .Set(t => t.WeiXin_UID, model.WeiXin_UID) .Set(t => t.DingTalk_UID, model.DingTalk_UID) .Set(t => t.AlarmType, model.AlarmType) .Set(t => t.Remark, model.Remark)); // 关闭本窗体(触发窗体的关闭事件) PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } } catch (Exception ex) { Alert.Show(ex.Message, MessageBoxIcon.Warning); } return(UIHelper.Result()); }