public void Refresh(string strMembershipID) { //myDataTable = myCreditPkg.GetValidMemberCreditPackage(strMembershipID); myDataTable = myCreditPkg.GetValidAndExpiredMemberCreditPackage(strMembershipID); if (myDataTable != null) { if (!myDataTable.Columns.Contains("Balance")) { DataColumn colBalance = new DataColumn("Balance", System.Type.GetType("System.Decimal")); myDataTable.Columns.Add(colBalance); } if (!myDataTable.Columns.Contains("strBalNew")) { DataColumn colFNew = new DataColumn("strBalNew", System.Type.GetType("System.String")); myDataTable.Columns.Add(colFNew); } MemberPackage memberPackage = new MemberPackage(); //Select Sum (mCreditPackageUsagePrice) From tblMemberPackage //Where nCreditPackageID = A.nCreditPackageID and nStatusID <> 2 Group by nCreditPackageID int nCreditPackageID = 0; foreach (DataRow r in myDataTable.Rows) { nCreditPackageID = ACMS.Convert.ToInt32(r["nCreditPackageID"]); r["Balance"] = ACMS.Convert.ToDecimal(r["mCreditAmount"]) + ACMS.Convert.ToDecimal(r["mFreeCredit"]) + ACMS.Convert.ToDecimal(r["mTopupAmount"]) - memberPackage.GetCreditPackageUsagePrice(nCreditPackageID); r["strBalNew"] = 0; } } }
public void MarkService(int nSessionID, DateTime dtDate, DateTime startTime, DateTime endTime, string strBranchCode, int nPackageID, string strServiceCode, int nEmployeeInChargeID, string remark) { MemberPackage memberPackage = new MemberPackage(); memberPackage.UpdateServiceSession(nSessionID, dtDate, startTime, endTime, strBranchCode, nPackageID, strServiceCode, nEmployeeInChargeID, remark, 5, false); }
/// <summary> /// 购买套餐 /// </summary> /// <param name="memberId">会员id</param> /// <param name="employeeId">员工id</param> /// <param name="packageId">套餐id</param> /// <param name="packagePrice">套餐价格</param> /// <param name="packageHour">套餐课时</param> /// <param name="packageDuration">套餐有效时限</param> /// <returns></returns> public bool BuyPackage(int memberId, int employeeId, int packageId, double packagePrice, int packageHour, int packageDuration) { var member = repository.GetById(memberId); var package = packageRepository.GetById(packageId); var transactor = employeeRepository.GetById(employeeId); //新增会员套餐 var memberPackage = new MemberPackage { PackageId = package.Id, PackageName = package.Name, ActivityId = package.ActivityId, ActivityName = package.ActivityName, MemberId = member.Id, MemberName = member.Name, StudioId = member.StudioId, StudioName = member.StudioName, Price = packagePrice, Hour = packageHour, Duration = packageDuration, RemainingHour = packageHour, StartTime = DateTime.Now, EndTime = DateTime.Now.AddDays(packageDuration) }; memberPackageRepository.Add(memberPackage); //新增套餐账单 var packageBill = new PackageBill { StudioId = member.StudioId, StudioName = member.StudioName, MemberId = member.Id, MemberName = member.Name, TransactorId = transactor.Id, TransactorName = transactor.Name, MemberPackageId = memberPackage.Id, PackageName = package.Name, ActivityId = package.ActivityId, ActivityName = package.ActivityName, Price = memberPackage.Price, Hour = memberPackage.Hour, Time = DateTime.Now }; packageBillRepository.Add(packageBill); return(true); }
//2006 // public DataTable SaveIntroduceFriendNew(string strMembershipID, string strIntroducerID, string strPackage, string strRemark, int employeeID) public bool SaveIntroduceFriendNew(string strMembershipID, string strIntroducerID, string strPackage, string strRemark, int employeeID, int nPackageID) { ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider(); TblMember sqlMember = new TblMember(); TblMemberPackage sqlMemberPackage = new TblMemberPackage(); TblPackage sqlPackage = new TblPackage(); try { sqlMember.MainConnectionProvider = connProvider; connProvider.OpenConnection(); connProvider.BeginTransaction("SaveIntroduceFriend"); // sqlMember.UpdateIntroducerMembershipID(strMembershipID, strIntroducerID); sqlMember.UpdateIntroducerMembershipID(strIntroducerID, strMembershipID); MemberPackage.CreateFreeMemberSpaPackage_IntroFriend(strMembershipID, strPackage, strRemark, ref nPackageID); // MemberPackage.CreateFreeMemberSpaPackage_IntroFriend(strIntroducerID, strPackage, strRemark, ref nPackageID); connProvider.CommitTransaction(); return(true); } catch (Exception ex) { throw; } finally { if (connProvider.CurrentTransaction != null) { connProvider.CurrentTransaction.Dispose(); } if (connProvider.DBConnection != null) { if (connProvider.DBConnection.State == ConnectionState.Open) { connProvider.DBConnection.Close(); } connProvider.DBConnection.Dispose(); } sqlPackage.Dispose(); sqlMember.Dispose(); } }
public DataView GetValidCreditPackage(string strMembershipID) { DataTable table = myCreditPkg.GetValid_NonExpiry_MemberCreditPackage(strMembershipID); if (table != null) { if (!table.Columns.Contains("Balance")) { DataColumn colBalance = new DataColumn("Balance", System.Type.GetType("System.Decimal")); table.Columns.Add(colBalance); } MemberPackage memberPackage = new MemberPackage(); //Select Sum (mCreditPackageUsagePrice) From tblMemberPackage //Where nCreditPackageID = A.nCreditPackageID and nStatusID <> 2 Group by nCreditPackageID int nCreditPackageID = 0; foreach (DataRow r in table.Rows) { nCreditPackageID = ACMS.Convert.ToInt32(r["nCreditPackageID"]); // r["Balance"] = ACMS.Convert.ToDecimal(r["mCreditAmount"]) + ACMS.Convert.ToDecimal(r["mTopupAmount"]) - // memberPackage.GetCreditPackageUsagePrice(nCreditPackageID); r["Balance"] = ACMS.Convert.ToDecimal(r["mCreditAmount"]) + ACMS.Convert.ToDecimal(r["mFreeCredit"]) + ACMS.Convert.ToDecimal(r["mTopupAmount"]) - memberPackage.GetCreditPackageUsagePrice(nCreditPackageID); } table.DefaultView.RowFilter = "Balance > 0"; return(table.DefaultView); } else { return(null); } }
public void RefreshForConvert(string strMembershipID, int nCategoryID, DataTable receiptItemTable) { if (nCategoryID == 1) { myDataTable = myCreditPkg.GetValidMemberCreditPackageForConvertToFit(strMembershipID); } else if (nCategoryID == 4 || nCategoryID == 5 || nCategoryID == 6 || nCategoryID == 7 || nCategoryID == 9) { myDataTable = myCreditPkg.GetValidMemberCreditPackageForConvert(strMembershipID); } else if (nCategoryID == 36) { myDataTable = myCreditPkg.GetValidMemberCreditPackageForConvertHolisticToHolisticFit(strMembershipID); } else if (nCategoryID == 37) { myDataTable = myCreditPkg.GetValidMemberCreditPackageForConvertHolistic(strMembershipID); } if (myDataTable != null) { if (!myDataTable.Columns.Contains("Balance")) { DataColumn colBalance = new DataColumn("Balance", System.Type.GetType("System.Decimal")); myDataTable.Columns.Add(colBalance); } if (!myDataTable.Columns.Contains("mPackagePaidAmount")) { DataColumn colBalance = new DataColumn("mPackagePaidAmount", System.Type.GetType("System.Decimal")); myDataTable.Columns.Add(colBalance); } if (!myDataTable.Columns.Contains("strBalNew")) { DataColumn colFNew = new DataColumn("strBalNew", System.Type.GetType("System.String")); myDataTable.Columns.Add(colFNew); } if (!myDataTable.Columns.Contains("nFreeUtil")) { DataColumn colNFreeUtil = new DataColumn("nFreeUtil", System.Type.GetType("System.Int32")); myDataTable.Columns.Add(colNFreeUtil); } if (!myDataTable.Columns.Contains("mFreeUtil")) { DataColumn colMFreeUtil = new DataColumn("mFreeUtil", System.Type.GetType("System.Decimal")); myDataTable.Columns.Add(colMFreeUtil); } if (!myDataTable.Columns.Contains("strCalculation")) { DataColumn colBalance = new DataColumn("strCalculation", System.Type.GetType("System.String")); myDataTable.Columns.Add(colBalance); } MemberPackage memberPackage = new MemberPackage(); double paidAmt = 0; int nCreditPackageID = 0; foreach (DataRow r in myDataTable.Rows) { string strCalculation = "Calculation:\n"; nCreditPackageID = ACMS.Convert.ToInt32(r["nCreditPackageID"]); r["strBalNew"] = 0; if (nCategoryID == 7 && nCategoryID == ACMS.Convert.ToInt32(r["nCategoryID"])) //Same spa credit category upgrade { r["Balance"] = ACMS.Convert.ToDecimal(r["mCreditAmount"]) + ACMS.Convert.ToDecimal(r["mTopupAmount"]) - memberPackage.GetCreditPackageUsagePrice(nCreditPackageID); if (memberPackage.GetCreditPackageUsagePrice(nCreditPackageID) == 0) { r["strBalNew"] = "New"; } strCalculation += "Is same category upgrade? Yes\n"; strCalculation += "Used Amt = " + memberPackage.GetCreditPackageUsagePrice(nCreditPackageID).ToString() + "\n"; } else if ((nCategoryID == 36 || nCategoryID == 37) && (ACMS.Convert.ToInt32(r["nCategoryID"]) == 36 || ACMS.Convert.ToInt32(r["nCategoryID"]) == 37)) //Same Holistic category upgrade { strCalculation += "Is same category upgrade? Yes\n"; strCalculation += "Used Amt = " + memberPackage.GetCreditPackageUsagePrice(nCreditPackageID).ToString() + "\n"; if ((ACMS.Convert.ToDecimal(r["mCreditAmount"]) + ACMS.Convert.ToDecimal(r["mTopupAmount"]) - memberPackage.GetCreditPackageUsagePrice(nCreditPackageID)) <= (ACMS.Convert.ToDecimal(r["mCreditAmount"]) / 2) || memberPackage.GetCreditPackageUsagePrice(nCreditPackageID) == 0) { r["Balance"] = ACMS.Convert.ToDecimal(r["mCreditAmount"]) + ACMS.Convert.ToDecimal(r["mTopupAmount"]) - memberPackage.GetCreditPackageUsagePrice(nCreditPackageID); if (memberPackage.GetCreditPackageUsagePrice(nCreditPackageID) == 0) { r["strBalNew"] = "New"; } } else { TblCreditPackage creditPackage = new TblCreditPackage(); creditPackage.StrCreditPackageCode = receiptItemTable.Rows[0]["strCode"].ToString(); creditPackage.SelectOne(); if (ACMS.Convert.ToDecimal(creditPackage.MCreditAmount) == ACMS.Convert.ToDecimal(r["mCreditAmount"]) && receiptItemTable.Rows.Count == 1) { r["Balance"] = (ACMS.Convert.ToDecimal(r["mCreditAmount"]) / 2); strCalculation += "Top up of same category Utilization < 50%\nBalance to convert only 50% of credit amount"; } else { r["Balance"] = ACMS.Convert.ToDecimal(r["mCreditAmount"]) + ACMS.Convert.ToDecimal(r["mTopupAmount"]) - memberPackage.GetCreditPackageUsagePrice(nCreditPackageID); } } } else if (ACMS.Convert.ToInt32(r["nCategoryID"]) == 36 || ACMS.Convert.ToInt32(r["nCategoryID"]) == 37) //Holistic different category upgrade { strCalculation += "Is same category upgrade? No\n"; strCalculation += "Used Amt = " + memberPackage.GetCreditPackageUsagePriceForDifferentCategoryConvert(nCreditPackageID).ToString() + "\n"; paidAmt = ACMS.Convert.ToDouble(r["mPackagePaidAmount"]); r["Balance"] = ACMS.Convert.ToDecimal(paidAmt) + ACMS.Convert.ToDecimal(r["mTopupAmount"]) - memberPackage.GetCreditPackageUsagePriceForDifferentCategoryConvert(nCreditPackageID); if (memberPackage.GetCreditPackageUsagePriceForDifferentCategoryConvert(nCreditPackageID) == 0) { r["strBalNew"] = "New"; } } else //Spa credit different category upgrade { paidAmt = ACMS.Convert.ToDouble(r["mPackagePaidAmount"]); r["Balance"] = ACMS.Convert.ToDecimal(paidAmt) + ACMS.Convert.ToDecimal(r["mTopupAmount"]) - memberPackage.GetCreditPackageUsagePriceForDifferentCategoryConvert(nCreditPackageID); if (memberPackage.GetCreditPackageUsagePrice(nCreditPackageID) == 0) { r["strBalNew"] = "New"; } strCalculation += "Is same category upgrade? No\n"; strCalculation += "Used Amt = " + memberPackage.GetCreditPackageUsagePriceForDifferentCategoryConvert(nCreditPackageID).ToString() + "\n"; } strCalculation += "Usage Bal Amt = " + r["Balance"].ToString(); r["strCalculation"] = strCalculation; } } }
/// <summary> /// Use Member Credit Package means use the credit to buy the package and then store in the tblMemberPackage /// be aware some package is not allow to purchase using credit package. Must check tblCreditPackageRestriction /// </summary> /// <returns></returns> public string[,] UseMemberCreditPackage(string[,] strPackageCode, int nCreditPackageID, string strSignID, string strSigKey, string strPdfExportPath, string remark) { //ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider(); DataRow[] rows, row1s = new DataRow[strPackageCode.Length / 2]; string[,] strUsage = new string[strPackageCode.Length / 2, 3]; //DataColumn[] dc = new DataColumn["Usage",System.Type.GetType("System.Int")]; try { TblMemberCreditPackage memberCreditPackage = new TblMemberCreditPackage(); //connProvider.OpenConnection(); //connProvider.BeginTransaction("UseMemberCreditPackage"); //memberCreditPackage.MainConnectionProvider = connProvider; memberCreditPackage.NCreditPackageID = nCreditPackageID; DataTable table = memberCreditPackage.SelectOne(); if (table == null || table.Rows.Count == 0) { throw new Exception("This member credit package been deleted by others"); } if (ACMS.Convert.ToInt32(table.Rows[0]["nStatusID"]) > 0) { throw new Exception("This member credit package has been deleted/expired/suspended."); } string strCreditPackageCode = memberCreditPackage.StrCreditPackageCode.Value; string strMembershipID = memberCreditPackage.StrMembershipID.Value; TblCreditPackageRestriction restriction = new TblCreditPackageRestriction(); restriction.StrCreditPackageCode = strCreditPackageCode; TblReceipt creditReceipt = new TblReceipt(); if (!memberCreditPackage.StrReceiptNo.IsNull) { creditReceipt.StrReceiptNo = memberCreditPackage.StrReceiptNo.Value; creditReceipt.SelectOne(); } DataTable restricttable = restriction.SelectAllWstrCreditPackageCodeLogic(); DataColumn colQuantity = new DataColumn("colQuantity", System.Type.GetType("System.Int32")); restricttable.Columns.Add(colQuantity); bool isAllowDiscount = false; if (restricttable.Rows.Count == 0) { throw new Exception("No allow to use credit package for this package."); } else { for (int j = 0; j < strPackageCode.Length / 2; j++) { rows = restricttable.Select("strPackageCode = '" + strPackageCode[j, 0] + "'", "strCreditPackageCode"); rows[0]["colQuantity"] = strPackageCode[j, 1]; row1s[j] = rows[0]; } if (row1s.Length == 0) { throw new Exception("No allow to use credit package for this package."); } // check later as got two package now //else //{ // isAllowDiscount = ACMS.Convert.ToBoolean(row1s[0]["fAllowDiscount"]); //} } // Must Check balance is enough to buy a Package or not TblCreditPackage creditPackage = new TblCreditPackage(); creditPackage.StrCreditPackageCode = memberCreditPackage.StrCreditPackageCode.Value; creditPackage.SelectOne(); decimal creditPackageValue = ACMS.Convert.ToDecimal(creditPackage.MCreditAmount); decimal mmbCreditPackageFreeCredit = ACMS.Convert.ToDecimal(creditPackage.MFreeCredit); decimal mmbCreditPackageTopupAmt = ACMS.Convert.ToDecimal(memberCreditPackage.MTopupAmount); decimal totalCreditUsage = GetCreditUsageFromMemberPackage(nCreditPackageID); decimal balance = (creditPackageValue + mmbCreditPackageTopupAmt + mmbCreditPackageFreeCredit) - totalCreditUsage; if (creditReceipt.MOutstandingAmount > 0 && !memberCreditPackage.StrReceiptNo.IsNull) { DataTable creditUsageMemberPackage = null; RefreshForPackageUsage(strMembershipID, ACMS.Convert.ToInt32(creditPackage.NCategoryID)); creditUsageMemberPackage = myDataTable; double m70PercPaidAmount = 0; if (creditUsageMemberPackage.Rows.Count > 0) { m70PercPaidAmount = ACMS.Convert.ToDouble(creditUsageMemberPackage.Select("nCreditPackageID=" + nCreditPackageID)[0]["PaidAmt"]) * 0.7; } if (totalCreditUsage > ACMS.Convert.ToDecimal(m70PercPaidAmount)) { throw new Exception(string.Format("Total usage is more than 70% of paid amount. \n Please clear the outstanding.")); } } if (balance < 0) { throw new Exception(string.Format("Balance for Member Credit Package : {0} is not enough.\n Please topup your credit.", nCreditPackageID.ToString())); } // Need to know here whether it is 1st use TblMemberPackage mp = new TblMemberPackage(); //mp.MainConnectionProvider = connProvider; mp.NCreditPackageID = nCreditPackageID; DataTable temptable = mp.SelectAllWnCreditPackageIDLogic(); bool is1stUseCreditPck = false; if (Convert.ToInt32(temptable.Compute("COUNT(nStatusID)", "nStatusID=0 or nStatusID=1")) == 0) { //means news insert is1stUseCreditPck = true; } int i = 0; foreach (DataRow drPackage in row1s) { for (int x = 0; x < ACMS.Convert.ToInt32(drPackage[3]); x++) // quantity { MemberPackage memberPackage = new MemberPackage(); DataTable memberPackageTable = memberPackage.New(false, strMembershipID); DataRow memberPackageRow = memberPackageTable.Rows[0]; memberPackageRow["nCreditPackageID"] = nCreditPackageID; memberPackageRow["strMembershipID"] = strMembershipID; memberPackageRow["dtPurchaseDate"] = DateTime.Now; memberPackageRow["strRemarks"] = remark; memberPackageRow["strSignatureID"] = strSignID; memberPackageRow["strSigKey"] = strSigKey; memberPackageRow["strSigPdfPath"] = strPdfExportPath; memberPackageRow["strUtilData"] = strSigKey; memberPackageRow["nStatusID"] = 0; memberPackageRow["strPackageCode"] = drPackage["strPackageCode"]; //strPackageCode; TblPackage package = new TblPackage(); package.StrPackageCode = drPackage["strPackageCode"].ToString(); // strPackageCode; package.SelectOne(); decimal creditUsage = 0; decimal packageListPrice = ACMS.Convert.ToDecimal(package.MListPrice); TblMember sqlMember = new TblMember(); //Check if redeemed spa single treatment from holistic in birthday month, give 50% discount if ((creditPackage.NCategoryID == 36 || creditPackage.NCategoryID == 37) && (package.NCategoryID == 4 || (package.NCategoryID == 6 && package.NMaxSession == 1)) && sqlMember.MembershipThisMonthBirtdayForUtilised(strMembershipID, nCreditPackageID)) { DialogResult result1 = MessageBox.Show("Member is having birthday this months and having 50% discount. Do you want to utilies?", "Warning", MessageBoxButtons.YesNo); if (result1 == DialogResult.Yes) { double discountPercent = 50; memberPackageRow["strPromotionCode"] = "120046SSD"; // calcualte usage * quantity creditUsage = packageListPrice - (packageListPrice * (decimal)discountPercent / 100); } else { if (ACMS.Convert.ToBoolean(drPackage["fAllowDiscount"])) { double discountPercent = creditPackage.DCreditDiscount.Value; // calcualte usage * quantity creditUsage = packageListPrice - (packageListPrice * (decimal)discountPercent / 100); } else { creditUsage = packageListPrice; } } } else if (ACMS.Convert.ToBoolean(drPackage["fAllowDiscount"])) { double discountPercent = creditPackage.DCreditDiscount.Value; // calcualte usage * quantity creditUsage = packageListPrice - (packageListPrice * (decimal)discountPercent / 100); } else { creditUsage = packageListPrice; } decimal previousBal = balance; balance = decimal.Parse(previousBal.ToString("N2")) - decimal.Parse(creditUsage.ToString("N2")); if (balance < 0) { throw new Exception(string.Format("Balance for Member Credit Package : {0} is not enough. \n Please topup your credit.", nCreditPackageID.ToString())); } memberPackageRow["mCreditPackageUsagePrice"] = creditUsage; memberPackageRow["strRemarks"] = memberPackageRow["strRemarks"] + " " + x; //Initially designed for immediate kick start if (memberPackageRow["dtStartDate"].ToString() == "") { int iduration = package.NPackageDuration.Value; DateTime dtNow = DateTime.Now.Date; memberPackageRow["dtStartDate"] = dtNow; if (package.StrDurationUnit.ToString().Trim() == "DAY") { memberPackageRow["dtExpiryDate"] = dtNow.AddDays(iduration - 1).AddDays(0); } else if (package.StrDurationUnit.ToString().Trim() == "WEEK") { iduration = iduration * 7; memberPackageRow["dtExpiryDate"] = dtNow.AddDays(iduration - 1).AddDays(0); } else { memberPackageRow["dtExpiryDate"] = dtNow.AddMonths(iduration).AddDays(-1); } } mp.SaveData(memberPackageTable); strUsage[i, 0] = package.StrDescription.ToString(); strUsage[i, 1] = creditUsage.ToString(); } strUsage[i, 2] = drPackage[3].ToString(); i++; } if (is1stUseCreditPck) { if (memberCreditPackage.DtStartDate.ToString() == "Null") { memberCreditPackage.NCreditPackageID = nCreditPackageID; memberCreditPackage.DtStartDate = DateTime.Now.Date; memberCreditPackage.DtExpiryDate = DateTime.Now.Date.AddMonths(ACMS.Convert.ToInt32(creditPackage.NValidMonths)).AddDays(-1); memberCreditPackage.Update(); } } //connProvider.CommitTransaction(); } catch (Exception) { //connProvider.RollbackTransaction("UseMemberCreditPackage"); throw; } finally { //if (connProvider.CurrentTransaction != null) // connProvider.CurrentTransaction.Dispose(); //if (connProvider.DBConnection != null) //{ // if (connProvider.DBConnection.State == ConnectionState.Open) // connProvider.DBConnection.Close(); //} } return(strUsage); }
/// <summary> /// 获取会员已拥有的套餐详情 /// </summary> /// <param name="memberPackageId"></param> /// <returns></returns> public JsonResult GetMemberPackageDetail(int memberPackageId) { MemberPackage memberPackage = domainModel.GetMemberPackageDetail(memberPackageId); return(Json(memberPackage)); }
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; // } //} if (lkpEdtBranchCode.Text == "") { MessageBox.Show(this, "Please select a branch."); this.DialogResult = DialogResult.None; //return; } else if (lkpEdtEmployeeID.Text == "") { MessageBox.Show(this, "Please select a therapist"); this.DialogResult = DialogResult.None; //return; } else if (lkpEdtServiceCode.Text == "") { MessageBox.Show(this, "Please select a treatment."); this.DialogResult = DialogResult.None; //return; } else { try { TblEmployee myTherapist = new TblEmployee(); myTherapist.NEmployeeID = this.TherapistID; DataTable tblTherapist = myTherapist.SelectOne(); MemberPackage myMemPackage = new MemberPackage(); DataTable tblMemberPackageBalance = MemberPackage.CalculateMemberPackageBalance(this.ServiceCode, myMemberShipID, myPackageID); myPackageBalance = (Convert.ToInt32(tblMemberPackageBalance.Rows[0]["Balance"].ToString()) - Convert.ToInt32(this.NQuantity)); string strBalance = myPackageBalance.ToString(); string strTherapist = tblTherapist.Rows[0]["strEmployeeName"].ToString(); string strDateTime = DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt"); string strDateTimeMM = DateTime.Now.ToString("dd/MM/yyyy hh:mm tt"); string strExpiryDate = Convert.ToDateTime(tblMemberPackageBalance.Rows[0]["dtExpiryDate"]).ToString("dd/MM/yyyy"); //** Insert Signature eric 15052009 //================================== string strSignatureID = ""; string strKeyData = ""; 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 Spa Service Utilisation //MemberID|DateTime|ExpiryDate|Branch|Therapist|PkgCode|ServCode|Qty|Bal strPdfExportPath = (string)ConfigurationSettings.AppSettings["SaveSpaServiceReceiptPath"].ToString() + "\\" + User.BranchCode + "\\" + myMemberShipID.Trim() + "_" + strDateTime.Replace(":", "").Replace(" ", "").Replace("/", "") + ".pdf"; strKeyData = myMemberShipID.Trim() + "|" + strExpiryDate + "|" + this.BranchCode + "|" + strTherapist + "|" + myPackageCode + "|" + this.ServiceCode + "|" + strBalance + "|" + this.NQuantity; myKeyData = strKeyData; if (myPackageCategoryID == 4 || myPackageCategoryID == 5 || myPackageCategoryID == 6 || myPackageCategoryID == 34) { MemberPackage myMemberPackage = new MemberPackage(); myMemberPackage.NewServiceSession(myPackageID, this.ServiceCode, myMemberShipID.Trim(), this.TherapistID, this.BranchCode, this.Date, this.StartTime, this.TreatmentDate, strSignatureID, System.Convert.ToInt32(this.NQuantity), false, myPackageCategoryID, strKeyData, strPdfExportPath, ref mydtSessionID, this.SsRemark); } else { MemberPackage myMemberPackage = new MemberPackage(); myMemberPackage.NewServiceSession(myPackageID, this.ServiceCode, myMemberShipID.Trim(), this.TherapistID, this.BranchCode, this.Date, this.StartTime, this.TreatmentDate, strSignatureID, System.Convert.ToInt32(this.NQuantity), false, myPackageCategoryID, "", "", this.SsRemark); } bool outputPrint = false; //Derek From Credit Package Usage Do not print if (!myIsFromCreditUsage) { if (myPackageCategoryID == 4 || myPackageCategoryID == 5 || myPackageCategoryID == 6 || myPackageCategoryID == 34) { DigSignature frmSig = new DigSignature(strKeyData, "ServiceUtilisation", null, null, dtServiceUtilization); DialogResult result1 = frmSig.ShowDialog(); if (result1 == DialogResult.OK) { strSignatureID = frmSig.ShowSignature(); //**DEREK Update Service Session Signature ID ** try { 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; * }*/ //============================================ //InitMemberPackage(CurrentMembershipID); //OnMemberPackageGridFocusRowChanged(); } //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("Therapist Name :", strSignatureID, strKeyData, myMemberShipID.Trim(), strDateTimeMM, strExpiryDate, this.BranchCode, strTherapist, myPackageCode, this.ServiceCode, strBalance, this.NQuantity); rpt.ExportToPdf(strPdfExportPath); if (outputPrint) { rpt.Print(); } } } else { if (myPackageCategoryID == 4 || myPackageCategoryID == 5 || myPackageCategoryID == 6 || myPackageCategoryID == 34) { //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 - Need A Different DataTable to Store SessionID dt.Rows.Add("Therapist Name :", myMemberShipID.Trim(), strDateTimeMM, strExpiryDate, this.BranchCode, strTherapist, myPackageCode, lblPackageDesc.Text.ToString(), this.ServiceCode, strBalance, this.NQuantity); mydtServiceUtilization = dt; } } } catch (Exception ex) { this.DialogResult = DialogResult.None; MessageBox.Show(this, ex.Message); } } }
public void NewRedemption(string strMembershipID, string itemCode, int qtyOfItemCodeToRedempt, ref int strTransNo) { ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider(); connProvider.OpenConnection(); TblRewardsCatalogue catalogue = new TblRewardsCatalogue(); catalogue.StrItemCode = itemCode; catalogue.SelectOne(); TblRewardsTransaction rewardTrans = new TblRewardsTransaction(); rewardTrans.MainConnectionProvider = connProvider; rewardTrans.StrMembershipID = strMembershipID; rewardTrans.DtDate = DateTime.Now; rewardTrans.NTypeID = 2; rewardTrans.StrReferenceNo = itemCode; rewardTrans.NEmployeeID = User.EmployeeID; rewardTrans.StrBranchCode = User.BranchCode; if (!catalogue.DRewardsPoints.IsNull) { rewardTrans.DRewardsPoints = -catalogue.DRewardsPoints.Value * qtyOfItemCodeToRedempt; } rewardTrans.Insert(); strTransNo = rewardTrans.NTransactionID.Value; TblPromotionFreebie promoFreebie = new TblPromotionFreebie(); promoFreebie.StrPromotionCode = itemCode; DataTable receiptFreebieTable = promoFreebie.SelectAllWstrPromotionCodeLogic(); //Code selected is Promotion Freebie Code if (receiptFreebieTable.Rows.Count > 0) { //TblProductInventory proInven = new TblProductInventory(); //proInven.MainConnectionProvider = connProvider; //// deduct stock //foreach (DataRow r in receiptFreebieTable.Rows) //{ // proInven.IncreaseQuantity(r["strItemCode"].ToString(), User.BranchCode, -qtyOfItemCodeToRedempt); //} } else { //Code selected is Package Code TblPackage pkg = new TblPackage(); pkg.StrPackageCode = itemCode; DataTable pkgTable = pkg.SelectOne(); if (pkgTable.Rows.Count > 0) { TblMemberPackage mp = new TblMemberPackage(); mp.SelectAll(); MemberPackage memberPackage = new MemberPackage(); DataTable memberPackageTable = memberPackage.New(false, strMembershipID); DataRow memberPackageRow = memberPackageTable.Rows[0]; memberPackageRow["strMembershipID"] = strMembershipID; memberPackageRow["dtPurchaseDate"] = DateTime.Now; memberPackageRow["strRemarks"] = "REWARDS"; memberPackageRow["nStatusID"] = 0; memberPackageRow["strPackageCode"] = itemCode; memberPackageRow["fFree"] = 1; mp.SaveData(memberPackageTable); } else { //Code selected is Product Code //TblProductInventory productInvent = new TblProductInventory(); //productInvent.MainConnectionProvider = connProvider; //productInvent.StrProductCode = itemCode; //productInvent.SelectOne(); //productInvent.NQuantity = ACMS.Convert.ToInt32(productInvent.NQuantity) - qtyOfItemCodeToRedempt; //productInvent.Update(); } } if (connProvider.CurrentTransaction != null) { connProvider.CurrentTransaction.Dispose(); } if (connProvider.DBConnection != null) { if (connProvider.DBConnection.State == ConnectionState.Open) { connProvider.DBConnection.Close(); } } }
private void simpleButtonOK_Click(object sender, EventArgs e) { //this.DialogResult = DialogResult.OK; //DEREK if (this.NClassInstanceID != -1) { //myMemberPackage.NewClassAttendance(MemberPackagePackageID, currMembershipID, TblClassInstance clsInstance = new TblClassInstance(); clsInstance.NClassInstanceID = this.NClassInstanceID; clsInstance.SelectOne(); int nType = this.IsGym ? 1 : 0; if (!ClassAttendance.VerifyMemberPackageAllowCertainClass(myPackageID, clsInstance.StrClassCode.Value)) { MessageBox.Show(this, "The package you wish to use is not allow to attend the class. Please use other package."); //return; } else if (clsInstance.NActualInstructorID.IsNull) { MessageBox.Show(this, "The Instructor has Not punch in yet."); //return; } else { try { //Edited by Albert on 20-Dec-06 //Change the User.BranchCode to frm.strBranchID. //To get the branch id from the dialog form. MemberPackage myMemberPackage = new MemberPackage(); myMemberPackage.NewClassAttendance(myPackageID, myMemberShipID, this.NClassInstanceID, nType, this.strBranchID, clsInstance.DtDate.Value, clsInstance.DtStartTime.Value, clsInstance.DtEndTime.Value, this.Refunded); this.DialogResult = DialogResult.OK; } catch (Exception ex) { this.DialogResult = DialogResult.None; MessageBox.Show(this, ex.Message); } } } else { try { ClassAttendance myClassAttendance = new ClassAttendance(); myClassAttendance.MarkGymAttendance(myPackageID, myMemberShipID, this.AttendanceDate, this.StartTime, this.EndTime, true); this.DialogResult = DialogResult.OK; } catch (Exception ex) { this.DialogResult = DialogResult.None; MessageBox.Show(this, ex.Message); } } }