Example #1
0
        private static bool IsDateLastInitializationOK()
        {
            Event clsEvent = new Event();

            try
            {
                clsEvent.AddEvent("Checking last initialization date");

                Data.Database clsDatabase           = new Data.Database();
                DateTime      dtDateLastInitialized = clsDatabase.DateLastInitialized(Constants.TerminalBranchID, CompanyDetails.TerminalNo);
                clsDatabase.CommitAndDispose();

                bool boReturn = false;

                if (DateTime.Now > dtDateLastInitialized)
                {
                    boReturn = true;
                    clsEvent.AddEventLn("OK: Last initialization is smaller than system date. DateLastInitialized=" + dtDateLastInitialized.ToString("yyyy-MM-dd hh:mm") + " SystemDate=" + DateTime.Now.ToString("yyyy-MM-dd hh:mm"));
                }
                else
                {
                    clsEvent.AddEventLn("Error: Last initialization is greater than system date. DateLastInitialized=" + dtDateLastInitialized.ToString("yyyy-MM-dd hh:mm") + " SystemDate=" + DateTime.Now.ToString("yyyy-MM-dd hh:mm"));
                }

                return(boReturn);
            }
            catch (Exception ex)
            {
                clsEvent.AddErrorEventLn(ex);
                return(false);
            }
        }
Example #2
0
		private bool IsDateLastInitializationOK(bool ShowMessageBox = true)
		{
			try
			{
				clsEvent.AddEvent("Checking last initialization date");

				Data.Database clsDatabase = new Data.Database(mConnection, mTransaction);
                mConnection = clsDatabase.Connection; mTransaction = clsDatabase.Transaction;

				DateTime dtDateLastInitialized = clsDatabase.DateLastInitialized(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);

				bool boRetValue = false;

				if (DateTime.Now > dtDateLastInitialized)
				{
					clsEvent.AddEventLn("OK: Last initialization is smaller than system date. DateLastInitialized=" + dtDateLastInitialized.ToString("yyyy-MM-dd hh:mm") + " SystemDate=" + DateTime.Now.ToString("yyyy-MM-dd hh:mm"));
				}
				else
				{
					clsEvent.AddEventLn("Error: Last initialization is greater than system date. DateLastInitialized=" + dtDateLastInitialized.ToString("yyyy-MM-dd hh:mm") + " SystemDate=" + DateTime.Now.ToString("yyyy-MM-dd hh:mm"));
					clsDatabase.CommitAndDispose();
					MessageBox.Show("FATAL ERROR Level 2.!!! System date is behind ZREAD last initialization date. Please adjust SYSTEM DATE!!!", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error);
					return boRetValue;
				}

				Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
                mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

				DateTime dteTransactionDate = Convert.ToDateTime(lblTransDate.Text);

				DateTime dteStartCutOffTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.StartCutOffTime);
				DateTime dteEndCutOffTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.EndCutOffTime);

				// if StartCutOffTime is greater than EndCutOffTime
				// this means that EndCutOffTime is in the morning.
				// Add 1 more day.
				if (dteStartCutOffTime >= dteEndCutOffTime)
					dteEndCutOffTime = dteEndCutOffTime.AddDays(1);

				DateTime dteAllowedStartDateTime; DateTime dteAllowedEndDateTime;
				if (dteTransactionDate < dteEndCutOffTime)
				{
					dteAllowedStartDateTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.EndCutOffTime).AddDays(-1).AddMilliseconds(1);
					dteAllowedEndDateTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.StartCutOffTime);
				}
				else
				{
					dteAllowedStartDateTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.EndCutOffTime).AddMilliseconds(1);
					dteAllowedEndDateTime = Convert.ToDateTime(Convert.ToDateTime(lblTransDate.Text).ToString("yyyy-MM-dd") + " " + mclsTerminalDetails.StartCutOffTime).AddDays(1);
				}
				if (dteTransactionDate < dteAllowedEndDateTime)
				{
					dteStartCutOffTime = dteStartCutOffTime.AddDays(1);
					dteEndCutOffTime = dteEndCutOffTime.AddDays(1);
				}

				DateTime dtePreviousStartCutOffTime = dteStartCutOffTime.AddDays(-1);
				DateTime dtePreviousEndCutOffTime = dteEndCutOffTime.AddDays(-1);
				DateTime dtePreviousAllowedStartDateTime = dteAllowedStartDateTime.AddDays(-1);
				DateTime dtePreviousAllowedEndDateTime = dteAllowedEndDateTime.AddDays(-1);

                DateTime dteMAXDateLastInitialized = clsTerminalReport.MAXDateLastInitialized(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo, Constants.C_DATE_MIN_VALUE);

				clsEvent.AddEventLn("Checking if MAXDateLastInitialized: " + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm") + " is already initialized.", true);
				if (dteMAXDateLastInitialized >= dteAllowedStartDateTime && dteMAXDateLastInitialized <= dteAllowedEndDateTime)
				{
					clsDatabase.CommitAndDispose();
					clsEvent.AddEventLn("Transaction is not allowed, ZRead is already initialized for this date.", true);
					MessageBox.Show("Sorry initialization is not permitted this time, ZRead is already initialized for this date.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
					txtBarCode.Text = "";
					return boRetValue;
				}
				clsEvent.AddEventLn("OK. MAXDateLastInitialized: " + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm") + " is for previous zreading.", true);

				if (dteMAXDateLastInitialized < dteAllowedStartDateTime)
				{
					if (dteMAXDateLastInitialized >= dtePreviousAllowedStartDateTime && dteMAXDateLastInitialized <= dtePreviousEndCutOffTime)
					{
						clsEvent.AddEventLn("OK: AllowedStartDateTime [" + dteAllowedStartDateTime.ToString("yyyy-MM-dd HH:mm:ss") + "] is now less than MAXDateLastInitialized [" + dteMAXDateLastInitialized.ToString("yyyy-MM-dd HH:mm:ss") + "].", true);
					}
					else if(mclsTerminalDetails.CheckCutOffTime == true)
					{
						clsEvent.AddEventLn("Transaction is not allowed, transaction date is 2-Days delayed. Please restart FE.", true);
						MessageBox.Show("Transaction is not allowed, transaction date is 2Days delayed. Please restart FE." +
							Environment.NewLine + "Sorry selling is not permitted this time, Please consult for the Selling time.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);
						txtBarCode.Text = "";
						return false;
					}
				}
				if (dteMAXDateLastInitialized > dteTransactionDate)
				{
					clsDatabase.CommitAndDispose();
					clsEvent.AddEventLn("Transaction is not allowed, transaction date is delayed. Please restart FE.", true);

                    // 22Jun2015 : ShowMessageBox = false if its from ZRead
                    if (ShowMessageBox) MessageBox.Show("Transaction is not allowed, transaction date is delayed. Please restart FE.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information);

					txtBarCode.Text = "";
					return boRetValue;
				}
				clsEvent.AddEventLn("OK to initialize...", true);
                clsDatabase.CommitAndDispose();

				boRetValue = true;

				return boRetValue;
			}
			catch (Exception ex)
			{
				InsertErrorLogToFile(ex);
				return false;
			}
		}
Example #3
0
        private static bool IsDateLastInitializationOK()
        {
            Event clsEvent = new Event();
            try
            {
                clsEvent.AddEvent("Checking last initialization date");

                Data.Database clsDatabase = new Data.Database();
                DateTime dtDateLastInitialized = clsDatabase.DateLastInitialized(Constants.TerminalBranchID, CompanyDetails.TerminalNo);
                clsDatabase.CommitAndDispose();

                bool boReturn = false;

                if (DateTime.Now > dtDateLastInitialized)
                {
                    boReturn = true;
                    clsEvent.AddEventLn("OK: Last initialization is smaller than system date. DateLastInitialized=" + dtDateLastInitialized.ToString("yyyy-MM-dd hh:mm") + " SystemDate=" + DateTime.Now.ToString("yyyy-MM-dd hh:mm"));
                }
                else
                {
                    clsEvent.AddEventLn("Error: Last initialization is greater than system date. DateLastInitialized=" + dtDateLastInitialized.ToString("yyyy-MM-dd hh:mm") + " SystemDate=" + DateTime.Now.ToString("yyyy-MM-dd hh:mm"));
                }

                return boReturn;
            }
            catch (Exception ex)
            {

                clsEvent.AddErrorEventLn(ex);
                return false;
            }
        }