public bool SaveIntroduceFriend(string strMembershipID, string strIntroducerID, double point, int employeeID) { ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider(); TblMember sqlMember = new TblMember(); TblRewardsTransaction sqlRewardsTransaction = new TblRewardsTransaction(); try { sqlRewardsTransaction.MainConnectionProvider = connProvider; sqlMember.MainConnectionProvider = connProvider; connProvider.OpenConnection(); connProvider.BeginTransaction("SaveIntroduceFriend"); sqlMember.UpdateIntroducerMembershipID(strMembershipID, strIntroducerID); sqlRewardsTransaction.DRewardsPoints = point; sqlRewardsTransaction.DtDate = DateTime.Now; sqlRewardsTransaction.NEmployeeID = employeeID; sqlRewardsTransaction.NTypeID = 0; sqlRewardsTransaction.StrMembershipID = strIntroducerID; sqlRewardsTransaction.StrReferenceNo = strMembershipID; sqlRewardsTransaction.Insert(); for (int i = 0; i < 5; i++) { sqlMember.InsertFWFChance(strIntroducerID); } connProvider.CommitTransaction(); return(true); } catch (Exception ex) { connProvider.RollbackTransaction("SaveIntroduceFriend"); if (ex.InnerException.Message.IndexOf("FK_tblMember_tblMember") >= 0 || ex.Message.IndexOf("FK_tblMember_tblMember") >= 0 || ex.InnerException.Message.IndexOf("FK_tblRewardsTransaction_tblMember") >= 0 || ex.Message.IndexOf("FK_tblRewardsTransaction_tblMember") >= 0) { ACMS.Utils.UI.ShowErrorMessage(null, "Please enter a valid Membership ID.", "Error"); return(false); } else { throw; } } finally { if (connProvider.CurrentTransaction != null) { connProvider.CurrentTransaction.Dispose(); } if (connProvider.DBConnection != null) { if (connProvider.DBConnection.State == ConnectionState.Open) { connProvider.DBConnection.Close(); } connProvider.DBConnection.Dispose(); } sqlRewardsTransaction.Dispose(); sqlMember.Dispose(); } }