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(); } }
private void SaveUpToDateReceiptNo(ACMSDAL.ConnectionProvider connProvider, DataTable branchReceiptNoTable) { TblBranchReceiptNo branchReceiptNo = new TblBranchReceiptNo(); branchReceiptNo.MainConnectionProvider = connProvider; branchReceiptNo.SaveData(branchReceiptNoTable); }
private void DeleteUselessIPP(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos) { DataRow[] rowListThatHaveIPP = pos.ReceiptPaymentTable.Select("nIPPID is not null", "", DataViewRowState.CurrentRows); if (rowListThatHaveIPP.Length > 0) { TblIPP sqlIPP = new TblIPP(); sqlIPP.MainConnectionProvider = connProvider; DataTable table = sqlIPP.GetIPP(pos.StrMembershipID, pos.StrBranchCode); foreach (DataRow r in rowListThatHaveIPP) { int nIPPID = ACMS.Convert.ToInt32(r["nIPPID"]); DataRow[] rowToUpdate = table.Select("nIPPID = " + nIPPID.ToString()); if (rowToUpdate.Length > 0) { rowToUpdate[0]["nIPPStatus"] = 0; } } DataRow[] rowListToDelete = table.Select("nIPPStatus = 3", "", DataViewRowState.CurrentRows); foreach (DataRow deleteRow in rowListToDelete) { deleteRow.Delete(); } sqlIPP.SaveData(table); } }
private void PostToStock(ACMSDAL.ConnectionProvider connProvider, DataTable TblQty, ACMSLogic.POS pos) { TblProductInventory proInven = new TblProductInventory(); proInven.MainConnectionProvider = connProvider; //SelectedGridItemChangedEventArgs(); // deduct stock foreach (DataRow r in TblQty.Rows) { if (r["strCode"].ToString().ToUpper() != "REG") { int nQuantity = ACMS.Convert.ToInt32(r["nQuantity"]); proInven.IncreaseQuantity(r["strCode"].ToString(), pos.StrBranchCode, -nQuantity); } } }
private void UpdateRegistrationFee(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos) { if (pos.ReceiptItemsTable.Select("strCode = 'Reg'", "", DataViewRowState.CurrentRows).Length == 1) { TblMember member = new TblMember(); member.MainConnectionProvider = connProvider; TblMemberPackage mp = new TblMemberPackage(); DataTable table = member.LoadData("Select * from tblMember Where strMembershipID = @strMembershipID", new string[] {"@strMembershipID"}, new object[]{pos.StrMembershipID}); table.Rows[0]["fRegistrationFee"] = 1; member.SaveData(table); } }
private int UpgradeCreditPackage(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos) { int OriginalCategoryID = 10 ; if (pos.NCategoryID == 10 && pos.NoCredit != 0) { //delete the old package TblMemberCreditPackage memberCreditPackage = new TblMemberCreditPackage(); //add back the uprade package memberCreditPackage.MainConnectionProvider = connProvider; DataTable memberCreditPackageTable = memberCreditPackage.FillSchema("Select * from tblMemberCreditPackage"); foreach (DataRow r in pos.ReceiptItemsTable.Rows) { int nQuantity = ACMS.Convert.ToInt32(r["nQuantity"]); memberCreditPackage.NCreditPackageID = ACMS.Convert.ToInt32(r[17]); memberCreditPackage.Delete(); for (int i = 0; i < nQuantity; i++) { DataRow rowToAdd = memberCreditPackageTable.NewRow(); CreditAccount.InitMemberCreditPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID, r["strCode"].ToString(), false); memberCreditPackageTable.Rows.Add(rowToAdd); } } if (memberCreditPackageTable.Rows.Count > 0) memberCreditPackage.SaveData(memberCreditPackageTable); } OriginalCategoryID= 7; return OriginalCategoryID; }
private void MakeDeposit(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos) { if (pos.NCategoryID == 16) { TblMember member = new TblMember(); member.MainConnectionProvider = connProvider; member.StrMembershipID = pos.StrMembershipID; member.SelectOne(); member.FLockerDeposit = true; member.Update(); } }
private void UpdateCategoryID(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos) { if (pos.NCategoryID == 0 ) { TblReceipt sqlReceipt = new TblReceipt(); sqlReceipt.MainConnectionProvider = connProvider; //foreach (DataRow row in pos.ReceiptItemsTable.Rows) //DataTable classAttendanceTable = classAttendance.GetForgetCardClassAttendance(pos.StrMembershipID, dtDate); DataTable receiptTable = new DataTable(); //receipt.NCategoryIDOld = GetOriginalCatID(connProvider, pos, ref branchReceiptNoTable); //receipt.NCategoryID = GetOriginalCatID(connProvider, pos, ref branchReceiptNoTable); sqlReceipt.StrReceiptNo = pos.StrReceiptNo; sqlReceipt.SelectOne(); sqlReceipt.SaveData(receiptTable);// .Update(); } }
private void GIROpkgTransaction(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos) { if (pos.NCategoryID == 2) { TblMemberPackage GIROPackage = new TblMemberPackage(); GIROPackage.MainConnectionProvider = connProvider; GIROPackage.NPackageID = pos.NExtendGIROpkg; DataTable memberGIROPKG = GIROPackage.SelectOne(); memberGIROPKG.Rows[0]["dtexpirydate"] = GIROPackage.DtExpiryDate.Value.AddMonths(1); GIROPackage.SaveData(memberGIROPKG); } }
private void LockerTransaction(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos) { if (pos.NCategoryID == 15) { if (pos.POSLockerAction == ACMSLogic.POS.LockerAction.Return) { // Locker Return. ACMSDAL.TblLocker sqlLocker = new ACMSDAL.TblLocker(); sqlLocker.MainConnectionProvider = connProvider; DataTable table = sqlLocker.GetOccupiedLocker(pos.StrBranchCode, pos.StrMembershipID); if (table == null || table.Rows.Count == 0) { throw new Exception("No lockers have been rented."); } ACMSDAL.TblBranch sqlBranch = new ACMSDAL.TblBranch(); sqlBranch.MainConnectionProvider = connProvider; sqlBranch.StrBranchCode = pos.StrBranchCode; sqlBranch.SelectOne(); int gracePeriod = ACMS.Convert.ToInt32(sqlBranch.NLockerGracePeriod); foreach (DataRow r in pos.ReceiptItemsTable.Rows) { string nLockerNo = r["strCode"].ToString(); DataRow[] lockerRows = table.Select("nLockerNo = " + nLockerNo); if (lockerRows.Length > 0) { DataRow lockerRow = lockerRows[0]; DateTime dtExpiryDate = ACMS.Convert.ToDateTime(lockerRow["dtExpiry"]); TimeSpan span = DateTime.Today.Subtract(dtExpiryDate.Date); if (span.Days > gracePeriod) throw new Exception(string.Format("locker No : {0} have exceed the grace period.", nLockerNo)); lockerRow["strMembershipID"] = DBNull.Value; lockerRow["strReceiptNo"] = DBNull.Value; lockerRow["dtExpiry"] = DBNull.Value; lockerRow["nStatusID"] = 0; } } sqlLocker.SaveData(table); } else if (pos.POSLockerAction == ACMSLogic.POS.LockerAction.Extend) { ACMSDAL.TblLocker sqllocker = new ACMSDAL.TblLocker(); sqllocker.MainConnectionProvider = connProvider; DataTable table = sqllocker.GetOccupiedLocker(pos.StrBranchCode, pos.StrMembershipID); if (table.Rows.Count > 0) { foreach (DataRow r in pos.ReceiptItemsTable.Rows) { string nLockerNo = r["strCode"].ToString(); DataRow[] lockerRows = table.Select("nLockerNo = " + nLockerNo); if (lockerRows.Length > 0) { DataRow lockerRow = lockerRows[0]; DateTime expiryDate = ACMS.Convert.ToDateTime(lockerRow["dtExpiry"]); int months = ACMS.Convert.ToInt32(r["nQuantity"]); if (DateTime.Now.Year == 2015 && (DateTime.Now.Month == 3 || DateTime.Now.Month == 4) && (pos.StrBranchCode == "TO" || pos.StrBranchCode == "SM" || pos.StrBranchCode == "HM" || pos.StrBranchCode == "TS" || pos.StrBranchCode == "BJ" || pos.StrBranchCode == "SV") && ACMS.Convert.ToInt32(r["nQuantity"]) >= 3) { int nFreeMonth; nFreeMonth = months / 3; DialogResult result1 = MessageBox.Show("Member entitled " + nFreeMonth.ToString() + " month free extension for locker ID " + nLockerNo.ToString() + ". Do you want to give the free extension?", "Warning", MessageBoxButtons.YesNo); if (result1 == DialogResult.Yes) { expiryDate = expiryDate.AddMonths(months + nFreeMonth); } else expiryDate = expiryDate.AddMonths(months); } else expiryDate = expiryDate.AddMonths(months); //lockerRow["dtExpiry"] = expiryDate.AddDays(-1); lockerRow["dtExpiry"] = expiryDate; } } sqllocker.SaveData(table); } } else if (pos.POSLockerAction == ACMSLogic.POS.LockerAction.New) { ACMSDAL.TblLocker sqllocker = new ACMSDAL.TblLocker(); sqllocker.MainConnectionProvider = connProvider; foreach (DataRow r in pos.ReceiptItemsTable.Rows) { if (r["strDescription"].ToString() != "Locker Deposit") { int nlockerNO = ACMS.Convert.ToInt32(r["strCode"]); int months = ACMS.Convert.ToInt32(r["nQuantity"]); sqllocker.NLockerNo = nlockerNO; sqllocker.SelectOne(); if (DateTime.Now.Year == 2015 && (DateTime.Now.Month == 3 || DateTime.Now.Month == 4) && (pos.StrBranchCode == "TO" || pos.StrBranchCode == "SM" || pos.StrBranchCode == "HM" || pos.StrBranchCode == "TS" || pos.StrBranchCode == "BJ" || pos.StrBranchCode == "SV") && ACMS.Convert.ToInt32(r["nQuantity"]) >= 3) { int nFreeMonth; nFreeMonth = months / 3; DialogResult result1 = MessageBox.Show("Member entitled " + nFreeMonth.ToString() + " month free extension for locker ID " + nlockerNO .ToString() + ". Do you want to give the free extension?", "Warning", MessageBoxButtons.YesNo); if (result1 == DialogResult.Yes) { sqllocker.DtExpiry = DateTime.Today.AddMonths(months+nFreeMonth).AddDays(-1); } else sqllocker.DtExpiry = DateTime.Today.AddMonths(months).AddDays(-1); } else sqllocker.DtExpiry = DateTime.Today.AddMonths(months).AddDays(-1); sqllocker.StrBranchCode = pos.StrBranchCode; sqllocker.StrMembershipID = pos.StrMembershipID; sqllocker.StrReceiptNo = pos.StrReceiptNo; sqllocker.NStatusID = 1; sqllocker.Update(); } } } } }
private int GetOriginalCatID(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos, ref DataTable tableRec) { TblReceipt strCatReceiptNo = new TblReceipt(); strCatReceiptNo.MainConnectionProvider = connProvider; tableRec = strCatReceiptNo.GetOriginalCatID(pos.StrParentReceiptNo); int orgCatID = 0; if (tableRec.Rows.Count > 0) { orgCatID = ACMS.Convert.ToInt32(tableRec.Rows[0]["nCategoryID"]); } return orgCatID; }
private int GetLatestReceiptNo(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos, ref DataTable branchReceiptNoTable) { TblBranchReceiptNo branchReceiptNo = new TblBranchReceiptNo(); branchReceiptNo.MainConnectionProvider = connProvider; branchReceiptNoTable = branchReceiptNo.GetLatestReceiptNo(pos.StrBranchCode, pos.NTerminalID); int receiptNo = 0; if (branchReceiptNoTable.Rows.Count > 0) { receiptNo = ACMS.Convert.ToInt32(branchReceiptNoTable.Rows[0]["nReceiptNo"]); } return receiptNo; }
private void ForgetCardTransaction(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos) { if (pos.NCategoryID == 17 && pos.POSForgetCardAction == ACMSLogic.POS.ForgetCardAction.Refund) { TblClassAttendance classAttendance = new TblClassAttendance(); classAttendance.MainConnectionProvider = connProvider; TblReceipt sqlReceipt = new TblReceipt(); sqlReceipt.MainConnectionProvider = connProvider; foreach (DataRow row in pos.ReceiptItemsTable.Rows) { DateTime dtDate = ACMS.Convert.ToDateTime(row["strReferenceNo"]); DataTable classAttendanceTable = classAttendance.GetForgetCardClassAttendance(pos.StrMembershipID, dtDate); foreach (DataRow r in classAttendanceTable.Rows) { r["fRefunded"] = true; } classAttendance.SaveData(classAttendanceTable); /* string receiptToVoid = row["strCode"].ToString(); sqlReceipt.StrReceiptNo = receiptToVoid; sqlReceipt.SelectOne(); sqlReceipt.FVoid = SqlBoolean.True; sqlReceipt.Update();*/ } } }
private void TopUpCreditPackage(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos) { if (pos.NCategoryID == 18) { TblMemberCreditPackage memberCreditPackage = new TblMemberCreditPackage(); memberCreditPackage.MainConnectionProvider = connProvider; foreach (DataRow r in pos.ReceiptItemsTable.Rows) { int nCreditPackageID = ACMS.Convert.ToInt32(r["strCode"]); memberCreditPackage.NCreditPackageID = nCreditPackageID; memberCreditPackage.SelectOne(); memberCreditPackage.MTopupAmount = ACMS.Convert.ToDecimal(memberCreditPackage.MTopupAmount) + ACMS.Convert.ToDecimal(r["mSubTotal"]); memberCreditPackage.Update(); } } }
private void MineralWaterTransaction(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos) { if (pos.NCategoryID == 21 && pos.ReceiptItemsTable.Rows.Count > 0) { string strProductCode = pos.ReceiptItemsTable.Rows[0]["strCode"].ToString(); int qtyToDeduct = ACMS.Convert.ToInt32(pos.ReceiptItemsTable.Rows[0]["MineralWaterQty"]); TblProductInventory producInv = new TblProductInventory(); producInv.MainConnectionProvider = connProvider; producInv.IncreaseQuantity(strProductCode, pos.StrBranchCode, -qtyToDeduct); } }
private void TopUpSingleTreatmentTransaction(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos) { if (pos.NCategoryID == 19) { TblServiceSession sqlserviceSession = new TblServiceSession(); sqlserviceSession.MainConnectionProvider = connProvider; string strServiceCode = ""; int nPackageID = -1; foreach (DataRow r in pos.ReceiptItemsTable.Rows) { strServiceCode = r["strCode"].ToString(); nPackageID = ACMS.Convert.ToInt32(r["strReferenceNo"]); sqlserviceSession.DtDate = DateTime.Today.Date; sqlserviceSession.DtStartTime = DateTime.Now; sqlserviceSession.DtEndTime = DateTime.Now.AddMinutes(15); sqlserviceSession.DtLastEditDate = DateTime.Now; sqlserviceSession.NEmployeeID = User.EmployeeID; sqlserviceSession.NPackageID = nPackageID; sqlserviceSession.NStatusID = 5; sqlserviceSession.StrBranchCode = User.BranchCode; sqlserviceSession.StrMembershipID = pos.StrMembershipID; sqlserviceSession.StrServiceCode = strServiceCode; sqlserviceSession.Insert(); r["strReferenceNo"] = sqlserviceSession.NSessionID; } } }
//Derek Instalment Plan Need Update tblPaymentPlan During Pay OutStanding //Derek Instalment Plan TblPaymentPlan.cs private int PayOutstanding(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos) { int OriginalCategoryID = 0 ; if (pos.NCategoryID == 0) { TblReceipt receipt = new TblReceipt(); receipt.MainConnectionProvider = connProvider; if (pos.ReceiptItemsTable.Rows.Count == 1) { string strReceiptNo = pos.ReceiptItemsTable.Rows[0]["strCode"].ToString(); decimal payAmount = ACMS.Convert.ToDecimal(pos.ReceiptItemsTable.Rows[0]["mSubtotal"]); receipt.StrReceiptNo = strReceiptNo; receipt.SelectOne(); OriginalCategoryID=receipt.NCategoryID.Value; receipt.MOutstandingAmount = 0; receipt.StrChildReceiptNo = pos.StrReceiptNo; pos.StrRewardsCode=receipt.StrRewardsCode.ToString(); //receipt.StrParentReceiptNo = strReceiptNo; if(receipt.NTherapistID.IsNull != true) { if(receipt.NTherapistID.Value.ToString().Length>0) pos.NTherapistID = receipt.NTherapistID.Value; } receipt.Update(); receipt.StrReceiptNo = pos.StrReceiptNo; receipt.SelectOne(); receipt.StrParentReceiptNo = strReceiptNo; receipt.Update(); } } return OriginalCategoryID; }
private void UpdateOldPackSetDeactivate(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos) { try { string strFreePackageCode, strReceiptNo; foreach (DataRow dr in pos.WantToUpgradeMemberPackageTable.Rows) { string strRemarks; if (Convert.ToInt32(dr["nCategoryID"]) == 7 || Convert.ToInt32(dr["nCategoryID"]) == 36 || Convert.ToInt32(dr["nCategoryID"]) == 37) { TblMemberCreditPackage mp = new TblMemberCreditPackage(); mp.MainConnectionProvider = connProvider; DataTable table = mp.LoadData("Select * from tblMemberCreditPackage Where nCreditPackageID = @nPackageID", new string[] { "@nPackageID" }, new object[] { dr["nPackageID"] }); strReceiptNo = table.Rows[0]["strReceiptNo"].ToString(); table.Rows[0]["nStatusID"] = 3; table.Rows[0]["strUpgradeTo"] = pos.StrReceiptNo; strRemarks = "Convert to: " + pos.StrReceiptNo; table.Rows[0]["strRemarks"] = strRemarks; mp.SaveData(table); } else if (Convert.ToInt32(dr["nCategoryID"]) == 8 || Convert.ToInt32(dr["nCategoryID"]) == 9) { DataSet dsCombo = new DataSet(); string strSQL = "select pge.*,re.strReceiptNo from tblReceiptEntries re, tblPackageGroupEntries pge where nEntryID =" + dr["nPackageID"] + " and re.strCode=pge.strPackageGroupCode"; SqlHelper.FillDataset(connection, CommandType.StoredProcedure, "UP_GETDATA", dsCombo, new string[] { "Table" }, new SqlParameter("@strSQL", strSQL)); foreach (DataRow drCombo in dsCombo.Tables["Table"].Rows) { for (int i = 1; i <= Convert.ToInt32(drCombo["nQuantity"]); i++) { TblMemberPackage mp = new TblMemberPackage(); mp.MainConnectionProvider = connProvider; DataTable table = mp.LoadData("Select top 1 mp.* from tblMemberPackage mp Where strPackageCode = @nPackageID and strReceiptNo=@strReceiptNo and nStatusID=0 and nPackageID not in (SELECT nPackageID FROM [dbo].[tblServiceSession] s WHERE nStatusID = 5 and mp.nPackageID = S.nPackageID) ", new string[] { "@nPackageID", "@strReceiptNo" }, new object[] { drCombo["strPackageCode"], drCombo["strReceiptNo"] }); strReceiptNo = drCombo["strReceiptNo"].ToString(); table.Rows[0]["nStatusID"] = 3; table.Rows[0]["strUpgradeTo"] = pos.StrReceiptNo; strRemarks = "Convert to: " + pos.StrReceiptNo; table.Rows[0]["strRemarks"] = strRemarks; mp.SaveData(table); } } } else { TblMemberPackage mp = new TblMemberPackage(); mp.MainConnectionProvider = connProvider; DataTable table = mp.LoadData("Select * from tblMemberPackage Where nPackageID = @nPackageID", new string[] { "@nPackageID" }, new object[] { dr["nPackageID"] }); strFreePackageCode = dr["strFreePkgCode"].ToString(); strReceiptNo = table.Rows[0]["strReceiptNo"].ToString(); table.Rows[0]["nStatusID"] = 3; table.Rows[0]["strUpgradeTo"] = pos.StrReceiptNo; strRemarks = "Convert to: " + pos.StrReceiptNo; table.Rows[0]["strRemarks"] = strRemarks; mp.SaveData(table); DataTable freePkgTable = mp.LoadData("select * from tblMemberPackage where strReceiptNo=@strReceiptNo and strPackageCode =@strFreePackageCode ", new string[] { "@strReceiptNo", "@strFreePackageCode" }, new object[] { strReceiptNo, strFreePackageCode }); if (freePkgTable.Rows.Count > 0) { freePkgTable.Rows[0]["nStatusID"] = 3; freePkgTable.Rows[0]["strUpgradeTo"] = pos.StrReceiptNo; freePkgTable.Rows[0]["strRemarks"] = strRemarks; mp.SaveData(freePkgTable); } } } } catch (Exception ex) { string strError = ex.Message; } }
private void PostToMemberCreditPackage(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos) { if (pos.NCategoryID == 7 || pos.NCategoryID == 36 || pos.NCategoryID == 37) { TblMemberCreditPackage memberCreditPackage = new TblMemberCreditPackage(); memberCreditPackage.MainConnectionProvider = connProvider; DataTable memberCreditPackageTable = memberCreditPackage.FillSchema("Select * from tblMemberCreditPackage"); 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); } 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"]); for (int i = 0; i < nQuantity; i++) { DataRow rowToAdd = memberCreditPackageTable.NewRow(); CreditAccount.InitMemberCreditPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID, r["strCode"].ToString(), false); rowToAdd["strUpgradeFrom"] = strUpgradeFrom; rowToAdd["strRemarks"] = strRemarks; memberCreditPackageTable.Rows.Add(rowToAdd); } } } if (memberCreditPackageTable.Rows.Count > 0) memberCreditPackage.SaveData(memberCreditPackageTable); } }
private void UpdateUsedCashVoucher(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos) { if (Convert.ToInt16(pos.ReceiptPaymentTable.Compute("COUNT(nPaymentID)", "strPaymentCode='CASHVOUCHER'")) > 0) { foreach (DataRow dr in pos.ReceiptPaymentTable.Rows) { if (dr["strPaymentCode"].ToString() == "CASHVOUCHER") { TblCashVoucher sqlCV = new TblCashVoucher(); sqlCV.MainConnectionProvider = connProvider; sqlCV.StrSN = dr["strReferenceNo"].ToString(); DataTable table = sqlCV.SelectOne(); sqlCV.NStatusID = 3; sqlCV.StrRedeemedByID = pos.StrMembershipID; sqlCV.DtRedeemedDate = DateTime.Now; sqlCV.StrRedeemedBranch = pos.StrBranchCode; sqlCV.Update(); sqlCV.SaveData(table); } } } }
//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); } }
private int UpgradePackage(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos) { int OriginalCategoryID = 10 ; if (pos.NCategoryID == 10 && pos.WantToUpgradeMemberPackageTable.Rows.Count == 1) { int wantToUpgrade_nPackageID = ACMS.Convert.ToInt32(pos.WantToUpgradeMemberPackageRow["nPackageID"]); string oldStrPackageCode = pos.WantToUpgradeMemberPackageRow["strPackageCode"].ToString(); foreach (DataRow r in pos.ReceiptItemsTable.Rows) { pos.CheckPackageWhenSave(r["strCode"].ToString(), wantToUpgrade_nPackageID); } // from here, we can get a list of strClassCode that already been used by member //DataTable attendedClassCodetable = GetAttendedClassCode(ACMS.Convert.ToInt32(myWantToUpgradeMemberPackageTable.Rows[0]["nPackageID"])); // from here, we can get a list of strClassCode that already been used by member //DataTable attendedServiceCodetable = GetAttendedServiceCode(ACMS.Convert.ToInt32(myWantToUpgradeMemberPackageTable.Rows[0]["nPackageID"])); TblMemberPackage memberPackage = new TblMemberPackage(); TblClassAttendance classAttendance = new TblClassAttendance(); TblServiceSession serviceSession = new TblServiceSession(); TblPackage freeSpaPackage = new TblPackage(); memberPackage.MainConnectionProvider = connProvider; classAttendance.MainConnectionProvider = connProvider; serviceSession.MainConnectionProvider = connProvider; freeSpaPackage.MainConnectionProvider = connProvider; DataTable memberPackagetable = memberPackage.FillSchema("Select * from tblMemberPackage"); //get old free spa package Code freeSpaPackage.StrPackageCode = oldStrPackageCode; DataTable OldFreePackageCode = freeSpaPackage.SelectSpaPackageFreebie(); string strOldFreePackage = OldFreePackageCode.Rows[0]["strFreePkgCode"].ToString(); foreach (DataRow r in pos.ReceiptItemsTable.Rows) { int nQuantity = ACMS.Convert.ToInt32(r["nQuantity"]); for (int i = 0; i < nQuantity; i++) { DataRow rowToAdd = memberPackagetable.NewRow(); MemberPackage.InitMemberPackageRowInPOS(rowToAdd, pos.StrReceiptNo, pos.StrMembershipID, r["strCode"].ToString(), "", false); memberPackagetable.Rows.Add(rowToAdd); } } //insert a new upgrade package to member package if (memberPackagetable.Rows.Count > 0) memberPackage.SaveData(memberPackagetable); DataTable newAddMemberPackageTable = memberPackage.SelectAllWstrReceiptNo(pos.StrReceiptNo); DataRow[] rowNewAddMemberPackage = newAddMemberPackageTable.Select("fFree = 0"); DataTable attendedClassTable = classAttendance.GetAllClassAttendancesBasePackageID(wantToUpgrade_nPackageID, pos.StrMembershipID, pos.StrBranchCode); DataTable serviceUsedTable = serviceSession.GetMemberServiceSessionBasePackageID(wantToUpgrade_nPackageID, pos.StrMembershipID, pos.StrBranchCode); //insert a new freebie package based on new added upgrade pacakge string newStrPackageCode = ""; for( int i = 0; i<newAddMemberPackageTable.Rows.Count; i++) { if (newAddMemberPackageTable.Rows[i]["fFree"].ToString() == "False") { if (newAddMemberPackageTable.Rows.Count > 1) newStrPackageCode = newAddMemberPackageTable.Rows[newAddMemberPackageTable.Rows.Count - 1]["strPackageCode"].ToString(); else newStrPackageCode = newAddMemberPackageTable.Rows[0]["strPackageCode"].ToString(); } } //get new free spa package Code freeSpaPackage.StrPackageCode = newStrPackageCode; DataTable NewFreePackageCode = freeSpaPackage.SelectSpaPackageFreebie(); string strNewFreePackage = NewFreePackageCode.Rows[0]["strFreePkgCode"].ToString(); if (strNewFreePackage != "") { DataTable FreememberPackagetable = memberPackage.FillSchema("Select * from tblMemberPackage"); DataRow rowToAdd2 = FreememberPackagetable.NewRow(); MemberPackage.InitMemberPackageRowInPOS(rowToAdd2, pos.StrReceiptNo, pos.StrMembershipID, strNewFreePackage, "", true); FreememberPackagetable.Rows.Add(rowToAdd2); if (FreememberPackagetable.Rows.Count > 0) memberPackage.SaveData(FreememberPackagetable); //move session from old freebie to new freebie //find old free package ID,via wantToUpgrade_nPackageID freeSpaPackage.NPackageID = wantToUpgrade_nPackageID; freeSpaPackage.StrPackageCode = oldStrPackageCode; DataTable OldFreePackageID = freeSpaPackage.SelectSpaPackageFreebieID(); int nOldFreePackageID; if (OldFreePackageID.Rows.Count > 0) nOldFreePackageID = ACMS.Convert.ToInt32(OldFreePackageID.Rows[OldFreePackageID.Rows.Count - 1]["nPackageID"]); else nOldFreePackageID = 0; DataTable newFreeMemberPackageTable = memberPackage.SelectAllWstrReceiptNo(pos.StrReceiptNo); DataRow[] rowNewFreeMemberPackage = newFreeMemberPackageTable.Select("fFree = 1"); DataTable freeserviceUsedTable = serviceSession.GetMemberServiceSessionBasePackageID(nOldFreePackageID, pos.StrMembershipID, pos.StrBranchCode); //foreach (DataRow FmemberPackageRow in rowNewFreeMemberPackage) //{ string strFreePackageCode =""; if (rowNewFreeMemberPackage.Length > 0) strFreePackageCode = rowNewFreeMemberPackage[rowNewFreeMemberPackage.Length - 1]["strPackageCode"].ToString(); DataRow[] tempRowList3 = freeserviceUsedTable.Select("nPackageID = '"+nOldFreePackageID+"'", "dtDate"); if (tempRowList3.Length > 0) { foreach (DataRow freeserviceUsedRow in tempRowList3) { freeserviceUsedRow["nPackageID"] = rowNewFreeMemberPackage[rowNewFreeMemberPackage.Length - 1]["nPackageID"]; } } if (tempRowList3.Length > 0) { //update the expiryDate TblPackage package = new TblPackage(); package.MainConnectionProvider = connProvider; package.StrPackageCode = strFreePackageCode; DataTable tablePackage = package.SelectOne(); if (tablePackage == null && tablePackage.Rows.Count == 0) throw new Exception("Package no found."); if (tempRowList3.Length > 0) { rowNewFreeMemberPackage[rowNewFreeMemberPackage.Length - 1]["DtStartDate"] = ACMS.Convert.ToDateTime(tempRowList3[0]["dtDate"]); rowNewFreeMemberPackage[rowNewFreeMemberPackage.Length - 1]["DtExpiryDate"] = ACMS.Convert.ToDateTime( rowNewFreeMemberPackage[rowNewFreeMemberPackage.Length - 1]["DtStartDate"]).AddMonths(ACMS.Convert.ToInt32(package.NPackageDuration.Value)).AddDays(-1); } } //} DataTable oldFreeMemberPackageTable = memberPackage.SelectPackageID(nOldFreePackageID); oldFreeMemberPackageTable.Rows[0]["nStatusID"] = 2; serviceSession.UpgradePackage(ACMS.Convert.ToInt32(rowNewFreeMemberPackage[rowNewFreeMemberPackage.Length - 1]["nPackageID"]), nOldFreePackageID, pos.StrMembershipID); memberPackage.SaveData(oldFreeMemberPackageTable); memberPackage.SaveData(newFreeMemberPackageTable); } //move session from old package to new package foreach (DataRow memberPackageRow in rowNewAddMemberPackage) { string strPackageCode = memberPackageRow["strPackageCode"].ToString(); DataRow[] tempRowList = attendedClassTable.Select("nPackageID = '" + wantToUpgrade_nPackageID + "'", "dtDate"); if (tempRowList.Length > 0) { foreach (DataRow attendedClassRow in tempRowList) { // new packageID attendedClassRow["nPackageID"] = memberPackageRow["nPackageID"]; } } DataRow[] tempRowList2 = serviceUsedTable.Select("nPackageID = '" + wantToUpgrade_nPackageID + "'", "dtDate"); if (tempRowList2.Length > 0) { foreach (DataRow serviceUsedRow in tempRowList2) { serviceUsedRow["nPackageID"] = memberPackageRow["nPackageID"]; } } if (tempRowList.Length > 0 || tempRowList2.Length > 0) { //update the expiryDate TblPackage package = new TblPackage(); package.MainConnectionProvider = connProvider; package.StrPackageCode = strPackageCode; DataTable tablePackage = package.SelectOne(); TblPackageExtension PackExtension = new TblPackageExtension(); PackExtension.MainConnectionProvider = connProvider; PackExtension.NPackageID = ACMS.Convert.ToInt32(rowNewAddMemberPackage[0]["nPackageID"]); PackExtension.NPackageIDOld = wantToUpgrade_nPackageID; int days = 0; DataTable tblPkgExt = PackExtension.SelectExtensionDays(); if (PackExtension.NDaysExtended.IsNull == false) days = System.Convert.ToInt32(PackExtension.NDaysExtended.Value); if (tablePackage == null && tablePackage.Rows.Count == 0) throw new Exception("Package no found."); if (tempRowList.Length > 0 && tempRowList2.Length == 0) { ///07/11/2012 Jackie DataTable myDataTable1; DateTime dtDate; ACMSDAL.TblClassAttendance ClassAttendance = new ACMSDAL.TblClassAttendance(); myDataTable1 = ClassAttendance.LoadData("Select top 1 dtDate From tblClassAttendance where nstatusid=1 and nPackageID= " + wantToUpgrade_nPackageID + " and " + " strMemberShipID = @strMembershipID order by dtDate", new string[] { "@strMembershipID" }, new object[] { pos.StrMembershipID }); dtDate = DateTime.Now; if (myDataTable1.Rows.Count > 0) dtDate = System.Convert.ToDateTime(myDataTable1.Rows[0][0]); memberPackageRow["DtStartDate"] = dtDate; // Stop memberPackageRow["DtExpiryDate"] = ACMS.Convert.ToDateTime( memberPackageRow["DtStartDate"]).AddMonths(ACMS.Convert.ToInt32(package.NPackageDuration.Value)).AddDays(days - 1); } else if (tempRowList2.Length > 0 && tempRowList.Length == 0) { memberPackageRow["DtStartDate"] = ACMS.Convert.ToDateTime(tempRowList2[0]["dtDate"]); memberPackageRow["DtExpiryDate"] = ACMS.Convert.ToDateTime( memberPackageRow["DtStartDate"]).AddMonths(ACMS.Convert.ToInt32(package.NValidMonths.Value)).AddDays(days - 1); } } } OriginalCategoryID= ACMS.Convert.ToDBInt32(pos.WantToUpgradeMemberPackageRow["nCategoryID"]) ; pos.WantToUpgradeMemberPackageRow["nStatusID"] = 2; serviceSession.UpgradePackage(ACMS.Convert.ToInt32(rowNewAddMemberPackage[0]["nPackageID"]), wantToUpgrade_nPackageID, pos.StrMembershipID); memberPackage.SaveData(pos.WantToUpgradeMemberPackageTable); memberPackage.SaveData(newAddMemberPackageTable); classAttendance.SaveData(wantToUpgrade_nPackageID,pos.StrMembershipID); } return OriginalCategoryID; }
private void CashVoucherTransaction(ACMSDAL.ConnectionProvider connProvider, ACMSLogic.POS pos) { if (pos.NCategoryID == 38) { DateTime dtStartDate = DateTime.Now.Date; DateTime dtExpiryDate; foreach (DataRow r in pos.ReceiptItemsTable.Rows) { TblCashVoucher sqlCV = new TblCashVoucher(); sqlCV.MainConnectionProvider = connProvider; string strCVCode = r["strCode"].ToString(); sqlCV.StrSN = strCVCode; DataTable table = sqlCV.SelectOne(); sqlCV.NStatusID = 1; sqlCV.StrSoldToID = pos.StrMembershipID; sqlCV.DtSoldDate = DateTime.Now; sqlCV.StrSoldBranch = pos.StrBranchCode; int iduration = Convert.ToInt32(sqlCV.NValidDuration.ToString()); if (sqlCV.StrDurationUnit.ToString().Trim() == "DAY") dtExpiryDate = dtStartDate.AddDays(iduration - 1).AddDays(0); else if (sqlCV.StrDurationUnit.ToString().Trim() == "WEEK") { iduration = iduration * 7; dtExpiryDate = dtStartDate.AddDays(iduration - 1).AddDays(0); } else dtExpiryDate = dtStartDate.AddMonths(iduration).AddDays(-1); sqlCV.DtStartDate = dtStartDate; sqlCV.DtExpiryDate = dtExpiryDate; sqlCV.Update(); sqlCV.SaveData(table); } } }