private void ListProductGetMaster() { if (this.ProductID > 0) { ListProductDTS.ListProductDataTable masterDataTable = this.MasterTableAdapter.GetData(this.ProductID); if (masterDataTable.Count > 0) { this.ListProductMaster.StopTracking(); this.ListProductMaster.EntryDate = masterDataTable[0].EntryDate; this.ListProductMaster.Description = masterDataTable[0].Description; this.ListProductMaster.LogoGenerator = masterDataTable[0].LogoGenerator; this.ListProductMaster.Remarks = masterDataTable[0].Remarks; this.ListProductMaster.StartTracking(); this.ListProductMaster.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.ListProductMaster); this.ListProductMaster.EntryDate = DateTime.Today; this.ListProductMaster.Reset(); } }
private bool SaveMaster(ref int productID) { ListProductDTS.ListProductDataTable masterDataTable; ListProductDTS.ListProductRow masterRow; if (this.listProductMaster.ProductID <= 0) //Add { masterDataTable = new ListProductDTS.ListProductDataTable(); masterRow = masterDataTable.NewListProductRow(); } else //Edit { if (!this.SaveUndo(listProductMaster.ProductID)) { throw new System.ArgumentException("Insufficient save", "Save undo"); } masterDataTable = this.MasterTableAdapter.GetData(listProductMaster.ProductID); if (masterDataTable.Count > 0) { masterRow = masterDataTable[0]; } else { throw new System.ArgumentException("Insufficient save", "Get for edit"); } } masterRow.EntryDate = DateTime.Now; masterRow.Description = this.listProductMaster.Description; masterRow.LogoGenerator = this.listProductMaster.LogoGenerator; masterRow.Remarks = this.listProductMaster.Remarks; masterRow.UserID = this.UserOrganization.UserID; masterRow.UserOrganizationID = this.UserOrganization.UserOrganizationID; masterRow.EntryStatusID = this.listProductMaster.ProductID <= 0 || (int)masterDataTable[0]["EntryStatusID"] == (int)GlobalEnum.EntryStatusID.IsNew ? (int)GlobalEnum.EntryStatusID.IsNew : (int)GlobalEnum.EntryStatusID.IsEdited; if (this.listProductMaster.ProductID <= 0) { masterDataTable.AddListProductRow(masterRow); } int rowsAffected = this.MasterTableAdapter.Update(masterRow); productID = masterRow.ProductID; return(rowsAffected == 1); }