public void Delete(int id) { DAL.QuyTacLamThemGio qt = dataContext.QuyTacLamThemGios.Where(t => t.ID == id).FirstOrDefault(); if (qt != null) { dataContext.QuyTacLamThemGios.DeleteOnSubmit(qt); Save(); } }
public int Insert(DAL.QuyTacLamThemGio qt) { if (qt != null) { dataContext.QuyTacLamThemGios.InsertOnSubmit(qt); Save(); return(qt.ID); } return(-1); }
protected void btnCapNhatQuyTac_Click(object sender, DirectEventArgs e) { try { DAL.QuyTacLamThemGio quyTac = new DAL.QuyTacLamThemGio(); if (e.ExtraParams["Command"] == "Edit") { quyTac = new QuyTacLamThemGioController().GetByID(int.Parse("0" + hdfIDQuyTac.Text)); } quyTac.TuGio = GetTime(tfTuGio.Text); quyTac.DenGio = GetTime(tfDenGio.Text); if (cbxLoaiNgay.SelectedItem.Value != null) { quyTac.LoaiNgay = cbxLoaiNgay.SelectedItem.Value; } if (txtHeSoLuong.Text != "") { quyTac.NhanHeSo = decimal.Parse("0" + txtHeSoLuong.Text.Replace('.', ',')); } //if (hdfQuyTacFrMaCa.Text != "") // quyTac.FrMaCa = int.Parse(hdfQuyTacFrMaCa.Text); //else // quyTac.FrMaCa = int.Parse(cbxQuyTacChonCaLamViec.SelectedItem.Value); quyTac.MaCa = e.ExtraParams["MaCa"].ToString(); quyTac.CreatedBy = CurrentUser.ID; quyTac.CreatedDate = DateTime.Now; quyTac.Order = int.Parse("0" + txtOrder.Text); if (e.ExtraParams["Command"] == "Edit") { new QuyTacLamThemGioController().Update(quyTac); Dialog.ShowNotification("Cập nhật dữ liệu thành công"); ResourceManager1.RegisterClientScriptBlock("rlst1", "#{wdQuyTacLamThemGio}.hide(); #{grp_QuyTacLamThemGio}.reload();"); } else { new QuyTacLamThemGioController().Insert(quyTac); Dialog.ShowNotification("Thêm mới dữ liệu thành công"); ResourceManager1.RegisterClientScriptBlock("rlst2", "#{grp_QuyTacLamThemGio}.reload();"); } if (e.ExtraParams["Closed"] == "True") { wdQuyTacLamThemGio.Hide(); } else { ResourceManager1.RegisterClientScriptBlock("rlst4", "ResetQuyTacLamThemGio();"); } } catch (Exception ex) { X.Msg.Alert("Thông báo", "Có lỗi xảy ra: " + ex.Message).Show(); } }
public void Update(DAL.QuyTacLamThemGio qt) { DAL.QuyTacLamThemGio tmp = dataContext.QuyTacLamThemGios.Single(t => t.ID == qt.ID); if (tmp != null) { tmp.ID = qt.ID; tmp.MaCa = qt.MaCa; tmp.TuGio = qt.TuGio; tmp.DenGio = qt.DenGio; tmp.LoaiNgay = qt.LoaiNgay; tmp.CreatedDate = qt.CreatedDate; tmp.CreatedBy = qt.CreatedBy; tmp.NhanHeSo = qt.NhanHeSo; tmp.Order = qt.Order; Save(); } }