コード例 #1
0
ファイル: User.cs プロジェクト: kimykunjun/test
        public bool Login(string nEmployeeID, string strPassword)
        {
            TblEmployee oEmployee = new TblEmployee();
            DataTable dtEmployee;
            int rowCount;

            ACMSDAL.TblEmployee emp = new ACMSDAL.TblEmployee();
            DataTable dt = emp.SelectAll();

            int empId = int.MinValue;

            DataRow row;
            foreach (DataRow tempLoopVar_row in dt.Rows)
            {
                row = tempLoopVar_row;
                if (row["strEmployeeName"].ToString() == nEmployeeID)
                {
                    empId = System.Convert.ToInt32(row[0].ToString());
                }
            }

            oEmployee.NEmployeeID = new SqlInt32(empId);
            oEmployee.StrPassword = new SqlString(strPassword.Trim());

            try
            {
                dtEmployee = oEmployee.SelectOne();
                rowCount = dtEmployee.Rows.Count;

                if (dtEmployee.Rows.Count > 0)
                {
                    DataRow dr;
                    dr = dtEmployee.Rows[0];

                    if (rowCount > 0 && dr[2].ToString() == strPassword)
                    {
                        EmployeeID = oEmployee.NEmployeeID.Value;
                        EmployeeName = oEmployee.StrEmployeeName.ToString();
                        JobPositionCode = oEmployee.StrJobPositionCode.ToString();
                        BranchCode = oEmployee.StrBranchCode.ToString();
                        RightsLevelID = oEmployee.NRightsLevelID.Value;
                        DepartmentID = oEmployee.NDepartmentID.Value;
                        dtCessation = System.Convert.ToDateTime(oEmployee.DtCessation.Value);
                        //RoadShow= ch
                        return true;
                    }
                }
                else
                {
                    return false;
                }
            //				oEmployee.Dispose();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
            return true;
        }
コード例 #2
0
ファイル: POS.cs プロジェクト: kimykunjun/test
        private void myReceiptMasterTable_ColumnChanged(object sender, DataColumnChangeEventArgs e)
        {
            if (IsColumnChangedDisable())
                return;

            if (System.String.Compare(e.Column.ColumnName, "strDiscountCode", true) == 0 ||
                System.String.Compare(e.Column.ColumnName, "DiscountAmt", true) == 0 ||
                System.String.Compare(e.Column.ColumnName, "mVoucherAmount", true) == 0 ||
                System.String.Compare(e.Column.ColumnName, "mNettAmount", true) == 0 ||
                System.String.Compare(e.Column.ColumnName, "mGSTAmount", true) == 0)
            {
                DisableColumnChanged();

                try
                {
                    RecalculateAll();
                }
                finally
                {
                    EnableColumnChanged();
                }
            }
            else if (System.String.Compare(e.Column.ColumnName, "nSalesPersonID", true) == 0)
            {
                DisableColumnChanged();

                try
                {
                    TblEmployee employee = new TblEmployee();
                    employee.NEmployeeID = ACMS.Convert.ToInt32(myReceiptMasterTable.Rows[0]["nSalesPersonID"]);
                    employee.SelectOne();
                    if (employee.StrEmployeeName.IsNull)
                        e.Row["strSalesPersonName"] = DBNull.Value;
                    else
                        e.Row["strSalesPersonName"] = employee.StrEmployeeName.Value;
                }
                finally
                {
                    EnableColumnChanged();
                }
            }
            else if (System.String.Compare(e.Column.ColumnName, "nTherapistID", true) == 0)
            {
                DisableColumnChanged();

                try
                {
                    TblEmployee employee = new TblEmployee();
                    employee.NEmployeeID = ACMS.Convert.ToInt32(myReceiptMasterTable.Rows[0]["nTherapistID"]);
                    employee.SelectOne();
                    if (employee.StrEmployeeName.IsNull)
                        e.Row["strTherapistName"] = DBNull.Value;
                    else
                        e.Row["strTherapistName"] = employee.StrEmployeeName.Value;
                }
                finally
                {
                    EnableColumnChanged();
                }
            }
            else if (System.String.Compare(e.Column.ColumnName, "strReceiptNo", true) == 0)
            {
                ChangeReceipNo();
            }
        }
コード例 #3
0
ファイル: MemberPackage.cs プロジェクト: kimykunjun/test
        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;
            }
        }
コード例 #4
0
ファイル: ClassAttendance.cs プロジェクト: kimykunjun/test
        public void PrintClassAttendance(DataTable sourceTable)
        {
            int nClassInstanceID = ACMS.Convert.ToInt32(sourceTable.Rows[0]["nClassInstanceID"]);

            DataTable table = GetClassAttendance(nClassInstanceID);

            string membershipID = "";
            foreach (DataRow r in table.Rows)
            {
                membershipID += r["strMembershipID"].ToString() + ",";
            }

            if (!sourceTable.Columns.Contains("MembershipIDList"))
            {
                DataColumn colMembershipIDList = new DataColumn("MembershipIDList", typeof(string));
                sourceTable.Columns.Add(colMembershipIDList);
            }

            if (!sourceTable.Columns.Contains("strReplacementVerifyName"))
            {
                DataColumn colstrReplacementVerifyName = new DataColumn("strReplacementVerifyName", typeof(string));
                sourceTable.Columns.Add(colstrReplacementVerifyName);
            }

            string strReplacementVerifyName = "";
            if (sourceTable.Rows[0]["nReplacementVerifyID"] != DBNull.Value &&
                sourceTable.Rows[0]["nReplacementVerifyID"].ToString() != "")
            {
                TblEmployee employee = new TblEmployee();
                employee.NEmployeeID = ACMS.Convert.ToInt32(sourceTable.Rows[0]["nReplacementVerifyID"]);
                employee.SelectOne();
                strReplacementVerifyName = employee.StrEmployeeName.Value;
            }
            sourceTable.Rows[0]["strReplacementVerifyName"] = strReplacementVerifyName;
            sourceTable.Rows[0]["MembershipIDList"] = membershipID;

            ACMSLogic.Report.ClassAttendanceReport report = new ACMSLogic.Report.ClassAttendanceReport();
            report.DataSource = sourceTable;
            report.CreateDataBindings();

            report.Print();
        }
コード例 #5
0
ファイル: ClassAttendance.cs プロジェクト: kimykunjun/test
        public bool LoginClassInstance(int nClassInstanceID, string employeeID, string employeePassword)
        {
            myClassInstance.NClassInstanceID = nClassInstanceID;
            myClassInstance.SelectOne();

            int nEmployeeID = 0;

            if (employeeID != TEMP_INSTRUCTOR)
            {
                try
                {
                    nEmployeeID = System.Convert.ToInt32(employeeID);
                }
                catch
                {
                    return false;
                }
            }

            if (employeeID.ToLower().Trim() != TEMP_INSTRUCTOR)
            {
                int nReplacementInstructorID = myClassInstance.NReplacementInstructorID.IsNull ? 0 : myClassInstance.NReplacementInstructorID.Value;
                int nPermanentInstructorID = myClassInstance.NPermanentInstructorID.IsNull ? 0 : myClassInstance.NPermanentInstructorID.Value;

                if (nReplacementInstructorID == nEmployeeID ||
                    nPermanentInstructorID == nEmployeeID)
                {
                    TblEmployee employee = new TblEmployee();
                    employee.NEmployeeID = nEmployeeID;
                    employee.SelectOne();
                    if (employee.StrPassword.Value == employeePassword)
                    {
                        myClassInstance.NActualInstructorID = nEmployeeID;
                        myClassInstance.DtInstructorLogin = DateTime.Now;

                        myClassInstance.Update();
                        return true;
                    }
                    else
                        return false;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return true;
            }
        }
コード例 #6
0
ファイル: ClassAttendance.cs プロジェクト: kimykunjun/test
        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;
        }
コード例 #7
0
ファイル: Appointment.cs プロジェクト: kimykunjun/test
        public bool VerifyAppointment(int verifyUserID, string verifyUserPassword, int nAppointmentID)
        {
            TblEmployee verifyUser = new TblEmployee();

            verifyUser.NEmployeeID = verifyUserID;

            verifyUser.SelectOne();

            if (verifyUser.StrPassword.IsNull)
                throw new Exception("Invalid User ID or Password");

            if (verifyUser.StrPassword.Value != verifyUserPassword)
                throw new Exception("Invalid User ID or Password");

            TblAppointment myAppointment = new TblAppointment();
            myAppointment.NAppointmentId = nAppointmentID;
            myAppointment.SelectOne();

            if (!myAppointment.NVerifiedBy.IsNull)
                throw new Exception("This appointment have been verified by other staff with the employee ID : " + myAppointment.NVerifiedBy.Value.ToString());

            myAppointment.NVerifiedBy = verifyUserID;
            //myAppointment.NStatus = 1;
            myAppointment.Update();
            return true;
        }
コード例 #8
0
        private void simpleButton1_Click(object sender, System.EventArgs e)
        {
            //if (DateTime.Compare(dtEdtStartTime.DateTime.Date, DateTime.Today.Date) < 0)
            //{
            //    if (oUser.NRightsLevelID() >= 1003 &&  oUser.NRightsLevelID() <= 1004 )
            //    {
            //        MessageBox.Show(this, "Invalid Date. Pls choose other date.");
            //        this.DialogResult   = DialogResult.None;
            //        return;
            //    }
            //}

            //this.DialogResult = DialogResult.OK;  //DEREK

            if (lkpEdtBranchCode.Text == "")
            {
                MessageBox.Show(this, "No Branch Selected.");
                this.DialogResult   = DialogResult.None;
                //return;

            }
            else if (lkpEdtEmployeeID.Text == "")
            {
                MessageBox.Show(this, "No Therapist Selected");
                this.DialogResult   = DialogResult.None;
                //return;

            }
            else if (lkpEdtServiceCode.Text == "")
            {
                MessageBox.Show(this, "No Treatment Selected.");
                this.DialogResult   = DialogResult.None;
                //return;

            }
            else
            {
                try
                {
                    TblEmployee myPT = new TblEmployee();
                    myPT.NEmployeeID = this.TherapistID;
                    DataTable tblPT = myPT.SelectOne();
                    MemberPackage myMemPackage = new MemberPackage();
                    DataTable tblMemberPackageBalance = MemberPackage.CalculateMemberPackageBalance(this.ServiceCode, myMemberShipID, myPackageID);

                    myPackageBalance = (Convert.ToInt32(tblMemberPackageBalance.Rows[0]["Balance"].ToString()) - 1);

                    string strBalance = myPackageBalance.ToString();
                    string strTherapist = tblPT.Rows[0]["strEmployeeName"].ToString();
                    string strExpiryDate = Convert.ToDateTime(tblMemberPackageBalance.Rows[0]["dtExpiryDate"]).ToString("dd/MM/yyyy");

                    //** Insert Signature eric 15052009
                    //==================================
                    string strSignatureID = "";
                    string strKeyData = "";
                    string strDateTime = DateTime.Now.ToString("dd/MM/yyyy  hh:mm:ss tt");
                    string strDateTimeMM = DateTime.Now.ToString("dd/MM/yyyy  hh:mm tt");
                    string strPdfExportPath = "";

                    //int mySessionID = 0;

                    DataTable dtss = new DataTable();
                    dtss.Columns.Add("nSessionID", typeof(int));
                    dtss.Columns.Add("strMembershipID", typeof(string));
                    mydtSessionID = dtss;

                    //Key data format for PT Service Utilisation
                    //MemberID|DateTime|ExpiryDate|Branch|PT|PkgCode|ServCode|Qty|Bal
                    strPdfExportPath = (string)ConfigurationSettings.AppSettings["SavePTServiceReceiptPath"].ToString() + "\\" + User.BranchCode + "\\" + myMemberShipID.Trim() + "_" + strDateTime.Replace(":", "").Replace(" ", "").Replace("/", "") + ".pdf";
                    strKeyData = myMemberShipID.Trim() + "|" + strExpiryDate + "|" + this.BranchCode + "|" + strTherapist + "|" + myPackageCode + "|" + this.ServiceCode + "|" + strBalance + "|1";

                    myKeyData = strKeyData;

                    if (myPackageCategoryID == 3)
                    {
                        MemberPackage myMemberPackage = new MemberPackage();

                        myMemberPackage.NewServiceSession(myPackageID, this.ServiceCode, myMemberShipID.Trim(),
                                this.TherapistID, this.BranchCode, this.Date, this.StartTime, this.StartTime, "", 1, this.bforfeit, myPackageCategoryID,
                                strKeyData, strPdfExportPath, ref mydtSessionID, "");
                    }

                    bool outputPrint = false;

                    //Derek From Credit Package Usage Do not print
                    if (!myIsFromCreditUsage)
                    {
                        if (myPackageCategoryID == 3)
                        {
                            DigSignature frmSig = new DigSignature(strKeyData, "ServiceUtilisation",null, null, dtServiceUtilization);
                            DialogResult result1 = frmSig.ShowDialog();

                            if (result1 == DialogResult.OK)
                            {
                                strSignatureID = frmSig.ShowSignature();

                                //**DEREK Need Fixing here Update Service Session Signature ID **
                                try
                                {
                                    //Derek Need Fixing Here loop throught mydtSessionID
                                    foreach (DataRow row in mydtSessionID.Rows)
                                    {
                                        //Derek Need Fixing Here - Update only strSignatureID and strPdfExportPath
                                        TblServiceSession myServiceSessionSigPath = new TblServiceSession();

                                        if (strSignatureID.Trim() != "" && strSignatureID.Trim() != "300D0A300D0A")
                                        {
                                            myServiceSessionSigPath.UpdateServiceSessionSigPdfPath(strSignatureID, strKeyData, strPdfExportPath, Convert.ToInt32(row["nSessionID"]), myMemberShipID);
                                        }
                                        else
                                        {
                                            myServiceSessionSigPath.UpdateServiceSessionSigPdfPath(strPdfExportPath, Convert.ToInt32(row["nSessionID"]), myMemberShipID);
                                        }

                                    }
                                }
                                catch { }

                                outputPrint = true;

                                /*if (strSignatureID == null || strSignatureID == "")
                                {
                                    DialogResult yes = MessageBox.Show(this, "Member haven't signed on signature pad. Confirm to print?", "Warning", MessageBoxButtons.YesNo);
                                    if (yes == DialogResult.No)
                                        return;
                                }*/

                                //OnPrintMemberPackageUsage(tblTherapist.Rows[0]["strEmployeeName"].ToString(), CurrentMembershipID, MemberPackageStrPackageCode, frm.ServiceCode, strBalance);//eric 18052009

                                //**Call Print Package A/C report
                                //rpt.PrintRpt(strSignatureID, CurrentMembershipID, strDateTime, frm.BranchCode, strTherapist, MemberPackageStrPackageCode, frm.ServiceCode, strBalance);

                            }

                            PackageAccountRpt rpt = new PackageAccountRpt();

                            rpt.PrintRpt("Personal Trainer :", strSignatureID, strKeyData, myMemberShipID.Trim(), strDateTimeMM, strExpiryDate, this.BranchCode, strTherapist, myPackageCode, this.ServiceCode, strBalance, 1);
                            string exportPath = (string)ConfigurationSettings.AppSettings["SavePTServiceReceiptPath"].ToString();
                            rpt.ExportToPdf(exportPath + "\\" + User.BranchCode + "\\" + myMemberShipID.Trim() + "_" + strDateTime.Replace(":", "").Replace(" ", "").Replace("/", "") + ".pdf");

                            if (outputPrint)
                            {
                                rpt.Print();
                            }

                            //InitMemberPackage(CurrentMembershipID);
                            //OnMemberPackageGridFocusRowChanged();
                        }
                    }
                    else
                    {
                        if (myPackageCategoryID == 3)
                        {
                            //Update DataTable
                            DataTable dt = new DataTable();
                            dt.Columns.Add("Caption", typeof(string));
                            dt.Columns.Add("MemberID", typeof(string));
                            dt.Columns.Add("DateTime", typeof(string));
                            dt.Columns.Add("ExpiryDate", typeof(string));
                            dt.Columns.Add("BranchCode", typeof(string));
                            dt.Columns.Add("StaffName", typeof(string));
                            dt.Columns.Add("PackageCode", typeof(string));
                            dt.Columns.Add("PackageDesc", typeof(string));//lblPackageDesc.Text
                            dt.Columns.Add("ServiceCode", typeof(string));
                            dt.Columns.Add("Balance", typeof(string));
                            dt.Columns.Add("Quantity", typeof(int));
                            //dt.Columns.Add("mySessionID", typeof(int)); //**DEREK Need Fixing here

                            dt.Rows.Add("Personal Trainer :", myMemberShipID.Trim(), strDateTimeMM, strExpiryDate, this.BranchCode, strTherapist,
                                myPackageCode, lblPackageDesc.Text.ToString(), this.ServiceCode, strBalance, 1);

                            mydtServiceUtilization = dt;
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.DialogResult = DialogResult.None;

                    MessageBox.Show(this, ex.Message);
                }
            }
        }