protected void btnLuuNTC_Click(object sender, EventArgs e) { string tenVN = string.Empty; int ts = 0; int.TryParse(txtTrongSo.Text, out ts); if (!MyUtility.TextBoxHopLe(txtTenNTC, out tenVN)) { lblLoiLuu.Text = "Tên không được bỏ trống!"; return; } else if (ts <= 0) { lblLoiLuu.Text = "Trọng số không hợp lệ!"; return; } else { lblLoiLuu.Text = ""; } NhomTieuChi nhomTC = new NhomTieuChi { MaDV = 1, TenNTC = tenVN, TrongSo = ts, MoTa = txtMoTa.Text }; kho.ThemNhomTieuChi(nhomTC); kho.Luu(); Response.Redirect(@"~/Admin/QLTieuChi.aspx?id="); }
public bool ThemNhomTieuChi(NhomTieuChi ntc) { try { var kq = TimNhomTieuChi(ntc.MaNTC); if (kq != default(NhomTieuChi)) { throw new Exception(); } dc.NhomTieuChis.InsertOnSubmit(ntc); return(true); } catch { return(false); } }
public bool SuaNhomTieuChi(NhomTieuChi ntc) { try { var kq = TimNhomTieuChi(ntc.MaNTC); if (kq == default(NhomTieuChi)) { throw new Exception(); } kq.TenNTC = ntc.TenNTC; kq.TrongSo = ntc.TrongSo; kq.MoTa = ntc.MoTa; kq.TenNTCEN = ntc.TenNTCEN; return(true); } catch { return(false); } }