private void lkpEdtClassInstant_EditValueChanged(object sender, System.EventArgs e) { int nClassInstanceID = ACMS.Convert.ToInt32(lkpEdtClassInstant.EditValue); ACMSDAL.TblClassInstance clsInstance = new ACMSDAL.TblClassInstance(); clsInstance.NClassInstanceID = nClassInstanceID; clsInstance.SelectOne(); txtEdtStartTime.Text = clsInstance.DtStartTime.Value.ToShortTimeString(); txtEdtEndTime.Text = clsInstance.DtEndTime.Value.ToShortTimeString(); }
public bool NewClassAttendance(int nPackageID, string strMemberShipID, int nClassInstance, int nType, string strBranchCode, DateTime classDate, DateTime startTime, DateTime endTime, bool isRefunded) { if (!isRefunded) { ACMSDAL.TblReceipt sqlReceipt = new ACMSDAL.TblReceipt(); DataTable receipttable = sqlReceipt.GetToDayForgetCardReceipt(strMemberShipID, 17); if (receipttable == null || receipttable.Rows.Count == 0) { throw new Exception("You have yet to pay the forget card deposit today."); } } TblClassAttendance classAttendance = new TblClassAttendance(); bool isPostFromOtherRecord = false; bool needtoAddBackOneDayExpiryDate = false; bool BalanceStatus = true; DataTable memberPackageTable = null; if (nType != 1) { DataRow classAttendanceRow = null; bool isAttendedNow = classAttendance.IsAttendedThisClass(nClassInstance, strMemberShipID, ref classAttendanceRow); if (isAttendedNow) { int nStatusID = ACMS.Convert.ToInt32(classAttendanceRow["nStatusID"]); if (nStatusID == 1) { // Process throw new Exception("Member already been marked in this class."); } else { //Forfeit and need to change to process if (classAttendanceRow != null) { int nClassAttendanceID = ACMS.Convert.ToInt32(classAttendanceRow["nAttendanceID"]); classAttendance.NAttendanceID = nClassAttendanceID; classAttendance.SelectOne(); isPostFromOtherRecord = true; nPackageID = classAttendance.NPackageID.Value; isRefunded = classAttendance.FRefunded.IsNull ? true : classAttendance.FRefunded.Value; // this only true if the package is unlimited one memberPackageTable = myMemberPackage.GetMemberPackage(nPackageID); if (ACMS.Convert.ToInt32(memberPackageTable.Rows[0]["nMaxSession"]) == 9999) needtoAddBackOneDayExpiryDate = true; } } } else if (classAttendanceRow != null && nType == 0) { int nClassAttendanceID = ACMS.Convert.ToInt32(classAttendanceRow["nAttendanceID"]); classAttendance.NAttendanceID = nClassAttendanceID; classAttendance.SelectOne(); isPostFromOtherRecord = true; nPackageID = classAttendance.NPackageID.Value; isRefunded = classAttendance.FRefunded.IsNull ? true : classAttendance.FRefunded.Value; } } if (memberPackageTable == null) { myMemberPackage.NPackageID = nPackageID; memberPackageTable = myMemberPackage.GetMemberPackage(nPackageID); } if (memberPackageTable == null || memberPackageTable.Rows.Count == 0) throw new Exception("Failed to create new class attendance. Member Package with npackageID = " + nPackageID.ToString() + "has been deleted"); classAttendance.NPackageID = nPackageID; classAttendance.StrMembershipID = strMemberShipID; classAttendance.NClassInstanceID = nClassInstance; classAttendance.NTypeID = nType; classAttendance.StrBranchCode = strBranchCode; classAttendance.DtDate = classDate; classAttendance.DtStartTime = startTime; classAttendance.DtEndTime = endTime; classAttendance.DtLastEditDate = DateTime.Now; classAttendance.NEmployeeID = ACMSLogic.User.EmployeeID; //indicated free class or not TblClassInstance classInstance = new TblClassInstance(); DataTable Instance = classInstance.LoadData("Select fFree from tblClassInstance Where nClassInstanceID = @nClassInstanceID", new string[] { "@nClassInstanceID" }, new object[] { nClassInstance }); if (Instance.Rows[0][0].ToString() == "True") classAttendance.NStatusID = 4; else classAttendance.NStatusID = 1; classAttendance.FRefunded = isRefunded;// System.Data.SqlTypes.SqlBoolean. //UnLinked is for temporary only if (memberPackageTable.Rows[0]["strPackageCode"].ToString() != "Unlinked") { CalculateMemberPackageBalance(memberPackageTable.Rows[0]["strPackageCode"].ToString(), strMemberShipID, memberPackageTable); DataRow masterRow = memberPackageTable.Rows[0]; // if (ACMS.Convert.ToDBInt32(memberPackageTable.Rows[0]["Balance"])<999 && ACMS.Convert.ToDBInt32(memberPackageTable.Rows[0]["nAdjust"])>=1) // { // memberPackageTable.Rows[0]["Balance"]=ACMS.Convert.ToDBInt32(memberPackageTable.Rows[0]["Balance"])- ACMS.Convert.ToDBInt32(memberPackageTable.Rows[0]["nAdjust"]); // } if (ACMS.Convert.ToInt32(memberPackageTable.Rows[0]["Balance"]) <= 0) { throw new Exception("Balance is zero"); masterRow["nBalance"] = false; BalanceStatus = false; } if (masterRow["fGiro"].ToString() != "1") { if ((masterRow["dtStartDate"] == DBNull.Value && masterRow["dtExpiryDate"] == DBNull.Value) || (masterRow["dtStartDate"] != DBNull.Value && Convert.ToDateTime(masterRow["dtStartDate"]) > classDate)) { // Means new class Attendance gonna insert TblPackage package = new TblPackage(); package.StrPackageCode = masterRow["strPackageCode"].ToString(); package.SelectOne(); //if (package.NPackageDuration.Value == 0 && package.NPackageDay.Value > 0) //{ // masterRow["dtStartDate"] = classDate; // masterRow["dtExpiryDate"] = classDate.AddDays(package.NPackageDay.Value - 1); //} //else //{ // masterRow["dtStartDate"] = classDate; // masterRow["dtExpiryDate"] = classDate.AddMonths(package.NPackageDuration.Value).AddDays(-1); //} //jackie Start 05042012 masterRow["dtStartDate"] = classDate; if (package.NPackageDuration.Value == 0) { string txt = package.StrPackageCode.ToString(); if (txt == "FTRIAL") { masterRow["dtExpiryDate"] = classDate.AddDays(1).AddDays(0); } else { string strduration; int cstarts = txt.IndexOf("(") + 1; int len = txt.IndexOf(")") - cstarts; txt = txt.Substring(cstarts, len); if (string.IsNullOrEmpty(txt)) { strduration = string.Empty; } else { int lens = txt.Length; strduration = txt.Substring(txt.Length - 1, 1); } if (strduration == "D") { strduration = txt.Replace("D", ""); int iduration = Int32.Parse(strduration); masterRow["dtExpiryDate"] = classDate.AddDays(iduration - 1).AddDays(0); } if (strduration == "W") { strduration = txt.Replace("W", ""); int iduration = Int32.Parse(strduration); iduration = iduration * 7; masterRow["dtExpiryDate"] = classDate.AddDays(iduration - 1).AddDays(0); } } } else { int iduration = package.NPackageDuration.Value; if (package.StrDurationUnit.ToString().Trim() == "DAY") masterRow["dtExpiryDate"] = classDate.AddDays(iduration - 1).AddDays(0); else if (package.StrDurationUnit.ToString().Trim() == "WEEK") { iduration = iduration * 7; masterRow["dtExpiryDate"] = classDate.AddDays(iduration - 1).AddDays(0); } else if (package.StrDurationUnit.ToString().Trim() == "MONTH") masterRow["dtExpiryDate"] = classDate.AddMonths(package.NPackageDuration.Value).AddDays(-1); } //jackie END 2/02/2012 } else { // Kean Yiap string strPackageCode = masterRow["strPackageCode"].ToString(); CalculateMemberPackageBalance(strPackageCode, strMemberShipID, memberPackageTable); DateTime memberPackageStartDate = ACMS.Convert.ToDateTime(masterRow["DtStartDate"]); DateTime memberPackageExpiryDate = ACMS.Convert.ToDateTime(masterRow["dtExpiryDate"]); //if (memberPackageStartDate > classDate) //{ //jackie why must change ExpiryDate 26042012 // masterRow["dtExpiryDate"] = memberPackageExpiryDate.Subtract(memberPackageStartDate.Subtract(classDate)); //} } } if (ACMS.Convert.ToInt32(memberPackageTable.Rows[0]["Balance"]) <= 1) { if (masterRow["strPackageCode"].ToString() == "FTRIAL") { memberPackageTable.Rows[0]["nBalance"] = 1; } else { memberPackageTable.Rows[0]["nBalance"] = 0; } } } ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider(); try { myMemberPackage.MainConnectionProvider = connProvider; classAttendance.MainConnectionProvider = connProvider; connProvider.OpenConnection(); connProvider.BeginTransaction("SaveClassAttendance"); if (needtoAddBackOneDayExpiryDate && memberPackageTable.Rows[0]["fGIRO"].ToString() != "1") { memberPackageTable.Rows[0]["dtExpiryDate"] = ACMS.Convert.ToDateTime(memberPackageTable.Rows[0]["dtExpiryDate"]).AddDays(1); } myMemberPackage.SaveData(memberPackageTable); if (BalanceStatus) { if (!isPostFromOtherRecord) classAttendance.Insert(); else classAttendance.Update(); connProvider.CommitTransaction(); } return true; } catch (Exception) { connProvider.RollbackTransaction("SaveClassAttendance"); throw new Exception("Failed to save Class Attendance"); } finally { if (connProvider.CurrentTransaction != null) connProvider.CurrentTransaction.Dispose(); if (connProvider.DBConnection != null) { if (connProvider.DBConnection.State == ConnectionState.Open) connProvider.DBConnection.Close(); } myMemberPackage.MainConnactionIsCreatedLocal = true; classAttendance.MainConnactionIsCreatedLocal = true; } }
public DataTable GetClassInstance(DateTime classDate, string strBranchCode, string strPackageCode) { TblClassInstance instance = new TblClassInstance(); return instance.GetValidClassInstance(classDate, strBranchCode, strPackageCode); }
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."); }
public void MarkAttendance(int nClassInstanceID, int nPackageID, string strMembershipID, int nClassType, bool isRefunded, bool needToVerifyMemberPackage) { MemberPackage memberPackage = new MemberPackage(); bool createNewClassAttendance = false; ACMSDAL.TblClassInstance sqlClassInstance = new TblClassInstance(); sqlClassInstance.NClassInstanceID = nClassInstanceID; sqlClassInstance.SelectOne(); if (sqlClassInstance.NActualInstructorID.IsNull) throw new Exception("No intructor has logined to this class. You cannot mark the attendance now."); //verify non peak package holder TblMemberPackage clsMemberPackage = new TblMemberPackage(); clsMemberPackage.NPackageID = nPackageID; clsMemberPackage.SelectOne(); TblPackage clsPackage = new TblPackage(); clsPackage.StrPackageCode = clsMemberPackage.StrPackageCode; clsPackage.SelectOne(); if (clsPackage.FPeak.IsNull == false && sqlClassInstance.FPeak.IsNull == false) { if (clsPackage.FPeak.Value == false && sqlClassInstance.FPeak == false) { } else { throw new Exception("Member holding Leisure Package and only allow to mark the attendance for non peak classes."); } } if (needToVerifyMemberPackage) { if (!VerifyMemberPackageAllowCertainClass(nPackageID, sqlClassInstance.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 mark 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; } } } createNewClassAttendance = memberPackage.NewClassAttendance(nPackageID, strMembershipID, nClassInstanceID, nClassType, User.BranchCode, sqlClassInstance.DtDate.Value, sqlClassInstance.DtStartTime.Value, sqlClassInstance.DtEndTime.Value, isRefunded); if (nPackageID >= 0) PrintClassAttendanceReminder(nPackageID, strMembershipID, nClassInstanceID); }
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 CancelReservation(int nAttendanceID) { TblCompany comp = new TblCompany(); DataTable table = comp.SelectAll(); int nhourBeforeToDelete = 0; if (table != null && table.Rows.Count>0) { nhourBeforeToDelete = ACMS.Convert.ToInt32(table.Rows[0]["nCancelBookingLimit"]); } TblClassAttendance classAttendance = new TblClassAttendance(); classAttendance.NAttendanceID = nAttendanceID; classAttendance.SelectOne(); TblClassInstance classInstance = new TblClassInstance(); classInstance.NClassInstanceID = classAttendance.NClassInstanceID.Value; classInstance.SelectOne(); if (DateTime.Today.Date > classInstance.DtDate.Value.Date) return; else if (DateTime.Today.Date == classInstance.DtDate.Value.Date) { // if (oUser.DateTime.Now.Hour + nhourBeforeToDelete > classAttendance.DtStartTime.Value.Hour) // throw new Exception("You are not allow to cancel this reservation because you have passed the time period that allow you to cancel the reservation."); // else // { classAttendance.NStatusID = 3; classAttendance.Update(); //} } else { try { classAttendance.NStatusID = 3; classAttendance.Update(); } catch(Exception ex) { MessageBox.Show(ex.Message); } } }
public void AddWaitingList(string strMembershipID, int nPackageID, int nClassInstanceID, bool needToVerifyMemberPackage) { TblClassInstance classInstance = new TblClassInstance(); classInstance.NClassInstanceID = nClassInstanceID; classInstance.SelectOne(); TblWaitingList wl = new TblWaitingList(); 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 add waiting list to the previous day class."); if (needToVerifyMemberPackage) { if (!VerifyMemberPackageAllowCertainClass(nPackageID, classInstance.StrClassCode.Value)) { DialogResult result = MessageBox.Show("The package you wish to use is not allow to attend the class. Do you still want to proceed. \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; } } } //Prompt Package going to expiry //Prompt Remaining class wl.NClassInstanceID = nClassInstanceID; wl.StrMembershipID = strMembershipID; wl.DtDate = classInstance.DtDate.Value; wl.DtRequestDate = DateTime.Today.Date; wl.DtStartTime = classInstance.DtStartTime.Value; wl.DtEndTime = classInstance.DtEndTime.Value; wl.StrBranchCode = User.BranchCode; wl.NStatusID = 0; wl.NPackageID = nPackageID; wl.StrRemarks = ""; wl.StrType = "System"; wl.Insert(); }
public static bool VerifyMemberPackageAllowCertainClass(int nPackageID, string strClassCode) { TblClassInstance clsInstance = new TblClassInstance(); string cmdText = " Select Count (*) from tblPackageClass A " + " inner join tblMemberPackage B on A.strPackageCode = B.strPackageCode " + " Where B.nPackageID = @nPackageID and A.strClassCode = @strClassCode"; object obj = clsInstance.ExecuteScalar(cmdText, new string[] {"@nPackageID", "@strClassCode"}, new object[] {nPackageID, strClassCode}); if (obj != null) { Int32 r = (Int32) obj; if (r > 0) return true; else return false; } else return true; }
public static void CreateClassInstance(System.DayOfWeek dayOfWeek) { TblClassInstance classInstance = new TblClassInstance(); TblClassSchedule classSchedule = new TblClassSchedule(); DateTime dateNow = System.DateTime.Today.Date; if (dateNow.DayOfWeek != dayOfWeek) { for (double i = 1; i < 8; i++) { dateNow = dateNow.AddDays(1).Date; if (dateNow.DayOfWeek == dayOfWeek) break; } } for (double i = 0; i < 2; i++) { DateTime date; if (i == 0) date = dateNow; else { double dayToAdd = i * 7; date = dateNow.AddDays(dayToAdd).Date; } int nDay = ConvertDateToNDay(date); DataTable table = classSchedule.SelectAllWnDay(nDay, User.BranchCode); if (table == null || table.Rows.Count == 0) continue; else { foreach (DataRow r in table.Rows) { //DateTime newdate = System.DateTime.(date.Year, date.Month, date.Year); //DateTime dt= System.Convert.ToDateTime(date.ToString("dd/MM/yyyy")); DateTime dtEndTime = ACMS.Convert.ToDateTime(r["dtEndTime"]); DateTime dtStartTime = ACMS.Convert.ToDateTime(r["dtStartTime"]); string strClassCode = r["strClassCode"].ToString(); int nHallNo = ACMS.Convert.ToInt32(r["nHallNo"]); bool createdInstance = classInstance.HaveClassInstance(date, dtEndTime, dtStartTime, strClassCode, nHallNo, User.BranchCode); if (!createdInstance) { classInstance.DtDate = date; classInstance.DtEndTime = ACMS.Convert.ToDateTime(r["dtEndTime"]); classInstance.DtStartTime = ACMS.Convert.ToDateTime(r["dtStartTime"]); classInstance.StrClassCode = ACMS.Convert.ToSqlString(r["strClassCode"]); classInstance.NHallNo = ACMS.Convert.ToSqlInt32(r["nHallNo"]); classInstance.NPermanentInstructorID = ACMS.Convert.ToSqlInt32(r["nInstructorID"]); classInstance.FFree = ACMS.Convert.ToBoolean(r["fFree"]); classInstance.FPeak = ACMS.Convert.ToBoolean(r["fPeak"]); classInstance.FAllowStudentOnPeak = ACMS.Convert.ToBoolean(r["fAllowStudentOnPeak"]); classInstance.FReservation = ACMS.Convert.ToBoolean(r["fReservation"]); classInstance.FPeak = ACMS.Convert.ToBoolean(r["fPeak"]); classInstance.FAllowStudentOnPeak = ACMS.Convert.ToBoolean(r["fAllowStudentOnPeak"]); classInstance.FReservation = ACMS.Convert.ToBoolean(r["fReservation"]); classInstance.NMaxNo = ACMS.Convert.ToSqlInt32(r["nMaxNo"]); classInstance.FAllowUOBBooking = ACMS.Convert.ToBoolean(r["fAllowUOBBooking"]); classInstance.NCommissionTypeID = ACMS.Convert.ToSqlInt32(r["nCommissionTypeID"]); classInstance.StrBranchCode = User.BranchCode; classInstance.FCancelled = System.Data.SqlTypes.SqlBoolean.False; classInstance.Insert(); } } } } }
private void Init() { //myDataTab myClassInstance = new TblClassInstance(); GetClassInstance(DateTime.Now.Date, User.BranchCode); connectionString = (string)ConfigurationSettings.AppSettings["Main.ConnectionString"]; connection = new SqlConnection(connectionString); }
public static void CreateClassInstance() { TblClassInstance classInstance = new TblClassInstance(); TblClassSchedule classSchedule = new TblClassSchedule(); classInstance.StrClassCode = "GYM"; DataTable temptable = classInstance.SelectAllWstrClassCodeLogic(); if (temptable == null || temptable.Rows.Count == 0) { TblInstructorTypeCommission dummyInstructorTypeCommission = new TblInstructorTypeCommission(); DataTable dummyTable = dummyInstructorTypeCommission.SelectAll(); if (dummyTable.Rows.Count == 0) throw new Exception("Please insert a record in InstructorTypeCommission table."); classInstance.StrClassCode = "GYM"; classInstance.NPermanentInstructorID = User.EmployeeID; classInstance.NCommissionTypeID = ACMS.Convert.ToInt32(dummyTable.Rows[0]["nCommissionTypeID"]); classInstance.StrBranchCode = User.BranchCode; classInstance.DtDate = DateTime.Today.Date; classInstance.DtEndTime = DateTime.Now; classInstance.DtStartTime = DateTime.Now; //classInstance.nClassScheduleID = 0; classInstance.Insert(); } DateTime dateNow = System.DateTime.Now; for (double i = 0; i < 2; i++) { DateTime date; if (i == 0) date = DateTime.Today.Date; else { double dayToAdd = i * 7; date = dateNow.AddDays(dayToAdd).Date; } int nDay = ConvertDateToNDay(date); DataTable table = classSchedule.SelectAllWnDay(nDay, User.BranchCode); if (table == null || table.Rows.Count == 0) continue; else { foreach (DataRow r in table.Rows) { //DateTime newdate = System.DateTime.(date.Year, date.Month, date.Year); //DateTime dt= System.Convert.ToDateTime(date.ToString("dd/MM/yyyy")); DateTime dtEndTime = ACMS.Convert.ToDateTime(r["dtEndTime"]); DateTime dtStartTime = ACMS.Convert.ToDateTime(r["dtStartTime"]); string strClassCode = r["strClassCode"].ToString(); int nHallNo = ACMS.Convert.ToInt32(r["nHallNo"]); bool createdInstance = classInstance.HaveClassInstance(date, dtEndTime, dtStartTime, strClassCode, nHallNo, User.BranchCode); if (!createdInstance) { classInstance.DtDate = date; classInstance.DtEndTime = ACMS.Convert.ToDateTime(r["dtEndTime"]); classInstance.DtStartTime = ACMS.Convert.ToDateTime(r["dtStartTime"]); classInstance.StrClassCode = ACMS.Convert.ToSqlString(r["strClassCode"]); classInstance.NHallNo = ACMS.Convert.ToSqlInt32(r["nHallNo"]); classInstance.NPermanentInstructorID = ACMS.Convert.ToSqlInt32(r["nInstructorID"]); classInstance.FFree = ACMS.Convert.ToBoolean(r["fFree"]); classInstance.FPeak = ACMS.Convert.ToBoolean(r["fPeak"]); classInstance.FAllowStudentOnPeak = ACMS.Convert.ToBoolean(r["fAllowStudentOnPeak"]); classInstance.FReservation = ACMS.Convert.ToBoolean(r["fReservation"]); classInstance.NMaxNo = ACMS.Convert.ToSqlInt32(r["nMaxNo"]); classInstance.FAllowUOBBooking = ACMS.Convert.ToBoolean(r["fAllowUOBBooking"]); classInstance.NCommissionTypeID = ACMS.Convert.ToSqlInt32(r["nCommissionTypeID"]); classInstance.StrBranchCode = User.BranchCode; classInstance.FCancelled = System.Data.SqlTypes.SqlBoolean.False; #region ====== Added by Albert ====== /*To insert class schedule id while creating class instance.*/ classInstance.nClassScheduleID = ACMS.Convert.ToSqlInt32(r["nClassScheduleID"]); #endregion classInstance.Insert(); } } } } }
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); } } }