private void ListCoilGetMaster() { if (this.CoilID > 0) { ListCoilDTS.ListCoilDataTable masterDataTable = this.MasterTableAdapter.GetData(this.CoilID); if (masterDataTable.Count > 0) { this.ListCoilMaster.StopTracking(); this.ListCoilMaster.EntryDate = masterDataTable[0].EntryDate; this.ListCoilMaster.Description = masterDataTable[0].Description; this.ListCoilMaster.Remarks = masterDataTable[0].Remarks; this.ListCoilMaster.StartTracking(); this.ListCoilMaster.Reset(); this.UserOrganization.UserID = masterDataTable[0].UserID; this.UserOrganization.UserOrganizationID = masterDataTable[0].UserOrganizationID; } else { throw new System.ArgumentException("Insufficient get data"); } } else { GlobalDefaultValue.Apply(this.ListCoilMaster); this.ListCoilMaster.EntryDate = DateTime.Today; this.ListCoilMaster.Reset(); } }
private bool SaveMaster(ref int coilID) { ListCoilDTS.ListCoilDataTable masterDataTable; ListCoilDTS.ListCoilRow masterRow; if (this.listCoilMaster.CoilID <= 0) //Add { masterDataTable = new ListCoilDTS.ListCoilDataTable(); masterRow = masterDataTable.NewListCoilRow(); } else //Edit { if (!this.SaveUndo(listCoilMaster.CoilID)) { throw new System.ArgumentException("Insufficient save", "Save undo"); } masterDataTable = this.MasterTableAdapter.GetData(listCoilMaster.CoilID); if (masterDataTable.Count > 0) { masterRow = masterDataTable[0]; } else { throw new System.ArgumentException("Insufficient save", "Get for edit"); } } masterRow.EntryDate = DateTime.Now; masterRow.Description = this.listCoilMaster.Description; masterRow.Remarks = this.listCoilMaster.Remarks; masterRow.UserID = this.UserOrganization.UserID; masterRow.UserOrganizationID = this.UserOrganization.UserOrganizationID; masterRow.EntryStatusID = this.listCoilMaster.CoilID <= 0 || (int)masterDataTable[0]["EntryStatusID"] == (int)GlobalEnum.EntryStatusID.IsNew ? (int)GlobalEnum.EntryStatusID.IsNew : (int)GlobalEnum.EntryStatusID.IsEdited; if (this.listCoilMaster.CoilID <= 0) { masterDataTable.AddListCoilRow(masterRow); } int rowsAffected = this.MasterTableAdapter.Update(masterRow); coilID = masterRow.CoilID; return(rowsAffected == 1); }