예제 #1
0
 public MemberPackage()
 {
     //
     // TODO: Add constructor logic here
     //
     connectionString = (string)ConfigurationSettings.AppSettings["Main.ConnectionString"];
     connection = new SqlConnection(connectionString);
     myMemberPackage = new TblMemberPackage();
     myAudit = new TblAudit();
 }
예제 #2
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;
            }
        }
예제 #3
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;
            }
        }
예제 #4
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;
            }
        }
예제 #5
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();
                }
            }
        }
예제 #6
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;
            }
        }
예제 #7
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();
            }
        }
예제 #8
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;
        }
예제 #9
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;
            }
        }
예제 #10
0
        public bool Reprint(string strMembershipID, int nEmployee, int CardStatus, string strCardBranchCode)
        {
            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("ReprintCard");

                sqlMember.UpdateCardStatus(strMembershipID, CardStatus, strCardBranchCode);
                sqlCardRequest.NEmployeeID = nEmployee;
                sqlCardRequest.NStatusID = CardStatus;
                sqlCardRequest.StrBranchCode = strCardBranchCode;
                sqlCardRequest.StrMembershipID = strMembershipID;
                sqlCardRequest.DtLastEditDate = DateTime.Now;
                sqlCardRequest.Insert();

                sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberCard;
                sqlAudit.NEmployeeID = nEmployee;
                sqlAudit.StrAuditEntry = "Reprint member card.";
                sqlAudit.StrReference = strMembershipID;
                sqlAudit.DtDate = DateTime.Now;
                sqlAudit.Insert();

                connProvider.CommitTransaction();
                isSuccess = true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("ReprintCard");
                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;
        }
예제 #11
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;
        }
예제 #12
0
 public DataTable GetCardRequestAudit(string strMembershipID)
 {
     if (myCardRequestAudit == null)
         myCardRequestAudit = new TblAudit();
     return myCardRequestAudit.SelectBynAuditTypeIDstrMembershipID(strMembershipID, ACMSLogic.AuditTypeID.MemberCard);
 }
예제 #13
0
 public DataTable GetAuditTrail(string strMembershipID)
 {
     if (myAuditTrail == null)
         myAuditTrail = new TblAudit();
     return myAuditTrail.SelectForMemberRecord(strMembershipID);
 }
예제 #14
0
        public bool Delete(string strMembershipID, User aUser, string strRemark)
        {
            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("DeleteMember");

                sqlMember.DeleteMember(strMembershipID, strRemark);
                sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberRecord;
                sqlAudit.NEmployeeID = aUser.NEmployeeID();
                sqlAudit.StrAuditEntry = "Delete member " +strMembershipID;
                sqlAudit.StrReference = strMembershipID;
                sqlAudit.DtDate = DateTime.Now;
                sqlAudit.Insert();

                connProvider.CommitTransaction();
                isSuccess = true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("DeleteMember");
                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;
        }
예제 #15
0
파일: POS.cs 프로젝트: kimykunjun/test
        //private int UpgradePackage(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos)
        //{
        //        UpgradeNonGIRO(connProvider, pos);
        private void PostToMemberPackage(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos)
        {
            //MemberRecord myMemberRecord = new MemberRecord(pos.StrMembershipID.ToString(), pos.StrBranchCode.ToString());
            TblMemberPackage memberPackage = new TblMemberPackage();
            memberPackage.MainConnectionProvider = connProvider;

            DataTable memberPackagetable = memberPackage.FillSchema("Select * from tblMemberPackage");

            string strUpgradeFrom="";
            string strRemarks = "";
            foreach (DataRow dr in pos.WantToUpgradeMemberPackageTable.Rows)
            {
                strRemarks += dr["strPackageCode"].ToString() + " / " + dr["strReceiptNo"].ToString() + " / " + dr["UsageBalAmt"].ToString() + ",";
                if (dr["nCategoryID"].ToString() == "7" || dr["nCategoryID"].ToString() == "36" || dr["nCategoryID"].ToString() == "37")
                    strUpgradeFrom += dr["nPackageID"].ToString() + "(C),";
                else if (dr["nCategoryID"].ToString() == "8" || dr["nCategoryID"].ToString() == "9")
                    strUpgradeFrom += dr["nPackageID"].ToString() + "(B),";
                else
                    strUpgradeFrom += dr["nPackageID"].ToString() + ",";

                if (ACMS.Convert.ToInt32(dr["nCategoryID"]) == 5 && dr["strFreePkgCode"] != DBNull.Value)
                {
                    TblMemberPackage mp = new TblMemberPackage();
                    mp.MainConnectionProvider = connProvider;
                    DataTable freePkgTable = mp.LoadData("select * from tblMemberPackage where strReceiptNo=@strReceiptNo and strPackageCode =@strFreePackageCode ",
                        new string[] { "@strReceiptNo", "@strFreePackageCode" }, new object[] { dr["strReceiptNo"], dr["strFreePkgCode"].ToString() });

                    if (freePkgTable.Rows.Count > 0)
                    {
                        if (dr["nCategoryID"].ToString() == "7" || dr["nCategoryID"].ToString() == "36" || dr["nCategoryID"].ToString() == "37")
                            strUpgradeFrom += freePkgTable.Rows[0]["nPackageID"].ToString() + "(C),";
                        else if (dr["nCategoryID"].ToString() == "8" || dr["nCategoryID"].ToString() == "9")
                            strUpgradeFrom += freePkgTable.Rows[0]["nPackageID"].ToString() + "(B),";
                        else
                            strUpgradeFrom += freePkgTable.Rows[0]["nPackageID"].ToString() + ",";
                    }
                }
            }
            if (pos.WantToUpgradeMemberPackageTable.Rows.Count > 0)
            {
                strUpgradeFrom = strUpgradeFrom.Remove(strUpgradeFrom.Length - 1, 1);
                strRemarks = "Convert from: " + strRemarks.Remove(strRemarks.Length - 1, 1);
            }

            if (pos.NCategoryID == 1 ||
                pos.NCategoryID == 3 || pos.NCategoryID == 4 ||
                pos.NCategoryID == 5 || pos.NCategoryID == 6 ||
                pos.NCategoryID == 14 || pos.NCategoryID == 23)

            {
                foreach (DataRow r in pos.ReceiptItemsTable.Rows)
                {
                    int nQuantity = ACMS.Convert.ToInt32(r["nQuantity"]);

                    if (r["strCode"].ToString().ToUpper() != "REG")
                    {
                        for (int i = 0; i < nQuantity; i++)
                        {
                            DataRow rowToAdd = memberPackagetable.NewRow();

                            MemberPackage.InitMemberPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID, r["strCode"].ToString(), "", false);
                            rowToAdd["strRemarks"] = strRemarks;
                            rowToAdd["strUpgradeFrom"] = strUpgradeFrom;
                            memberPackagetable.Rows.Add(rowToAdd);
                        }
                    }
                    else
                    {

                        TblMember sqlMember = new TblMember();
                        TblCardRequest sqlCardRequest = new TblCardRequest();
                        TblAudit sqlAudit = new TblAudit();
                        try
                        {
                            sqlMember.MainConnectionProvider = connProvider;
                            sqlCardRequest.MainConnectionProvider = connProvider;
                            sqlAudit.MainConnectionProvider = connProvider;
                            sqlMember.UpdateCardStatus(pos.StrMembershipID.ToString(), 0, pos.StrBranchCode.ToString());
                            sqlCardRequest.NEmployeeID = pos.NCashierID;
                            sqlCardRequest.NStatusID = 0;
                            sqlCardRequest.StrBranchCode = pos.StrBranchCode.ToString();
                            sqlCardRequest.StrMembershipID = pos.StrMembershipID.ToString();
                            sqlCardRequest.DtLastEditDate = DateTime.Now;
                            sqlCardRequest.Insert();

                            sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberCard;
                            sqlAudit.NEmployeeID = pos.NCashierID;
                            sqlAudit.StrAuditEntry = "Reprint member card.";
                            sqlAudit.StrReference = pos.StrMembershipID.ToString();
                            sqlAudit.DtDate = DateTime.Now;
                            sqlAudit.Insert();

                        }
                        catch (Exception)
                        {
                            throw;
                        }
                        finally
                        {

                            sqlMember.Dispose();
                            sqlCardRequest.Dispose();
                            sqlAudit.Dispose();
                        }

                    }
                }

                if (memberPackagetable.Rows.Count > 0)
                    memberPackage.SaveData(memberPackagetable);
            }
            else if (pos.NCategoryID == 7 ||
                pos.NCategoryID == 36 || pos.NCategoryID == 37) //Credit Pkg
            {
                foreach (DataRow r in pos.ReceiptItemsTable.Rows)
                {
                    if (r["strCode"].ToString() == "JOINFEES" || r["strCode"].ToString() == "JOINFEE" || r["strCode"].ToString() == "FA")
                    {
                        int nQuantity = ACMS.Convert.ToInt32(r["nQuantity"]);

                        if (r["strCode"].ToString().ToUpper() != "REG")
                        {
                            for (int i = 0; i < nQuantity; i++)
                            {
                                DataRow rowToAdd = memberPackagetable.NewRow();

                                MemberPackage.InitMemberPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID, r["strCode"].ToString(), "", false);
                                rowToAdd["strRemarks"] = strRemarks;
                                rowToAdd["strUpgradeFrom"] = strUpgradeFrom;
                                memberPackagetable.Rows.Add(rowToAdd);
                            }
                        }
                        else
                        {

                            TblMember sqlMember = new TblMember();
                            TblCardRequest sqlCardRequest = new TblCardRequest();
                            TblAudit sqlAudit = new TblAudit();
                            try
                            {
                                sqlMember.MainConnectionProvider = connProvider;
                                sqlCardRequest.MainConnectionProvider = connProvider;
                                sqlAudit.MainConnectionProvider = connProvider;
                                sqlMember.UpdateCardStatus(pos.StrMembershipID.ToString(), 0, pos.StrBranchCode.ToString());
                                sqlCardRequest.NEmployeeID = pos.NCashierID;
                                sqlCardRequest.NStatusID = 0;
                                sqlCardRequest.StrBranchCode = pos.StrBranchCode.ToString();
                                sqlCardRequest.StrMembershipID = pos.StrMembershipID.ToString();
                                sqlCardRequest.DtLastEditDate = DateTime.Now;
                                sqlCardRequest.Insert();

                                sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberCard;
                                sqlAudit.NEmployeeID = pos.NCashierID;
                                sqlAudit.StrAuditEntry = "Reprint member card.";
                                sqlAudit.StrReference = pos.StrMembershipID.ToString();
                                sqlAudit.DtDate = DateTime.Now;
                                sqlAudit.Insert();

                            }
                            catch (Exception)
                            {
                                throw;
                            }
                            finally
                            {

                                sqlMember.Dispose();
                                sqlCardRequest.Dispose();
                                sqlAudit.Dispose();
                            }
                        }
                    }
                }

                if (memberPackagetable.Rows.Count > 0)
                    memberPackage.SaveData(memberPackagetable);
            }
            else if ((pos.NCategoryID == 2) || (pos.NCategoryID == 34) || (pos.NCategoryID == 35))//New GIRO = 35
            {
                TblGIRO giro = new TblGIRO();
                giro.MainConnectionProvider = connProvider;

                foreach (DataRow r in pos.ReceiptItemsTable.Rows)
                {
                    // need to save tblGiro 1st
                    int nQuantity = ACMS.Convert.ToInt32(r["nQuantity"]);
                    DataRow[] giroRows = pos.GiroTable.Select("nEntryID = " + r["nEntryID"].ToString(), "", DataViewRowState.CurrentRows);
                    if (giroRows.Length > 0)
                    {

                        giro.strCardHolderName = giroRows[0]["strCardHolderName"].ToString();
                        giro.strReceiptNo = pos.StrReceiptNo;
                        giro.nCreditCard = giroRows[0]["nCreditCard"].ToString();
                        giro.dtCreditCardExpired = DateTime.Now;
                        giro.strTypeofCard = giroRows[0]["strTypeofCard"].ToString();
                        giro.strReceiptNo = pos.StrReceiptNo;
                        giro.Insert();

                        for (int i = 0; i < nQuantity; i++)
                        {
                            DataRow rowToAdd = memberPackagetable.NewRow();
                            MemberPackage.InitMemberPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID, r["strCode"].ToString(), "",
                                false, giro.NGIRORefID.IsNull ? -1 : giro.NGIRORefID.Value, pos.dtPackageStart, pos.NProrateDays);

                            memberPackagetable.Rows.Add(rowToAdd);
                        }
                    }
                    else
                    {
                        TblMemberPackage GIROPackage = new TblMemberPackage();
                        GIROPackage.MainConnectionProvider = connProvider;
                        GIROPackage.NPackageID = pos.NExtendGIROpkg;
                        DataTable memberGIROPKG = GIROPackage.SelectOne();

                        //start
                        //if (pos.NExtendGIROpkg == 0)
                        //{

                        //    foreach (DataRow rs in pos.ReceiptItemsTable.Rows)
                        //    {
                        //        int nQuantity1 = ACMS.Convert.ToInt32(r["nQuantity"]);

                        //        if (rs["strCode"].ToString().ToUpper() != "REG")
                        //        {
                        //            for (int i = 0; i < nQuantity1; i++)
                        //            {
                        //                DataRow rowToAdd = memberPackagetable.NewRow();

                        //                MemberPackage.InitMemberPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID, rs["strCode"].ToString(), "", false);

                        //                memberPackagetable.Rows.Add(rowToAdd);

                        //            }
                        //        }

                        //    }
                        //GIROPackage.SaveData(memberGIROPKG);

                        //}
                        //else

                        //GIROPackage start
                        //  {
                        //DateTime ExtendExpiryDate = System.Convert.ToDateTime(GIROPackage.DtExpiryDate.ToString());
                        //if (ExtendExpiryDate.Day > 27)
                        //    memberGIROPKG.Rows[0]["dtexpirydate"] = new DateTime(ExtendExpiryDate.Year, ExtendExpiryDate.Month, 1).AddMonths(2).AddDays(-1);
                        //else if (ExtendExpiryDate.Day == 15)
                        //    memberGIROPKG.Rows[0]["dtexpirydate"] = new DateTime(ExtendExpiryDate.Year, ExtendExpiryDate.Month, 15).AddMonths(1);
                        //memberGIROPKG.Rows[0]["fGiroStatus"] = "S";

                        DateTime ExtendExpiryDate = System.Convert.ToDateTime(GIROPackage.DtExpiryDate.ToString());
                        if (ExtendExpiryDate.Day > 27)
                            if (nQuantity > 1)
                                memberGIROPKG.Rows[0]["dtexpirydate"] = new DateTime(ExtendExpiryDate.Year, ExtendExpiryDate.Month, 1).AddMonths(nQuantity + 1).AddDays(-1);
                            else
                                memberGIROPKG.Rows[0]["dtexpirydate"] = new DateTime(ExtendExpiryDate.Year, ExtendExpiryDate.Month, 1).AddMonths(2).AddDays(-1);
                        else if (ExtendExpiryDate.Day == 15)
                            if (nQuantity > 1)
                                memberGIROPKG.Rows[0]["dtexpirydate"] = new DateTime(ExtendExpiryDate.Year, ExtendExpiryDate.Month, 15).AddMonths(nQuantity + 1);
                            else
                                memberGIROPKG.Rows[0]["dtexpirydate"] = new DateTime(ExtendExpiryDate.Year, ExtendExpiryDate.Month, 15).AddMonths(1);

                        memberGIROPKG.Rows[0]["fGiroStatus"] = "S";

                        //set package status to active if expired date > today
                        if (Convert.ToDateTime(memberGIROPKG.Rows[0]["dtexpirydate"]) > DateTime.Now)
                            memberGIROPKG.Rows[0]["nStatusID"] = 0;

                        if (pos.NCategoryID == 34)
                        {
                            memberGIROPKG.Rows[0]["nAdjust"] = ACMS.Convert.ToDBInt32(memberGIROPKG.Rows[0]["nAdjust"]) + 1;

                            POSHelper myPOSHelper = new POSHelper(pos);
                            DataTable tblSpaPackage = myPOSHelper.SearchOnePackageCode(memberGIROPKG.Rows[0]["strPackageCode"].ToString());
                            if (tblSpaPackage != null)
                            {
                                if (tblSpaPackage.Rows.Count > 0)
                                {
                                    string strFreePackageCode = tblSpaPackage.Rows[0]["strFreePkgCode"].ToString();
                                    DataTable tblFreePackage = GIROPackage.SelectPackageCode(strFreePackageCode, pos.StrMembershipID);
                                    int nFreePackageID = Convert.ToInt32(tblFreePackage.Rows[0]["nPackageID"]);

                                    TblMemberPackage GIROFreePackage = new TblMemberPackage();
                                    GIROFreePackage.MainConnectionProvider = connProvider;
                                    GIROFreePackage.NPackageID = nFreePackageID;

                                    DataTable memberGIROFREEPKG = GIROFreePackage.SelectOne();

                                    memberGIROFREEPKG.Rows[0]["nAdjust"] = ACMS.Convert.ToDBInt32(memberGIROFREEPKG.Rows[0]["nAdjust"]) + 1;

                                    if (ExtendExpiryDate.Day > 27)
                                        memberGIROFREEPKG.Rows[0]["dtexpirydate"] = new DateTime(ExtendExpiryDate.Year, ExtendExpiryDate.Month, 1).AddMonths(2).AddDays(-1);
                                    else if (ExtendExpiryDate.Day == 15)
                                        memberGIROFREEPKG.Rows[0]["dtexpirydate"] = new DateTime(ExtendExpiryDate.Year, ExtendExpiryDate.Month, 15).AddMonths(1);
                                    memberGIROFREEPKG.Rows[0]["fGiroStatus"] = "S";
                                    GIROFreePackage.SaveData(memberGIROFREEPKG);
                                }
                            }
                        }
                        GIROPackage.SaveData(memberGIROPKG);
                        // }//GIROPackage start
                    }
                }

                if (memberPackagetable.Rows.Count > 0)
                    memberPackage.SaveData(memberPackagetable);
            }

            else if (pos.NCategoryID == 8 || pos.NCategoryID == 9)
            {
                TblPackageGroupEntries pckGroupEntries = new TblPackageGroupEntries();
                pckGroupEntries.MainConnectionProvider = connProvider;

                foreach (DataRow r in pos.ReceiptItemsTable.Rows)
                {
                    string strPackageGroupCode = r["strCode"].ToString();
                    int nQuantity = ACMS.Convert.ToInt32(r["nQuantity"]);

                    DataTable table = pckGroupEntries.GetPackageCodeList(strPackageGroupCode);

                    if (table != null && table.Rows.Count > 0)
                    {
                        int packageQty = 0;

                        foreach (DataRow r2 in table.Rows)
                        {
                            packageQty = ACMS.Convert.ToInt32(r2["nQuantity"]);

                            for (int i = 0; i < nQuantity; i++)
                            {
                                for (int j = 0; j < packageQty; j++)
                                {
                                    DataRow rowToAdd = memberPackagetable.NewRow();

                                    MemberPackage.InitMemberPackageRowInPOS(rowToAdd, pos.StrReceiptNo,
                                        pos.StrMembershipID, r2["strPackageCode"].ToString(), "", false);
                                    rowToAdd["strUpgradeFrom"] = strUpgradeFrom;
                                    rowToAdd["strRemarks"] = strRemarks;
                                    memberPackagetable.Rows.Add(rowToAdd);
                                }
                            }
                        }
                    }
                }
                if (memberPackagetable.Rows.Count > 0)
                    memberPackage.SaveData(memberPackagetable);
            }
        }
예제 #16
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;
            }
        }
예제 #17
0
파일: POS.cs 프로젝트: kimykunjun/test
        private void ReplaceMembershipCardTransaction(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos)
        {
            if (pos.NCategoryID == 20)
            {
                TblMember sqlMember = new TblMember();
                sqlMember.MainConnectionProvider = connProvider;

                sqlMember.StrMembershipID = pos.StrMembershipID;
                sqlMember.SelectOne();
                sqlMember.NCardStatusID = 0;
                sqlMember.StrCardBranchCode = "WL";
                sqlMember.Update();

                TblMember sqlIntroduceMember = new TblMember();
                sqlIntroduceMember.MainConnectionProvider = connProvider;
                sqlIntroduceMember.StrIntroducerMembershipID = pos.StrMembershipID;
                DataTable introduceMemberTable = sqlIntroduceMember.SelectAllWstrIntroducerMembershipIDLogic();

                if (introduceMemberTable != null && introduceMemberTable.Rows.Count > 0)
                {
                    foreach (DataRow r in introduceMemberTable.Rows)
                        r["StrIntroducerMembershipID"] = DBNull.Value;

                    sqlIntroduceMember.SaveData(introduceMemberTable);
                }

                string membershipID = pos.StrMembershipID;
                string newStrMembershipID = "";
                bool isMember = !membershipID.StartsWith("NMC");

                if (!isMember)
                {
                    TblCardRequest sqlCardRequest = new TblCardRequest();
                    TblCompany sqlCompany = new TblCompany();
                    sqlCompany.MainConnectionProvider = connProvider;
                    sqlCardRequest.MainConnectionProvider = connProvider;

                    sqlCompany.IncOne();

                    sqlMember.StrMembershipID = pos.StrMembershipID;
                    DataTable memberTable = sqlMember.SelectOne();

                    newStrMembershipID = "NMC" + sqlCompany.NNonMembershipNo.Value.ToString();
                    string origStrMembershipID = sqlMember.StrMembershipID.Value;
                    pos.StrNewMembershipID = newStrMembershipID;

                    memberTable.Rows[0]["nMembershipNo"] = sqlCompany.NNonMembershipNo.Value;
                    memberTable.Rows[0]["strMembershipID"] = newStrMembershipID;
                    memberTable.Rows[0]["nCardStatusID"] = (int)CardStatusType.RequestPrint;

                    string cmdText = "Update tblMember SET strMembershipID = @NewStrMembershipID, " +
                        " nMembershipNo = @nMembershipNo Where strMembershipID = @OriginalStrMembershipID";

                    sqlMember.UpdateKey(memberTable,  cmdText, "@NewStrMembershipID",  newStrMembershipID,
                        "@OriginalStrMembershipID", origStrMembershipID, new string[] {"@nMembershipNo"},
                        new object[] {sqlCompany.NNonMembershipNo.Value});

                    #region ====== Added By Albert ======
                    //To update member packages after changing MembershipID.
                    TblMemberPackage mMemberPackage;
                    mMemberPackage = new TblMemberPackage();
                    mMemberPackage.StrMembershipIDOld = origStrMembershipID;
                    mMemberPackage.StrMembershipID = newStrMembershipID;
                    mMemberPackage.UpdateAllWstrMembershipIDLogic();

                    TblMemberCreditPackage mMemberCreditPackage;
                    mMemberCreditPackage = new TblMemberCreditPackage();
                    mMemberCreditPackage.StrMembershipIDOld = origStrMembershipID;
                    mMemberCreditPackage.StrMembershipID = newStrMembershipID;
                    mMemberCreditPackage.UpdateAllWstrMembershipIDLogic();
                    #endregion

                    //Request print for new non member
                    sqlCardRequest.NEmployeeID = pos.NCashierID;
                    sqlCardRequest.NStatusID = (int)CardStatusType.RequestPrint;
                    sqlCardRequest.StrBranchCode = pos.StrBranchCode;
                    sqlCardRequest.StrMembershipID = "NMC" +sqlCompany.NNonMembershipNo;
                    sqlCardRequest.DtLastEditDate = DateTime.Now;
                    sqlCardRequest.Insert();
                }
                else
                {
                    TblCardRequest sqlCardRequest = new TblCardRequest();
                    TblBranch sqlBranch = new TblBranch();

                    sqlBranch.MainConnectionProvider = connProvider;
                    sqlCardRequest.MainConnectionProvider = connProvider;

                    sqlBranch.StrBranchCode = pos.StrBranchCode;
                    sqlBranch.IncOne();

                    sqlMember.StrMembershipID = pos.StrMembershipID;
                    DataTable memberTable = sqlMember.SelectOne();

                    newStrMembershipID = pos.StrBranchCode.TrimEnd() + ACMS.Convert.ToInt32(sqlBranch.NMembershipNo);
                    string origStrMembershipID = sqlMember.StrMembershipID.Value;
                    pos.StrNewMembershipID = newStrMembershipID;

                    memberTable.Rows[0]["nMembershipNo"] = ACMS.Convert.ToInt32(sqlBranch.NMembershipNo);
                    memberTable.Rows[0]["strMembershipID"] = newStrMembershipID;
                    memberTable.Rows[0]["nCardStatusID"] = (int)CardStatusType.RequestPrint;

                    string cmdText = "Update tblMember SET strMembershipID = @NewStrMembershipID, " +
                        " nMembershipNo = @nMembershipNo Where strMembershipID = @OriginalStrMembershipID";

                    sqlMember.UpdateKey(memberTable,  cmdText, "@NewStrMembershipID",  newStrMembershipID,
                        "@OriginalStrMembershipID", origStrMembershipID, new string[] {"@nMembershipNo"},
                        new object[] {ACMS.Convert.ToInt32(sqlBranch.NMembershipNo)});

                    #region ====== Added By Albert ======
                    //To update member packages after changing MembershipID.
                    TblMemberPackage mMemberPackage;
                    mMemberPackage = new TblMemberPackage();
                    mMemberPackage.StrMembershipIDOld = origStrMembershipID;
                    mMemberPackage.StrMembershipID = newStrMembershipID;
                    mMemberPackage.UpdateAllWstrMembershipIDLogic();

                    TblMemberCreditPackage mMemberCreditPackage;
                    mMemberCreditPackage = new TblMemberCreditPackage();
                    mMemberCreditPackage.StrMembershipIDOld = origStrMembershipID;
                    mMemberCreditPackage.StrMembershipID = newStrMembershipID;
                    mMemberCreditPackage.UpdateAllWstrMembershipIDLogic();
                    #endregion

                    //Request print for new non member
                    sqlCardRequest.NEmployeeID = pos.NCashierID;
                    sqlCardRequest.NStatusID = (int)CardStatusType.RequestPrint;
                    sqlCardRequest.StrBranchCode = pos.StrBranchCode;
                    sqlCardRequest.StrMembershipID = newStrMembershipID;
                    sqlCardRequest.DtLastEditDate = DateTime.Now;
                    sqlCardRequest.Insert();
                }

                if (introduceMemberTable != null && introduceMemberTable.Rows.Count > 0)
                {
                    foreach (DataRow r in introduceMemberTable.Rows)
                        r["StrIntroducerMembershipID"] = newStrMembershipID;

                    sqlIntroduceMember.SaveData(introduceMemberTable);
                }

                TblAudit sqlAudit = new TblAudit();
                sqlAudit.MainConnectionProvider = connProvider;
                //Audit trail for request print
                sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberCard;
                sqlAudit.NEmployeeID = pos.NCashierID;
                sqlAudit.StrAuditEntry = "Replace member card with new ID";
                sqlAudit.StrReference = newStrMembershipID;
                sqlAudit.DtDate = DateTime.Now;
                sqlAudit.Insert();
            }
        }
예제 #18
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;
        }