private void simpleButtonOK_Click(object sender, System.EventArgs e) { DataRow r = gridView1.GetDataRow(gridView1.FocusedRowHandle); if (r != null) { ACMSDAL.TblMemberPackage sqlCalcAnyOS1 = new ACMSDAL.TblMemberPackage(); decimal dOutAmount = sqlCalcAnyOS1.OutstandingAmount(myPOS.StrMembershipID); if (myPOS.ReceiptMasterTable.Rows[0]["nCategoryID"].ToString() == "9") { if (myPOS.ReceiptItemsTable.Select("strCode='" + r["strPackageGroupCode"].ToString() + "'").Length > 0) { MessageBox.Show(this, r["strPackageGroupCode"].ToString() + " already selected!", "Warning"); return; } } if (dOutAmount > 0) { DialogResult result1 = MessageBox.Show(this, myPOS.ReceiptMasterTable.Rows[0]["strMemberName"] + " has Outstanding amount of " + (string.Format("{0:C}", dOutAmount)) + "\nDo you want to continue?", "Warning", MessageBoxButtons.YesNo); if (result1 == DialogResult.No) return; } if (myCategoryID == 4) { //2106 TblMember sqlMember = new TblMember(); if (sqlMember.MembershipThisMonthBirtdayForUtilised(myPOS.StrMembershipID)) { 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) { myPOS.NewBillDiscount("120046SSD"); myPOS.NewReceiptEntry(r["strPackageCode"].ToString(), -1, r["strDescription"].ToString(), 1, (ACMS.Convert.ToDecimal(r["mListPrice"])), ""); } else { myPOS.NewReceiptEntry(r["strPackageCode"].ToString(), -1, r["strDescription"].ToString(), 1, ACMS.Convert.ToDecimal(r["mListPrice"]), ""); } } else { myPOS.NewReceiptEntry(r["strPackageCode"].ToString(), -1, r["strDescription"].ToString(), 1, ACMS.Convert.ToDecimal(r["mListPrice"]), ""); } } // END TEST if (myCategoryID == 1 || myCategoryID == 3 ||// myCategoryID == 4 || myCategoryID == 6 || myCategoryID == 14 || myCategoryID == 23) { myPOS.NewReceiptEntry(r["strPackageCode"].ToString(), -1, r["strDescription"].ToString(), 1, ACMS.Convert.ToDecimal(r["mListPrice"]), ""); } else if (myCategoryID == 5) { myPOS.NewReceiptEntry(r["strPackageCode"].ToString(), -1, r["strDescription"].ToString(), 1, ACMS.Convert.ToDecimal(r["mListPrice"]), ""); DataTable myTblspapacakge = myPOSHelper.SearchOnePackageCode(r["strPackageCode"].ToString()); if (myTblspapacakge.Rows[0]["strFreePkgCode"].ToString() != string.Empty) { // ACMSLogic.POSEntries myEntry = new ACMSLogic.POSEntries(r); myPOS.EditItemFreebieAndDiscount(myTblspapacakge.Rows[0]["strFreePkgCode"].ToString()); } } else if (myCategoryID == 2) { decimal mBasePrice = 0M; decimal mProRateTotal = 0M; string strTypeCard = string.Empty; string strCode = string.Empty; string strDesc = string.Empty; string strCardHolder = txtCardHolder.Text.Trim(); string strCreditCardNo = txtCreditCardNo.Text.Trim(); string strRefNo = string.Empty; DateTime dtFrom = dtProrateFrom.Value; mBasePrice = ACMS.Convert.ToDecimal(r["mListPrice"]); mProRateTotal = (2 * mBasePrice); strCode = r["strPackageCode"].ToString(); strDesc = r["strDescription"].ToString(); lblAmount.Text = "$" + mProRateTotal.ToString(); myPOS.dtPackageStart = dtFrom; if (dtProrateFrom.Value.Day != 1 && dtProrateFrom.Value.Day != 16) { MessageBox.Show(" Please select the date either 1st or 16th of the month "); this.DialogResult = DialogResult.None; return; } { myPOS.NewReceiptEntry(strCode, -1, strDesc, 1, mProRateTotal, strRefNo, strCardHolder, strTypeCard, strCreditCardNo); } } else if (myCategoryID == 7 || myCategoryID == 36 || myCategoryID == 37) { myPOS.NewReceiptEntry(r["strCreditPackageCode"].ToString(), -1, r["strDescription"].ToString(), 1, ACMS.Convert.ToDecimal(r["mListPrice"]), ""); } else if (myCategoryID == 38) { myPOS.NewReceiptEntry(r["strSN"].ToString(), -1, r["strDescription"].ToString(), 1, ACMS.Convert.ToDecimal(r["mValue"]), ""); } else if (myCategoryID == 8 || myCategoryID == 9) { myPOS.NewReceiptEntry(r["strPackageGroupCode"].ToString(), -1, r["strDescription"].ToString(), 1, ACMS.Convert.ToDecimal(r["mListPrice"]), ""); } else if (myCategoryID == 11 || myCategoryID == 12) { myPOS.NewReceiptEntry(r["strProductCode"].ToString(), -1, r["strDescription"].ToString(), 1, ACMS.Convert.ToDecimal(r["mBaseUnitPrice"]), ""); } } }
private void CalculateBalance(string strMembershipID,string strMembershipPackageCode) { if (myDataTable != null) { if (!myDataTable.Columns.Contains("strBalNew")) { DataColumn colBalNew = new DataColumn("strBalNew", System.Type.GetType("System.String")); myDataTable.Columns.Add(colBalNew); } if (!myDataTable.Columns.Contains("Balance")) { DataColumn colBalance = new DataColumn("Balance", System.Type.GetType("System.Int32")); myDataTable.Columns.Add(colBalance); } if (!myDataTable.Columns.Contains("strPackageType")) { DataColumn colPackageType = new DataColumn("strPackageType", System.Type.GetType("System.String")); myDataTable.Columns.Add(colPackageType); } TblClassAttendance classAttendance = new TblClassAttendance(); TblServiceSession serviceSession = new TblServiceSession(); DataTable gymTable = new DataTable(); DataColumn colDtdate = new DataColumn("dtDate", typeof(string)); DataColumn colPackageID = new DataColumn("nPackageID", typeof(int)); DataColumn colAttendanceID = new DataColumn("nAttendanceID", typeof(int)); gymTable.Columns.Add(colDtdate); gymTable.Columns.Add(colPackageID); gymTable.Columns.Add(colAttendanceID); foreach (DataRow r in myDataTable.Rows) { r["Balance"] = r["nMaxSession"]; if (ACMS.Convert.ToInt32(r["nMaxSession"]) == 9999) { r["Balance"] = 9999; r["strBalNew"] = r["Balance"].ToString(); if (r["dtStartDate"] == DBNull.Value) r["strBalNew"] = "New"; else { if (r["strPackageType"].ToString() == "Normal Package") { if (ACMS.Convert.ToInt32(r["nMaxSession"]) == ACMS.Convert.ToInt32(r["Balance"]) && ACMS.Convert.ToInt32(r["nMaxSession"])!=9999) r["strBalNew"] = "New"; } } continue; } int nCategoryID = ACMS.Convert.ToInt32(r["nCategoryID"]); int nPackageID = ACMS.Convert.ToInt32(r["nPackageID"]); // class Attendance if (nCategoryID == 1 || nCategoryID == 2) { classAttendance.NPackageID = nPackageID; DataTable classAttendanceTable = classAttendance.SelectAllWnPackageIDLogic(); if (classAttendanceTable == null || classAttendanceTable.Rows.Count == 0) { if (ACMS.Convert.ToDBInt32(r["nAdjust"])>=1 && ACMS.Convert.ToInt32(r["nMaxSession"]) < 9999) { r["Balance"]=ACMS.Convert.ToDBInt32(r["Balance"])-ACMS.Convert.ToDBInt32(r["nAdjust"]); } r["strBalNew"] = r["Balance"].ToString(); if (r["dtStartDate"] == DBNull.Value) r["strBalNew"] = "New"; else { if (r["strPackageType"].ToString() == "Normal Package") { if (ACMS.Convert.ToInt32(r["nMaxSession"]) == ACMS.Convert.ToInt32(r["Balance"])) r["strBalNew"] = "New"; } } continue; } DataView classAttendanceTableView = classAttendanceTable.DefaultView; // Need to filter out the non GYM attendance here classAttendanceTableView.RowFilter = "((nStatusID = 1 or nStatusID = 2) AND nTypeID = 0)"; if (classAttendanceTableView.Count > 0) { ACMSDAL.TblMemberPackage sqlFindPackageCode = new ACMSDAL.TblMemberPackage(); string strPackageCode = sqlFindPackageCode.GetPackageCode(strMembershipID, nPackageID); //if (strPackageCode == "AA(1080/12)" || strPackageCode == "AA(2160/24)" ) //{ // r["Balance"] = ACMS.Convert.ToInt32(r["Balance"]) - myDTransactionID; //} if (r["fEntries"].ToString()=="True") { if (nCategoryID == 2) //2604 { string strPackageID = nPackageID.ToString(); ACMSDAL.TblMemberPackage sqlCalcTotalGIRO = new ACMSDAL.TblMemberPackage();//jackie 15/03/2012 int intTotalGIRO = sqlCalcTotalGIRO.CalculateTotalGIRO(strMembershipID, strPackageID, strPackageCode); ACMSDAL.TblMemberPackage sqlCalcPackages = new ACMSDAL.TblMemberPackage(); int myDTransactionID = sqlCalcPackages.CalculateSpecialSessionPackages(strMembershipID, nPackageID); r["Balance"] = (intTotalGIRO * ACMS.Convert.ToInt32(r["Balance"])) - myDTransactionID; } else { //1203 jackie ACMSDAL.TblMemberPackage sqlCalcPackages = new ACMSDAL.TblMemberPackage(); int myDTransactionID = sqlCalcPackages.CalculateSpecialSessionPackages(strMembershipID, nPackageID); r["Balance"] = ACMS.Convert.ToInt32(r["Balance"]) - myDTransactionID; } } else//2604 if ( strPackageCode == "FTRIAL") { r["Balance"] = classAttendanceTableView.Count; } else { if (nCategoryID == 2 || ACMS.Convert.ToInt32(r["Balance"]) == 9999) //2604 { string strPackageID = nPackageID.ToString(); ACMSDAL.TblMemberPackage sqlCalcTotalGIRO = new ACMSDAL.TblMemberPackage();//jackie 15/03/2012 int intTotalGIRO = sqlCalcTotalGIRO.CalculateTotalGIRO(strMembershipID, strPackageID,strPackageCode); r["Balance"] = (intTotalGIRO * ACMS.Convert.ToInt32(r["Balance"])) - classAttendanceTableView.Count; } else { r["Balance"] = ACMS.Convert.ToInt32(r["Balance"]) - classAttendanceTableView.Count; } } } else { if (nCategoryID == 2) //2604 { if (r["fEntries"].ToString() == "True") { ACMSDAL.TblMemberPackage sqlFindPackageCode = new ACMSDAL.TblMemberPackage(); string strPackageCode = sqlFindPackageCode.GetPackageCode(strMembershipID, nPackageID); string strPackageID = nPackageID.ToString(); ACMSDAL.TblMemberPackage sqlCalcTotalGIRO = new ACMSDAL.TblMemberPackage();//jackie 15/03/2012 int intTotalGIRO = sqlCalcTotalGIRO.CalculateTotalGIRO(strMembershipID, strPackageID, strPackageCode); ACMSDAL.TblMemberPackage sqlCalcPackages = new ACMSDAL.TblMemberPackage(); int myDTransactionID = sqlCalcPackages.CalculateSpecialSessionPackages(strMembershipID, nPackageID); r["Balance"] = (intTotalGIRO * ACMS.Convert.ToInt32(r["Balance"])); } else { ACMSDAL.TblMemberPackage sqlFindPackageCode = new ACMSDAL.TblMemberPackage(); string strPackageCode = sqlFindPackageCode.GetPackageCode(strMembershipID, nPackageID); string strPackageID = nPackageID.ToString(); ACMSDAL.TblMemberPackage sqlCalcTotalGIRO = new ACMSDAL.TblMemberPackage();//jackie 15/03/2012 int intTotalGIRO = sqlCalcTotalGIRO.CalculateTotalGIRO(strMembershipID, strPackageID, strPackageCode); r["Balance"] = (intTotalGIRO * ACMS.Convert.ToInt32(r["Balance"])); } } } if (ACMS.Convert.ToDBInt32(r["nAdjust"])>=1 && ACMS.Convert.ToInt32(r["nMaxSession"]) < 9999) { r["Balance"]=ACMS.Convert.ToDBInt32(r["Balance"])-ACMS.Convert.ToDBInt32(r["nAdjust"]); } // Start calculate the POWER Package // It is consider PWR Package if the class attendance is GYM Class classAttendanceTableView.RowFilter = "((nStatusID = 1 or nStatusID = 2) AND nTypeID = 1 AND nPackageID ='" +nPackageID+ "')"; if (classAttendanceTableView.Count > 0) { for (int i = 0; i < classAttendanceTableView.Count; i ++) { DataRow row = classAttendanceTableView[i].Row; string dtDate = ACMS.Convert.ToDateTime(row["dtDate"]).ToString("yyyy/MM/dd"); int nAttendanceID = ACMS.Convert.ToInt32(row["nAttendanceID"]); DataRow[] foundRow = gymTable.Select("dtDate = '" + dtDate + "'" + "AND nPackageID = '" + nPackageID + "'"); if (foundRow.Length == 0) { DataRow addRow = gymTable.NewRow(); addRow["dtDate"] = dtDate; addRow["nPackageID"] = nPackageID; addRow["nAttendanceID"] = nAttendanceID; gymTable.Rows.Add(addRow); } } foreach (DataRow pRow in gymTable.Rows) { DateTime dtDate = ACMS.Convert.ToDateTime(pRow["dtDate"]); int nPackageIDInGymTable = ACMS.Convert.ToInt32(pRow["nPackageID"]); string strFilter = string.Format("(nStatusID = 1 or nStatusID = 2) " + " AND nTypeID = 0 AND nPackageID = {0} AND DtDate = #{1}#", nPackageID, dtDate.ToString("yyyy/MM/dd")); DataRow[] foundRow = classAttendanceTable.Select(strFilter, "nPackageID", DataViewRowState.CurrentRows); if (foundRow.Length > 0) r["Balance"] = ACMS.Convert.ToInt32(r["Balance"]) + 1; } if (gymTable.Rows.Count>0) r["Balance"] = ACMS.Convert.ToInt32(r["Balance"]) - gymTable.Rows.Count; gymTable.Rows.Clear(); //////////// //ACMSDAL.TblMemberPackage sqlCalcPackages = new ACMSDAL.TblMemberPackage();//jackie 15/03/2012 //int myDTransactionID = sqlCalcPackages.CalculateSpecialSessionPackages(strMembershipID, nPackageID); //ACMSDAL.TblMemberPackage sqlFindPackageCode = new ACMSDAL.TblMemberPackage(); //string strPackageCode = sqlFindPackageCode.GetPackageCode(strMembershipID, nPackageID); ////if (strPackageCode == "AA(1080/12)" || strPackageCode == "AA(2160/24)") ////{ //// r["Balance"] = ACMS.Convert.ToInt32(r["nMaxSession"]) - myDTransactionID; ////} //if (r["fEntries"].ToString() == "True") //{ // r["Balance"] = ACMS.Convert.ToInt32(r["nMaxSession"]) - myDTransactionID; //} //else // if (strPackageCode == "FTRIAL") // { // r["Balance"] = myDTransactionID; // } // else // ///////// // { // r["Balance"] = ACMS.Convert.ToInt32(r["Balance"]) - gymTable.Rows.Count; // } //gymTable.Rows.Clear(); } } else if (nCategoryID == 3 || nCategoryID == 4 || nCategoryID == 5 || nCategoryID == 6 || nCategoryID == 34) // Service Session { serviceSession.NPackageID = nPackageID; DataView serviceSessionTable = serviceSession.SelectAllWnPackageIDLogic().DefaultView; serviceSessionTable.RowFilter = "nStatusID = 5 or nStatusID = 6"; if (nCategoryID == 34) { r["Balance"] = ACMS.Convert.ToInt32(r["Balance"]) - serviceSessionTable.Count + ACMS.Convert.ToDBInt32(r["nAdjust"]); } else { ACMSDAL.TblMemberPackage sqlCalcPackages = new ACMSDAL.TblMemberPackage();//jackie 15/03/2012 int myDTransactionID = sqlCalcPackages.CalculateSpecialSessionPackages(strMembershipID, nPackageID); ACMSDAL.TblMemberPackage sqlFindPackageCode = new ACMSDAL.TblMemberPackage(); string strPackageCode = sqlFindPackageCode.GetPackageCode(strMembershipID, nPackageID); if (strPackageCode == "AA(1080/12)" || strPackageCode == "AA(2160/24)" ) { r["Balance"] = ACMS.Convert.ToInt32(r["Balance"]) - myDTransactionID; } else if (strPackageCode == "FTRIAL") { r["Balance"] = myDTransactionID; } else { if (nCategoryID == 2 || ACMS.Convert.ToInt32(r["Balance"]) == 9999) //2604 { string strPackageID = nPackageID.ToString(); ACMSDAL.TblMemberPackage sqlCalcTotalGIRO = new ACMSDAL.TblMemberPackage();//jackie 15/03/2012 int intTotalGIRO = sqlCalcTotalGIRO.CalculateTotalGIRO(strMembershipID, strPackageID,strPackageCode); r["Balance"] = (intTotalGIRO * ACMS.Convert.ToInt32(r["Balance"])) - serviceSessionTable.Count; } else { r["Balance"] = ACMS.Convert.ToInt32(r["Balance"]) - serviceSessionTable.Count; } } if (ACMS.Convert.ToDBInt32(r["nAdjust"]) >= 1 && ACMS.Convert.ToInt32(r["nMaxSession"]) < 9999) { //jackie r["Balance"] = ACMS.Convert.ToDBInt32(r["Balance"]) - ACMS.Convert.ToDBInt32(r["nAdjust"]); } } //if (dr["strFreePkgCode"].ToString() != string.Empty) //{ // myPOS.EditItemFreebieAndDiscount(dr["strFreePkgCode"].ToString()); //} } r["strBalNew"] = r["Balance"].ToString(); if (r["dtStartDate"] == DBNull.Value) r["strBalNew"] = "New"; else { if (r["strPackageType"].ToString() == "Normal Package") { if (ACMS.Convert.ToInt32(r["nMaxSession"]) == ACMS.Convert.ToInt32(r["Balance"])) r["strBalNew"] = "New"; } } } } }
private void simpleButtonOK_Click(object sender, System.EventArgs e) { DataRow r = gridView1.GetDataRow(gridView1.FocusedRowHandle); if (r != null) { ACMSDAL.TblMemberPackage sqlCalcAnyOS1 = new ACMSDAL.TblMemberPackage(); decimal dOutAmount = sqlCalcAnyOS1.OutstandingAmount(myPOS.StrMembershipID); if (myPOS.ReceiptMasterTable.Rows[0]["nCategoryID"].ToString() == "9") { if (myPOS.ReceiptItemsTable.Select("strCode='" + r["strPackageGroupCode"].ToString() + "'").Length > 0) { MessageBox.Show(this, r["strPackageGroupCode"].ToString() + " already selected!", "Warning"); return; } } if (dOutAmount > 0) { DialogResult result1 = MessageBox.Show(this, myPOS.ReceiptMasterTable.Rows[0]["strMemberName"] + " has Outstanding amount of " + (string.Format("{0:C}", dOutAmount)) + "\nDo you want to continue?", "Warning", MessageBoxButtons.YesNo); if (result1 == DialogResult.No) { return; } } if (myCategoryID == 4) { //2106 TblMember sqlMember = new TblMember(); if (sqlMember.MembershipThisMonthBirtdayForUtilised(myPOS.StrMembershipID)) { 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) { myPOS.NewBillDiscount("120046SSD"); myPOS.NewReceiptEntry(r["strPackageCode"].ToString(), -1, r["strDescription"].ToString(), 1, (ACMS.Convert.ToDecimal(r["mListPrice"])), ""); } else { myPOS.NewReceiptEntry(r["strPackageCode"].ToString(), -1, r["strDescription"].ToString(), 1, ACMS.Convert.ToDecimal(r["mListPrice"]), ""); } } else { myPOS.NewReceiptEntry(r["strPackageCode"].ToString(), -1, r["strDescription"].ToString(), 1, ACMS.Convert.ToDecimal(r["mListPrice"]), ""); } } // END TEST if (myCategoryID == 1 || myCategoryID == 3 || // myCategoryID == 4 || myCategoryID == 6 || myCategoryID == 14 || myCategoryID == 23) { myPOS.NewReceiptEntry(r["strPackageCode"].ToString(), -1, r["strDescription"].ToString(), 1, ACMS.Convert.ToDecimal(r["mListPrice"]), ""); } else if (myCategoryID == 5) { myPOS.NewReceiptEntry(r["strPackageCode"].ToString(), -1, r["strDescription"].ToString(), 1, ACMS.Convert.ToDecimal(r["mListPrice"]), ""); DataTable myTblspapacakge = myPOSHelper.SearchOnePackageCode(r["strPackageCode"].ToString()); if (myTblspapacakge.Rows[0]["strFreePkgCode"].ToString() != string.Empty) { // ACMSLogic.POSEntries myEntry = new ACMSLogic.POSEntries(r); myPOS.EditItemFreebieAndDiscount(myTblspapacakge.Rows[0]["strFreePkgCode"].ToString()); } } else if (myCategoryID == 2) { decimal mBasePrice = 0M; decimal mProRateTotal = 0M; string strTypeCard = string.Empty; string strCode = string.Empty; string strDesc = string.Empty; string strCardHolder = txtCardHolder.Text.Trim(); string strCreditCardNo = txtCreditCardNo.Text.Trim(); string strRefNo = string.Empty; DateTime dtFrom = dtProrateFrom.Value; mBasePrice = ACMS.Convert.ToDecimal(r["mListPrice"]); mProRateTotal = (2 * mBasePrice); strCode = r["strPackageCode"].ToString(); strDesc = r["strDescription"].ToString(); lblAmount.Text = "$" + mProRateTotal.ToString(); myPOS.dtPackageStart = dtFrom; if (dtProrateFrom.Value.Day != 1 && dtProrateFrom.Value.Day != 16) { MessageBox.Show(" Please select the date either 1st or 16th of the month "); this.DialogResult = DialogResult.None; return; } { myPOS.NewReceiptEntry(strCode, -1, strDesc, 1, mProRateTotal, strRefNo, strCardHolder, strTypeCard, strCreditCardNo); } } else if (myCategoryID == 7 || myCategoryID == 36 || myCategoryID == 37) { myPOS.NewReceiptEntry(r["strCreditPackageCode"].ToString(), -1, r["strDescription"].ToString(), 1, ACMS.Convert.ToDecimal(r["mListPrice"]), ""); } else if (myCategoryID == 38) { myPOS.NewReceiptEntry(r["strSN"].ToString(), -1, r["strDescription"].ToString(), 1, ACMS.Convert.ToDecimal(r["mValue"]), ""); } else if (myCategoryID == 8 || myCategoryID == 9) { myPOS.NewReceiptEntry(r["strPackageGroupCode"].ToString(), -1, r["strDescription"].ToString(), 1, ACMS.Convert.ToDecimal(r["mListPrice"]), ""); } else if (myCategoryID == 11 || myCategoryID == 12) { myPOS.NewReceiptEntry(r["strProductCode"].ToString(), -1, r["strDescription"].ToString(), 1, ACMS.Convert.ToDecimal(r["mBaseUnitPrice"]), ""); } } }