private void btnSave_Click(object sender, EventArgs e) { if(_project == null) { _project = new Project(); _project.Name = txtName.Text; _project.Description = txtDescription.Text; if(ProjectBLL.Current.Insert(_project)) { ShowSuccessMessage("Thêm project thành công!"); this.DialogResult = DialogResult.OK; Close(); } } else { _project.Name = txtName.Text; _project.Description = txtDescription.Text; if (ProjectBLL.Current.Update(_project)) { ShowSuccessMessage("Sửa project thành công!"); this.DialogResult = DialogResult.OK; Close(); } } }
public ProjectAddEditForm(Project project = null) { InitializeComponent(); _project = project; if(_project != null) { txtName.Text = _project.Name; txtDescription.Text = _project.Description; } }
public bool Insert(Project obj) { using (var entityConntext = new GeoViewerEntities()) { SecurityBLL.Current.CheckPermissionThrowException(SecurityBLL.ROLE_DATA_MANAGE); Validate(obj); entityConntext.Projects.AddObject(obj); return entityConntext.SaveChanges() > 0; } }
/// <summary> /// Deprecated Method for adding a new object to the Projects EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToProjects(Project project) { base.AddObject("Projects", project); }
/// <summary> /// Create a new Project object. /// </summary> /// <param name="projectID">Initial value of the ProjectID property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="isDefault">Initial value of the IsDefault property.</param> public static Project CreateProject(global::System.Int32 projectID, global::System.String name, global::System.Boolean isDefault) { Project project = new Project(); project.ProjectID = projectID; project.Name = name; project.IsDefault = isDefault; return project; }
public void Validate(Project obj) { if (!obj.Name.IsValidLength(1, 255)) throw new Exception("Tên project không được bỏ trống và nhỏ hơn 255 ký tự."); }
public bool Update(Project obj) { using (var entityConntext = new GeoViewerEntities()) { SecurityBLL.Current.CheckPermissionThrowException(new string[] { SecurityBLL.ROLE_DATA_EDIT, SecurityBLL.ROLE_DATA_MANAGE }); Validate(obj); entityConntext.AttachUpdatedObject(obj); return entityConntext.SaveChanges() > 0; } }