partial void OnValidate(System.Data.Linq.ChangeAction action) { if (action == System.Data.Linq.ChangeAction.Insert || action == System.Data.Linq.ChangeAction.Update) { if (string.IsNullOrEmpty(this.Name) || string.IsNullOrEmpty(this.Name.Trim())) { throw new Exception("Nhập danh mục"); } RedBloodDataContext db = new RedBloodDataContext(); int count = (from cats in db.SideEffects where cats.ID != this.ID && object.Equals(cats.ParentID, this.ParentID) && cats.Name.Trim() == this.Name.Trim() select cats).Count(); if (count > 0) { throw new Exception("Trùng tên"); } SideEffectBLL.SetFullname(this); } }
protected void btnLevel1New_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtLevel1.Text.Trim())) { return; } string r = SideEffectBLL.Insert(txtLevel1.Text.Trim(), 1, null); ActionStatus.Text = r; txtLevel1.Text = ""; GridView1.DataBind(); }
public void SetSideEffect(string value) { value = value.Trim(); if (String.IsNullOrEmpty(value)) { SideEffectID1 = null; SideEffectID2 = null; SideEffectID3 = null; } else { SideEffect g = SideEffectBLL.GetByFullname(value); if (g == null) { throw new Exception("Nhập sai triệu chứng."); } else { SideEffectID1 = null; SideEffectID2 = null; SideEffectID3 = null; if (g.Level == 1) { SideEffectID1 = g.ID; } if (g.Level == 2) { SideEffectID2 = g.ID; SideEffectID1 = g.ParentSideEffect.ID; } if (g.Level == 3) { SideEffectID3 = g.ID; SideEffectID2 = g.ParentSideEffect.ID; SideEffectID1 = g.ParentSideEffect.ParentSideEffect.ID; } } } }
protected void btnLevel3New_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtLevel3.Text.Trim())) { return; } if (GridView2.SelectedValue == null) { return; } string r = SideEffectBLL.Insert(txtLevel3.Text.Trim(), 3, (Guid)GridView2.SelectedValue); ActionStatus.Text = r; txtLevel3.Text = ""; GridView3.DataBind(); }