コード例 #1
0
ファイル: LoyaltyProgram.cs プロジェクト: kimykunjun/test
 public LoyaltyProgram()
 {
     //
     // TODO: Add constructor logic here
     //
     myRewardsTrans = new TblRewardsTransaction();
     myDataTable    = new DataTable();
 }
コード例 #2
0
ファイル: LoyaltyProgram.cs プロジェクト: kimykunjun/test
        public void DeleteRedemption(int nTransactionID, int qtyOfItemToRestoreAfterDelete)
        {
            TblRewardsTransaction rewardTrans = new TblRewardsTransaction();

            rewardTrans.NTransactionID = nTransactionID;
            rewardTrans.SelectOne();

            if (rewardTrans.NTypeID != 2 || (Convert.ToDateTime(rewardTrans.DtDate.Value).Date != DateTime.Now.Date && ACMSLogic.User.RightsLevelID != 9000))
            {
                throw new Exception("You have no right to delete this record. It is not a redemption or the redemption date is before today. ");
            }

            string itemCode = rewardTrans.StrReferenceNo.IsNull ? "" : rewardTrans.StrReferenceNo.Value;

            //TblProductInventory productInvent = new TblProductInventory();
            //productInvent.StrProductCode = itemCode;
            //productInvent.SelectOne();

            //productInvent.NQuantity = ACMS.Convert.ToInt32(productInvent.NQuantity) + qtyOfItemToRestoreAfterDelete;

            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try
            {
                rewardTrans.MainConnectionProvider = connProvider;
                //productInvent.MainConnectionProvider = connProvider;

                connProvider.OpenConnection();
                connProvider.BeginTransaction("DeleteRedemption");
                rewardTrans.Delete();
                //productInvent.Update();

                connProvider.CommitTransaction();
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("DeleteRedemption");
                throw;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                {
                    connProvider.CurrentTransaction.Dispose();
                }

                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                    {
                        connProvider.DBConnection.Close();
                    }
                }
                rewardTrans.MainConnactionIsCreatedLocal = true;
                //productInvent.MainConnactionIsCreatedLocal = true;
            }
        }
コード例 #3
0
ファイル: MemberRecord.cs プロジェクト: kimykunjun/test
        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();
            }
        }
コード例 #4
0
ファイル: LoyaltyProgram.cs プロジェクト: kimykunjun/test
        public void NewRedemption(string strMembershipID, string itemCode, int qtyOfItemCodeToRedempt, ref int strTransNo)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            connProvider.OpenConnection();
            TblRewardsCatalogue catalogue = new TblRewardsCatalogue();

            catalogue.StrItemCode = itemCode;
            catalogue.SelectOne();

            TblRewardsTransaction rewardTrans = new TblRewardsTransaction();

            rewardTrans.MainConnectionProvider = connProvider;
            rewardTrans.StrMembershipID        = strMembershipID;
            rewardTrans.DtDate         = DateTime.Now;
            rewardTrans.NTypeID        = 2;
            rewardTrans.StrReferenceNo = itemCode;
            rewardTrans.NEmployeeID    = User.EmployeeID;
            rewardTrans.StrBranchCode  = User.BranchCode;

            if (!catalogue.DRewardsPoints.IsNull)
            {
                rewardTrans.DRewardsPoints = -catalogue.DRewardsPoints.Value * qtyOfItemCodeToRedempt;
            }

            rewardTrans.Insert();
            strTransNo = rewardTrans.NTransactionID.Value;
            TblPromotionFreebie promoFreebie = new TblPromotionFreebie();

            promoFreebie.StrPromotionCode = itemCode;
            DataTable receiptFreebieTable = promoFreebie.SelectAllWstrPromotionCodeLogic();

            //Code selected is Promotion Freebie Code
            if (receiptFreebieTable.Rows.Count > 0)
            {
                //TblProductInventory proInven = new TblProductInventory();
                //proInven.MainConnectionProvider = connProvider;

                //// deduct stock
                //foreach (DataRow r in receiptFreebieTable.Rows)
                //{
                //    proInven.IncreaseQuantity(r["strItemCode"].ToString(), User.BranchCode, -qtyOfItemCodeToRedempt);
                //}
            }
            else
            {
                //Code selected is Package Code
                TblPackage pkg = new TblPackage();
                pkg.StrPackageCode = itemCode;
                DataTable pkgTable = pkg.SelectOne();
                if (pkgTable.Rows.Count > 0)
                {
                    TblMemberPackage mp = new TblMemberPackage();
                    mp.SelectAll();
                    MemberPackage memberPackage      = new MemberPackage();
                    DataTable     memberPackageTable = memberPackage.New(false, strMembershipID);
                    DataRow       memberPackageRow   = memberPackageTable.Rows[0];

                    memberPackageRow["strMembershipID"] = strMembershipID;
                    memberPackageRow["dtPurchaseDate"]  = DateTime.Now;
                    memberPackageRow["strRemarks"]      = "REWARDS";
                    memberPackageRow["nStatusID"]       = 0;
                    memberPackageRow["strPackageCode"]  = itemCode;
                    memberPackageRow["fFree"]           = 1;

                    mp.SaveData(memberPackageTable);
                }
                else
                {
                    //Code selected is Product Code
                    //TblProductInventory productInvent = new TblProductInventory();
                    //productInvent.MainConnectionProvider = connProvider;
                    //productInvent.StrProductCode = itemCode;
                    //productInvent.SelectOne();

                    //productInvent.NQuantity = ACMS.Convert.ToInt32(productInvent.NQuantity) - qtyOfItemCodeToRedempt;
                    //productInvent.Update();
                }
            }

            if (connProvider.CurrentTransaction != null)
            {
                connProvider.CurrentTransaction.Dispose();
            }

            if (connProvider.DBConnection != null)
            {
                if (connProvider.DBConnection.State == ConnectionState.Open)
                {
                    connProvider.DBConnection.Close();
                }
            }
        }