Example #1
0
        public void CheckPackageWhenSave(string packageWantToUpgrade, int oldPackageID)
        {
            // 1) Check Package to upgrade to have the class/service that no allow in current branch
            // Check tblPackageClass or tblPackageService

            // from here, we can get a list of strClassCode that already been used by member
            DataTable attendedClassCodetable = GetAttendedClassCode(oldPackageID);

            // from here, we can get a list of strClassCode that already been used by member
            DataTable attendedServiceCodetable = GetAttendedServiceCode(oldPackageID);

            if (attendedClassCodetable == null) attendedClassCodetable = new DataTable();
            if (attendedServiceCodetable == null) attendedServiceCodetable = new DataTable();

            if (attendedClassCodetable.Rows.Count > 0 ||
                attendedServiceCodetable.Rows.Count > 0)
            {
                TblPackageClass pkgClass = new TblPackageClass();

                string strClassCode = "";

                foreach (DataRow r in attendedClassCodetable.Rows)
                {
                    strClassCode= r["strClassCode"].ToString();
                    pkgClass.StrClassCode= strClassCode;
                    DataTable tempTable = pkgClass.SelectAllWstrClassCodeLogic();

                    //if this tempTable no have packageWantToUpgrade, then means cannot update..
                    DataRow[] rowList = tempTable.Select("strPackageCode = '"+packageWantToUpgrade+"'");

                    if (rowList.Length == 0)
                    {
                        throw new Exception(string.Format("Class Code <{0}> that been attended before is not allow in Package {1}, purchase of single session is required. ", strClassCode, packageWantToUpgrade));
                    }
                }

                TblPackageService pkgSvr = new TblPackageService();

                string strServiceCode = "";

                foreach (DataRow r in attendedServiceCodetable.Rows)
                {
                    strServiceCode = r["strServiceCode"].ToString();
                    pkgSvr.StrServiceCode = strServiceCode;
                    DataTable tempTable = pkgSvr.SelectAllWstrServiceCodeLogic();

                    //if this tempTable no have packageWantToUpgrade, then means cannot update..
                    DataRow[] rowList = tempTable.Select("strPackageCode = '"+packageWantToUpgrade+"'");
                    if (rowList.Length == 0)
                    {
                        //throw new Exception(string.Format(" Service Code <{0}> that been used before is not allow in Package {1}, purchase of single session is required. ", strServiceCode, packageWantToUpgrade));
                    }
                }
            }

            // 2) Check whether old package is been used.
            //  2a) If been used, check whether the used Class/Service
            //		(* read comment below on how to get what class/service been use) is include in that
            //		upgraded package allow list (check tblPackageClass/tblPackageService)

            //		2ai) If any of used class/service is no include,
            //			 prompt msg that purchase of single session required
            //      2aii) If one of the used class/service is included but
            //            the others no used class/service no included, then can upgrade.
            //		2aiii) If all of the used class/service include, then can upgrade..
            //  2b) if no been used, then can upgrade.

            // * How to get attended class/used service
        }
Example #2
0
        public bool CheckPackage(string packageWantToUpgrade, int nCategoryID_of_PackageWantToUpgrade)
        {
            // 1) Check Package to upgrade to have the class/service that no allow in current branch
            // Check tblPackageClass or tblPackageService

            // from here, we can get a list of strClassCode that already been used by member
            DataTable attendedClassCodetable = GetAttendedClassCode(ACMS.Convert.ToInt32(myWantToUpgradeMemberPackageTable.Rows[0]["nPackageID"]));

            // from here, we can get a list of strClassCode that already been used by member
            DataTable attendedServiceCodetable = GetAttendedServiceCode(ACMS.Convert.ToInt32(myWantToUpgradeMemberPackageTable.Rows[0]["nPackageID"]));

            if (attendedClassCodetable == null) attendedClassCodetable = new DataTable();
            if (attendedServiceCodetable == null) attendedServiceCodetable = new DataTable();

            if (attendedClassCodetable.Rows.Count > 0 ||
                attendedServiceCodetable.Rows.Count > 0)
            {
                if (nCategoryID_of_PackageWantToUpgrade == 1 ||
                    nCategoryID_of_PackageWantToUpgrade == 2 ||
                    nCategoryID_of_PackageWantToUpgrade == 3)
                {

                    TblPackageClass pkgClass = new TblPackageClass();

                    string strClassCode = "";

                    foreach (DataRow r in attendedClassCodetable.Rows)
                    {
                        strClassCode= r["strClassCode"].ToString();
                        pkgClass.StrClassCode= strClassCode;
                        DataTable tempTable = pkgClass.SelectAllWstrClassCodeLogic();

                        //if this tempTable no have packageWantToUpgrade, then means cannot update..
                        DataRow[] rowList = tempTable.Select("strPackageCode = '"+packageWantToUpgrade+"'");

                        if (rowList.Length == 0)
                        {
                            //katty request due to BM001(88) treatment
                            MessageBox.Show(string.Format("Class Code <{0}> that been attended before is not allow in Package {1}, purchase of single session is required. ", strClassCode, packageWantToUpgrade), "Upgrade Failed");
                            return false;
                        }
                    }
                }
                else if (nCategoryID_of_PackageWantToUpgrade == 4 ||
                    nCategoryID_of_PackageWantToUpgrade == 5 ||
                    nCategoryID_of_PackageWantToUpgrade == 6 )
                {

                    TblPackageService pkgSvr = new TblPackageService();

                    string strServiceCode = "";

                    foreach (DataRow r in attendedServiceCodetable.Rows)
                    {
                        strServiceCode = r["strServiceCode"].ToString();
                        pkgSvr.StrServiceCode = strServiceCode;
                        DataTable tempTable = pkgSvr.SelectAllWstrServiceCodeLogic();

                        //if this tempTable no have packageWantToUpgrade, then means cannot update..
                        DataRow[] rowList = tempTable.Select("strPackageCode = '"+packageWantToUpgrade+"'");
                        if (rowList.Length == 0)
                        {
                            //katty request due to BM001(88) treatment
                            //MessageBox.Show(string.Format(" Service Code <{0}> that been used before is not allow in Package {1}, purchase of single session is required. ", strServiceCode, packageWantToUpgrade), "Upgrade Failed");
                            return true;
                        }
                    }
                }
            }

            // 2) Check whether old package is been used.
            //  2a) If been used, check whether the used Class/Service
            //		(* read comment below on how to get what class/service been use) is include in that
            //		upgraded package allow list (check tblPackageClass/tblPackageService)

            //		2ai) If any of used class/service is no include,
            //			 prompt msg that purchase of single session required
            //      2aii) If one of the used class/service is included but
            //            the others no used class/service no included, then can upgrade.
            //		2aiii) If all of the used class/service include, then can upgrade..
            //  2b) if no been used, then can upgrade.

            // * How to get attended class/used service
            return true;
        }