Beispiel #1
0
    public double? CalculatePrice(Tblfoodbeverage fb)
    {
        try
        {
            if (!IsHappyHourDisableToday())
            {
                double price = 0;

                TimeSpan HappyHourDurationFrom = RegistryReader.HappyHourDurationFrom_First.TimeOfDay;
                TimeSpan HappyHourDurationTo = RegistryReader.HappyHourDurationTo_First.TimeOfDay;

                TimeSpan SecondHappyHourDurationFrom = RegistryReader.HappyHourDurationFrom_Second.TimeOfDay;
                TimeSpan SecondHappyHourDurationTo = RegistryReader.HappyHourDurationTo_Second.TimeOfDay;

                TimeSpan ThirdHappyHourDurationFrom = RegistryReader.HappyHourDurationFrom_Third.TimeOfDay;
                TimeSpan ThirdHappyHourDurationTo = RegistryReader.HappyHourDurationTo_Third.TimeOfDay;

                TimeSpan now = DateTime.Now.TimeOfDay;

                if ((now >= HappyHourDurationFrom && now <= HappyHourDurationTo) && HappyHourDurationFrom < HappyHourDurationTo)
                {
                    price = fb.Foodbeveragehappyhourprice.Value;
                    if (price > 0)
                    {
                        return price;
                    }
                    else if (fb.Foodbeveragehappyhourpercentage.Value > 0)
                    {
                        return fb.Foodbeverageprice - (fb.Foodbeverageprice * fb.Foodbeveragehappyhourpercentage / 100);
                    }
                }
                if ((now >= SecondHappyHourDurationFrom && now <= SecondHappyHourDurationTo) && SecondHappyHourDurationFrom < SecondHappyHourDurationTo)
                {
                    price = fb.Foodbeveragesecondhappyhourprice.Value;
                    if (price > 0)
                    {
                        return price;
                    }
                    else if (fb.Foodbeveragesecondhappyhourpercentage.Value > 0)
                    {
                        return fb.Foodbeverageprice - (fb.Foodbeverageprice * fb.Foodbeveragesecondhappyhourpercentage / 100);
                    }
                }
                if ((now >= ThirdHappyHourDurationFrom && now <= ThirdHappyHourDurationTo) && ThirdHappyHourDurationFrom < ThirdHappyHourDurationTo)
                {
                    price = fb.Foodbeveragethirdhappyhourprice.Value;
                    if (price > 0)
                    {
                        return price;
                    }
                    else if (fb.Foodbeveragethirdhappyhourpercentage.Value > 0)
                    {
                        return fb.Foodbeverageprice - (fb.Foodbeverageprice * fb.Foodbeveragethirdhappyhourpercentage / 100);
                    }
                }
            }
            return fb.Foodbeverageprice;

            #region George's Codes

            //bool iFoundHappyHourFlag = false;

            //if (IsHappyHourDisableToday(CurrentSalesPK) == false && ReadHappyHourDurationFrom > ReadHappyHourDurationTo)
            //{
            //    DateTime idatetimefrom = DateTime.Parse(string.Format("00:00", ReadHappyHourDurationFrom));
            //    DateTime idatetimeto = DateTime.Parse(string.Format("00:00", ReadHappyHourDurationTo));
            //    idatetimeto = idatetimeto.AddDays(1);

            //    DateTime idatetimenow = DateTime.Parse(string.Format("00:00", DateTime.Now));

            //    if (DateTime.Compare(idatetimefrom.ToString("t"), idatetimenow.ToString("t")) <= 0 | DateTime.Compare(idatetimenow.ToString("t"), idatetimeto.ToString("t")) <= 0)
            //    {
            //        //str(2) is price, change it to happy hour rate
            //        double dbl = 0;
            //        dbl = i.Foodbeveragehappyhourprice.Value;// GetHappyHourPrice(Conversion.str(0));
            //        if (dbl > 0)
            //        {
            //            Conversion.str(2) = dbl;
            //            hh1Price = dbl;
            //            nPrice = 0;
            //            iFoundHappyHourFlag = true;
            //        }

            //        if (dbl == 0)
            //        {
            //            double per = 0;
            //            per = i.Foodbeveragehappyhourpercentage.Value;// GetHappyHourPercentage(Conversion.str(0));
            //            if (per > 0)
            //            {
            //                hhPercentage = per;
            //                iFoundHappyHourFlag = true;
            //            }
            //        }
            //    }
            //}
            //else
            //{
            //    if (IsHappyHourDisableToday(CurrentSalesPK) == false && DateTime.Compare(ReadHappyHourDurationFrom.ToString("t"), System.DateTime.Now.ToString("t")) <= 0 && DateTime.Compare(System.DateTime.Now.ToString("t"), ReadHappyHourDurationTo.ToString("t")) <= 0)
            //    {
            //        //str(2) is price, change it to happy hour rate
            //        double dbl = 0;
            //        dbl = i.Foodbeveragehappyhourprice.Value;// GetHappyHourPrice(Conversion.str(0));

            //        if (dbl > 0)
            //        {
            //            Conversion.str(2) = dbl;
            //            hh1Price = dbl;
            //            nPrice = 0;
            //            iFoundHappyHourFlag = true;
            //        }

            //        if (dbl == 0)
            //        {
            //            double per = 0;
            //            per = i.Foodbeveragehappyhourpercentage.Value;// GetHappyHourPercentage(Conversion.str(0));
            //            if (per > 0)
            //            {
            //                hhPercentage = per;
            //                iFoundHappyHourFlag = true;
            //            }
            //        }
            //    }
            //}

            //if (IsHappyHourDisableToday(CurrentSalesPK) == false && ReadSecondHappyHourDurationFrom > ReadSecondHappyHourDurationTo)
            //{
            //    DateTime idatetimefrom = DateTime.Parse(ReadSecondHappyHourDurationFrom);
            //    DateTime idatetimeto = DateTime.Parse(ReadSecondHappyHourDurationTo);
            //    idatetimeto = idatetimeto.AddDays(1);

            //    DateTime idatetimenow = DateTime.Parse(Strings.Format(DateTime.Now, "HH:mm"));

            //    if (DateTime.Compare(idatetimefrom.ToString("t"), idatetimenow.ToString("t")) <= 0 | DateTime.Compare(idatetimenow.ToString("t"), idatetimeto.ToString("t")) <= 0 && iFoundHappyHourFlag == false)
            //    {
            //        double dbl = 0;
            //        dbl = i.Foodbeveragesecondhappyhourprice.Value; // GetSecondHappyHourPrice(Conversion.str(0));

            //        if (dbl > 0)
            //        {
            //            Conversion.str(2) = dbl;
            //            hh2Price = dbl;
            //            nPrice = 0;
            //            iFoundHappyHourFlag = true;
            //        }

            //        if (dbl == 0)
            //        {
            //            double per = 0;
            //            per = i.Foodbeveragesecondhappyhourpercentage.Value;// GetSecondHappyHourPercentage(Conversion.str(0));
            //            if (per > 0)
            //            {
            //                hhPercentage = per;
            //                iFoundHappyHourFlag = true;
            //            }
            //        }
            //    }
            //}
            //else
            //{
            //    if (IsHappyHourDisableToday(CurrentSalesPK) == false && DateTime.Compare(ReadSecondHappyHourDurationFrom.ToString("t"), System.DateTime.Now.ToString("t")) <= 0 && DateTime.Compare(System.DateTime.Now.ToString("t"), ReadSecondHappyHourDurationTo.ToString("t")) <= 0 && iFoundHappyHourFlag == false)
            //    {
            //        double dbl = 0;
            //        dbl = i.Foodbeveragesecondhappyhourprice.Value; //  GetSecondHappyHourPrice(Conversion.str(0));

            //        if (dbl > 0)
            //        {
            //            Conversion.str(2) = dbl;
            //            hh2Price = dbl;
            //            nPrice = 0;
            //            iFoundHappyHourFlag = true;
            //        }

            //        if (dbl == 0)
            //        {
            //            double per = 0;
            //            per = i.Foodbeveragesecondhappyhourpercentage.Value;//  GetSecondHappyHourPercentage(Conversion.str(0));
            //            if (per > 0)
            //            {
            //                hhPercentage = per;
            //                iFoundHappyHourFlag = true;
            //            }
            //        }
            //    }
            //}

            //if (IsHappyHourDisableToday(CurrentSalesPK) == false && ReadThirdHappyHourDurationFrom > ReadThirdHappyHourDurationTo)
            //{
            //    DateTime idatetimefrom = ReadThirdHappyHourDurationFrom;
            //    DateTime idatetimeto = ReadThirdHappyHourDurationTo;
            //    idatetimeto = idatetimeto.AddDays(1);

            //    DateTime idatetimenow = DateTime.Parse(Strings.Format(DateTime.Now, "HH:mm"));

            //    if (DateTime.Compare(idatetimefrom.ToString("t"), idatetimenow.ToString("t")) <= 0 | DateTime.Compare(idatetimenow.ToString("t"), idatetimeto.ToString("t")) <= 0 && iFoundHappyHourFlag == false)
            //    {
            //        double dbl = 0;
            //        dbl = i.Foodbeveragethirdhappyhourprice.Value;  //GetThirdHappyHourPrice(Conversion.str(0));

            //        if (dbl > 0)
            //        {
            //            Conversion.str(2) = dbl;
            //            hh3Price = dbl;
            //            nPrice = 0;
            //            iFoundHappyHourFlag = true;
            //        }

            //        if (dbl == 0)
            //        {
            //            double per = 0;
            //            per = i.Foodbeveragethirdhappyhourpercentage.Value;// GetThirdHappyHourPercentage(Conversion.str(0));
            //            if (per > 0)
            //            {
            //                hhPercentage = per;
            //                iFoundHappyHourFlag = true;
            //            }
            //        }
            //    }
            //}
            //else
            //{
            //    if (IsHappyHourDisableToday(CurrentSalesPK) == false && DateTime.Compare(ReadThirdHappyHourDurationFrom.ToString("t"), System.DateTime.Now.ToString("t")) <= 0 && DateTime.Compare(System.DateTime.Now.ToString("t"), ReadThirdHappyHourDurationTo.ToString("t")) <= 0 && iFoundHappyHourFlag == false)
            //    {
            //        double dbl = 0;
            //        dbl = i.Foodbeveragethirdhappyhourprice.Value;  //GetThirdHappyHourPrice(Conversion.str(0));

            //        if (dbl > 0)
            //        {
            //            Conversion.str(2) = dbl;
            //            hh3Price = dbl;
            //            nPrice = 0;
            //            iFoundHappyHourFlag = true;
            //        }

            //        if (dbl == 0)
            //        {
            //            double per = 0;
            //            per = i.Foodbeveragethirdhappyhourpercentage.Value;//GetThirdHappyHourPercentage(Conversion.str(0));
            //            if (per > 0)
            //            {
            //                hhPercentage = per;
            //                iFoundHappyHourFlag = true;
            //            }
            //        }
            //    }
            //}
            #endregion
        }
        catch
        {
            return fb.Foodbeverageprice;
            // throw new Exception("Registry can not be read.");
        }
    }
Beispiel #2
0
 partial void DeleteTblfoodbeverage(Tblfoodbeverage instance);
Beispiel #3
0
 partial void InsertTblfoodbeverage(Tblfoodbeverage instance);
Beispiel #4
0
 partial void UpdateTblfoodbeverage(Tblfoodbeverage instance);
Beispiel #5
0
 private void detach_Tblfoodbeverages(Tblfoodbeverage entity)
 {
     this.SendPropertyChanging("Tblfoodbeverages");
     entity.Tblfoodbeveragegroup = null;
 }