private void ListEmployeeGetDetail() { this.listEmployeeDetailList.RaiseListChangedEvents = false; this.listEmployeeDetailList.Clear(); if (this.EmployeeID >= 0) { ListEmployeeDTS.ListEmployeeDetailDataTable detailDataTable = this.DetailTableAdapter.GetData(this.EmployeeID); if (detailDataTable.Count > 0) { foreach (ListEmployeeDTS.ListEmployeeDetailRow detailRow in detailDataTable.Rows) { this.listEmployeeDetailList.Add(new ListEmployeeDetail(detailRow.CommonID, detailRow.CommonValue, detailRow.Remarks)); } } } this.listEmployeeDetailList.RaiseListChangedEvents = true; this.listEmployeeDetailList.ResetBindings(); }
private bool SaveDetail(int employeeID) { int serialID = 0; int rowsAffected = 0; #region <Save collection> serialID = 0; ListEmployeeDTS.ListEmployeeDetailDataTable detailDataTable = new ListEmployeeDTS.ListEmployeeDetailDataTable(); foreach (ListEmployeeDetail listEmployeeDetail in this.ListEmployeeDetailList) { ListEmployeeDTS.ListEmployeeDetailRow detailRow = detailDataTable.NewListEmployeeDetailRow(); detailRow.EmployeeID = employeeID; detailRow.SerialID = ++serialID; detailRow.CommonID = listEmployeeDetail.CommonID; detailRow.CommonValue = listEmployeeDetail.CommonValue; detailRow.Remarks = listEmployeeDetail.Remarks; detailDataTable.AddListEmployeeDetailRow(detailRow); } rowsAffected = this.DetailTableAdapter.Update(detailDataTable); if (rowsAffected != this.listEmployeeDetailList.Count) { throw new System.ArgumentException("Insufficient save", "Save detail"); } #endregion <Save collection> return(true); }