Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
        public bool Delete(int nCaseID)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try
            {
                myCase.MainConnectionProvider = connProvider;
                myCaseAction.MainConnectionProvider = connProvider;

                connProvider.OpenConnection();
                connProvider.BeginTransaction("CancelMemberPackage");

                myCase.NCaseID = nCaseID;
                myCaseAction.NCaseID = nCaseID;

                myCaseAction.DeleteAllWnCaseIDLogic();
                myCase.Delete();

                connProvider.CommitTransaction();
                return true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("DeleteCase");
                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();
                }
                myCase.MainConnactionIsCreatedLocal = true;
                myCaseAction.MainConnactionIsCreatedLocal = true;
            }
        }
Esempio n. 3
0
        public void UpdateClassAttendance(int nAttendanceID, int nNewPackageID)
        {
            TblClassAttendance classAttendance = new TblClassAttendance();
            System.Data.SqlTypes.SqlInt32 nOldPackageID;

            classAttendance.NAttendanceID = nAttendanceID;
            DataTable table = classAttendance.SelectOne();
            if (table != null && table.Rows.Count > 0)
            {
                nOldPackageID = classAttendance.NPackageID;
                classAttendance.NEmployeeID = User.EmployeeID;
                classAttendance.NPackageID = nNewPackageID;

                myMemberPackage.NPackageID = nNewPackageID;
                DataTable memberPackageTable = myMemberPackage.SelectOne();
                if (memberPackageTable == null || memberPackageTable.Rows.Count == 0)
                    throw new Exception("Failed to update/transfer class attendance. Member Package with Package ID = "+ nNewPackageID.ToString() + "has been deleted");

                DataRow masterRow = memberPackageTable.Rows[0];
                TblPackage package = new TblPackage();
                package.StrPackageCode = masterRow["strPackageCode"].ToString();
                package.SelectOne();

                if (masterRow["dtStartDate"] == DBNull.Value)
                {
                    if (!package.FGIRO || package.FGIRO.IsNull)
                    {
                        myMemberPackage.DtStartDate = classAttendance.DtDate;
                        int iduration = package.NPackageDuration.Value;
                        if (package.StrDurationUnit.ToString().Trim() == "DAY")
                            myMemberPackage.DtExpiryDate = classAttendance.DtDate.Value.AddDays(iduration - 1).AddDays(0);
                        else if (package.StrDurationUnit.ToString().Trim() == "WEEK")
                        {
                            iduration = iduration * 7;
                            myMemberPackage.DtExpiryDate = classAttendance.DtDate.Value.AddDays(iduration - 1).AddDays(0);
                        }
                        else
                            myMemberPackage.DtExpiryDate = classAttendance.DtDate.Value.AddMonths(package.NPackageDuration.Value).AddDays(-1);
                    }
                }
                else
                {
                    if (!package.FGIRO || package.FGIRO.IsNull)
                    {
                        if (classAttendance.DtDate < ACMS.Convert.ToDateTime(masterRow["DtStartDate"]))
                        {
                            myMemberPackage.DtStartDate = classAttendance.DtDate;
                            int iduration = package.NPackageDuration.Value;
                            if (package.StrDurationUnit.ToString().Trim() == "DAY")
                                myMemberPackage.DtExpiryDate = classAttendance.DtDate.Value.AddDays(iduration - 1).AddDays(0);
                            else if (package.StrDurationUnit.ToString().Trim() == "WEEK")
                            {
                                iduration = iduration * 7;
                                myMemberPackage.DtExpiryDate = classAttendance.DtDate.Value.AddDays(iduration - 1).AddDays(0);
                            }
                            else
                                myMemberPackage.DtExpiryDate = classAttendance.DtDate.Value.AddMonths(package.NPackageDuration.Value).AddDays(-1);
                        }
                        else
                        {
                            DateTime memberPackageStartDate = ACMS.Convert.ToDateTime(masterRow["DtStartDate"]);
                            DateTime memberPackageExpiryDate = ACMS.Convert.ToDateTime(masterRow["dtExpiryDate"]);

                            if (memberPackageStartDate > classAttendance.DtDate)
                            {
                                myMemberPackage.DtExpiryDate = memberPackageExpiryDate.Subtract(memberPackageStartDate.Subtract(classAttendance.DtDate.Value));
                                myMemberPackage.DtStartDate = classAttendance.DtDate;
                            }
                        }
                    }
                }

                ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

                try
                {
                    myMemberPackage.MainConnectionProvider = connProvider;
                    classAttendance.MainConnectionProvider = connProvider;

                    connProvider.OpenConnection();
                    connProvider.BeginTransaction("SaveClassAttendance");

                    myMemberPackage.Update();
                    classAttendance.Update();
                    //UpdateStartExpiryDate(nOldPackageID);

                    connProvider.CommitTransaction();
                    connProvider.BeginTransaction("SaveClassAttendance");
                    UpdateStartExpiryDate(nOldPackageID);
                    connProvider.CommitTransaction();
                }
                catch (Exception)
                {
                    connProvider.RollbackTransaction("SaveClassAttendance");
                    throw new Exception("Failed to save Class Attendance");
                }
                finally
                {
                    if (connProvider.CurrentTransaction != null)
                        connProvider.CurrentTransaction.Dispose();
                    if (connProvider.DBConnection != null)
                    {
                        if (connProvider.DBConnection.State == ConnectionState.Open)
                            connProvider.DBConnection.Close();
                    }
                    myMemberPackage.MainConnactionIsCreatedLocal = true;
                    classAttendance.MainConnactionIsCreatedLocal = true;
                }
            }
        }
Esempio n. 4
0
        //public void SaveExtensionHistory(int nPackageID, DataTable packageExtensionTable, DateTime oldExpiryDate)
        public void SaveExtensionHistory(int nPackageID, DataTable packageExtensionTable, DateTime oldExpiryDate, bool isGiro, DateTime StartDate, DateTime EndDate, int iReasonID)
        {
            // *TO Do -- if dtStartDate is null, no allow extend
            DataRow packExtRow = packageExtensionTable.Rows[0];
            int nReasonID=0;
            if (iReasonID != 0)
                nReasonID = iReasonID;
            else
                nReasonID = ACMS.Convert.ToInt32(packExtRow["nReasonID"]);

            if (nReasonID < 0)
                return;
            // Assume that nReasonID = 0 is Others

            TblPackageExtension packageExt = new TblPackageExtension();
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            if (nReasonID > 0)
            {
                try
                {
                    myMemberPackage.MainConnectionProvider = connProvider;
                    packageExt.MainConnectionProvider = connProvider;

                    connProvider.OpenConnection();
                    connProvider.BeginTransaction("SaveExtension");

                        DateTime packageExtensionStartDate;
                        DateTime packageExtensionEndDate;

                        if (isGiro == true)
                    {
                        packExtRow["dtStartDate"] = StartDate;
                        packExtRow["dtEndDate"] = EndDate;
                        packageExtensionStartDate = StartDate;
                        packageExtensionEndDate = EndDate;
                    }
                    else
                    {
                            //to support extension for multiple package at once
                        if (StartDate.ToString() != "" && EndDate.ToString() != "")
                        {
                            // C=Leave Start Date
                            packageExtensionStartDate = Convert.ToDateTime(StartDate);
                            // D=Leave End Date
                            packageExtensionEndDate = Convert.ToDateTime(EndDate);
                        }
                        else
                        {
                            // C=Leave Start Date
                            packageExtensionStartDate = ACMS.Convert.ToDateTime(packExtRow["dtStartDate"]);
                            // D=Leave End Date
                            packageExtensionEndDate = ACMS.Convert.ToDateTime(packExtRow["dtEndDate"]);
                        }
                    }

                    //B4 Save, must Check whether the startdate have overlap with previous one or not
                    packageExt.NPackageID = nPackageID;
                    DataTable table = packageExt.SelectAllWnPackageIDLogic();
                    if (table != null && table.Rows.Count > 0)
                    {
            //						DataRow[] tempRow = table.Select("nStatusID = 0 and dtEndDate > '" + packageExtensionStartDate + "'", "nExtensionID");
            //						if (tempRow.Length > 0)
            //							throw new Exception("Overlapped date in extension package.");
                        int RowExtention;
                        DateTime e = packageExtensionStartDate;
                        DateTime f = packageExtensionEndDate;
                        for (RowExtention = 0; RowExtention <= table.Rows.Count-1; RowExtention++)
                        {
                            if (e < ACMS.Convert.ToDateTime(table.Rows[RowExtention]["dtEndDate"]) && f >= ACMS.Convert.ToDateTime(table.Rows[RowExtention]["dtStartDate"])
                                || (f < e))
                            {
                            throw new Exception("Overlapped date in extension package.");
                            }
                        }

                    }
                    //end checking

                    myMemberPackage.NPackageID = nPackageID;
                    DataTable memberPackageTable = myMemberPackage.SelectOne();

                    if  (myMemberPackage.DtStartDate.IsNull)
                        throw new Exception("Member Package not been used yet.");

                    if  (memberPackageTable.Rows[0]["DtStartDate"] == DBNull.Value)
                        return;

                    //bool isGiro = !myMemberPackage.NGIRORefID.IsNull;

                    // A=Member Package Start Date
                    DateTime memberPackageStartDate = myMemberPackage.DtStartDate.Value;
                    // B=Member Package End Date
                    DateTime memberPackageExpiryDate = myMemberPackage.DtExpiryDate.Value;
                    DateTime memberPackagePurchaseDate = myMemberPackage.DtPurchaseDate.Value;

                    //if (packageExtensionStartDate > memberPackageExpiryDate)
                    //	throw new Exception("Extension Start Date is not allow to later than Member Package's Expiry Date.");

                    if (isGiro == false)
                    {
                        if (packageExtensionStartDate > memberPackageExpiryDate)
                            throw new Exception("Extension Start Date is not allow to later than Member Package's Expiry Date.");

                        DateTime latestNewExpiryDate = DateTime.MinValue;

                        if ( packageExtensionStartDate > memberPackageStartDate)
                        {

                              DateTime latestExpiryDate = DateTime.ParseExact("2012-04-01", "yyyy'-'MM'-'dd", null);
                              if (memberPackagePurchaseDate > latestExpiryDate && nReasonID != 6)
                            {
                                TimeSpan duration = packageExtensionEndDate.Subtract(packageExtensionStartDate);

                                    if (2 > duration.Days )//01042012 Member only can apply extension with a minimun of 3 days
                                    {
                                        throw new Exception("Extension only can apply for minimun of 3 days.");
                                    }
                                    else
                                    {
                                        TimeSpan duration1 = packageExtensionEndDate.Subtract(packageExtensionStartDate);
                                        myMemberPackage.DtExpiryDate = myMemberPackage.DtExpiryDate.Value.Add(duration1).AddDays(1);
                                    }

                            }
                            else
                            {
                                           TimeSpan duration = packageExtensionEndDate.Subtract(packageExtensionStartDate);
                                            myMemberPackage.DtExpiryDate = myMemberPackage.DtExpiryDate.Value.Add(duration).AddDays(1);
                            }
                        }
                        else if (packageExtensionStartDate < memberPackageStartDate)
                        {
                            TimeSpan duration = packageExtensionEndDate.Subtract(memberPackageStartDate);
                            myMemberPackage.DtExpiryDate = myMemberPackage.DtExpiryDate.Value.Add(duration).AddDays(1);
                        }

                        myMemberPackage.DtLastEdit = System.DateTime.Now;
                        myMemberPackage.NEmployeeID = User.EmployeeID;
                    }
                    else
                    {
                        //int nGiroRefID = (int)myMemberPackage.NGIRORefID;
                        // if the member package is Giro
                        // then need to make sure all the extension is follow the base one

                        myMemberPackage.NPackageID = nPackageID;
                        DataTable tempTable = myMemberPackage.SelectAllWnGIROPackageIDLogic();

                        if (tempTable == null)
                            return;
                        if (tempTable.Rows.Count == 0)
                            return;

                        if (tempTable.Rows.Count > 1)
                        {
                            DataRow[] rowList = tempTable.Select("dtStartDate is not null", "nGiroRefID", DataViewRowState.CurrentRows);

                            if (rowList.Length > 0)
                            {
                                DateTime latestNewExpiryDate = DateTime.MinValue;
                                DateTime tempnewExpiryDate = DateTime.MinValue;

                                memberPackageStartDate = ACMS.Convert.ToDateTime(rowList[0]["dtStartDate"]);
                                memberPackageExpiryDate = ACMS.Convert.ToDateTime(rowList[0]["dtExpiryDate"]);

                                if (packageExtensionStartDate > memberPackageStartDate)
                                {
                                    TimeSpan duration = packageExtensionEndDate.Subtract(packageExtensionStartDate);
                                    tempnewExpiryDate = memberPackageExpiryDate.Add(duration).AddDays(1);
                                }
                                else if (packageExtensionStartDate < memberPackageStartDate)
                                {
                                    TimeSpan duration = packageExtensionEndDate.Subtract(memberPackageStartDate);
                                    tempnewExpiryDate = memberPackageExpiryDate.Add(duration).AddDays(1);
                                }

                                tempTable.BeginInit();
                                foreach (DataRow r in rowList)
                                {
                                    r["dtExpiryDate"] = tempnewExpiryDate;
                                    r["dtLastEdit"] = DateTime.Now;
                                    r["nEmployeeID"] = User.EmployeeID;
                                }
                                tempTable.EndInit();
                            }
                            else
                                return;
                        }
                        else
                        {
                            isGiro = false;
                            myMemberPackage.NPackageID = nPackageID;
                            myMemberPackage.SelectOne();
                            myMemberPackage.DtLastEdit = System.DateTime.Now;
                            myMemberPackage.NEmployeeID = User.EmployeeID;
                            DateTime latestNewExpiryDate = DateTime.MinValue;

                            if (packageExtensionStartDate > memberPackageStartDate)
                            {
                                TimeSpan duration = packageExtensionEndDate.Subtract(packageExtensionStartDate);
                                myMemberPackage.DtExpiryDate = myMemberPackage.DtExpiryDate.Value.Add(duration).AddDays(1);
                            }
                            else if (packageExtensionStartDate < memberPackageStartDate)
                            {
                                TimeSpan duration = packageExtensionEndDate.Subtract(memberPackageStartDate);
                                myMemberPackage.DtExpiryDate = myMemberPackage.DtExpiryDate.Value.Add(duration).AddDays(1);
                            }
                        }
                    }

                    //To support extension for multiple package at once
                    object dtEndValue = packExtRow["dtEndDate"];
                    object dtStartDate = packExtRow["dtEndDate"];
                    if (dtEndValue == DBNull.Value && dtStartDate == DBNull.Value)
                    {
                        packExtRow["dtEndDate"] = EndDate;
                        packExtRow["dtStartDate"] = StartDate;
                    }
                    TimeSpan nDaysExtend = ACMS.Convert.ToDateTime(packExtRow["dtEndDate"]).Subtract(ACMS.Convert.ToDateTime(packExtRow["dtStartDate"]));

                    packExtRow["nDaysExtended"] = nDaysExtend.TotalDays+1;
                    packExtRow["dtOldExpiry"]=oldExpiryDate;
                    packExtRow["dtNewExpiry"]=	oldExpiryDate.AddDays(nDaysExtend.TotalDays+1);
                    packExtRow["dtCreateDate"] = System.DateTime.Now; //jackie 14032012
                    if (nReasonID != 0)
                        packExtRow["nReasonID"] = nReasonID;

                    packExtRow["nDaysExtended"]=(nDaysExtend.TotalDays)+1;
                    #region ====== Added By Albert ======
                    //To update member package status. If expiry date is greater than today date, change the status to active.
                    DateTime dtExpireDate = Convert.ToDateTime(myMemberPackage.DtExpiryDate.ToString());
                    if(DateTime.Compare(dtExpireDate,DateTime.Now)>0)
                        myMemberPackage.NStatusID = 0;
                    #endregion
                    myMemberPackage.Update();

                    packageExt.SaveData(packageExtensionTable);

                    connProvider.CommitTransaction();
                }
                catch (Exception ex)
                {
                    connProvider.RollbackTransaction("SaveExtension");
                    throw ex;
                }
                finally
                {
                    if (connProvider.CurrentTransaction != null)
                        connProvider.CurrentTransaction.Dispose();
                    if (connProvider.DBConnection != null)
                    {
                        if (connProvider.DBConnection.State == ConnectionState.Open)
                            connProvider.DBConnection.Close();
                    }
                    myMemberPackage.MainConnactionIsCreatedLocal = true;
                    packageExt.MainConnactionIsCreatedLocal = true;
                }
            }
            else
            {
                try
                {
                    myMemberPackage.MainConnectionProvider = connProvider;
                    packageExt.MainConnectionProvider = connProvider;

                    connProvider.OpenConnection();
                    connProvider.BeginTransaction("SaveExtension");

                    myMemberPackage.NPackageID = nPackageID;
                    myMemberPackage.SelectOne();

                    if (myMemberPackage.DtStartDate.IsNull)
                        throw new Exception("Member Package is yet been used. No need to extend");

                    myMemberPackage.DtExpiryDate = oldExpiryDate;
                    myMemberPackage.DtLastEdit = System.DateTime.Today;
                    myMemberPackage.NEmployeeID = User.EmployeeID;
                    //packageExt
                    packExtRow["dtStartDate"] = myMemberPackage.DtStartDate.Value;
                    packExtRow["dtEndDate"] =  myMemberPackage.DtExpiryDate.Value;
                    packExtRow["nDaysExtended"] = myMemberPackage.DtExpiryDate.Value.CompareTo(myMemberPackage.DtStartDate.Value);

                    packageExt.SaveData(packageExtensionTable);
                    myMemberPackage.Update();

                    connProvider.CommitTransaction();
                }
                catch (Exception ex)
                {
                    connProvider.RollbackTransaction("SaveExtension");
                    throw ex;
                }
                finally
                {
                    if (connProvider.CurrentTransaction != null)
                        connProvider.CurrentTransaction.Dispose();
                    if (connProvider.DBConnection != null)
                    {
                        if (connProvider.DBConnection.State == ConnectionState.Open)
                            connProvider.DBConnection.Close();
                    }
                    myMemberPackage.MainConnactionIsCreatedLocal = true;
                    packageExt.MainConnactionIsCreatedLocal = true;
                }
            }
        }
Esempio n. 5
0
        public bool NewClassAttendance(int nPackageID, string strMemberShipID, int nClassInstance,
            int nType, string strBranchCode, DateTime classDate,
            DateTime startTime, DateTime endTime, bool isRefunded)
        {
            if (!isRefunded)
            {
                ACMSDAL.TblReceipt sqlReceipt = new ACMSDAL.TblReceipt();
                DataTable receipttable = sqlReceipt.GetToDayForgetCardReceipt(strMemberShipID, 17);

                if (receipttable == null || receipttable.Rows.Count == 0)
                {
                    throw new Exception("You have yet to pay the forget card deposit today.");
                }
            }

            TblClassAttendance classAttendance = new TblClassAttendance();
            bool isPostFromOtherRecord = false;
            bool needtoAddBackOneDayExpiryDate = false;
            bool BalanceStatus = true;
            DataTable memberPackageTable = null;

            if (nType != 1)
            {

                DataRow classAttendanceRow = null;

                bool isAttendedNow = classAttendance.IsAttendedThisClass(nClassInstance, strMemberShipID, ref classAttendanceRow);

                if (isAttendedNow)
                {
                    int nStatusID = ACMS.Convert.ToInt32(classAttendanceRow["nStatusID"]);

                    if (nStatusID == 1)
                    {
                        // Process
                        throw new Exception("Member already been marked in this class.");
                    }
                    else
                    {
                        //Forfeit and need to change to process
                        if (classAttendanceRow != null)
                        {
                            int nClassAttendanceID = ACMS.Convert.ToInt32(classAttendanceRow["nAttendanceID"]);
                            classAttendance.NAttendanceID = nClassAttendanceID;
                            classAttendance.SelectOne();
                            isPostFromOtherRecord = true;
                            nPackageID = classAttendance.NPackageID.Value;
                            isRefunded = classAttendance.FRefunded.IsNull ? true : classAttendance.FRefunded.Value;

                            // this only true if the package is unlimited one
                            memberPackageTable = myMemberPackage.GetMemberPackage(nPackageID);

                            if (ACMS.Convert.ToInt32(memberPackageTable.Rows[0]["nMaxSession"]) == 9999)
                                needtoAddBackOneDayExpiryDate = true;
                        }
                    }
                }
                else if (classAttendanceRow != null && nType == 0)
                {
                    int nClassAttendanceID = ACMS.Convert.ToInt32(classAttendanceRow["nAttendanceID"]);

                    classAttendance.NAttendanceID = nClassAttendanceID;
                    classAttendance.SelectOne();
                    isPostFromOtherRecord = true;
                    nPackageID = classAttendance.NPackageID.Value;
                    isRefunded = classAttendance.FRefunded.IsNull ? true : classAttendance.FRefunded.Value;
                }
            }

            if (memberPackageTable == null)
            {
                myMemberPackage.NPackageID = nPackageID;
                memberPackageTable = myMemberPackage.GetMemberPackage(nPackageID);
            }

            if (memberPackageTable == null || memberPackageTable.Rows.Count == 0)
                throw new Exception("Failed to create new class attendance. Member Package with npackageID = " + nPackageID.ToString() + "has been deleted");

            classAttendance.NPackageID = nPackageID;
            classAttendance.StrMembershipID = strMemberShipID;
            classAttendance.NClassInstanceID = nClassInstance;
            classAttendance.NTypeID = nType;
            classAttendance.StrBranchCode = strBranchCode;
            classAttendance.DtDate = classDate;
            classAttendance.DtStartTime = startTime;
            classAttendance.DtEndTime = endTime;
            classAttendance.DtLastEditDate = DateTime.Now;
            classAttendance.NEmployeeID = ACMSLogic.User.EmployeeID;

            //indicated free class or not
            TblClassInstance classInstance = new TblClassInstance();
            DataTable Instance = classInstance.LoadData("Select fFree from tblClassInstance Where nClassInstanceID = @nClassInstanceID",
                new string[] { "@nClassInstanceID" }, new object[] { nClassInstance });

            if (Instance.Rows[0][0].ToString() == "True")
                classAttendance.NStatusID = 4;
            else
                classAttendance.NStatusID = 1;

            classAttendance.FRefunded = isRefunded;// System.Data.SqlTypes.SqlBoolean.

            //UnLinked is for temporary only
            if (memberPackageTable.Rows[0]["strPackageCode"].ToString() != "Unlinked")
            {
                CalculateMemberPackageBalance(memberPackageTable.Rows[0]["strPackageCode"].ToString(), strMemberShipID, memberPackageTable);

                DataRow masterRow = memberPackageTable.Rows[0];

                //				if (ACMS.Convert.ToDBInt32(memberPackageTable.Rows[0]["Balance"])<999 &&  ACMS.Convert.ToDBInt32(memberPackageTable.Rows[0]["nAdjust"])>=1)
                //				{
                //					memberPackageTable.Rows[0]["Balance"]=ACMS.Convert.ToDBInt32(memberPackageTable.Rows[0]["Balance"])- ACMS.Convert.ToDBInt32(memberPackageTable.Rows[0]["nAdjust"]);
                //				}

                if (ACMS.Convert.ToInt32(memberPackageTable.Rows[0]["Balance"]) <= 0)
                {
                    throw new Exception("Balance is zero");
                    masterRow["nBalance"] = false;
                    BalanceStatus = false;
                }

                if (masterRow["fGiro"].ToString() != "1")
                {
                    if ((masterRow["dtStartDate"] == DBNull.Value &&
                    masterRow["dtExpiryDate"] == DBNull.Value) || (masterRow["dtStartDate"] != DBNull.Value && Convert.ToDateTime(masterRow["dtStartDate"]) > classDate))
                    {
                        // Means new class Attendance gonna insert
                        TblPackage package = new TblPackage();
                        package.StrPackageCode = masterRow["strPackageCode"].ToString();
                        package.SelectOne();

                        //if (package.NPackageDuration.Value == 0 && package.NPackageDay.Value > 0)
                        //{
                        //    masterRow["dtStartDate"] = classDate;
                        //    masterRow["dtExpiryDate"] = classDate.AddDays(package.NPackageDay.Value - 1);
                        //}
                        //else
                        //{
                        //    masterRow["dtStartDate"] = classDate;
                        //    masterRow["dtExpiryDate"] = classDate.AddMonths(package.NPackageDuration.Value).AddDays(-1);
                        //}

                        //jackie Start 05042012
                        masterRow["dtStartDate"] = classDate;
                        if (package.NPackageDuration.Value == 0)
                        {

                            string txt = package.StrPackageCode.ToString();

                            if (txt == "FTRIAL")
                            {
                                masterRow["dtExpiryDate"] = classDate.AddDays(1).AddDays(0);
                            }
                            else
                            {
                                string strduration;

                                int cstarts = txt.IndexOf("(") + 1;
                                int len = txt.IndexOf(")") - cstarts;
                                txt = txt.Substring(cstarts, len);

                                if (string.IsNullOrEmpty(txt))
                                {
                                    strduration = string.Empty;
                                }
                                else
                                {
                                    int lens = txt.Length;
                                    strduration = txt.Substring(txt.Length - 1, 1);
                                }

                                if (strduration == "D")
                                {

                                    strduration = txt.Replace("D", "");
                                    int iduration = Int32.Parse(strduration);
                                    masterRow["dtExpiryDate"] = classDate.AddDays(iduration - 1).AddDays(0);

                                }
                                if (strduration == "W")
                                {
                                    strduration = txt.Replace("W", "");
                                    int iduration = Int32.Parse(strduration);
                                    iduration = iduration * 7;
                                    masterRow["dtExpiryDate"] = classDate.AddDays(iduration - 1).AddDays(0);

                                }
                            }

                        }
                        else
                        {
                            int iduration = package.NPackageDuration.Value;
                            if (package.StrDurationUnit.ToString().Trim() == "DAY")
                                masterRow["dtExpiryDate"] = classDate.AddDays(iduration - 1).AddDays(0);
                            else if (package.StrDurationUnit.ToString().Trim() == "WEEK")
                            {
                                iduration = iduration * 7;
                                masterRow["dtExpiryDate"] = classDate.AddDays(iduration - 1).AddDays(0);
                            }
                            else if (package.StrDurationUnit.ToString().Trim() == "MONTH")
                                masterRow["dtExpiryDate"] = classDate.AddMonths(package.NPackageDuration.Value).AddDays(-1);
                        }
                        //jackie END 2/02/2012

                    }
                    else
                    {
                        // Kean Yiap
                        string strPackageCode = masterRow["strPackageCode"].ToString();
                        CalculateMemberPackageBalance(strPackageCode, strMemberShipID, memberPackageTable);
                        DateTime memberPackageStartDate = ACMS.Convert.ToDateTime(masterRow["DtStartDate"]);
                        DateTime memberPackageExpiryDate = ACMS.Convert.ToDateTime(masterRow["dtExpiryDate"]);

                        //if (memberPackageStartDate > classDate)
                        //{
                        //jackie why must change ExpiryDate 26042012
                        //	masterRow["dtExpiryDate"] = memberPackageExpiryDate.Subtract(memberPackageStartDate.Subtract(classDate));
                        //}
                    }
                }

                if (ACMS.Convert.ToInt32(memberPackageTable.Rows[0]["Balance"]) <= 1)
                {
                    if (masterRow["strPackageCode"].ToString() == "FTRIAL")
                    {
                        memberPackageTable.Rows[0]["nBalance"] = 1;
                    }
                    else
                    {
                        memberPackageTable.Rows[0]["nBalance"] = 0;
                    }
                }

            }

            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try
            {
                myMemberPackage.MainConnectionProvider = connProvider;
                classAttendance.MainConnectionProvider = connProvider;

                connProvider.OpenConnection();
                connProvider.BeginTransaction("SaveClassAttendance");

                if (needtoAddBackOneDayExpiryDate && memberPackageTable.Rows[0]["fGIRO"].ToString() != "1")
                {
                    memberPackageTable.Rows[0]["dtExpiryDate"] = ACMS.Convert.ToDateTime(memberPackageTable.Rows[0]["dtExpiryDate"]).AddDays(1);
                }

                myMemberPackage.SaveData(memberPackageTable);

                if (BalanceStatus)
                {
                    if (!isPostFromOtherRecord)
                        classAttendance.Insert();
                    else
                        classAttendance.Update();

                    connProvider.CommitTransaction();
                }

                return true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("SaveClassAttendance");
                throw new Exception("Failed to save Class Attendance");
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();
                }
                myMemberPackage.MainConnactionIsCreatedLocal = true;
                classAttendance.MainConnactionIsCreatedLocal = true;
            }
        }
Esempio n. 6
0
        public void TransferMemberCreditPackage(int nCreditPackageID, string newStrMemberShipID, string remark)
        {
            myCreditPkg.NCreditPackageID = nCreditPackageID;
            myCreditPkg.SelectOne();
            myCreditPkg.StrRemarks = remark;
            TblAudit audit = new TblAudit();

            audit.NAuditTypeID          = AuditTypeID.TransferMemberCreditPackage;
            audit.NEmployeeID           = User.EmployeeID;
            audit.DtDate                = DateTime.Now;
            audit.StrReference          = nCreditPackageID.ToString();
            audit.StrAuditEntry         = "Old Owner : " + myCreditPkg.StrMembershipID + " New Owner : " + newStrMemberShipID;
            myCreditPkg.StrMembershipID = newStrMemberShipID;

            TblMemberPackage sqlMemberPackage = new TblMemberPackage();

            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try
            {
                myCreditPkg.MainConnectionProvider      = connProvider;
                audit.MainConnectionProvider            = connProvider;
                sqlMemberPackage.MainConnectionProvider = connProvider;

                sqlMemberPackage.NCreditPackageID = nCreditPackageID;
                DataTable memberPackageTable = sqlMemberPackage.SelectAllWnCreditPackageIDLogic();

                foreach (DataRow row in memberPackageTable.Rows)
                {
                    row["strMembershipID"] = newStrMemberShipID;
                }

                connProvider.OpenConnection();
                connProvider.BeginTransaction("TransferMemberCreditPackage");

                myCreditPkg.Update();
                sqlMemberPackage.SaveData(memberPackageTable);
                audit.Insert();

                connProvider.CommitTransaction();
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("TransferMemberCreditPackage");
                throw;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                {
                    connProvider.CurrentTransaction.Dispose();
                }
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                    {
                        connProvider.DBConnection.Close();
                    }
                }
                myCreditPkg.MainConnactionIsCreatedLocal = true;
                audit.MainConnactionIsCreatedLocal       = true;
            }
        }
Esempio n. 7
0
        public void CancelClassInstance(int nClassInstanceID, string remark)
        {
            myClassInstance.NClassInstanceID = nClassInstanceID;
            myClassInstance.SelectOne();
            myClassInstance.FCancelled = System.Data.SqlTypes.SqlBoolean.True;
            myClassInstance.StrRemarks = remark;
            TblAudit audit = new TblAudit();

            audit.DtDate = DateTime.Today;
            audit.NAuditTypeID = AuditTypeID.ClassAuditTypeID;
            audit.NEmployeeID = ACMSLogic.User.EmployeeID;
            audit.StrAuditEntry = "Cancel class instance " + nClassInstanceID.ToString();
            audit.StrReference = nClassInstanceID.ToString();

            TblClassAttendance classAttendance = new TblClassAttendance();
            classAttendance.NClassInstanceID = nClassInstanceID;
            DataTable classAttendanceTable = classAttendance.SelectAllWnClassInstanceIDLogic();

            if (classAttendanceTable != null && classAttendanceTable.Rows.Count > 0)
            {
                foreach (DataRow r in classAttendanceTable.Rows)
                {
                    r["nStatusID"] = 3;
                }
            }

            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try
            {
                myClassInstance.MainConnectionProvider = connProvider;
                audit.MainConnectionProvider = connProvider;
                classAttendance.MainConnectionProvider = connProvider;

                connProvider.OpenConnection();
                connProvider.BeginTransaction("CancelClassInstance");
                myClassInstance.Update();
                audit.Insert();
                classAttendance.SaveData(classAttendanceTable);
                connProvider.CommitTransaction();

                DataTable dtAttendance = new DataTable();
                dtAttendance = GetClassAttendanceReservedAndAttended(nClassInstanceID);

                DialogResult result1 = MessageBox.Show("Push Notification to Mobile app users? ", "Confirm", MessageBoxButtons.YesNo);
                if (result1 == DialogResult.Yes)
                {
                    foreach (DataRow row in dtAttendance.Rows)
                    {
                        string strMsgContent = row["strDescription"].ToString() + " at " + row["strBranchName"] + " at " + Convert.ToDateTime(myClassInstance.DtStartTime).ToString("h.mmtt") + " on " + Convert.ToDateTime(myClassInstance.DtStartTime).ToString("dd MMM") + " has been cancelled. Sorry for any inconvenience caused.";
                        PushNotification(row["strMembershipID"].ToString(), strMsgContent);
                    }
                }
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("CancelClassInstance");
                throw;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();
                }
                myClassInstance.MainConnactionIsCreatedLocal = true;
            }
        }
Esempio n. 8
0
        public bool UpdateCardStatus(string strMembershipID, User aUser, CardStatusType myType, int nRequestID,
                                     string strBranchCode)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember      sqlMember      = new TblMember();
            TblCardRequest sqlCardRequest = new TblCardRequest();
            TblAudit       sqlAudit       = new TblAudit();

            bool isSuccess = false;

            try
            {
                sqlMember.MainConnectionProvider      = connProvider;
                sqlCardRequest.MainConnectionProvider = connProvider;
                sqlAudit.MainConnectionProvider       = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("ChangeCardStatus");

                if (CardStatusType.RequestPrint == myType)
                {
                    sqlMember.UpdateCardStatus(strMembershipID, (int)myType, "HQ");
                }
                else
                {
                    sqlMember.UpdateCardStatus(strMembershipID, (int)myType, strBranchCode);
                }
                sqlCardRequest.NEmployeeID     = aUser.NEmployeeID();
                sqlCardRequest.NRequestID      = nRequestID;
                sqlCardRequest.NStatusID       = (int)myType;
                sqlCardRequest.StrBranchCode   = strBranchCode;
                sqlCardRequest.StrMembershipID = strMembershipID;
                sqlCardRequest.DtLastEditDate  = DateTime.Now;
                sqlCardRequest.Update();

                sqlAudit.NAuditTypeID  = ACMSLogic.AuditTypeID.MemberCard;
                sqlAudit.NEmployeeID   = aUser.NEmployeeID();
                sqlAudit.StrAuditEntry = "Update member card to " + myType.ToString() + ".";
                sqlAudit.StrReference  = strMembershipID;
                sqlAudit.DtDate        = DateTime.Now;
                sqlAudit.Insert();

                connProvider.CommitTransaction();
                isSuccess = true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("ChangeCardStatus");
                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();
                }
                sqlMember.Dispose();
                sqlCardRequest.Dispose();
                sqlAudit.Dispose();
            }
            return(isSuccess);
        }
Esempio n. 9
0
        public bool SavePOS(ACMSLogic.POS pos)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            //ACMSDAL.ConnectionProvider connProvider1 = new ConnectionProvider();

            try
            {
                DataTable branchReceiptNoTable = new DataTable();
                int latestReceiptNo = GetLatestReceiptNo(connProvider, pos, ref branchReceiptNoTable) + 1;
                string receiptNo = pos.StrBranchCode.ToString().Trim() + pos.NTerminalID.ToString().Trim() + latestReceiptNo.ToString().Trim();

                pos.StrReceiptNo = receiptNo;

                //Derek Instalment Plan Need to Add PaymentPlan Table Here
                //Get pos.NCategoryID here to determine if the item is Pay O/S
                //Here Can get the new Receipt No Value
                //3 Main table that always need to update

                TblReceipt receipt = new TblReceipt();
                TblReceiptEntries receiptEntries = new TblReceiptEntries();
                TblReceiptPayment receiptPayment = new TblReceiptPayment();
                TblPaymentPlan myPaymentPlan = new TblPaymentPlan();

                receipt.MainConnectionProvider = connProvider;
                receiptEntries.MainConnectionProvider = connProvider;
                receiptPayment.MainConnectionProvider = connProvider;
                myPaymentPlan.MainConnectionProvider = connProvider;

                connProvider.OpenConnection();
                connProvider.BeginTransaction("SaveReceipt");

                DataTable receiptTable = pos.ReceiptMasterTable.Copy();
                DataTable receiptEntriesTable = pos.ReceiptItemsTable.Copy();
                DataTable receiptPaymentTable = pos.ReceiptPaymentTable.Copy();
                DataTable freeMemberPackageTable = receipt.FillSchema("Select * From tblMemberPackage"); // use to store the free member package.
                DataTable freeMemberCreditPackageTable = receipt.FillSchema("Select * From tblMemberCreditPackage");

                if (pos.PaymentPlanTable != null && pos.NCategoryID != 0)
                {
                    DataTable paymentPlanTable = pos.PaymentPlanTable.Copy();

                    if (paymentPlanTable != null && paymentPlanTable.Rows.Count > 0)
                    {
                        foreach (DataRow r in paymentPlanTable.Rows)
                        {
                            r["strReceiptNo"] = pos.StrReceiptNo;

                            if (r["nInstalmentNo"].ToString() == "1")
                            {
                                r["strPaymentReceiptNo"] = pos.StrReceiptNo;

                                myPaymentPlan.IPPPrimaryEntry(r["strReceiptNo"].ToString(), Convert.ToInt32(r["nInstalmentNo"]),
                                                                r["strPaymentReceiptNo"].ToString(), Convert.ToDecimal(r["mPaymentPlanAmt"]),
                                                                Convert.ToDecimal(r["mPaidAmount"]), Convert.ToDecimal(r["mAdjustedPaymentPlanAmt"]),
                                                                Convert.ToDecimal(r["mOutstandingAmt"]), Convert.ToDateTime(r["dtPaymentDate"]),
                                                                Convert.ToDateTime(r["dtDueDate"]), Convert.ToDateTime(r["dtFinalDueDate"]),
                                                                Convert.ToInt32(r["nPaymentPlanID"]));

                            }
                            else
                            {
                                myPaymentPlan.IPPSubsequentEntry(r["strReceiptNo"].ToString(), Convert.ToInt32(r["nInstalmentNo"]),
                                                                    Convert.ToDecimal(r["mPaymentPlanAmt"]), Convert.ToDecimal(r["mPaidAmount"]),
                                                                    Convert.ToDecimal(r["mAdjustedPaymentPlanAmt"]), Convert.ToDecimal(r["mOutstandingAmt"]),
                                                                    Convert.ToDateTime(r["dtDueDate"]), Convert.ToDateTime(r["dtFinalDueDate"]),
                                                                    Convert.ToInt32(r["nPaymentPlanID"]));
                            }
                        }
                        paymentPlanTable.AcceptChanges();
                    }
                    pos.PaymentPlanTable.AcceptChanges();

                }
                else if (pos.PaymentPlanTable != null && pos.NCategoryID == 0)
                {
                    DataTable paymentPlanTable = pos.PaymentPlanTable.Copy();

                    if (paymentPlanTable != null && paymentPlanTable.Rows.Count > 0)
                    {
                        foreach (DataRow r in paymentPlanTable.Rows)
                        {
                            if (r["lastestUpdate"].ToString() == "1")
                            {
                                r["strPaymentReceiptNo"] = pos.StrReceiptNo;

                                myPaymentPlan.IPPPrimaryUpdate(Convert.ToInt32(r["nPaymentPlanID"]), r["strReceiptNo"].ToString(),
                                                                Convert.ToInt32(r["nInstalmentNo"]), r["strPaymentReceiptNo"].ToString(),
                                                                Convert.ToDecimal(r["mPaidAmount"]), Convert.ToDecimal(r["mAdjustedPaymentPlanAmt"]),
                                                                Convert.ToDecimal(r["mOutstandingAmt"]), Convert.ToDateTime(r["dtPaymentDate"]));

                            }
                            else
                            {
                                myPaymentPlan.IPPSubsequentUpdate(Convert.ToInt32(r["nPaymentPlanID"]), r["strReceiptNo"].ToString(),
                                                                    Convert.ToInt32(r["nInstalmentNo"]), Convert.ToDecimal(r["mPaidAmount"]),
                                                                    Convert.ToDecimal(r["mAdjustedPaymentPlanAmt"]), Convert.ToDecimal(r["mOutstandingAmt"]));
                            }
                        }

                        //paymentPlanTable.AcceptChanges();
                    }
                    pos.PaymentPlanTable.AcceptChanges();
                }

                receipt.SaveData(receiptTable);
                receiptEntries.SaveData(receiptEntriesTable);
                receiptPayment.SaveData(receiptPaymentTable);

                receiptEntries.StrReceiptNo = pos.StrReceiptNo;
                DataTable savedReceiptEntriesTable = receiptEntries.SelectAllWstrReceiptNoLogic();

                pos.ReceiptMasterTable.AcceptChanges();

                if (pos.StrFreebieCode.HasValue && pos.StrFreebieCode.ToString() != "")
                {
                    //Update Bill Freebie here
                    if (pos.ReceiptFreebieTable.Rows.Count > 0)
                    {
                        TblReceiptFreebie receiptFreebie = new TblReceiptFreebie();
                        receiptFreebie.MainConnectionProvider = connProvider;
                        DataTable receiptFreebieTable = pos.ReceiptFreebieTable.Copy();

                        // Save Bill Receipt Freebie
                        receiptFreebie.SaveData(receiptFreebieTable);

                        //TblProductInventory proInven = new TblProductInventory();
                        //proInven.MainConnectionProvider = connProvider;

                        //// deduct stock
                        //foreach (DataRow r in receiptFreebieTable.Rows)
                        //{
                        //    proInven.IncreaseQuantity(r["strItemCode"].ToString(), pos.StrBranchCode, -1);
                        //}
                    }
                    if (pos.ReceiptPackageTable.Rows.Count > 0)
                    {
                        // update package

                        foreach (DataRow r in pos.ReceiptPackageTable.Rows)
                        {
                            TblCreditPackage p = new TblCreditPackage();
                            p.StrCreditPackageCode = r["strPackageCode"].ToString();
                            p.SelectOne();

                            if (p.StrDescription.ToString() != "Null")
                            {
                                DataRow rowToAdd = freeMemberCreditPackageTable.NewRow();

                                ACMSLogic.MemberPackage.InitMemberCreditPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID,
                                    r["strPackageCode"].ToString(), r["strPromotionCode"].ToString(), true);

                                // Add to freeMemberPackageTable and will save
                                freeMemberCreditPackageTable.Rows.Add(rowToAdd);
                            }
                            else
                            {
                                DataRow rowToAdd = freeMemberPackageTable.NewRow();

                                ACMSLogic.MemberPackage.InitMemberPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID,
                                    r["strPackageCode"].ToString(), r["strPromotionCode"].ToString(), true);

                                // Add to freeMemberPackageTable and will save
                                freeMemberPackageTable.Rows.Add(rowToAdd);
                            }
                        }
                    }
                    //else
                    //{
                    //    throw new Exception("Bill Freebie have no free any product or package although the strFreebieCode is not null");
                    //}
                }

                if (pos.ReceiptItemsFreebiePackageTable.Rows.Count > 0)
                {
                    foreach (DataRow r in pos.ReceiptItemsFreebiePackageTable.Rows)
                    {
                        TblCreditPackage p = new TblCreditPackage();
                        p.StrCreditPackageCode = r["strPackageCode"].ToString();
                        p.SelectOne();

                        if (p.StrDescription.ToString() != "Null")
                        {
                            DataRow rowToAdd = freeMemberCreditPackageTable.NewRow();

                            ACMSLogic.MemberPackage.InitMemberCreditPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID,
                                r["strPackageCode"].ToString(), r["strPromotionCode"].ToString(), true);

                            // Add to freeMemberPackageTable and will save
                            freeMemberCreditPackageTable.Rows.Add(rowToAdd);
                        }
                        else
                        {
                            DataRow rowToAdd = freeMemberPackageTable.NewRow();
                            // Kean Yiap
                            if (pos.NCategoryID == 34)
                            {
                                MemberPackage.InitMemberPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID, r["strPackageCode"].ToString(), "",
                                    true, -1, pos.dtPackageStart, pos.NProrateDays);
                            }
                            else
                            {
                                ACMSLogic.MemberPackage.InitMemberPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID,
                                    r["strPackageCode"].ToString(), r["strPromotionCode"].ToString(), true);
                            }
                            // Add to freeMemberPackageTable and will save
                            freeMemberPackageTable.Rows.Add(rowToAdd);
                        }
                    }
                }

                if (pos.ReceiptItemsFreebieProductTable.Rows.Count > 0)
                {
                    //					Update product
                    TblReceiptFreebie receiptFreebie = new TblReceiptFreebie();
                    receiptFreebie.MainConnectionProvider = connProvider;
                    DataTable receiptItemsFreebieProductTable = pos.ReceiptFreebieTable.Clone(); // i have to use this structure bcoz i wan to save to this table;

                    foreach (DataRow r in pos.ReceiptItemsFreebieProductTable.Rows)
                    {
                        DataRow rowToAdd = receiptItemsFreebieProductTable.NewRow();
                        rowToAdd["strReceiptNo"] = pos.StrReceiptNo;
                        rowToAdd["strItemCode"] = r["strProductCode"];
                        rowToAdd["strPromotionCode"] = r["strPromotionCode"];

                        DataRow[] tempRows = savedReceiptEntriesTable.Select("nTempEntryID = " + r["nEntryID"].ToString(),
                            "", DataViewRowState.CurrentRows);

                        if (tempRows.Length > 0)
                            rowToAdd["nEntryID"] = tempRows[0]["nEntryID"];

                        receiptItemsFreebieProductTable.Rows.Add(rowToAdd);
                    }

                    receiptFreebie.SaveData(receiptItemsFreebieProductTable);

                    //TblProductInventory proInven = new TblProductInventory();
                    //proInven.MainConnectionProvider = connProvider;

                    //foreach (DataRow r in receiptItemsFreebieProductTable.Rows)
                    //{
                    //    proInven.IncreaseQuantity(r["strItemCode"].ToString(), pos.StrBranchCode, -1);
                    //}
                }

                if (freeMemberPackageTable.Rows.Count > 0)
                {
                    // update the member package to database
                    TblMemberPackage memberPackage = new TblMemberPackage();
                    memberPackage.MainConnectionProvider = connProvider;
                    memberPackage.SaveData(freeMemberPackageTable);
                }

                if (freeMemberCreditPackageTable.Rows.Count > 0)
                {
                    // update the member package to database
                    TblMemberCreditPackage memberPackage = new TblMemberCreditPackage();
                    memberPackage.MainConnectionProvider = connProvider;
                    memberPackage.SaveData(freeMemberCreditPackageTable);
                }

            //part 2
                DeleteUselessIPP(connProvider, pos);
                UpdateRegistrationFee(connProvider, pos);
                UpdateOldPackSetDeactivate(connProvider, pos); //Update when upgrade
                PostToMemberCreditPackage(connProvider, pos);
                PostToMemberPackage(connProvider, pos);
                UpdateUsedCashVoucher(connProvider, pos);

                int ParentCategoryID = pos.NCategoryID;

                if (pos.NCategoryID == 10)
                {
                    ParentCategoryID = UpgradePackage(connProvider, pos);
                    if (ParentCategoryID == 10)
                    {
                        ParentCategoryID = UpgradeCreditPackage(connProvider, pos);
                    }
                }

                TopUpCreditPackage(connProvider, pos);
                TopUpSingleTreatmentTransaction(connProvider, pos);
                MakeDeposit(connProvider, pos);

                CashVoucherTransaction(connProvider, pos);
                LockerTransaction(connProvider, pos);
                ForgetCardTransaction(connProvider, pos);
                ReplaceMembershipCardTransaction(connProvider, pos);
                //MineralWaterTransaction(connProvider, pos);
                TblRewards rewardcode = new TblRewards();
                ACMSDAL.TblCategory category = new ACMSDAL.TblCategory();
                category.NCategoryID = pos.NCategoryID;
                category.SelectOne();
                int SalesCategory = ACMS.Convert.ToInt32(category.NSalesCategoryID);

                //Derek Instalment Plan - Here it assigned the Category to the Pay O/S Receipt Record
                if (pos.NCategoryID == 0)
                {
                    ParentCategoryID = PayOutstanding(connProvider, pos);
                    pos.StrRewardsCode = rewardcode.SelectRewards(ParentCategoryID, pos.StrBranchCode);
                }
                else
                    pos.StrRewardsCode = rewardcode.SelectRewards(pos.NCategoryID, pos.StrBranchCode);

                if (pos.StrRewardsCode.HasValue && pos.StrRewardsCode.ToString() != "" && pos.StrRewardsCode.ToString() != "Null")
                {
                    TblRewards rewards = new TblRewards();
                    rewards.StrRewardsCode = pos.StrRewardsCode.ToString();
                    rewards.SelectOne();

                    double dRewardPoint = 0;

                    double dRewardPercent = (rewards.DRewardsPercent.IsNull ? 0 : rewards.DRewardsPercent.Value);
                    double dRewardValue = (rewards.DRewardsValue.IsNull ? 0 : rewards.DRewardsValue.Value);

                    //jackie 23 others give 50% GIRO
                    //if (ParentCategoryID == 23 && pos.MNettAmount > 60)//pos.MNettAmount
                    //{
                    //    dRewardPercent = 50;

                    //}

                    if (dRewardPercent > 0 && dRewardValue == 0)
                    {
                        decimal mnettTotal = 0;

                        if (pos.MOutstandingAmount > 0)
                        {
                            mnettTotal = pos.MNettAmount - (pos.MOutstandingAmount - pos.MGSTAmount);
                        }
                        else
                        {
                            mnettTotal = pos.MNettAmount;
                        }

                        dRewardPoint = ((double)mnettTotal) * dRewardPercent / 100;
                    }
                    else
                    {
                        if (pos.NCategoryID == 0)
                        {
                            dRewardPoint = dRewardValue;
                        }
                    }
                    if (pos.NThisMonthBirthday == 1)
                    {
                        DialogResult result1 = MessageBox.Show("Member is having birthday this months. Do you want to give double point?", "Warning",
                        MessageBoxButtons.YesNo);

                        if (result1 == DialogResult.Yes)
                            dRewardPoint *= 2;
                    }

                    TblRewardsTransaction rewardTran = new TblRewardsTransaction();
                    rewardTran.MainConnectionProvider = connProvider;
                    if (pos.NCategoryID == 20)
                    {
                        rewardTran.StrMembershipID = pos.StrNewMembershipID;
                    }
                    else
                    {
                        rewardTran.StrMembershipID = pos.StrMembershipID;
                    }
                    rewardTran.DtDate = pos.DtDate;
                    rewardTran.NTypeID = 1;
                    rewardTran.NEmployeeID = pos.NCashierID;
                    rewardTran.DRewardsPoints = dRewardPoint;
                    rewardTran.StrReferenceNo = pos.StrReceiptNo;
                    if (dRewardPoint > 0) // rewards point > 0 then insert records //3004
                    {
                        rewardTran.Insert();
                    }
                }

                if (pos.StrRewardsCode.ToString() == "Null") pos.StrRewardsCode = "";

                DataTable QtyTable = receiptEntries.Get_StrCodeReceiptNo(pos.StrReceiptNo);
                //check is the receipt fully paid
                string Nett = pos.MNettAmount.ToString();
                string Outstanding = pos.MOutstandingAmount.ToString();

                //if (pos.MOutstandingAmount == 0 && (pos.NCategoryID == 11 || pos.NCategoryID == 12))
                //    PostToStock(connProvider, QtyTable, pos);

                receiptTable = pos.ReceiptMasterTable.Copy();
                int PosCategory = ACMS.Convert.ToInt32(receiptTable.Rows[0]["nCategoryID"]);
                if (PosCategory == 24)
                {
                    receiptTable.Rows[0]["fDeposit"] = true;
                    receipt.SaveData(receiptTable);
                }

                if (pos.StrBillReferenceNo != "")
                {
                    receiptTable.Rows[0]["strBillReferenceNo"] = pos.StrBillReferenceNo;
                    receipt.SaveData(receiptTable);
                }

                if (pos.NCategoryID == 0 || pos.NCategoryID == 10)
                {
                    receipt.StrReceiptNo = pos.StrReceiptNo;
                    receipt.SelectOne();
                    receipt.MOutstandingAmount = Convert.ToDecimal(pos.MOutstandingAmount);
                    receipt.NCategoryID = ParentCategoryID;
                    receipt.Update();
                    //TblReceipt receipt3 = new TblReceipt();
                    //receipt3.StrReceiptNo = pos.StrReceiptNo;
                    //receipt3.SelectOne();
                    //receipt3.MOutstandingAmount = Convert.ToDecimal(pos.MOutstandingAmount);
                    //receipt3.NCategoryID = ParentCategoryID;
                    //receipt3.Update();
                }

                if (pos.StrDeposit != "")
                {
                    receipt.StrReceiptNo = pos.StrDeposit;
                    DataTable tblDeposit = receipt.SelectOne();
                    if (tblDeposit.Rows.Count > 0)
                    {
                        receipt.FDeposit = false;
                        receipt.Update();

                    }
                    else
                    {
                        TblMemberPackage ConvertedPackage = new TblMemberPackage();
                        ConvertedPackage.NPackageID = ACMS.Convert.ToSqlInt32(pos.StrDeposit);
                        ConvertedPackage.NStatusID = 1;
                        ConvertedPackage.UpdateConvertedPackageStatus();
                    }
                }

                if (pos.ReceiptItemsTable.Select("", "", DataViewRowState.ModifiedCurrent).Length > 0)
                {
                    receiptEntriesTable = pos.ReceiptItemsTable.Copy();
                    receipt.SaveData(receiptEntriesTable);
                }
                //1503
                branchReceiptNoTable.Rows[0]["nReceiptNo"] = latestReceiptNo;

                SaveUpToDateReceiptNo(connProvider, branchReceiptNoTable);
                connProvider.CommitTransaction();

                if (pos.StrDeposit != "")
                {
                    TblReceipt receipt2 = new TblReceipt();
                    receipt2.StrReceiptNo = pos.StrDeposit;
                    receipt2.SelectOne();
                    receipt2.StrChildReceiptNo = receiptNo;
                    receipt2.Update();
                }
                return true;

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();

                }
            }
        }
Esempio n. 10
0
        public bool UpdateMember(string strMembershipID, 
                                    object dateDob, 
                                    bool fAirCrew, 
                                    bool fBoundCheck, 
                                    bool fEmail, 
			                        bool fGiroFailed, 
                                    bool fPostalMail, 
                                    bool fSingaporean, 
                                    bool fSMS, 
                                    int nLoyaltyStatusID, 
                                    string strAdd1, 
                                    string strAdd2, 
			                        string strAltEmail, 
                                    string strCardName, 
                                    string strCompany, 
                                    string strCreditCardNo, 
                                    string strEmail, 
			                        string strEmergencyContactNo, 
                                    string strEmergencyContactPerson, 
                                    string strHomeNo, 
                                    string strMemberName, 
			                        string strMobileNo, 
                                    string strNIRCFIN, 
                                    string strOccupation, 
                                    string strOfficeNo, 
                                    string strPagerNo, 
			                        string strPostalCode, 
                                    string strRemark, 
                                    int nMediaSourceID, 
                                    string strMediaSource, 
                                    string strBeforePhoto,
			                        string strAfterPhoto, 
                                    byte[] imgPhoto, 
                                    User aUser, 
                                    bool fFemale,
                                    bool fPhoneCall,
                                    string strSecurityQuestion,
                                    string strSecurityAnswer,
                                    string strMobileAppPwd)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember sqlMember = new TblMember();
            TblAudit sqlAudit = new TblAudit();

            bool isSuccess = false;

            try
            {
                sqlMember.MainConnectionProvider = connProvider;
                sqlAudit.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("UpdateMemberRecord");

                sqlMember.StrMembershipID = strMembershipID;
                sqlMember.FFemale = fFemale;
                sqlMember.FAirCrew = fAirCrew;
                sqlMember.FBounceCheck = fBoundCheck;
                sqlMember.FEmail = fEmail;
                sqlMember.FGIROFailed = fGiroFailed;
                sqlMember.FPostalMail = fPostalMail;
                sqlMember.FSingaporean = fSingaporean;
                sqlMember.FSMS = fSMS;
                sqlMember.FPhoneCall = fPhoneCall;

                if (nLoyaltyStatusID != 0)
                {
                    sqlMember.NLoyaltyStatusID = nLoyaltyStatusID;
                }

                sqlMember.StrAddress1 = strAdd1;
                sqlMember.StrAddress2 = strAdd2;
                sqlMember.StrAltEmail = strAltEmail;
                sqlMember.StrCardName = strCardName;
                sqlMember.StrCompany = strCompany;
                sqlMember.StrCreditCardNo = strCreditCardNo;
                sqlMember.StrEmail = strEmail;
                sqlMember.StrEmergencyContactNumber = strEmergencyContactNo;
                sqlMember.StrEmergencyContactPerson = strEmergencyContactPerson;
                sqlMember.StrHomeNo = strHomeNo;
                sqlMember.StrMemberName = strMemberName;
                sqlMember.StrMobileNo = strMobileNo;
                sqlMember.StrNRICFIN = strNIRCFIN;
                sqlMember.StrOccupation = strOccupation;
                sqlMember.StrOfficeNo = strOfficeNo;
                sqlMember.StrPagerNo = strPagerNo;
                sqlMember.StrPostalCode = strPostalCode;
                sqlMember.StrRemarks = strRemark;
                sqlMember.NMediaSourceID = nMediaSourceID;
                sqlMember.StrMediaSource = strMediaSource;
                sqlMember.NEmployeeID = aUser.NEmployeeID();
                sqlMember.StrSecurityQuestion = strSecurityQuestion;
                sqlMember.StrSecurityAnswer = strSecurityAnswer;
                sqlMember.StrPassword = strMobileAppPwd;

                sqlMember.Update2(dateDob, strBeforePhoto, strAfterPhoto, imgPhoto);

                sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberRecord;
                sqlAudit.NEmployeeID = aUser.NEmployeeID();
                sqlAudit.StrAuditEntry = "Update member " +strMembershipID;
                sqlAudit.StrReference = strMembershipID;
                sqlAudit.DtDate = DateTime.Now;
                sqlAudit.Insert();

                connProvider.CommitTransaction();
                isSuccess = true;

            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("UpdateMemberRecord");
                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();
                }
                sqlMember.Dispose();
                sqlAudit.Dispose();
            }
            return isSuccess;
        }
Esempio n. 11
0
        public static bool BlockMembershipID(int numberOfNonMemberID, int numberOfMemberID, string strBranchCode)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblCompany sqlCompany = new TblCompany();
            TblBranch sqlBranch = new TblBranch();

            try
            {
                sqlCompany.MainConnectionProvider = connProvider;
                sqlBranch.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("BlockMembershipID");

                if (numberOfNonMemberID > 0)
                    sqlCompany.UpdateBlockNonMembershipID(numberOfNonMemberID);
                if (numberOfMemberID > 0)
                    sqlBranch.UpdateBlockMembershipID(strBranchCode, numberOfMemberID);

                connProvider.CommitTransaction();
                return true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("BlockMembershipID");
                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();
                }
                sqlCompany.Dispose();
                sqlBranch.Dispose();
            }
        }
Esempio n. 12
0
        public bool UpdateCardStatus(string strMembershipID, User aUser, CardStatusType myType, int nRequestID, 
			string strBranchCode)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember sqlMember = new TblMember();
            TblCardRequest sqlCardRequest = new TblCardRequest();
            TblAudit sqlAudit = new TblAudit();

            bool isSuccess = false;
            try
            {
                sqlMember.MainConnectionProvider = connProvider;
                sqlCardRequest.MainConnectionProvider = connProvider;
                sqlAudit.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("ChangeCardStatus");

                if (CardStatusType.RequestPrint == myType)
                    sqlMember.UpdateCardStatus(strMembershipID, (int)myType, "HQ");
                else
                    sqlMember.UpdateCardStatus(strMembershipID, (int)myType, strBranchCode);
                sqlCardRequest.NEmployeeID = aUser.NEmployeeID();
                sqlCardRequest.NRequestID = nRequestID;
                sqlCardRequest.NStatusID = (int)myType;
                sqlCardRequest.StrBranchCode = strBranchCode;
                sqlCardRequest.StrMembershipID = strMembershipID;
                sqlCardRequest.DtLastEditDate = DateTime.Now;
                sqlCardRequest.Update();

                sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberCard;
                sqlAudit.NEmployeeID = aUser.NEmployeeID();
                sqlAudit.StrAuditEntry = "Update member card to " +myType.ToString() +".";
                sqlAudit.StrReference = strMembershipID;
                sqlAudit.DtDate = DateTime.Now;
                sqlAudit.Insert();

                connProvider.CommitTransaction();
                isSuccess = true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("ChangeCardStatus");
                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();
                }
                sqlMember.Dispose();
                sqlCardRequest.Dispose();
                sqlAudit.Dispose();
            }
            return isSuccess;
        }
Esempio n. 13
0
        //2006
        // public DataTable SaveIntroduceFriendNew(string strMembershipID, string strIntroducerID, string strPackage, string strRemark, int employeeID)
        public bool SaveIntroduceFriendNew(string strMembershipID, string strIntroducerID, string strPackage, string strRemark, int employeeID,int nPackageID)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember sqlMember = new TblMember();
            TblMemberPackage sqlMemberPackage = new TblMemberPackage();
            TblPackage sqlPackage = new TblPackage();
            try
            {

                sqlMember.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("SaveIntroduceFriend");

              //  sqlMember.UpdateIntroducerMembershipID(strMembershipID, strIntroducerID);
                sqlMember.UpdateIntroducerMembershipID(strIntroducerID, strMembershipID);
                MemberPackage.CreateFreeMemberSpaPackage_IntroFriend(strMembershipID, strPackage, strRemark, ref nPackageID);
               // MemberPackage.CreateFreeMemberSpaPackage_IntroFriend(strIntroducerID, strPackage, strRemark, ref nPackageID);

                connProvider.CommitTransaction();
                return true;
            }
            catch (Exception ex)
            {
                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();
                }
                sqlPackage.Dispose();
                sqlMember.Dispose();
            }
        }
Esempio n. 14
0
        //Amended by TBBC on 22 September 2015 for Intro friend package.
        public bool SaveIntroduceFriendforPackage(string strMembershipID, string strIntroducerID, string strPromotionCode, int employeeID)
        {
            bool bolReturn = false;
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember sqlMember = new TblMember();
            try
            {
                sqlMember.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("SaveIntroduceFriendforPackage");

                //sqlMember.UpdateIntroducerMembershipID(strMembershipID, strIntroducerID);
                DataTable IntroFriendFreebieTable = sqlMember.AddIntroFriendPackage(strIntroducerID, "INTRO " + strMembershipID, strPromotionCode, employeeID);

                //if (IntroFriendFreebieTable.Rows.Count > 0)
                //{
                //    bolReturn = true;
                //}
                connProvider.CommitTransaction();
                return true;
            }
            catch (Exception ex)
            {
                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();
            }
        }
Esempio n. 15
0
        public bool Cancel(int NPackageID)
        {
            myMemberPackage.NPackageID = NPackageID;
            myMemberPackage.SelectOne();
            myMemberPackage.NStatusID = 2;// 2 represent cancel
            myAudit.DtDate = DateTime.Today;
            myAudit.NAuditTypeID = 0;
            myAudit.NEmployeeID = ACMSLogic.User.EmployeeID;
            myAudit.StrAuditEntry = "Cancel Member Package " + NPackageID.ToString();
            myAudit.StrReference = NPackageID.ToString();

            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try
            {

                myMemberPackage.MainConnectionProvider = connProvider;
                myAudit.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("CancelMemberPackage");

                myMemberPackage.Update();
                myAudit.Insert();

                connProvider.CommitTransaction();
                return true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("CancelMemberPackage");
                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();
                }
                myMemberPackage.MainConnactionIsCreatedLocal = true;
                myAudit.MainConnactionIsCreatedLocal = true;
            }
        }
Esempio n. 16
0
        public void DeleteLastExtensionHistory(int nPackageID, int last_nExtensionID)
        {
            myMemberPackage.NPackageID = nPackageID;
            myMemberPackage.SelectOne();

            TblPackageExtension packageExt = new TblPackageExtension();
            packageExt.NPackageID = nPackageID;
            DataTable packageExtTable = packageExt.SelectAllWnPackageIDLogic();

            if (packageExtTable == null)
                throw new Exception("This extension row has been deleted by others");
            if (packageExtTable.Rows.Count == 0)
                throw new Exception("This extension row has been deleted by others");

            if (packageExtTable.Rows.Count > 0)
            {
                DataRow [] rowList = packageExtTable.Select(" nStatusID = 0 AND nExtensionID > " + last_nExtensionID.ToString());
                if (rowList.Length > 0) // mean is not last package extension
                {
                    throw new Exception("Only the most recent package extension can be deleted.");
                }
            }

            DataRow[] deletedDataRowList = packageExtTable.Select("nStatusID = 0 and nExtensionID = " + last_nExtensionID, "nExtensionID", DataViewRowState.CurrentRows);
            if (deletedDataRowList.Length == 0)
                throw new Exception("This extension row has been deleted by others");
            //deletedDataRowList should be one row
            deletedDataRowList[0]["nStatusID"] = 1;
            TimeSpan durationToReverse = TimeSpan.FromDays((double) ACMS.Convert.ToInt32(deletedDataRowList[0]["nDaysExtended"]));

            DataRow[] tempDataRowList = packageExtTable.Select("nStatusID = 0", "nExtensionID", DataViewRowState.CurrentRows);
            // now need to use the last row's info to calculate the expriry date.
            // but if there is the only row in extension package for this member package, i have to use other info to calculate the expiry date for this memberpackage

            myMemberPackage.DtExpiryDate = myMemberPackage.DtExpiryDate.Value.Subtract(durationToReverse);

            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try
            {
                myMemberPackage.MainConnectionProvider = connProvider;
                packageExt.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("SaveExtension");
                myMemberPackage.Update();
                packageExt.SaveData(packageExtTable);
                connProvider.CommitTransaction();
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("SaveExtension");
                throw new Exception("Failed to Create New Extension");
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
             		{
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();
                }
                myMemberPackage.MainConnactionIsCreatedLocal = true;
                packageExt.MainConnactionIsCreatedLocal = true;
            }
        }
Esempio n. 17
0
        public bool ForfeitBooking(int nSessionID)
        {
            myServiceSession.NSessionID = nSessionID;
            myServiceSession.SelectOne();

            myServiceSession.NStatusID = 6;
            myServiceSession.DtLastEditDate = DateTime.Now;
            myServiceSession.NEmployeeID = ACMSLogic.User.EmployeeID;

            TblAudit audit = new TblAudit();
            audit.DtDate = DateTime.Today;
            audit.NAuditTypeID = AuditTypeID.Service;
            audit.NEmployeeID = ACMSLogic.User.EmployeeID;
            audit.StrAuditEntry = "Cancel Booking " + nSessionID.ToString();
            audit.StrReference = nSessionID.ToString();

            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try
            {

                myServiceSession.MainConnectionProvider = connProvider;
                audit.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("ForfeitBooking");
                myServiceSession.Update();
                audit.Insert();
                connProvider.CommitTransaction();
                return true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("ForfeitBooking");
                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();
                }
                myServiceSession.MainConnactionIsCreatedLocal = true;
                audit.MainConnactionIsCreatedLocal = true;
            }
        }
Esempio n. 18
0
        public DataTable SaveIntroduceFriend(string strMembershipID, string strIntroducerID, string Freebie, string strBranchCode,int employeeID)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember sqlMember = new TblMember();
            try
            {
            sqlMember.MainConnectionProvider = connProvider;
            connProvider.OpenConnection();
            connProvider.BeginTransaction("SaveIntroduceFriend");

            sqlMember.UpdateIntroducerMembershipID(strMembershipID, strIntroducerID);
            DataTable IntroFriendFreebieTable =sqlMember.AddIntroFriendFreebie(strMembershipID,strIntroducerID,Freebie,strBranchCode,employeeID);

            connProvider.CommitTransaction();
            return IntroFriendFreebieTable;
            }
            catch (Exception ex)
            {
                    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();
            }
        }
Esempio n. 19
0
        public void DeleteLastCreditPackageExtensionHistory(int nCreditPackageID, int last_nExtensionID, string CurrentMembershipID)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            TblMemberCreditPackage myMemberCreditPackage = new TblMemberCreditPackage();
            TblCreditPackageExtension myCreditPackageExtension = new TblCreditPackageExtension();

            myMemberCreditPackage.MainConnectionProvider = connProvider;
            myCreditPackageExtension.MainConnectionProvider = connProvider;

            connProvider.OpenConnection();
            connProvider.BeginTransaction("SaveCreditPackageExtension");

            myCreditPackageExtension.NCreditPackageID = nCreditPackageID;

            DataTable tblCreditPackageExtension = myCreditPackageExtension.SelectAllWnCreditPackageIDLogic();

            if (tblCreditPackageExtension == null)
            {
                throw new Exception("This extension row has been deleted by others");
            }
            else if (tblCreditPackageExtension.Rows.Count == 0)
            {
                throw new Exception("This extension row has been deleted by others");
            }

            if (tblCreditPackageExtension.Rows.Count > 0)
            {
                DataRow[] rowList = tblCreditPackageExtension.Select(" nStatusID = 0 AND nExtensionID > " + last_nExtensionID.ToString());

                if (rowList.Length > 0) // mean is not last package extension
                {
                    throw new Exception("Only the most recent package extension can be deleted.");
                }
            }

            DataRow[] deletedDataRowList = tblCreditPackageExtension.Select("nStatusID = 0 and nExtensionID = " + last_nExtensionID, "nExtensionID", DataViewRowState.CurrentRows);

            if (deletedDataRowList.Length == 0)
            {
                throw new Exception("This extension row has been deleted by others");
            }

            DateTime dtOldExpiry = Convert.ToDateTime(deletedDataRowList[0]["dtOldExpiry"]);

            int nCreditPackageStatusID = -1;

            if (DateTime.Compare(dtOldExpiry, DateTime.Now) < 0)
            {
                nCreditPackageStatusID = 1;
            }

            try
            {
                //Update Credit Package Extension set nStatusID = 1 => Deleted
                myCreditPackageExtension.MemberCreditPackage_ExtensionDelete(nCreditPackageID, last_nExtensionID);

                //Update Member Credit Package Expiry Date; nStatusID = 1 If Expired
                myMemberCreditPackage.MemberCreditPackage_ExtensionUpdate(nCreditPackageID, nCreditPackageStatusID, dtOldExpiry, CurrentMembershipID);

                connProvider.CommitTransaction();
            }
            catch (Exception)
            {
                             connProvider.RollbackTransaction("SaveCreditPackageExtension");
                throw new Exception("Failed to Create New Extension");
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                {
                    connProvider.CurrentTransaction.Dispose();
                }

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

                myMemberCreditPackage.MainConnactionIsCreatedLocal = true;
                myCreditPackageExtension.MainConnactionIsCreatedLocal = true;
            }
        }
Esempio n. 20
0
        public bool VerifyIntructor(int nClassInstanceIDToBeVerified, int verifyUserID,string verifyUserPassword,
			int nStandingIntructorID, string remark)
        {
            TblEmployee verifyUser = new TblEmployee();

            verifyUser.NEmployeeID = verifyUserID;

            verifyUser.SelectOne();

            int [,] intArray = new int[50,2];

            int ArrayNo=1;

            if (verifyUser.StrPassword.Value != verifyUserPassword)

                return false;

            myClassInstance.NClassInstanceID = nClassInstanceIDToBeVerified;

            myClassInstance.SelectOne();

            if (myClassInstance.NActualInstructorID.IsNull)

                throw new Exception("Missing Intructor login info");

            if (myClassInstance.NActualInstructorID.Value == verifyUserID)

                throw new Exception("Instructor are not allowed to verfiy for the same class.");

            if (!myClassInstance.NVerifyID.IsNull)

                throw new Exception("This class have been verify by other staff with the employee ID : "+  myClassInstance.NVerifyID.Value.ToString());

            bool isLate =false;

            DateTime StartTime;

            DateTime LoginTime;

            myClassInstance.MInstructorDeduction=0;

            StartTime=ACMS.Convert.ToDBDateTime(myClassInstance.DtStartTime.Value.ToLongTimeString());

            LoginTime=ACMS.Convert.ToDBDateTime(myClassInstance.DtInstructorLogin.Value.ToLongTimeString());

            if (DateTime.Compare(LoginTime,StartTime)>0)

            {

                isLate=true;

            }

            bool haveStandingIntructor = nStandingIntructorID > 0;

            if (haveStandingIntructor)

                myClassInstance.NStandinInstructorID = nStandingIntructorID;

            if (isLate)

            {

                TblCompany company = new TblCompany();

                DataTable companyTable = company.SelectAll();

                decimal instructorLateDeductionFee = 0;

                if (companyTable.Rows.Count > 0)

                {

                    instructorLateDeductionFee =  ACMS.Convert.ToDecimal(companyTable.Rows[0]["mInstructorLateDeductionFee"]);

                }

                myClassInstance.MInstructorDeduction=instructorLateDeductionFee;

                if (nStandingIntructorID != 0)

                    myClassInstance.MStandinInstructorFees = instructorLateDeductionFee;

            }

            int nCommissionTypeID = myClassInstance.NCommissionTypeID.Value;

            TblEmployee actualInstructor = new TblEmployee();

            actualInstructor.NEmployeeID = myClassInstance.NActualInstructorID;

            actualInstructor.SelectOne();

            int nInstructorTypeID = ACMS.Convert.ToInt32(actualInstructor.NInstructorTypeID);

            myClassInstance.MInstructorFees = (GetCommission(nCommissionTypeID, nInstructorTypeID) - myClassInstance.MInstructorDeduction);

            TblClassAttendance classAttendance = new TblClassAttendance();

            classAttendance.NClassInstanceID = nClassInstanceIDToBeVerified;

            DataTable classAttendanceTable = classAttendance.SelectAllWnClassInstanceIDLogic();

            DataRow[] classAttendanceRowList = null;

            if (classAttendanceTable != null && classAttendanceTable.Rows.Count > 0)

            {

                classAttendanceRowList = classAttendanceTable.Select("nStatusID = 0", "nAttendanceID", DataViewRowState.CurrentRows);

                foreach (DataRow r in classAttendanceRowList)

                {

                    r["nStatusID"] = 2;
                    r["nTypeID"]=0;

                }

            }

            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try

            {

                myClassInstance.MainConnectionProvider = connProvider;

                classAttendance.MainConnectionProvider = connProvider;

                connProvider.OpenConnection();

                connProvider.BeginTransaction("VerifyClassInstance");

                myClassInstance.NVerifyID = verifyUserID;

                myClassInstance.StrRemarks = remark;

                myClassInstance.Update();

                classAttendance.SaveData(classAttendanceTable);

                TblMemberPackage sqlMemberPackage = new TblMemberPackage();

                sqlMemberPackage.MainConnectionProvider = connProvider;

                if (classAttendanceRowList != null)

                {

                    int nPackageID = -1;

                    foreach (DataRow r in classAttendanceRowList)

                    {

                        nPackageID = ACMS.Convert.ToInt32(r["nPackageID"]);

                        int nAttendanceID=ACMS.Convert.ToInt32(r["nAttendanceID"]);

                        DataTable memberPackageTable = sqlMemberPackage.GetMemberPackage(nPackageID);

                        if (memberPackageTable.Rows[0]["strPackageCode"].ToString() != "Unlinked")

                        {

                            #region test

                            //MemberPackage.CalculateMemberPackageBalance(memberPackageTable, connProvider);

                            if (ACMS.Convert.ToInt32(memberPackageTable.Rows[0]["Balance"]) > 0)

                            {

                                DateTime classDate = myClassInstance.DtDate.IsNull ? DateTime.Today.Date : myClassInstance.DtDate.Value;

                                DataRow masterRow = memberPackageTable.Rows[0];// Means new class Attendance gonna insert

                                if (masterRow["dtStartDate"] == DBNull.Value &&

                                    masterRow["dtExpiryDate"] == DBNull.Value)

                                {

                                    TblPackage package = new TblPackage();

                                    package.StrPackageCode = masterRow["strPackageCode"].ToString();

                                    package.SelectOne();

                                    if (package.NPackageDuration == 0 && package.NPackageDay > 0)
                                    {
                                        masterRow["dtStartDate"] = classDate;
                                        masterRow["dtExpiryDate"] = classDate.AddDays(package.NPackageDay.Value -1);
                                    }
                                    else
                                    {
                                        masterRow["dtStartDate"] = classDate;
                                        masterRow["dtExpiryDate"] = classDate.AddMonths(package.NPackageDuration.Value).AddDays(-1);
                                    }

                                }

                                else

                                {

                                    DateTime memberPackageStartDate =  ACMS.Convert.ToDateTime(masterRow["DtStartDate"]);

                                    DateTime memberPackageExpiryDate = ACMS.Convert.ToDateTime(masterRow["dtExpiryDate"]);

                                    if (memberPackageStartDate > classDate)

                                    {

                                        masterRow["dtExpiryDate"] = memberPackageExpiryDate.Subtract(memberPackageStartDate.Subtract(classDate));

                                    }

                                }

                            }

                            else if (ACMS.Convert.ToInt32(memberPackageTable.Rows[0]["Balance"]) <=0)

                            {

                                intArray[ArrayNo,0]=nPackageID;

                                intArray[ArrayNo,1]=nAttendanceID;

                                ArrayNo=ArrayNo+1;

                                MessageBox.Show("Package Balance of " + memberPackageTable.Rows[0]["strMembershipID"].ToString().TrimEnd() + " is Zero. Attendance will be cancel");

                            }

                            #endregion

                        }

                        if (ACMS.Convert.ToInt32(memberPackageTable.Rows[0]["nMaxSession"]) == 9999 && memberPackageTable.Rows[0]["fGIRO"].ToString() != "1")
                        {

                            DateTime dtExpiryDate = ACMS.Convert.ToDateTime(memberPackageTable.Rows[0]["dtExpiryDate"]);

                            DateTime dtStartDate = ACMS.Convert.ToDateTime(memberPackageTable.Rows[0]["dtStartDate"]);

                            if (dtExpiryDate != DateTime.MinValue)

                            {

                                memberPackageTable.Rows[0]["dtExpiryDate"] = dtExpiryDate.AddDays(-1);

                            }

                        }

                        sqlMemberPackage.SaveData(memberPackageTable);

                    }

                }

                connProvider.CommitTransaction();

            }

            catch (Exception)

            {

                connProvider.RollbackTransaction("VerifyClassInstance");

                throw;

            }

            finally

            {

                if (connProvider.CurrentTransaction != null)

                    connProvider.CurrentTransaction.Dispose();

                if (connProvider.DBConnection != null)

                {

                    if (connProvider.DBConnection.State == ConnectionState.Open)

                        connProvider.DBConnection.Close();

                }

                myClassInstance.MainConnactionIsCreatedLocal = true;

                classAttendance.MainConnactionIsCreatedLocal = true;

            }

            for (int j=1;j<=50;j++)

            {

                if (intArray[j,0]>0) DeleteClassAttendance(intArray[j,0],intArray[j,1],"");

                else if (intArray[j,0]<=0)

                {return true;}

            }

            return true;
        }
Esempio n. 21
0
        public void TransferMemberCreditPackage(int nCreditPackageID, string newStrMemberShipID, string remark)
        {
            myCreditPkg.NCreditPackageID = nCreditPackageID;
            myCreditPkg.SelectOne();
            myCreditPkg.StrRemarks = remark;
            TblAudit audit = new TblAudit();
            audit.NAuditTypeID = AuditTypeID.TransferMemberCreditPackage;
            audit.NEmployeeID = User.EmployeeID;
            audit.DtDate = DateTime.Now;
            audit.StrReference= nCreditPackageID.ToString();
            audit.StrAuditEntry= "Old Owner : " + myCreditPkg.StrMembershipID + " New Owner : " + newStrMemberShipID;
            myCreditPkg.StrMembershipID = newStrMemberShipID;

            TblMemberPackage sqlMemberPackage = new TblMemberPackage();

            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try
            {

                myCreditPkg.MainConnectionProvider = connProvider;
                audit.MainConnectionProvider = connProvider;
                sqlMemberPackage.MainConnectionProvider = connProvider;

                sqlMemberPackage.NCreditPackageID = nCreditPackageID;
                DataTable memberPackageTable = sqlMemberPackage.SelectAllWnCreditPackageIDLogic();

                foreach (DataRow row in memberPackageTable.Rows)
                {
                    row["strMembershipID"] = newStrMemberShipID;
                }

                connProvider.OpenConnection();
                connProvider.BeginTransaction("TransferMemberCreditPackage");

                myCreditPkg.Update();
                sqlMemberPackage.SaveData(memberPackageTable);
                audit.Insert();

                connProvider.CommitTransaction();
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("TransferMemberCreditPackage");
                throw;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();
                }
                myCreditPkg.MainConnactionIsCreatedLocal = true;
                audit.MainConnactionIsCreatedLocal = true;
            }
        }
Esempio n. 22
0
        public void ChangeClass(int nClassInstanceID, string strClassCode, string strRemark)
        {
            TblAudit audit = new TblAudit();
            TblClassInstance sqlClassIns = new TblClassInstance();
            TblClass sqlClass = new TblClass();
            TblBranch sqlBranch = new TblBranch();

            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            string oldClassCode = "";
            string oldClassName="";
            string newClassName = "";
            string strBranchName = "";

            try
            {
                sqlClassIns.MainConnectionProvider = connProvider;
                audit.MainConnectionProvider = connProvider;

                connProvider.OpenConnection();
                connProvider.BeginTransaction("ChangeClassInstance");

                sqlClassIns.NClassInstanceID = nClassInstanceID;
                sqlClassIns.SelectOne();
                oldClassCode = sqlClassIns.StrClassCode.Value;
                if (sqlClassIns.DtDate < DateTime.Now.Date)
                    throw new Exception("Only future class can assign new class code");

                sqlClassIns.StrClassCode = strClassCode;
                sqlClassIns.StrRemarks = strRemark;
                sqlClassIns.Update();

                sqlClass.StrClassCode = oldClassCode;
                sqlClass.SelectOne();
                oldClassName = sqlClass.StrDescription.ToString();

                sqlBranch.StrBranchCode = sqlClassIns.StrBranchCode.ToString();
                sqlBranch.SelectOne();
                strBranchName = sqlBranch.StrBranchName.ToString();

                sqlClass.StrClassCode = strClassCode;
                sqlClass.SelectOne();
                newClassName = sqlClass.StrDescription.ToString();

                audit.DtDate = DateTime.Now;
                audit.NAuditTypeID = AuditTypeID.ClassAuditTypeID;
                audit.NEmployeeID = ACMSLogic.User.EmployeeID;
                audit.StrAuditEntry = string.Format("Old Class Code = {0}, " +
                                                    "New Class Code = {1}",
                                                    oldClassCode, strClassCode); // "Change class instance : " + nClassInstanceID.ToString() + " to class code: " + strClassCode;
                audit.StrReference = "Class InstanceID :" + nClassInstanceID.ToString();
                audit.Insert();
                connProvider.CommitTransaction();

                DataTable dtAttendance = new DataTable();
                dtAttendance = GetClassAttendanceReservedAndAttended(nClassInstanceID);

                DialogResult result1 = MessageBox.Show("Push Notification to Mobile app users? ", "Confirm", MessageBoxButtons.YesNo);
                if (result1 == DialogResult.Yes)
                {
                    foreach (DataRow row in dtAttendance.Rows)
                    {
                        string strMsgContent = oldClassName + " at " + strBranchName + " at " + Convert.ToDateTime(row["dtStartTime"]).ToString("h.mmtt") + " on " + Convert.ToDateTime(row["dtStartTime"]).ToString("dd MMM") + " has been changed to " + newClassName + ". Sorry for any inconvenience caused.";
                        PushNotification(row["strMembershipID"].ToString(), strMsgContent);
                    }
                }
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("ChangeClassInstance");
                throw;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();
                }
            }
        }
Esempio n. 23
0
        public bool Delete(int creditPackageID)
        {
            myCreditPkg.NCreditPackageID = creditPackageID;
            myCreditPkg.SelectOne();
            myCreditPkg.NStatusID = 2;
            TblAudit audit = new TblAudit();
            audit.NAuditTypeID = AuditTypeID.DeleteMemberCreditPackage;
            audit.NEmployeeID = User.EmployeeID;
            audit.StrAuditEntry = " Delete member credit Package " + creditPackageID.ToString();
            audit.StrReference = creditPackageID.ToString();

            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try
            {

                myCreditPkg.MainConnectionProvider = connProvider;
                audit.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("DeleteMemberCreditPackage");

                myCreditPkg.Update();
                audit.Insert();

                connProvider.CommitTransaction();
                return true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("DeleteMemberCreditPackage");
                throw;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();
                }
                myCreditPkg.MainConnactionIsCreatedLocal = true;
                audit.MainConnactionIsCreatedLocal = true;
            }
        }
Esempio n. 24
0
        public void DeleteLastCreditPackageExtensionHistory(int nCreditPackageID, int last_nExtensionID, string CurrentMembershipID)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            TblMemberCreditPackage    myMemberCreditPackage    = new TblMemberCreditPackage();
            TblCreditPackageExtension myCreditPackageExtension = new TblCreditPackageExtension();

            myMemberCreditPackage.MainConnectionProvider    = connProvider;
            myCreditPackageExtension.MainConnectionProvider = connProvider;

            connProvider.OpenConnection();
            connProvider.BeginTransaction("SaveCreditPackageExtension");

            myCreditPackageExtension.NCreditPackageID = nCreditPackageID;

            DataTable tblCreditPackageExtension = myCreditPackageExtension.SelectAllWnCreditPackageIDLogic();

            if (tblCreditPackageExtension == null)
            {
                throw new Exception("This extension row has been deleted by others");
            }
            else if (tblCreditPackageExtension.Rows.Count == 0)
            {
                throw new Exception("This extension row has been deleted by others");
            }

            if (tblCreditPackageExtension.Rows.Count > 0)
            {
                DataRow[] rowList = tblCreditPackageExtension.Select(" nStatusID = 0 AND nExtensionID > " + last_nExtensionID.ToString());

                if (rowList.Length > 0) // mean is not last package extension
                {
                    throw new Exception("Only the most recent package extension can be deleted.");
                }
            }

            DataRow[] deletedDataRowList = tblCreditPackageExtension.Select("nStatusID = 0 and nExtensionID = " + last_nExtensionID, "nExtensionID", DataViewRowState.CurrentRows);

            if (deletedDataRowList.Length == 0)
            {
                throw new Exception("This extension row has been deleted by others");
            }

            DateTime dtOldExpiry = Convert.ToDateTime(deletedDataRowList[0]["dtOldExpiry"]);

            int nCreditPackageStatusID = -1;

            if (DateTime.Compare(dtOldExpiry, DateTime.Now) < 0)
            {
                nCreditPackageStatusID = 1;
            }

            try
            {
                //Update Credit Package Extension set nStatusID = 1 => Deleted
                myCreditPackageExtension.MemberCreditPackage_ExtensionDelete(nCreditPackageID, last_nExtensionID);

                //Update Member Credit Package Expiry Date; nStatusID = 1 If Expired
                myMemberCreditPackage.MemberCreditPackage_ExtensionUpdate(nCreditPackageID, nCreditPackageStatusID, dtOldExpiry, CurrentMembershipID);

                connProvider.CommitTransaction();
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("SaveCreditPackageExtension");
                throw new Exception("Failed to Create New Extension");
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                {
                    connProvider.CurrentTransaction.Dispose();
                }

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

                myMemberCreditPackage.MainConnactionIsCreatedLocal    = true;
                myCreditPackageExtension.MainConnactionIsCreatedLocal = true;
            }
        }
Esempio n. 25
0
        public void Refund(string strReceiptNo, string strChequeNo, double mRefundAmount)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try
            {
                // Check Access Right here
                TblReceipt receipt = new TblReceipt();
                receipt.MainConnectionProvider = connProvider;

                connProvider.OpenConnection();
                connProvider.BeginTransaction("Refund");

                receipt.StrReceiptNo = strReceiptNo;
                receipt.SelectOne();

                receipt.FRefund = System.Data.SqlTypes.SqlBoolean.True;
                receipt.StrChequeNo = strChequeNo;
                receipt.MRefundAmount = ACMS.Convert.ToDecimal(mRefundAmount);
                receipt.NChequeUpdateBy = User.EmployeeID;
                receipt.UpdateChequeDetails();

                connProvider.CommitTransaction();
            }
            catch (Exception ex)
            {
                connProvider.RollbackTransaction("Refund");
                throw ex;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();

                }
            }
        }
Esempio n. 26
0
        public bool NewServiceSession(int nPackageID, string strServiceCode, string strMemberShipID, int nEmployeeID,
            string strBranchCode, DateTime dtDate, DateTime startTime, DateTime dtTreatment, string strSignID, int nQuatity, Boolean forfeited,
            int MemberPackageCategoryID, string strSigKey, string strPdfExportPath, ref DataTable dtSessionID, string SsRemark)
        {
            // i will know whether the service session is for PT or not by using strServiceCode and query out the record from tblService.
            // i also can calculate the endTime using the data(nduration) from tblService

            TblService service = new TblService();
            service.StrServiceCode = strServiceCode;
            DataTable table = service.SelectOne();
            if (table == null || table.Rows.Count == 0)
                throw new Exception("The service is not available.");

            int duration = ACMS.Convert.ToInt32(service.NDuration);

            bool isPT = ACMS.Convert.ToInt32(service.NServiceTypeID) == 0;

            DateTime endTime = startTime.AddMinutes((Double)duration);

            TblEmployee Employee = new TblEmployee();
            Employee.NEmployeeID = nEmployeeID;
            DataTable Emptable = Employee.SelectOne();

            if (Emptable.Rows[0]["fPartTime"].ToString() == "True" || ACMSLogic.SpaBooking.TherapistIsAvailableToBook(nEmployeeID, dtDate, startTime, endTime, strBranchCode))
            {

                TblServiceSession serviceSession = new TblServiceSession();
                serviceSession.NPackageID = nPackageID;
                serviceSession.StrMembershipID = strMemberShipID;
                serviceSession.StrServiceCode = strServiceCode;
                serviceSession.NStatusID = 5;
                serviceSession.DtDate = dtDate;
                serviceSession.DtStartTime = startTime;
                serviceSession.DtEndTime = endTime;
                serviceSession.DtLastEditDate = DateTime.Now;
                serviceSession.NEmployeeID = User.EmployeeID;
                serviceSession.NMarkedByID = User.EmployeeID;
                serviceSession.NServiceEmployeeID = nEmployeeID;
                serviceSession.DtTreatment = dtTreatment;
                serviceSession.StrSignID = strSignID;
                serviceSession.StrSigKey = strSigKey;
                serviceSession.StrSigPdfPath = strPdfExportPath;
                serviceSession.StrUtilData = strSigKey;
                serviceSession.StrRemarks = SsRemark;

                if (forfeited == true)
                {
                    serviceSession.StrRemarks = "FORFEITED";
                }

                if (isPT)
                {
                    serviceSession.StrBranchCode = strBranchCode;
                }
                else
                    serviceSession.StrBranchCode = User.BranchCode;

                TblMemberPackage memberPackage = new TblMemberPackage();
                //1309
                memberPackage.NPackageID = nPackageID;
                DataTable memberPackageTable = memberPackage.GetMemberPackage(nPackageID);
                if (memberPackageTable == null || memberPackageTable.Rows.Count == 0)
                    throw new Exception("Failed to create new service session. Member Package with npackageID = " + nPackageID.ToString() + "has been deleted");

                CalculateMemberPackageBalance(strServiceCode, strMemberShipID, memberPackageTable);
                if (ACMS.Convert.ToInt32(memberPackageTable.Rows[0]["Balance"]) == 0 || ACMS.Convert.ToInt32(memberPackageTable.Rows[0]["Balance"]) - nQuatity < 0)
                    throw new Exception("The balance of this member's package is zero.");

                // Kean Yiap
                DataRow masterRow = memberPackageTable.Rows[0];
                if (masterRow["dtStartDate"] == DBNull.Value &&
                    masterRow["dtExpiryDate"] == DBNull.Value)
                {
                    // Means new service session gonna insert
                    TblPackage package = new TblPackage();
                    package.StrPackageCode = masterRow["strPackageCode"].ToString();
                    package.SelectOne();
                    masterRow["dtStartDate"] = dtDate;
                    masterRow["dtExpiryDate"] = dtDate.AddMonths(package.NPackageDuration.Value).AddDays(-1);
                }
                else
                {
                    DateTime memberPackageStartDate = ACMS.Convert.ToDateTime(masterRow["DtStartDate"]);
                    DateTime memberPackageExpiryDate = ACMS.Convert.ToDateTime(masterRow["dtExpiryDate"]);

                    if (memberPackageStartDate > dtDate)
                    {
                        masterRow["dtExpiryDate"] = memberPackageExpiryDate.Subtract(memberPackageStartDate.Subtract(dtDate));
                    }
                }

                ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

                try
                {
                    memberPackage.MainConnectionProvider = connProvider;
                    serviceSession.MainConnectionProvider = connProvider;

                    connProvider.OpenConnection();
                    connProvider.BeginTransaction("SaveServiceSession");

                    memberPackage.SaveData(memberPackageTable);

                    for (int i = 0; i < nQuatity; i++)
                    {
                        serviceSession.Insert();  //Capture Session ID Here

                        DataRow ssRow;
                        ssRow = dtSessionID.NewRow();
                        ssRow["nSessionID"] = Convert.ToInt32(serviceSession.NSessionID.Value);
                        ssRow["strMembershipID"] = strMemberShipID;
                        dtSessionID.Rows.Add(ssRow);
                    }

                    connProvider.CommitTransaction();
                    //DEREK Wrong Here Need to Fix //Use DataTable //Same goes with Live Version
                    //mySessionID = Convert.ToInt32(serviceSession.NSessionID.Value);

                    return true;
                }
                catch (Exception ex)
                {
                    connProvider.RollbackTransaction("SaveClassAttendance");
                    throw new Exception("Failed to save Class Attendance");
                }
                finally
                {
                    if (connProvider.CurrentTransaction != null)
                        connProvider.CurrentTransaction.Dispose();
                    if (connProvider.DBConnection != null)
                    {
                        if (connProvider.DBConnection.State == ConnectionState.Open)
                            connProvider.DBConnection.Close();
                    }
                    memberPackage.MainConnactionIsCreatedLocal = true;
                    serviceSession.MainConnactionIsCreatedLocal = true;

                }

            }
            else
            {
                return false;
            }
        }
Esempio n. 27
0
        //Derek Instalment Plan - Void Pay OS - Update Payment Plan
        public void VoidReceipt(string strReceiptNo, bool VoidPre)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try
            {
                // Check Access Right here
                TblReceipt receipt = new TblReceipt();
                TblReceiptFreebie sqlReceiptFreebie = new TblReceiptFreebie();
                TblRewardsTransaction mRewardTransaction = new TblRewardsTransaction();
                TblReceiptPayment sqlReceiptPayment = new TblReceiptPayment();
                TblPaymentPlan myPaymentPlan = new TblPaymentPlan();

                myPaymentPlan.MainConnectionProvider = connProvider;
                mRewardTransaction.MainConnectionProvider = connProvider;
                receipt.MainConnectionProvider = connProvider;
                sqlReceiptFreebie.MainConnectionProvider = connProvider;
                sqlReceiptPayment.MainConnectionProvider = connProvider;

                connProvider.OpenConnection();
                connProvider.BeginTransaction("VoidReceipt");

                receipt.StrReceiptNo = strReceiptNo;
                receipt.SelectOne();

                int nCategoryID = receipt.NCategoryID.Value;
                string strBranchCode = receipt.StrBranchCode.Value;

                if (receipt.DtDate.Value != System.DateTime.Today && VoidPre == false)
                    throw new Exception("Not allow to void previous data receipt. ");

                if (strBranchCode != User.BranchCode)
                    throw new Exception("Not allow to void other's branches' receipt. ");

                receipt.FVoid = System.Data.SqlTypes.SqlBoolean.True;
                receipt.Update();

                string strSQL;
                if (receipt.NCategoryID == 7 || receipt.NCategoryID == 36 || receipt.NCategoryID == 37)
                    strSQL = "select top 1 * from tblMemberCreditPackage where strReceiptNo ='" + receipt.StrReceiptNo.ToString() + "' AND fFree=0";
                else
                    strSQL = "select top 1 * from tblMemberPackage where strReceiptNo ='" + receipt.StrReceiptNo.ToString() + "' AND fFree=0";
                DataSet _ds1 = new DataSet();
                SqlHelper.FillDataset(connection, CommandType.StoredProcedure, "UP_GETDATA", _ds1, new string[] { "table" }, new SqlParameter("@strSQL", strSQL));

                //Roll back when package conversion
                if (_ds1.Tables["table"].Rows.Count > 0)
                {
                    string strPkgRemark = _ds1.Tables["table"].Rows[0]["strUpgradeFrom"].ToString();
                    string[] rollbackPackages = strPkgRemark.ToString().Split(',');

                    foreach (string rollbackPackage in rollbackPackages)
                    {
                        if (rollbackPackage.Trim() != "" && rollbackPackage.Trim() != "Null")
                        {
                            if (rollbackPackage.Contains("(C)"))
                            {
                                int nPackageID = Convert.ToInt32(rollbackPackage.Trim().Replace("(C)", ""));
                                TblMemberCreditPackage mp2 = new TblMemberCreditPackage();
                                mp2.NCreditPackageID = nPackageID;
                                mp2.SelectOne();
                                mp2.StrUpgradeTo = "";
                                mp2.StrRemarks = "";
                                mp2.NStatusID = 0;
                                mp2.Update();
                            }
                            else if (rollbackPackage.Contains("(B)"))
                            {
                                string strSQL2 = "select * from tblMemberPackage where strUpgradeTo='" + receipt.StrReceiptNo.ToString() + "' ";
                                DataSet _ds2 = new DataSet();
                                SqlHelper.FillDataset(connection, CommandType.StoredProcedure, "UP_GETDATA", _ds2, new string[] { "table" }, new SqlParameter("@strSQL", strSQL2));
                                foreach (DataRow drComboPkg in _ds2.Tables["table"].Rows)
                                {
                                    TblMemberPackage mp = new TblMemberPackage();
                                    DataTable convertedPkgTable = mp.LoadData("select * from tblMemberPackage where nPackageID=" + drComboPkg["nPackageID"].ToString());
                                    if (convertedPkgTable.Rows.Count > 0)
                                    {
                                        convertedPkgTable.Rows[0]["nStatusID"] = 0;
                                        convertedPkgTable.Rows[0]["strUpgradeTo"] = "";
                                        convertedPkgTable.Rows[0]["strRemarks"] = "";
                                        mp.SaveData(convertedPkgTable);
                                    }
                                }
                            }
                            else
                            {
                                int nPackageID = Convert.ToInt32(rollbackPackage.Trim());
                                TblMemberPackage mp2 = new TblMemberPackage();
                                mp2.NPackageID = nPackageID;
                                mp2.SelectOne();
                                mp2.StrUpgradeTo = "";
                                mp2.StrRemarks = "";
                                mp2.NStatusID = 0;
                                mp2.Update();

                                //rollback free package if have any
                                TblMemberPackage mp3 = new TblMemberPackage();
                                string strFreePackageCode = "";
                                string strSQL3 = "select strFreePkgCode from tblPackage where strPackageCode='" + Convert.ToString(mp2.StrPackageCode) + "' ";
                                DataSet _ds = new DataSet();
                                SqlHelper.FillDataset(connection, CommandType.StoredProcedure, "UP_GETDATA", _ds, new string[] { "table" }, new SqlParameter("@strSQL", strSQL3));
                                if (_ds.Tables["table"].Rows.Count > 0)
                                {
                                    strFreePackageCode = _ds.Tables["table"].Rows[0]["strFreePkgCode"].ToString();
                                }
                                DataTable freePkgTable = mp3.LoadData("select * from tblMemberPackage where strReceiptNo=@strReceiptNo and strPackageCode =@strFreePackageCode ",
                                    new string[] { "@strReceiptNo", "@strFreePackageCode" }, new object[] { mp2.StrReceiptNo.ToString(), strFreePackageCode });

                                if (freePkgTable.Rows.Count > 0)
                                {
                                    freePkgTable.Rows[0]["nStatusID"] = 0;
                                    freePkgTable.Rows[0]["strUpgradeTo"] = "";
                                    freePkgTable.Rows[0]["strRemarks"] = "";
                                    mp3.SaveData(freePkgTable);
                                }
                            }
                        }
                    }
                }

                receipt.MUpgradeAmount = System.Data.SqlTypes.SqlMoney.Null;
                receipt.StrRemarks = "";
                receipt.Update();

                #region ====== Added By Albert ======
                /*
                 * To remove reward transaction.
                 */
                mRewardTransaction.StrReferenceNo = strReceiptNo;
                mRewardTransaction.SelectAllWReferenceNo();
                mRewardTransaction.NTypeID = 3;
                mRewardTransaction.Update();
                #endregion

                //rollback used cash voucher
                TblReceiptPayment tblReceiptPayment = new ACMSDAL.TblReceiptPayment();
                tblReceiptPayment.StrReceiptNo = strReceiptNo;
                DataTable tblPayment = tblReceiptPayment.SelectAllWstrReceiptNoLogic();

                foreach (DataRow dr in tblPayment.Rows)
                {
                    if (dr["strPaymentCode"].ToString() == "CASHVOUCHER")
                    {
                        TblCashVoucher sqlCV = new TblCashVoucher();
                        sqlCV.MainConnectionProvider = connProvider;
                        sqlCV.StrSN = dr["strReferenceNo"].ToString();
                        DataTable table = sqlCV.SelectOne();
                        sqlCV.NStatusID = 1;
                        sqlCV.StrRedeemedByID = System.Data.SqlTypes.SqlString.Null;
                        sqlCV.DtRedeemedDate = System.Data.SqlTypes.SqlDateTime.Null;
                        sqlCV.StrRedeemedBranch = System.Data.SqlTypes.SqlString.Null;
                        sqlCV.Update();
                        sqlCV.SaveData(table);
                    }
                }

                if (!receipt.StrChildReceiptNo.IsNull)
                {
                    int IsVoid = 0;

                    IsVoid = receipt.CheckIfChildReceiptVoid(receipt.StrChildReceiptNo.Value);

                    if (IsVoid == 0)
                    {
                        throw new Exception("The receipt given has child receipt, please void child receipt first before void this receipt");
                    }
                }

                string strDepositReceiptNo = "";

                if (!receipt.StrParentReceiptNo.IsNull)
                {
                    TblReceiptEntries pReceipt = new TblReceiptEntries();
                    pReceipt.StrReceiptNo = receipt.StrParentReceiptNo.Value;
                    pReceipt.SelectAllWstrReceiptNoLogic();
                    if (pReceipt.StrCode.Value != "Deposit")
                    {
                        nCategoryID = 0; //Check if pay outstanding receipt, reset category to 0
                    }
                    else if (pReceipt.StrCode.Value == "Deposit")
                    {
                        strDepositReceiptNo = receipt.StrParentReceiptNo.Value;
                    }
                    pReceipt.Dispose();
                }

                if (strDepositReceiptNo != "")
                {
                    try
                    {
                        receipt.ReviveDepositForVoidMasterReceipt(strReceiptNo, strDepositReceiptNo);
                    }
                    catch { }
                }

                if (nCategoryID == 1 || nCategoryID == 3 || nCategoryID == 4 || nCategoryID == 5 ||
                    nCategoryID == 6 || nCategoryID == 8 || nCategoryID == 9 || nCategoryID == 14 || nCategoryID == 23)
                {
                    ActionTakeWhenVoidReceiptForCategory_1_3_4_5_6_8_9_14_23(strReceiptNo, connProvider);
                }
                else if (nCategoryID == 2)
                {
                    //Fitness GIRO
                    ActionTakeWhenVoidReceiptForCategory_2(strReceiptNo, connProvider);
                }
                else if (nCategoryID == 7)
                {
                    // Spa Credit Account
                    ActionTakeWhenVoidReceiptForCategory_7(strReceiptNo, connProvider);
                }
                else if (nCategoryID == 36 || nCategoryID == 37)
                {
                    // Holistic Credit Account
                    ActionTakeWhenVoidReceiptForCategory_7(strReceiptNo, connProvider);
                }
                else if (nCategoryID == 38)
                {
                    // Cash Voucher
                    ActionTakeWhenVoidReceiptForCategory_38(strReceiptNo, connProvider);
                }
                else
                {
                    DeleteFreeMemberPackage(strReceiptNo, connProvider);

                    if (nCategoryID == 11 || nCategoryID == 12)
                    {
                        //ActionTakeWhenVoidReceiptForCategory_11_12(strReceiptNo, connProvider);
                    }
                    else if (nCategoryID == 21)
                    {
                        // mineral water
                    }
                    else if (nCategoryID == 15)
                    {
                        //Locker Rental
                    }
                    else if (nCategoryID == 0)
                    {
                        // Pay Outstanding
                        ActionTakeWhenVoidReceiptForCategory_0(receipt, connProvider);

                        //Get New Payment Plan
                        //If Table Row Count > 0 Then Update Payment Plan

                        //Derek Instalment Plan - Update tblPaymentPlan (if any)
                        //Reset Payment Plan's Receipt by payment receipt No - Bool 1 Updated 0 Not Found
                        //Get Bool If 1
                        //Find the Master Receipt No if 1

                        string strMasterReceiptNo = "";

                        strMasterReceiptNo = myPaymentPlan.GetInhouseIPPMasterOSReceiptSimple(strReceiptNo);

                        if (strMasterReceiptNo != "")
                        {
                            if (myPaymentPlan.GetInhouseResetIPP_VoidPayOS(strReceiptNo) == 1)
                            {
                                DataTable paymentPlanTable = myPaymentPlan.GetInhouseAdjustedIPP_VoidPayOS(strMasterReceiptNo);

                                if (paymentPlanTable != null && paymentPlanTable.Rows.Count > 0)
                                {
                                    foreach (DataRow r in paymentPlanTable.Rows)
                                    {
                                        if (r["lastestUpdate"].ToString() == "1")
                                        {
                                            myPaymentPlan.IPPSubsequentUpdate(Convert.ToInt32(r["nPaymentPlanID"]), r["strReceiptNo"].ToString(),
                                                                                Convert.ToInt32(r["nInstalmentNo"]), Convert.ToDecimal(r["mPaidAmount"]),
                                                                                Convert.ToDecimal(r["mAdjustedPaymentPlanAmt"]), Convert.ToDecimal(r["mOutstandingAmt"]));
                                        }
                                    }
                                    //paymentPlanTable.AcceptChanges();
                                }
                            }
                        }
                    }
                    else if (nCategoryID == 18)
                    {
                        ActionTakeWhenVoidReceiptForCategory_18(strReceiptNo, connProvider);
                    }
                    else if (nCategoryID == 19)
                    {
                        ActionTakeWhenVoidReceiptForCategory_19(strReceiptNo, connProvider);
                    }
                    #region Un-support voiding
                    /*
                    else if (nCategoryID == 17)
                    {
                        //throw new Exception("Forget card's receipt is not allow to void.");
                        //do notthing. Just void the receipt
                    }
                    else if (nCategoryID == 10)
                    {
                        //throw new Exception("Upgrade Package's receipt is not allow to void.");
                        // do notthing. Just void the receipt.
                    }
                    else if (nCategoryID == 20)
                    {
                        //Replace Membership Card
                        //throw new Exception("Replace member card's receipt is not allow to void.");
                        //do notthing, just void the receipt
                    }
                    */
                    #endregion

                }

                connProvider.CommitTransaction();
            }
            catch (Exception ex)
            {
                connProvider.RollbackTransaction("VoidReceipt");
                throw ex;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();

                }
            }
        }
Esempio n. 28
0
        public void TransferMemberPackage(int packageID, string currMemberID, string newMemberID, string remark)
        {
            TblClassAttendance classAttendance = new TblClassAttendance();
            TblServiceSession serviceSession = new TblServiceSession();

            classAttendance.NPackageID = packageID;
            DataTable tableClassAttendance = classAttendance.SelectAllWnPackageIDLogic();

            serviceSession.NPackageID = packageID;
            DataTable tableServiceSession = serviceSession.SelectAllWnPackageIDLogic();

            //classAttendance.nP
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try
            {
                classAttendance.MainConnectionProvider = connProvider;
                serviceSession.MainConnectionProvider = connProvider;
                myMemberPackage.MainConnectionProvider = connProvider;
                myAudit.MainConnectionProvider = connProvider;

                connProvider.OpenConnection();
                connProvider.BeginTransaction("TransferMemberPackage");

                if (tableClassAttendance != null && tableClassAttendance.Rows.Count > 0)
                {
                    foreach (DataRow r in tableClassAttendance.Rows)
                    {
                        r["strMembershipID"] = newMemberID;
                    }
                    //classAttendance.StrMembershipID = newMemberID;
                    //classAttendance.UpdateAllWnEmployeeIDLogic();
                }

                if (tableServiceSession != null && tableServiceSession.Rows.Count > 0)
                {
            //					serviceSession.StrMembershipID = newMemberID;
            //					serviceSession.UpdateAllWnPackageIDLogic();
                    foreach (DataRow r in tableServiceSession.Rows)
                    {
                        r["strMembershipID"] = newMemberID;
                    }
                }

                myMemberPackage.NPackageID = packageID;
                myMemberPackage.SelectOne();
                myMemberPackage.StrMembershipID = newMemberID;
                myMemberPackage.StrRemarks = remark;

                myAudit.DtDate = DateTime.Today;
                myAudit.NAuditTypeID = 1;
                myAudit.NEmployeeID = ACMSLogic.User.EmployeeID;
                myAudit.StrAuditEntry = "Transfer Member Package " + packageID.ToString() + "from " + currMemberID + "to " + newMemberID;
                myAudit.StrReference = packageID.ToString();

                classAttendance.SaveData(tableClassAttendance);
                serviceSession.SaveData(tableServiceSession);
                myMemberPackage.Update();
                myAudit.Insert();

                connProvider.CommitTransaction();
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("CancelMemberPackage");
                throw new Exception("Failed to transfer Member Package");
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();
                    //connProvider.DBConnection.Dispose();
                }
                myMemberPackage.MainConnactionIsCreatedLocal = true;
                myAudit.MainConnactionIsCreatedLocal = true;
                classAttendance.MainConnactionIsCreatedLocal = true;
                serviceSession.MainConnactionIsCreatedLocal = true;
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Include member or non member
        /// </summary>
        /// <param name="isMember"></param>
        /// <param name="branchCode"></param>
        /// <param name="name"></param>
        /// <param name="isSingaporean"></param>
        /// <param name="NRIC"></param>
        /// <param name="nSignUpID"></param>
        /// <param name="dob"></param>
        /// <param name="aUser"></param>
        ///
        /// 0705
        public string AddNewMember(bool isMember, string branchCode, string name, bool isSingaporean, string NRIC, int nSignUpID,
                                   DateTime dob, User aUser, bool isFemale, int nmediaSource)
        {
            string    membershipID = string.Empty;
            TblMember sqlMember    = new TblMember();

            sqlMember.FMember       = isMember;
            sqlMember.StrMemberName = name;
            sqlMember.FFemale       = isFemale;
            if (name.Length >= 19)
            {
                sqlMember.StrCardName = name.Substring(0, 19);
            }
            else
            {
                sqlMember.StrCardName = name;
            }
            sqlMember.StrNRICFIN     = NRIC;
            sqlMember.DtDOB          = dob;
            sqlMember.StrBranchCode  = branchCode;
            sqlMember.FSingaporean   = isSingaporean;
            sqlMember.NMediaSourceID = nmediaSource;
            TblCardRequest sqlCardRequest = new TblCardRequest();
            TblAudit       sqlAudit       = new TblAudit();

            if (!isMember)
            {
                ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
                TblCompany sqlCompany = new TblCompany();

                try
                {
                    sqlCompany.MainConnectionProvider     = connProvider;
                    sqlMember.MainConnectionProvider      = connProvider;
                    sqlCardRequest.MainConnectionProvider = connProvider;
                    sqlAudit.MainConnectionProvider       = connProvider;
                    connProvider.OpenConnection();
                    connProvider.BeginTransaction("AddNewNonMember");

                    sqlCompany.IncOne();
                    sqlMember.NMembershipNo   = sqlCompany.NNonMembershipNo;
                    sqlMember.NStatus         = 1;
                    sqlMember.NSignupID       = nSignUpID;
                    sqlMember.StrMembershipID = "NMC" + sqlCompany.NNonMembershipNo;
                    sqlMember.DtSignupDate    = DateTime.Now;
                    //sqlMember.NCardStatusID = (int)CardStatusType.RequestPrint;
                    sqlMember.NLoyaltyStatusID = 1;
                    sqlMember.Insert();

                    membershipID = "NMC" + sqlCompany.NNonMembershipNo;

                    connProvider.CommitTransaction();
                }
                catch (Exception)
                {
                    connProvider.RollbackTransaction("AddNewNonMember");
                    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();
                    }
                    sqlCompany.MainConnactionIsCreatedLocal     = true;
                    sqlMember.MainConnactionIsCreatedLocal      = true;
                    sqlCardRequest.MainConnactionIsCreatedLocal = true;
                }
            }
            else
            {
                ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
                TblBranch sqlBranch = new TblBranch();

                try
                {
                    sqlBranch.MainConnectionProvider      = connProvider;
                    sqlMember.MainConnectionProvider      = connProvider;
                    sqlCardRequest.MainConnectionProvider = connProvider;
                    sqlAudit.MainConnectionProvider       = connProvider;
                    connProvider.OpenConnection();
                    connProvider.BeginTransaction("AddNewNonMember");

                    sqlBranch.StrBranchCode = branchCode;
                    //sqlBranch.StrBranchCode = "PM";
                    sqlBranch.IncOne();
                    sqlMember.NMembershipNo   = sqlBranch.NMembershipNo;
                    sqlMember.NStatus         = 1;
                    sqlMember.NSignupID       = nSignUpID;
                    sqlMember.StrMembershipID = branchCode.TrimEnd() + sqlBranch.NMembershipNo;
                    // sqlMember.StrMembershipID = "PM" + sqlBranch.NMembershipNo;
                    sqlMember.DtSignupDate      = DateTime.Now;
                    sqlMember.NCardStatusID     = (int)CardStatusType.RequestPrint;
                    sqlMember.StrCardBranchCode = "HQ";
                    sqlMember.NLoyaltyStatusID  = 1;
                    sqlMember.Insert();

                    //Request print for member --now only for fitness member
//					sqlCardRequest.NEmployeeID = aUser.NEmployeeID();
//					sqlCardRequest.NStatusID = (int)CardStatusType.RequestPrint;
//					sqlCardRequest.StrBranchCode = aUser.StrBranchCode();
//					sqlCardRequest.StrMembershipID = branchCode.TrimEnd() +sqlBranch.NMembershipNo;
//					sqlCardRequest.DtLastEditDate = DateTime.Now;
//					sqlCardRequest.Insert();

                    //Audit trail for request print
//					sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberCard;
//					sqlAudit.NEmployeeID = aUser.NEmployeeID();
//					sqlAudit.StrAuditEntry = "New member card request when create new member.";
//					sqlAudit.StrReference = branchCode.TrimEnd() +sqlBranch.NMembershipNo;
//					sqlAudit.DtDate = DateTime.Now;
//					sqlAudit.Insert();

                    membershipID = branchCode.TrimEnd() + sqlBranch.NMembershipNo;

                    connProvider.CommitTransaction();
                }
                catch (Exception)
                {
                    connProvider.RollbackTransaction("AddNewNonMember");
                    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();
                    }
                    sqlBranch.Dispose();
                    sqlMember.Dispose();
                    sqlCardRequest.Dispose();
                }
            }

            return(membershipID);
        }
Esempio n. 30
0
        /// <summary>
        /// Use to Transfer Service Session or Update the service Session
        /// </summary>
        /// <param name="nSessionID"></param>
        /// <param name="dtDate"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="strBranchCode"></param>
        /// <param name="nPackageID"></param>
        /// <param name="strServiceCode"></param>
        /// <param name="nEmployeeInChargeID"></param>
        /// <param name="remark"></param>
        /// <param name="isTransfer"></param>
        public void UpdateServiceSession(int nSessionID, DateTime dtDate, DateTime startTime,  DateTime endTime,
			string strBranchCode, int nPackageID, string strServiceCode, 
			int nEmployeeInChargeID, string remark, int status, bool isTransfer)
        {
            TblServiceSession serviceSession = new TblServiceSession();
            serviceSession.NSessionID = nSessionID;
            DataTable table = serviceSession.SelectOne();
            if (table == null || table.Rows.Count == 0)
                throw new Exception("failed to update this package. Record not found");

            TblService service = new TblService();
            service.StrServiceCode = strServiceCode;
            DataTable serviceTable = service.SelectOne();
            if (serviceTable == null || serviceTable.Rows.Count == 0)
                throw new Exception("The service is not available.");

            int duration = ACMS.Convert.ToInt32(service.NDuration);

            bool isPT = ACMS.Convert.ToInt32(service.NServiceTypeID) == 0;

            if (!isTransfer)
            {
                if (!isPT && !ACMSLogic.SpaBooking.VerifyMemberPackageAllowCertainService(nPackageID, strServiceCode))
                    throw new Exception("this member package is not allow to use the service");

                if (endTime == DateTime.MinValue)
                    endTime = startTime.AddMinutes((Double)duration);

                if (dtDate != DateTime.MinValue)
                    serviceSession.DtDate = dtDate;
                if (startTime != DateTime.MinValue)
                    serviceSession.DtStartTime = startTime;
                if (endTime != DateTime.MinValue)
                    serviceSession.DtEndTime= endTime;
                if (strBranchCode != "")
                    serviceSession.StrBranchCode = strBranchCode;
                if (strServiceCode != "")
                    serviceSession.StrServiceCode = strServiceCode;
                if (nEmployeeInChargeID != -1)
                    serviceSession.NServiceEmployeeID = nEmployeeInChargeID;
                if (nPackageID != -1)
                    serviceSession.NPackageID = nPackageID;
                if (remark != "")
                    serviceSession.StrRemarks = remark;
                if (status != -1)
                    serviceSession.NStatusID  = status;

                if (status == 5)
                    serviceSession.NMarkedByID = User.EmployeeID;
            }
            else
            {
                serviceSession.NPackageID = nPackageID;
            }

            myMemberPackage.NPackageID = nPackageID;
            DataTable memberPackageTable = myMemberPackage.SelectOne();

            if (memberPackageTable == null || memberPackageTable.Rows.Count == 0)
                throw new Exception("Failed to create new service session. Member Package with npackageID = "+ nPackageID.ToString() + "has been deleted");

            DataRow masterRow = memberPackageTable.Rows[0];

            if (masterRow["dtStartDate"] == DBNull.Value)
            {
                // Means new class Attendance gonna insert
                TblPackage package = new TblPackage();
                package.StrPackageCode = masterRow["strPackageCode"].ToString();
                DataTable tablePackage = package.SelectOne();

                if (tablePackage == null && tablePackage.Rows.Count == 0)
                    throw new Exception("Failed to update service session. Package no found.");

                myMemberPackage.DtStartDate = serviceSession.DtDate.Value;
                myMemberPackage.DtExpiryDate = serviceSession.DtDate.Value.AddMonths(package.NPackageDuration.Value).AddDays(-1);
            }
            else
            {
                DateTime memberPackageStartDate =  ACMS.Convert.ToDateTime(masterRow["DtStartDate"]);
                DateTime memberPackageExpiryDate = ACMS.Convert.ToDateTime(masterRow["dtExpiryDate"]);

                if (memberPackageStartDate > serviceSession.DtDate.Value)
                {
                    myMemberPackage.DtExpiryDate = memberPackageExpiryDate.Subtract(memberPackageStartDate.Subtract(serviceSession.DtDate.Value));
                }
            }

            serviceSession.NEmployeeID = User.EmployeeID;
            serviceSession.DtLastEditDate = DateTime.Now;

            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try
            {
                myMemberPackage.MainConnectionProvider = connProvider;
                serviceSession.MainConnectionProvider = connProvider;

                connProvider.OpenConnection();
                connProvider.BeginTransaction("SaveServiceSession");

                myMemberPackage.Update();
                serviceSession.Update();

                connProvider.CommitTransaction();
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("SaveServiceSession");
                throw new Exception("Failed to save Service Session");
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();
                }
                myMemberPackage.MainConnactionIsCreatedLocal = true;
                serviceSession.MainConnactionIsCreatedLocal = true;
            }
        }
Esempio n. 31
0
        public string ConvertMember(DataRow rowMember, User aUser)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember      sqlMember      = new TblMember();
            TblBranch      sqlBranch      = new TblBranch();
            TblAudit       sqlAudit       = new TblAudit();
            TblCardRequest sqlCardRequest = new TblCardRequest();

            try
            {
                sqlBranch.MainConnectionProvider      = connProvider;
                sqlMember.MainConnectionProvider      = connProvider;
                sqlAudit.MainConnectionProvider       = connProvider;
                sqlCardRequest.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("ConvertMember");

                sqlBranch.StrBranchCode = aUser.StrBranchCode();
                sqlBranch.IncOne();
                string newMembershipID = aUser.StrBranchCode().TrimEnd() + sqlBranch.NMembershipNo;
                sqlMember.StrBranchCode = aUser.StrBranchCode();
                sqlMember.ConvertMember(rowMember["strMembershipID"].ToString(), newMembershipID);
                sqlMember.ConvertMemberPurchase(rowMember["strMembershipID"].ToString(), newMembershipID);
                sqlAudit.UpdateAllWstrReferenceLogic(newMembershipID, rowMember["strMembershipID"].ToString());
                sqlAudit.NAuditTypeID  = ACMSLogic.AuditTypeID.MemberRecord;
                sqlAudit.NEmployeeID   = aUser.NEmployeeID();
                sqlAudit.StrAuditEntry = "Convert member from " + rowMember["strMembershipID"].ToString() + " to " + newMembershipID;
                sqlAudit.StrReference  = newMembershipID;
                sqlAudit.DtDate        = DateTime.Now;
                sqlAudit.Insert();

                //Request print for convert non member to member
                //sqlCardRequest.NEmployeeID = aUser.NEmployeeID();
                //sqlCardRequest.NStatusID = (int)CardStatusType.RequestPrint;
                //sqlCardRequest.StrBranchCode = aUser.StrBranchCode();
                //sqlCardRequest.StrMembershipID = newMembershipID;
                //sqlCardRequest.DtLastEditDate = DateTime.Now;
                //sqlCardRequest.Insert();

                ////Audit trail for request print
                //sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberCard;
                //sqlAudit.NEmployeeID = aUser.NEmployeeID();
                //sqlAudit.StrAuditEntry = "New member card request when create convert member.";
                //sqlAudit.StrReference = newMembershipID;
                //sqlAudit.DtDate = DateTime.Now;
                //sqlAudit.Insert();

                connProvider.CommitTransaction();
                return(newMembershipID);
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("ConvertMember");
                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();
                }
                sqlBranch.Dispose();
                sqlMember.Dispose();
                sqlAudit.Dispose();
                sqlCardRequest.Dispose();
            }
        }
Esempio n. 32
0
        public void DeleteClassAttendance(int nPackageID, int nAttendanceID, string remark)
        {
            // i need to know it is only one record, and it is 1st record also
            TblClassAttendance classAttendance = new TblClassAttendance();
            classAttendance.NPackageID = nPackageID;
            DataTable table = classAttendance.SelectAllWnPackageIDLogic();

            bool setNullInMemberPackage = false;
            bool isDelete1stRecord = false;
            bool isGIRO = false;
            bool isGiveBackOneDay = false;

            DateTime newfirstRecordClassAttendanceDate = DateTime.MinValue;

            if (table != null && table.Rows.Count > 0)
            {
                table.DefaultView.RowFilter = "nStatusID = 1 or nStatusID = 2 or nStatusID = 4";

                if (table.DefaultView.Count == 1)
                {
                    DataSet ds = new DataSet();

                    string strSQL = "select nCategoryID from tblMemberPackage mp join tblPackage p on mp.strPackageCode=p.strPackageCode where nPackageID=" + nPackageID.ToString();
                    SqlHelper.FillDataset(connection, CommandType.StoredProcedure, "UP_GETDATA", ds, new string[] { "Table" }, new SqlParameter("@strSQL", strSQL));

                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["nCategoryID"].ToString() == "2")
                        {
                            isGIRO = true;
                            setNullInMemberPackage = false;
                        }
                        else
                            setNullInMemberPackage = true;
                    }
                    else
                        setNullInMemberPackage = true;
                }
                else
                {
                    DataRow [] rowList = table.Select("nStatusID = 1 or nStatusID = 2 or nStatusID = 4",
                        "nAttendanceID", DataViewRowState.CurrentRows);

                    int firstRecord_nAttendanceID = ACMS.Convert.ToInt32(rowList[0]["nAttendanceID"]);
                    if (firstRecord_nAttendanceID == nAttendanceID)
                    {
                        isDelete1stRecord = true;
                        newfirstRecordClassAttendanceDate = ACMS.Convert.ToDateTime(rowList[1]["dtDate"]);
                    }
                }
            }

            classAttendance.NAttendanceID = nAttendanceID;
            classAttendance.SelectOne();
            classAttendance.DtLastEditDate = DateTime.Now;
            classAttendance.NEmployeeID = ACMSLogic.User.EmployeeID;
            if (classAttendance.NStatusID == 2)
                isGiveBackOneDay = true;
            classAttendance.NStatusID = 5;
            classAttendance.StrRemarks = remark;

            TblAudit audit = new TblAudit();
            audit.DtDate = DateTime.Now;
            audit.NAuditTypeID = 3;
            audit.NEmployeeID = User.EmployeeID;
            audit.StrAuditEntry = "Delete class attendance with nAttendanceID = " + nAttendanceID +
                " and nPackageID = " + nPackageID;
            audit.StrReference = nAttendanceID.ToString();

            TblMemberPackage memberPackage = new TblMemberPackage();
            memberPackage.NPackageID = nPackageID;
            memberPackage.SelectOne();

            if (setNullInMemberPackage)
            {
                //				bool isUnlimited = memberPackage.IsUnlimitedPackage(nPackageID);
                //
                //				if (!isUnlimited)
                //				{
                memberPackage.DtExpiryDate = System.Data.SqlTypes.SqlDateTime.Null;
                memberPackage.DtStartDate = System.Data.SqlTypes.SqlDateTime.Null;
                memberPackage.DtLastEdit = DateTime.Now;
                memberPackage.NEmployeeID = User.EmployeeID;
                //				}
            }
            else if (isDelete1stRecord)
            {
                if (!isGIRO)
                {
                    TimeSpan duration = memberPackage.DtExpiryDate.Value.Subtract(memberPackage.DtStartDate.Value);
                    DateTime newExpriry = newfirstRecordClassAttendanceDate.Add(duration);
                    memberPackage.DtExpiryDate = newExpriry;
                    memberPackage.DtStartDate = newfirstRecordClassAttendanceDate;
                    memberPackage.DtLastEdit = DateTime.Now;
                    memberPackage.NEmployeeID = User.EmployeeID;
                }
            }
            else if (isGiveBackOneDay)
            {
                if (!isGIRO)
                {
                    // Check if status = forfeited, give back 1 day to duration pkg
                    DateTime newExpriry = memberPackage.DtExpiryDate.Value.AddDays(1);
                    memberPackage.DtExpiryDate = newExpriry;
                    memberPackage.DtLastEdit = DateTime.Now;
                    memberPackage.NEmployeeID = User.EmployeeID;
                }
            }

            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try
            {
                memberPackage.MainConnectionProvider = connProvider;
                classAttendance.MainConnectionProvider = connProvider;
                audit.MainConnectionProvider = connProvider;

                connProvider.OpenConnection();
                connProvider.BeginTransaction("DeleteClassAttendance");

                memberPackage.Update();
                audit.Insert();
                classAttendance.Update();

                connProvider.CommitTransaction();
                //return true;
            }
            catch (Exception ex)
            {
                connProvider.RollbackTransaction("DeleteClassAttendance");
                throw new Exception("Failed to delete Class Attendance :: " + ex.Message);
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();
                }
                memberPackage.MainConnactionIsCreatedLocal = true;
                classAttendance.MainConnactionIsCreatedLocal = true;
                audit.MainConnactionIsCreatedLocal = true;
            }
        }
Esempio n. 33
0
        public bool UpdateMember(string strMembershipID,
                                 object dateDob,
                                 bool fAirCrew,
                                 bool fBoundCheck,
                                 bool fEmail,
                                 bool fGiroFailed,
                                 bool fPostalMail,
                                 bool fSingaporean,
                                 bool fSMS,
                                 int nLoyaltyStatusID,
                                 string strAdd1,
                                 string strAdd2,
                                 string strAltEmail,
                                 string strCardName,
                                 string strCompany,
                                 string strCreditCardNo,
                                 string strEmail,
                                 string strEmergencyContactNo,
                                 string strEmergencyContactPerson,
                                 string strHomeNo,
                                 string strMemberName,
                                 string strMobileNo,
                                 string strNIRCFIN,
                                 string strOccupation,
                                 string strOfficeNo,
                                 string strPagerNo,
                                 string strPostalCode,
                                 string strRemark,
                                 int nMediaSourceID,
                                 string strMediaSource,
                                 string strBeforePhoto,
                                 string strAfterPhoto,
                                 byte[] imgPhoto,
                                 User aUser,
                                 bool fFemale,
                                 bool fPhoneCall,
                                 string strSecurityQuestion,
                                 string strSecurityAnswer,
                                 string strMobileAppPwd)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember sqlMember = new TblMember();
            TblAudit  sqlAudit  = new TblAudit();

            bool isSuccess = false;

            try
            {
                sqlMember.MainConnectionProvider = connProvider;
                sqlAudit.MainConnectionProvider  = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("UpdateMemberRecord");

                sqlMember.StrMembershipID = strMembershipID;
                sqlMember.FFemale         = fFemale;
                sqlMember.FAirCrew        = fAirCrew;
                sqlMember.FBounceCheck    = fBoundCheck;
                sqlMember.FEmail          = fEmail;
                sqlMember.FGIROFailed     = fGiroFailed;
                sqlMember.FPostalMail     = fPostalMail;
                sqlMember.FSingaporean    = fSingaporean;
                sqlMember.FSMS            = fSMS;
                sqlMember.FPhoneCall      = fPhoneCall;

                if (nLoyaltyStatusID != 0)
                {
                    sqlMember.NLoyaltyStatusID = nLoyaltyStatusID;
                }

                sqlMember.StrAddress1               = strAdd1;
                sqlMember.StrAddress2               = strAdd2;
                sqlMember.StrAltEmail               = strAltEmail;
                sqlMember.StrCardName               = strCardName;
                sqlMember.StrCompany                = strCompany;
                sqlMember.StrCreditCardNo           = strCreditCardNo;
                sqlMember.StrEmail                  = strEmail;
                sqlMember.StrEmergencyContactNumber = strEmergencyContactNo;
                sqlMember.StrEmergencyContactPerson = strEmergencyContactPerson;
                sqlMember.StrHomeNo                 = strHomeNo;
                sqlMember.StrMemberName             = strMemberName;
                sqlMember.StrMobileNo               = strMobileNo;
                sqlMember.StrNRICFIN                = strNIRCFIN;
                sqlMember.StrOccupation             = strOccupation;
                sqlMember.StrOfficeNo               = strOfficeNo;
                sqlMember.StrPagerNo                = strPagerNo;
                sqlMember.StrPostalCode             = strPostalCode;
                sqlMember.StrRemarks                = strRemark;
                sqlMember.NMediaSourceID            = nMediaSourceID;
                sqlMember.StrMediaSource            = strMediaSource;
                sqlMember.NEmployeeID               = aUser.NEmployeeID();
                sqlMember.StrSecurityQuestion       = strSecurityQuestion;
                sqlMember.StrSecurityAnswer         = strSecurityAnswer;
                sqlMember.StrPassword               = strMobileAppPwd;

                sqlMember.Update2(dateDob, strBeforePhoto, strAfterPhoto, imgPhoto);

                sqlAudit.NAuditTypeID  = ACMSLogic.AuditTypeID.MemberRecord;
                sqlAudit.NEmployeeID   = aUser.NEmployeeID();
                sqlAudit.StrAuditEntry = "Update member " + strMembershipID;
                sqlAudit.StrReference  = strMembershipID;
                sqlAudit.DtDate        = DateTime.Now;
                sqlAudit.Insert();

                connProvider.CommitTransaction();
                isSuccess = true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("UpdateMemberRecord");
                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();
                }
                sqlMember.Dispose();
                sqlAudit.Dispose();
            }
            return(isSuccess);
        }
Esempio n. 34
0
        public void DeleteServiceSession(int nPackageID, int nSessionID, string remark)
        {
            // i need to know it is only one record, and it is 1st record also
            TblServiceSession serviceSession = new TblServiceSession();
            serviceSession.NPackageID = nPackageID;
            DataTable table = serviceSession.SelectAllWnPackageIDLogic();

            bool setNullInMemberPackage = false;
            bool isDelete1stRecord = false;
            DateTime newfirstRecordServiceSessionDate = DateTime.MinValue;

            if (table != null && table.Rows.Count > 0)
            {
                if (table.Rows.Count == 1)
                {
                    setNullInMemberPackage = true;
                }
                else
                {
                    DataRow [] rowList = table.Select("", "nSessionID", DataViewRowState.CurrentRows);

                    int firstRecord_nSessionID = ACMS.Convert.ToInt32(rowList[0]["nSessionID"]);
                    if (firstRecord_nSessionID == nSessionID)
                    {
                        isDelete1stRecord = true;
                        newfirstRecordServiceSessionDate = ACMS.Convert.ToDateTime(rowList[1]["dtDate"]);
                    }
                }
            }

            serviceSession.NSessionID = nSessionID;
            serviceSession.SelectOne();

            serviceSession.DtLastEditDate = DateTime.Now;
            serviceSession.NEmployeeID = ACMSLogic.User.EmployeeID;
            //serviceSession.NPackageID = -1;
            serviceSession.NStatusID = 1;
            serviceSession.StrRemarks = remark;

            TblAudit audit = new TblAudit();
            audit.DtDate = DateTime.Now;
            audit.NAuditTypeID = 4;
            audit.NEmployeeID = User.EmployeeID;
            audit.StrAuditEntry = "Delete service session with nSessionID = " + nSessionID+
                " and nPackageID = " + nPackageID;
            audit.StrReference = nSessionID.ToString();

            TblMemberPackage memberPackage = new TblMemberPackage();
            memberPackage.NPackageID = nPackageID;
            memberPackage.SelectOne();

            if (setNullInMemberPackage)
            {
                bool isUnlimited = memberPackage.IsUnlimitedPackage(nPackageID);

                if (!isUnlimited)
                {

                    memberPackage.DtStartDate = System.Data.SqlTypes.SqlDateTime.Null;
                    memberPackage.DtExpiryDate = System.Data.SqlTypes.SqlDateTime.Null;
                    memberPackage.DtLastEdit = DateTime.Now;
                    memberPackage.NEmployeeID = User.EmployeeID;
                }
            }
            else if (isDelete1stRecord)
            {
                TimeSpan duration = memberPackage.DtExpiryDate.Value.Subtract(memberPackage.DtStartDate.Value);
                DateTime newExpriry = newfirstRecordServiceSessionDate.Add(duration);
                memberPackage.DtExpiryDate = newExpriry;
                memberPackage.DtStartDate = newfirstRecordServiceSessionDate;
            }

            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            try
            {
                memberPackage.MainConnectionProvider = connProvider;
                serviceSession.MainConnectionProvider = connProvider;
                audit.MainConnectionProvider = connProvider;

                connProvider.OpenConnection();
                connProvider.BeginTransaction("DeleteServiceSession");

                memberPackage.Update();
                audit.Insert();
                serviceSession.Update();

                connProvider.CommitTransaction();
                //return true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("DeleteServiceSession");
                throw new Exception("Failed to delete Service Session");
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                    connProvider.CurrentTransaction.Dispose();
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                        connProvider.DBConnection.Close();
                }
                memberPackage.MainConnactionIsCreatedLocal = true;
                serviceSession.MainConnactionIsCreatedLocal = true;
                audit.MainConnactionIsCreatedLocal = true;
            }
        }
Esempio n. 35
0
        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();
            }
        }
        private void SaveExtensionHistory(int nCreditPackageID, string strMembershipID, DateTime dtOldExpiry, DateTime dtNewExpiry, DateTime dtStartDate, DateTime dtEndDate, 
                                            int nDaysExtended, int nStatusID, int nReasonID, string strRemarks, int nEmployeeID, DateTime dtCreateDate)
        {
            int nCreditPackageStatusID = -1;

            if (DateTime.Compare(dtNewExpiry, DateTime.Now) > 0)
            {
                nCreditPackageStatusID = 0;
            }

            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();

            TblMemberCreditPackage myMemberCreditPackage = new TblMemberCreditPackage();
            TblCreditPackageExtension myCreditPackageExtension = new TblCreditPackageExtension();

            myMemberCreditPackage.MainConnectionProvider = connProvider;
            myCreditPackageExtension.MainConnectionProvider = connProvider;

            connProvider.OpenConnection();
            connProvider.BeginTransaction("SaveCreditPackageExtension");

            try
            {
                //Update MemberCreditPackage - New Expiry Date & Status ID by nCreditPackageID
                myMemberCreditPackage.MemberCreditPackage_ExtensionUpdate(nCreditPackageID, nCreditPackageStatusID, dtNewExpiry, strMembershipID);

                //Add Record to Credit Package Extension
                myCreditPackageExtension.NCreditPackageID = nCreditPackageID;
                myCreditPackageExtension.DtOldExpiry = dtOldExpiry;
                myCreditPackageExtension.DtNewExpiry = dtNewExpiry;
                myCreditPackageExtension.DtStartDate = dtStartDate;
                myCreditPackageExtension.DtEndDate = dtEndDate;
                myCreditPackageExtension.NDaysExtended = nDaysExtended;
                myCreditPackageExtension.NStatusID = nStatusID;
                myCreditPackageExtension.NReasonID = nReasonID;
                myCreditPackageExtension.StrRemarks = strRemarks;
                myCreditPackageExtension.NEmployeeID = nEmployeeID;

                myCreditPackageExtension.Insert();

                //Commit Transaction
                connProvider.CommitTransaction();
                //*** Remember to Disable the Update Expiry Button for Credit Packages
            }
            catch
            {
                //RollBack Transaction
                connProvider.RollbackTransaction("SaveCreditPackageExtension");
            }
            finally
            {
                //connProvider.CurrentTransaction.Dispose();
                //connProvider.DBConnection.Close();
                if (connProvider.CurrentTransaction != null)
                {
                    connProvider.CurrentTransaction.Dispose();
                }

                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                    {
                        connProvider.DBConnection.Close();
                    }
                }
                myMemberCreditPackage.MainConnactionIsCreatedLocal = true;
                myCreditPackageExtension.MainConnactionIsCreatedLocal = true;
            }
        }
Esempio n. 37
0
        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();
            }
        }