private void btnOK_Click(object sender, EventArgs e) { HR_JobPositionController _controller = new HR_JobPositionController(); if (txtJobId.Text.Equals(string.Empty)) { HR_JobPosition _item = new HR_JobPosition(); _item.Name = txtJobName.Text; _item.JobDescription = txtDescription.Text; _item.DepartmentId = Convert.ToInt32(cboDept2.SelectedValue); _item.Created = DateTime.Now; _controller.Add(_item); } else { HR_JobPosition _item = _controller.GetById(Convert.ToInt32(txtJobId.Text)); _item.Name = txtJobName.Text; _item.JobDescription = txtDescription.Text; _item.DepartmentId = Convert.ToInt32(cboDept2.SelectedValue); _controller.Edit(_item); } BindingJobs(-1, string.Empty); tabControl1.SelectedIndex = 0; }
private void BindingJobs(int deptId, string searchKey) { try { HR_JobPositionController _controller = new HR_JobPositionController(); List <HR_JobPosition> _list = _controller.GetJobPositions(deptId, -1, searchKey); if (_list == null) { _list = new List <HR_JobPosition>(); } dgvJobs.DataSource = _list; } catch (Exception ex) { SingletonLogger.Instance.Error(this.Name, ex); } }
public static void BindingJob2Combo(ComboBox cbo) { try { HR_JobPositionController _controller = new HR_JobPositionController(); List <HR_JobPosition> _list = _controller.GetJobPositions(-1, -1, string.Empty); HR_JobPosition _item = new HR_JobPosition(); _item.Id = -1; _item.Name = "-- Chọn vị trí --"; _list.Insert(0, _item); cbo.DataSource = _list; cbo.DisplayMember = "Name"; cbo.ValueMember = "Id"; } catch (Exception ex) { SingletonLogger.Instance.Error("BindingCntrol.BindingJob2Combo", ex); } }