private VnsDmNhomDonVi GetObjectFromControl() { VnsDmNhomDonVi _tmp = new VnsDmNhomDonVi(); _tmp.Ma = txtMaLoaiDoanRa.Text; _tmp.TenNhom = txtTenLoaiDoanRa.Text; _tmp.MoTa = txtMoTa.Text; return(_tmp); }
private void gvDanhMuc_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { if (gvDanhMuc.FocusedRowHandle < 0) { return; } SelectObject = (VnsDmNhomDonVi)gvDanhMuc.GetRow(gvDanhMuc.FocusedRowHandle); if (SelectObject == null) { return; } FormStatus = FormUpdate.Update; SetObjectToControl(SelectObject); }
private void SaveData() { VnsDmNhomDonVi tmp = new VnsDmNhomDonVi(); tmp = GetObjectFromControl(); switch (FormStatus) { case FormUpdate.Insert: VnsDmNhomDonViService.Save(tmp); break; case FormUpdate.Update: tmp.Id = SelectObject.Id; VnsDmNhomDonViService.SaveOrUpdate(tmp); break; } ReloadData(FormStatus, tmp); }
private void ReloadData(FormUpdate status, VnsDmNhomDonVi tmp) { switch (status) { case FormUpdate.Insert: lstDanhMuc.Add(tmp); break; case FormUpdate.Update: SelectObject = tmp; break; case FormUpdate.Delete: lstDanhMuc.Remove(SelectObject); break; } grdDanhMuc.DataSource = lstDanhMuc; grdDanhMuc.RefreshDataSource(); }
private void SetObjectToControl(VnsDmNhomDonVi obj) { this.txtTenLoaiDoanRa.EditValue = obj.TenNhom; this.txtMaLoaiDoanRa.EditValue = obj.Ma; txtMoTa.EditValue = obj.MoTa; }