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(); } }
//DEREK Instalment Plan Need to Update Receipt Here public void PrintReceipt(string receiptNo) { DataColumn colItemDiscountAmt = new DataColumn("DiscountAmt", typeof(decimal)); DataColumn colBillDiscountAmt = new DataColumn("DiscountAmt", typeof(decimal)); DataColumn colMemberName = new DataColumn("strMemberName", typeof(string)); DataColumn colRewardPoint = new DataColumn("RewardPoint", typeof(decimal)); DataColumn colGSTPaid = new DataColumn("GSTPaid", typeof(decimal)); //DataColumn colOSAmt = new DataColumn("mOutstandingAmount", typeof(decimal)); TblReceipt receipt = new TblReceipt(); receipt.StrReceiptNo = receiptNo; DataTable tableReceipt = receipt.SelectOne(); tableReceipt.TableName = "TblReceipt"; tableReceipt.Columns.Add(colBillDiscountAmt); tableReceipt.Columns.Add(colMemberName); tableReceipt.Columns.Add(colRewardPoint); tableReceipt.Columns.Add(colGSTPaid); // tableReceipt.Columns.Add(colOSAmt); TblMember sqlMember = new TblMember(); sqlMember.StrMembershipID = receipt.StrMembershipID; sqlMember.SelectOne(); tableReceipt.Rows[0]["strMemberName"] = sqlMember.StrMemberName.IsNull ? "" : sqlMember.StrMemberName.Value.ToUpper(); TblBranch sqlBranch = new TblBranch(); sqlBranch.StrBranchCode = receipt.StrBranchCode == SqlString.Null ? "" : receipt.StrBranchCode.Value; DataTable branchTable = sqlBranch.SelectOne(); TblRewardsTransaction sqlRewTrans = new TblRewardsTransaction(); decimal rewardpoint = sqlRewTrans.GetMemberLoyaltyPoint(receipt.StrMembershipID.Value); tableReceipt.Rows[0]["RewardPoint"] = System.Math.Round(rewardpoint); TblReceiptEntries receiptEntries = new TblReceiptEntries(); receiptEntries.StrReceiptNo = receiptNo; DataTable tableReceiptEntries = receiptEntries.SelectAllWstrReceiptNoLogic(); tableReceiptEntries.TableName = "TblReceiptEntries"; tableReceiptEntries.Columns.Add(colItemDiscountAmt); TblReceiptFreebie freebie = new TblReceiptFreebie(); freebie.StrReceiptNo = receiptNo; DataTable tableReceiptFreebie = freebie.SelectReceiptFreebie(); tableReceiptFreebie.TableName = "TblReceiptFreebie"; TblMemberPackage FreePackage = new TblMemberPackage(); FreePackage.StrReceiptNo = receiptNo; DataTable tableFreePackage = FreePackage.GetFreePackage(receiptNo); tableFreePackage.TableName = "TblFreePackage"; TblMemberPackage ConvertedPackage = new TblMemberPackage(); ConvertedPackage.StrReceiptNo = receiptNo; DataTable tableConvertedPackage = ConvertedPackage.GetConvertedPackage(receiptNo); tableConvertedPackage.TableName = "TblConvertedPackage"; TblPaymentPlan myPaymentPlan = new TblPaymentPlan(); DataTable tablePaymentPlan = myPaymentPlan.GetInhouseIPPOSByReceiptNo(receiptNo); tablePaymentPlan.TableName = "TblPaymentPlan"; DataTable tableDeposit = myPaymentPlan.GetInhouseIPPReceiptDeposit(receiptNo); tableDeposit.TableName = "TblReceiptDeposit"; // TblProduct Product = new TblProduct(); // // Product.StrProductCode = tableReceiptFreebie.Rows[0]["strItemCode"].ToString(); // DataTable tableProduct = Product.SelectAll(); // tableProduct.TableName = "TblProductName"; decimal nettAmountB4Discount = 0; decimal discoutnAmt =0; decimal depositAmt = 0; if (tableDeposit.Rows.Count > 0) { depositAmt = Convert.ToDecimal(tableDeposit.Rows[0]["TotalDeposit"]); } foreach (DataRow r in tableReceiptEntries.Rows) { int qty = ACMS.Convert.ToInt32(r["nQuantity"]); decimal unitPrice = ACMS.Convert.ToDecimal(r["mUnitPrice"]); decimal currSubtotal = ACMS.Convert.ToDecimal(r["mSubTotal"]); discoutnAmt = (unitPrice * qty) - currSubtotal; r["DiscountAmt"] = decimal.Round(discoutnAmt, 2); nettAmountB4Discount += currSubtotal; } //Sub Total DataColumn colSubTotal = new DataColumn("mSubTotal", typeof(decimal)); tableReceipt.Columns.Add(colSubTotal); tableReceipt.Rows[0]["mSubTotal"] = nettAmountB4Discount; decimal nettAmountAfterDiscount = ACMS.Convert.ToDecimal(tableReceipt.Rows[0]["mNettAmount"]); if (tableReceipt.Rows[0]["strDiscountCode"].ToString().Length > 0 && tableReceipt.Rows[0]["strDiscountCode"] != DBNull.Value) { tableReceipt.Rows[0]["DiscountAmt"] = nettAmountB4Discount - (nettAmountAfterDiscount + depositAmt); } TblReceiptPayment receiptPayment = new TblReceiptPayment(); receiptPayment.StrReceiptNo = receiptNo; DataTable tableReceiptPayment = receiptPayment.SelectAllWstrReceiptNoLogic(); tableReceiptPayment.TableName = "TblReceiptPayment"; TblCompany comp = new TblCompany(); DataTable compTable = comp.SelectAll(); int myTaxID = ACMS.Convert.ToInt32(compTable.Rows[0]["NTaxID"]); TblTax tax = new TblTax(); tax.NTaxID = myTaxID; tax.SelectOne(); decimal myGSTRate = tax.DTaxRate.IsNull ? 0 : (decimal)tax.DTaxRate.Value; decimal GSTAmtPaid=0; decimal GSTRate1=myGSTRate;//0.05M; decimal GSTRate2=myGSTRate+1;// 1.05M; foreach (DataRow p in tableReceiptPayment.Rows) { GSTAmtPaid=GSTAmtPaid+ACMS.Convert.ToDecimal(p[3])* GSTRate1 /GSTRate2; } if (receipt.NCategoryID.ToString() != "38") { tableReceipt.Rows[0]["GSTPaid"] = decimal.Round(GSTAmtPaid, 2); } else { tableReceipt.Rows[0]["GSTPaid"] = decimal.Round(0, 2); } DataSet newDS = new DataSet("Receipt"); newDS.Tables.Add(tableReceipt); newDS.Tables.Add(tableReceiptEntries); newDS.Tables.Add(tableReceiptPayment); newDS.Tables.Add(branchTable); // newDS.Tables.Add(tableProduct); newDS.Tables.Add(tableReceiptFreebie); newDS.Tables.Add(tableFreePackage); newDS.Tables.Add(tableConvertedPackage); newDS.Tables.Add(tablePaymentPlan); newDS.Tables.Add(tableDeposit); DataRelation relation1 = new DataRelation("Receipt_ReceiptEntries_Relation", newDS.Tables["TblReceipt"].Columns["strReceiptNo"], newDS.Tables["TblReceiptEntries"].Columns["strReceiptNo"], false); DataRelation relation2 = new DataRelation("Receipt_ReceiptPayment_Relation", newDS.Tables["TblReceipt"].Columns["strReceiptNo"], newDS.Tables["TblReceiptPayment"].Columns["strReceiptNo"], false); DataRelation relation3 = new DataRelation("Receipt_ReceiptFreebie_Relation", newDS.Tables["TblReceipt"].Columns["strReceiptNo"], newDS.Tables["TblReceiptFreebie"].Columns["strReceiptNo"], false); DataRelation relation4 = new DataRelation("Receipt_FreePackage_Relation", newDS.Tables["TblReceipt"].Columns["strReceiptNo"], newDS.Tables["TblFreePackage"].Columns["strReceiptNo"], false); DataRelation relation5 = new DataRelation("Receipt_ConvertedPackage_Relation", newDS.Tables["TblReceipt"].Columns["strReceiptNo"], newDS.Tables["TblConvertedPackage"].Columns["strReceiptNo"], false); DataRelation relation6 = new DataRelation("Receipt_PaymentPlan_Relation", newDS.Tables["TblReceipt"].Columns["strReceiptNo"], newDS.Tables["TblPaymentPlan"].Columns["strReceiptNo"], false); DataRelation relation7 = new DataRelation("Receipt_Deposit_Relation", newDS.Tables["TblReceipt"].Columns["strReceiptNo"], newDS.Tables["TblReceiptDeposit"].Columns["strReceiptNo"], false); newDS.Relations.Add(relation1); newDS.Relations.Add(relation2); newDS.Relations.Add(relation3); newDS.Relations.Add(relation4); newDS.Relations.Add(relation5); newDS.Relations.Add(relation6); newDS.Relations.Add(relation7); //display GST % DataColumn colGstTax = new DataColumn("GstTax", typeof(int)); tableReceipt.Columns.Add(colGstTax); tableReceipt.Rows[0]["GstTax"] = myGSTRate * 100; ACMSLogic.Report.Receipt receiptReport = new ACMSLogic.Report.Receipt(); receiptReport.DataSource = newDS; // if (ACMS.Convert.ToDecimal(tableReceipt.Rows[0]["DiscountAmt"])==0) // { // receiptReport.HideFields(false); // } // else // { // receiptReport.HideFields(true); // } // receiptReport.ShowDesignerDialog(); receiptReport.Print(); }
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(); } } } } }
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(); } } }
public void NormalReserve(string strMembershipID, int nPackageID, int nClassInstanceID, bool needToVerifyMemberPackage) { TblClassInstance classInstance = new TblClassInstance(); classInstance.NClassInstanceID = nClassInstanceID; classInstance.SelectOne(); TblClassAttendance classAttendance = new TblClassAttendance(); DateTime classDate = new DateTime(classInstance.DtDate.Value.Year, classInstance.DtDate.Value.Month, classInstance.DtDate.Value.Day, classInstance.DtStartTime.Value.Hour, classInstance.DtStartTime.Value.Minute, classInstance.DtStartTime.Value.Second); if (DateTime.Today > classDate) throw new Exception("You are not allow to reserve the previous day class."); if (classAttendance.IsReservedThisClass(nClassInstanceID, strMembershipID)) { throw new Exception("You have reserved this class."); } if (classAttendance.GetReservation(nClassInstanceID).Rows.Count > ACMS.Convert.ToInt32(classInstance.NMaxNo)) { throw new Exception("Class is fully reserved by members. Please try again later."); } if (needToVerifyMemberPackage) { if (!VerifyMemberPackageAllowCertainClass(nPackageID, classInstance.StrClassCode.Value)) { //throw new Exception("The package you wish to use is not allow to attend the class. Please use other package."); DialogResult result = MessageBox.Show("The package you wish to use is not allow to attend the class. Do you still want to reserve it. \n " + "(An unlinked record will be create if you click yes) ", "Warning",MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { MemberPackage.CreateUnlinkedMemberPackage(strMembershipID, ref nPackageID); } else { return; } } } // if (!VerifyMemberPackageAllowCertainClass(nPackageID, classInstance.StrClassCode.Value)) // throw new Exception("The package you wish to use is not allow to reserve the class. Please use other package."); //Prompt Package going to expiry //Prompt Remaining class classAttendance.NClassInstanceID = nClassInstanceID; classAttendance.StrMembershipID = strMembershipID; classAttendance.NEmployeeID = User.EmployeeID; classAttendance.NReservedByID = User.EmployeeID; classAttendance.FUOBBooking = System.Data.SqlTypes.SqlBoolean.False; classAttendance.DtDate = classInstance.DtDate.Value; classAttendance.DtReservationDate = DateTime.Today.Date; classAttendance.DtStartTime = Convert.ToDateTime(classInstance.DtDate.Value.ToString("yyyy-MM-dd")+" "+ classInstance.DtStartTime.Value.ToString("H:mm:ss")); classAttendance.DtEndTime = Convert.ToDateTime(classInstance.DtDate.Value.ToString("yyyy-MM-dd") + " " + classInstance.DtEndTime.Value.ToString("H:mm:ss")); classAttendance.StrBranchCode = User.BranchCode; classAttendance.DtLastEditDate = DateTime.Now; classAttendance.NStatusID = 0; classAttendance.NPackageID = nPackageID; classAttendance.Insert(); TblBranch sqlBranch = new TblBranch(); TblClass sqlClass = new TblClass(); sqlBranch.StrBranchCode = classAttendance.StrBranchCode.ToString(); sqlBranch.SelectOne(); sqlClass.StrClassCode = classInstance.StrClassCode; sqlClass.SelectOne(); if (isMobileAppUser(strMembershipID)) PushNotification(strMembershipID, "Your class booking for " + sqlClass.StrDescription.ToString() + " at " + sqlBranch.StrBranchName.ToString() + " at " + classAttendance.DtStartTime.Value.ToString("h.mmtt") + " on " + classAttendance.DtStartTime.Value.ToString("dd MMM") + " has been confirmed."); }
private void OnConfirmLockerDeposit() { ACMSDAL.TblBranch branch = new ACMSDAL.TblBranch(); branch.StrBranchCode = myPOS.StrBranchCode; branch.SelectOne(); decimal lockerDeposit = ACMS.Convert.ToDecimal(branch.MLockerDepositRate); ACMSDAL.TblMember member = new ACMSDAL.TblMember(); member.StrMembershipID = myPOS.StrMembershipID; member.SelectOne(); if (myPOS.ReceiptItemsTable.Rows.Count == 0) { ACMSDAL.TblLocker sqlLocker = new ACMSDAL.TblLocker(); DataTable table = sqlLocker.GetOccupiedLocker(myPOS.StrBranchCode, myPOS.StrMembershipID); if (table.Rows.Count > 0) { MessageBox.Show(this, "Please return your locker before a new Deposit can make."); return; } if (!member.FLockerDeposit.IsNull) { if (member.FLockerDeposit.IsTrue) MessageBox.Show(this, "Deposit has been saved in system."); else { DialogResult result = MessageBox.Show(this, string.Format("Locker Deposit is $ {0}, Continue?", lockerDeposit), "Add Deposit", MessageBoxButtons.OKCancel); if (result == DialogResult.OK) myPOS.NewReceiptEntry(myPOS.StrMembershipID, -1, "Locker Deposit", 1, lockerDeposit, myPOS.StrMembershipID); } } else { DialogResult result = MessageBox.Show(this, string.Format("Locker Deposit is $ {0}, Continue?", lockerDeposit), "Add Deposit", MessageBoxButtons.OKCancel); if (result == DialogResult.OK) myPOS.NewReceiptEntry(myPOS.StrMembershipID, -1, "Locker Deposit", 1, lockerDeposit, myPOS.StrMembershipID); } } else { MessageBox.Show(this, "Only one deposit is allow in one receipt."); } }
private void OnReplaceMembershipCard() { if (myPOS.ReceiptItemsTable.Rows.Count > 0) { DialogResult result = MessageBox.Show(this, "Only one item is allow. Do you want to overwrite the existing one?", "Warning", MessageBoxButtons.YesNo); if (result == DialogResult.No) return; else myPOS.ReceiptItemsTable.Rows.Clear(); } string membershipID = myPOS.StrMembershipID; bool isMember = !membershipID.StartsWith("NMC"); TblCompany sqlCompany = new TblCompany(); DataTable compTable = sqlCompany.SelectAll(); decimal replaceCardRate = ACMS.Convert.ToDecimal(compTable.Rows[0]["mReplaceCardRate"]); if (!isMember) { int nextNonMemberNo = ACMS.Convert.ToInt32(compTable.Rows[0]["nNonMembershipNo"]) + 1; string newStrMembershipID = "NMC" + nextNonMemberNo.ToString(); string origStrMembershipID = myPOS.StrMembershipID; myPOS.NewReceiptEntry(newStrMembershipID, -1, string.Format("Replace New Member Card. Possible ID : {0}", newStrMembershipID), 1, replaceCardRate, origStrMembershipID); } else { TblBranch sqlbranch = new TblBranch(); sqlbranch.StrBranchCode = myPOS.StrBranchCode; sqlbranch.SelectOne(); int nextNonMemberNo = sqlbranch.NMembershipNo.Value + 1; string newStrMembershipID = myPOS.StrBranchCode.TrimEnd() + nextNonMemberNo.ToString(); string origStrMembershipID = myPOS.StrMembershipID; myPOS.NewReceiptEntry(newStrMembershipID, -1, string.Format("Replace New Member Card. Possible ID : {0}", newStrMembershipID), 1, replaceCardRate, origStrMembershipID); StrNewMembershipID = newStrMembershipID; } }
public static bool BlockMembershipID(int numberOfNonMemberID, int numberOfMemberID, string strBranchCode) { ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider(); TblCompany sqlCompany = new TblCompany(); TblBranch sqlBranch = new TblBranch(); try { sqlCompany.MainConnectionProvider = connProvider; sqlBranch.MainConnectionProvider = connProvider; connProvider.OpenConnection(); connProvider.BeginTransaction("BlockMembershipID"); if (numberOfNonMemberID > 0) sqlCompany.UpdateBlockNonMembershipID(numberOfNonMemberID); if (numberOfMemberID > 0) sqlBranch.UpdateBlockMembershipID(strBranchCode, numberOfMemberID); connProvider.CommitTransaction(); return true; } catch (Exception) { connProvider.RollbackTransaction("BlockMembershipID"); throw; } finally { if (connProvider.CurrentTransaction != null) connProvider.CurrentTransaction.Dispose(); if (connProvider.DBConnection != null) { if (connProvider.DBConnection.State == ConnectionState.Open) connProvider.DBConnection.Close(); connProvider.DBConnection.Dispose(); } sqlCompany.Dispose(); sqlBranch.Dispose(); } }
private void Init() { BindData(); TblBranch branch = new TblBranch(); DataTable branchTable = branch.SelectAll(); new XtraUtils.LookupEditBuilder.BranchCodeLookupEditBuilder(branchTable, lkpEdtBranchCode.Properties); TblCaseType casetype = new TblCaseType(); DataTable caseTypeTable = casetype.SelectAll(); new XtraUtils.LookupEditBuilder.CaseTypeLookupEditBuilder(caseTypeTable, lkpEdtCaseType.Properties); TblCaseCategory category = new TblCaseCategory(); DataTable categoryTable = category.SelectAll(); new XtraUtils.LookupEditBuilder.CaseCategoryLookupEditBuilder(categoryTable, lkpEdtCategory.Properties); TblDepartment department = new TblDepartment(); DataTable deptTable = department.SelectAll(); new XtraUtils.LookupEditBuilder.DepartmentLookupEditBuilder(deptTable, lkpEdtDeptID.Properties); new XtraUtils.LookupEditBuilder.EmployeeIDLookupEditBuilder(lkpEdtStaff.Properties, false); new XtraUtils.LookupEditBuilder.DepartmentLookupEditBuilder(deptTable, lkpEdtDeptAssignedID.Properties); }
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(); } }
/// <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; }
public static void CurrentLastMembershipID(string strTerminalBranch, ref int lastNonMemberID, ref int lastMemberID) { ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider(); TblCompany sqlCompany = new TblCompany(); TblBranch sqlBranch = new TblBranch(); try { sqlCompany.MainConnectionProvider = connProvider; sqlBranch.MainConnectionProvider = connProvider; connProvider.OpenConnection(); connProvider.BeginTransaction("LastMembershipID"); DataTable companyTable = sqlCompany.SelectAll(); sqlBranch.StrBranchCode = strTerminalBranch; DataTable branchTable = sqlBranch.SelectOne(); connProvider.CommitTransaction(); lastNonMemberID = ACMS.Convert.ToInt32(companyTable.Rows[0]["nNonMembershipNo"]); lastMemberID = ACMS.Convert.ToInt32(branchTable.Rows[0]["nMembershipNo"]); return; } catch (Exception) { connProvider.RollbackTransaction("ResetMembershipID"); throw; } finally { if (connProvider.CurrentTransaction != null) connProvider.CurrentTransaction.Dispose(); if (connProvider.DBConnection != null) { if (connProvider.DBConnection.State == ConnectionState.Open) connProvider.DBConnection.Close(); connProvider.DBConnection.Dispose(); } sqlCompany.Dispose(); sqlBranch.Dispose(); } }
private void InitLookupEdit() { myBranch = new TblBranch(); dtblBranchLookupEdit = myBranch.SelectAllForLookupEdit(); }
private void Init() { BindData(); TblBranch branch = new TblBranch(); DataTable branchTable = branch.SelectAll(); new XtraUtils.LookupEditBuilder.BranchCodeLookupEditBuilder(branchTable, lkpEdtBranchCode.Properties); TblCaseType casetype = new TblCaseType(); DataTable caseTypeTable = casetype.SelectAll(); new XtraUtils.LookupEditBuilder.CaseTypeLookupEditBuilder(caseTypeTable, lkpEdtCaseType.Properties); // TblMember member = new TblMember(); // DataTable memberTable = member.SelectAll(); // new XtraUtils.LookupEditBuilder.MemberIDLookupEditBuilder(memberTable, lkpEdtMemberID.Properties); TblCaseCategory category = new TblCaseCategory(); DataTable categoryTable = category.SelectAll(); new XtraUtils.LookupEditBuilder.CaseCategoryLookupEditBuilder(categoryTable, lkpEdtCategory.Properties); TblDepartment department = new TblDepartment(); DataTable deptTable = department.SelectAll(); new XtraUtils.LookupEditBuilder.DepartmentLookupEditBuilder(deptTable, lkpEdtDeptID.Properties); }