Beispiel #1
0
        public void UpdatePromotional(Promotional model)
        {
            var key = string.Format(PROMOTIONAL_CACHE_BY_ID, model.Id);

            _cacheManager.GetCache(key).Remove(model.Id.ToString());
            _promotionalRepository.Update(model);
        }
Beispiel #2
0
 public void InsertPromotional(Promotional model)
 {
     if (model != null)
     {
         _promotionalRepository.Insert(model);
     }
 }
Beispiel #3
0
        public void LoadPromotionDetails(int PromotionalID)
        {
            Promotional objPromotional = new Promotional();

            _NoOfPrintedTickets = 0;
            pbPrint.Value       = _NoOfPrintedTickets;
            _NoOfTickets        = objPromotional.BPromotionalTicketCount(PromotionalID);
            IsPrintedCompleted  = false;
            _printThread        = new Thread(new ThreadStart(this.PrintTickets));
            _printThread.Name   = "PROMO_PRINT";
            _printThread.Start();
        }
Beispiel #4
0
        public void PrintTickets()
        {
            try
            {
                App application = App.Current as App;
                Thread.CurrentThread.CurrentUICulture = application.CurrentUICulture;
                Thread.CurrentThread.CurrentCulture   = application.CurrentCulture;

                this.Dispatcher.Invoke(new Action(() =>
                {
                    pbPrint.Value                 = _NoOfPrintedTickets;
                    this.lblErrorMsg.Content      = string.Empty;
                    this.lblPrintedTicket.Content = _NoOfPrintedTickets;
                    this.lblTotalTicket.Content   = _NoOfTickets;
                    pbPrint.Minimum               = _NoOfPrintedTickets;
                    pbPrint.Maximum               = _NoOfTickets;
                }), System.Windows.Threading.DispatcherPriority.Normal);


                long lValue = 0;
                if (strValue != null && strValue != string.Empty)
                {
                    lValue = Convert.ToInt64(strValue.GetSingleFromString() * 100);
                }
                else
                {
                    lValue = 0;
                }

                this.Dispatcher.Invoke(new Action(() =>
                {
                    pbPrint.Value = _NoOfPrintedTickets;
                }), System.Windows.Threading.DispatcherPriority.Normal);

                Promotional objPromotional = new Promotional();

                try
                {
                    while ((_NoOfPrintedTickets < _NoOfTickets) && !_mreShutdown.WaitOne(1))
                    {
                        if (_mreResume.WaitOne())
                        {
                            if (_mreShutdown.WaitOne(10))
                            {
                                LogManager.WriteLog("Print screen was closed. So exiting now.", LogManager.enumLogLevel.Info);
                                return;
                            }
                        }

                        this.Dispatcher.Invoke(new Action(() =>
                        {
                            lblPrintedTicket.Content = _NoOfPrintedTickets.ToString();
                            lblTotalTicket.Content   = _NoOfTickets.ToString();
                        }), System.Windows.Threading.DispatcherPriority.Normal);


                        if (true)
                        {
                            string strBarcode;
                            this.Dispatcher.Invoke(new Action(() =>
                            {
                                pbPrint.Value = _NoOfPrintedTickets;
                            }), System.Windows.Threading.DispatcherPriority.Normal);

                            IssueTicketEntity issueTicketEntity = new IssueTicketEntity();
                            issueTicketEntity.Type = UIIssueTicketConstants.STANDARDTICKET;
                            if (PromoTicketType == 1)
                            {
                                issueTicketEntity.TicketHeader = "PLAYABLE VOUCHER";
                            }
                            else if (PromoTicketType == 0)
                            {
                                issueTicketEntity.TicketHeader = "CASHABLE PROMO VOUCHER";
                            }
                            else
                            {
                                issueTicketEntity.TicketHeader = "CASH DESK VOUCHER";
                            }

                            LogManager.WriteLog("Ticket Header : " + issueTicketEntity.TicketHeader, LogManager.enumLogLevel.Info);

                            //   issueTicketEntity.VoidDate = DateTime.Now.ToString();// (Convert.ToDateTime(this.ExpiryDate, new CultureInfo(ExtensionMethods.CurrentDateCulture))).ToString();
                            issueTicketEntity.VoidDate  = (Convert.ToDateTime(this.ExpiryDate, new CultureInfo(ExtensionMethods.CurrentDateCulture))).ToString();
                            issueTicketEntity.dblValue  = Convert.ToDouble(this.PromotionTicketAmount, new CultureInfo(ExtensionMethods.CurrentCurrenyCulture));;
                            issueTicketEntity.lnglValue = long.Parse((this.PromotionTicketAmount * 100).ToString());
                            System.TimeSpan ts = (ExpiryDate).Subtract(DateTime.Now);
                            issueTicketEntity.NumberOfDays = ts.Days;
                            // issueTicketEntity.Date = DateTime.Now;

                            string PrintedDateTime = string.Empty;
                            //PrintedDateTime = (Convert.ToDateTime(System.DateTime.Now, new CultureInfo(ExtensionMethods.CurrentDateCulture))).ToString();

                            issueTicketEntity.Date = DateTime.Now;//Convert.ToDateTime(PrintedDateTime);
                            PrintTicketErrorCodes PrintResult = objCashDeskOperator.IssueTicket(issueTicketEntity);
                            strBarcode = issueTicketEntity.BarCode;
                            this.Dispatcher.Invoke(new Action(() =>
                            {
                                this.lblErrorMsg.Visibility      = Visibility.Visible;
                                this.pbPrint.Visibility          = Visibility.Visible;
                                this.lblPrintedTicket.Visibility = Visibility.Visible;
                                this.lblTotalTicket.Visibility   = Visibility.Visible;
                                this.btnCancel.Visibility        = Visibility.Visible;
                                this.btnPause.Visibility         = Visibility.Visible;


                                switch (PrintResult)
                                {
                                case PrintTicketErrorCodes.OpenCOMPortFailure:
                                    {
                                        _FailureTickets++;
                                        //    MessageBox.ShowBox("MessageID295", BMC_Icon.Warning); //Unable to open COM Port. Please check connectivity.
                                        lblErrorMsg.Content = "Unable to open COM Port. Please check connectivity";
                                        return;
                                    }

                                case PrintTicketErrorCodes.OutofPaper:
                                    {
                                        _FailureTickets++;
                                        //  MessageBox.ShowBox("MessageID294", BMC_Icon.Warning); //out of Paper
                                        lblErrorMsg.Content = "Out of Paper";
                                        return;
                                    }

                                case PrintTicketErrorCodes.Success:
                                    {
                                        lblErrorMsg.Content = string.Empty;
                                        _SucceededTickets++;
                                        pbPrint.Value = _NoOfPrintedTickets;


                                        if (!String.IsNullOrEmpty(DisplayTicketPrintedSuccessMsg))
                                        {
                                            if (DisplayTicketPrintedSuccessMsg.ToUpper().Trim() == "TRUE")
                                            {
                                                lblErrorMsg.Content = " Voucher printed successfully";
                                            }
                                        }
                                        _NoOfPrintedTickets += 1;


                                        pbPrint.Value                = _NoOfPrintedTickets;
                                        lblPrintedTicket.Content     = _NoOfPrintedTickets.ToString();
                                        int UpdateVoucherPromotionID = objPromotional.BUpdateVoucherPromotion(this.PromotionID, strBarcode);    //Update PromotionalID in Voucher Table

                                        break;
                                    }

                                case PrintTicketErrorCodes.eVoltErr:
                                    {
                                        _FailureTickets++;
                                        // MessageBox.ShowBox("MsgPromErr1", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Voltage Error";

                                        return;
                                    }

                                case PrintTicketErrorCodes.eHeadErr:
                                    {
                                        _FailureTickets++;
                                        //  MessageBox.ShowBox("MsgPromErr2", BMC_Icon.Error);
                                        lblErrorMsg.Content = " Printer Head Error";
                                        return;
                                    }

                                case PrintTicketErrorCodes.ePaperOut:
                                    {
                                        _FailureTickets++;
                                        // MessageBox.ShowBox("MsgPromErr3", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Out of Paper";
                                        return;
                                    }

                                case PrintTicketErrorCodes.ePlatenUP:
                                    {
                                        _FailureTickets++;
                                        //  MessageBox.ShowBox("MsgPromErr4", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Platen Up";
                                        return;
                                    }

                                case PrintTicketErrorCodes.eSysErr:
                                    {
                                        _FailureTickets++;
                                        // MessageBox.ShowBox("MsgPromErr5", BMC_Icon.Error);
                                        lblErrorMsg.Content = "System Error";
                                        return;
                                    }

                                case PrintTicketErrorCodes.eBusy:
                                    {
                                        _FailureTickets++;
                                        //   MessageBox.ShowBox("MsgPromErr6", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Printer is Busy";
                                        return;
                                    }

                                case PrintTicketErrorCodes.eJobMemOF:
                                    {
                                        _FailureTickets++;
                                        //  MessageBox.ShowBox("MsgPromErr7", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Job Memory off";
                                        return;
                                    }

                                case PrintTicketErrorCodes.eBufOF:
                                    {
                                        _FailureTickets++;
                                        // MessageBox.ShowBox("MsgPromErr8", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Buffer off";
                                        return;
                                    }

                                case PrintTicketErrorCodes.eLibLoadErr:
                                    {
                                        _FailureTickets++;
                                        //  MessageBox.ShowBox("MsgPromErr9", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Library Load Error";
                                        return;
                                    }

                                case PrintTicketErrorCodes.ePRDataErr:
                                    {
                                        _FailureTickets++;
                                        //   MessageBox.ShowBox("MsgPromErr10", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Printer Data Error";
                                        return;
                                    }

                                case PrintTicketErrorCodes.eLibRefErr:
                                    {
                                        _FailureTickets++;
                                        //  MessageBox.ShowBox("MsgPromErr11", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Library Reference Error";
                                        return;
                                    }

                                case PrintTicketErrorCodes.eTempErr:
                                    {
                                        _FailureTickets++;
                                        //   MessageBox.ShowBox("MsgPromErr12", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Temp Error";
                                        return;
                                    }

                                case PrintTicketErrorCodes.eMissingSupplyIndex:
                                    {
                                        _FailureTickets++;
                                        //   MessageBox.ShowBox("MsgPromErr13", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Supply Index is Missing";
                                        return;
                                    }

                                case PrintTicketErrorCodes.eFlashProgErr:
                                    {
                                        _FailureTickets++;
                                        //   MessageBox.ShowBox("MsgPromErr14", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Flash Program Error";
                                        return;
                                    }

                                case PrintTicketErrorCodes.ePaperInChute:
                                    {
                                        _FailureTickets++;
                                        //   MessageBox.ShowBox("MsgPromErr15", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Paper in Chute";
                                        return;
                                    }

                                case PrintTicketErrorCodes.ePrintLibCorr:
                                    {
                                        _FailureTickets++;
                                        //   MessageBox.ShowBox("MsgPromErr16", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Print library is corrupted.";
                                        return;
                                    }

                                case PrintTicketErrorCodes.eCmdErr:
                                    {
                                        _FailureTickets++;
                                        // MessageBox.ShowBox("MsgPromErr17", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Command Error";
                                        return;
                                    }

                                case PrintTicketErrorCodes.ePaperLow:
                                    {
                                        _FailureTickets++;
                                        //  MessageBox.ShowBox("MsgPromErr18", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Paper low.";
                                        return;
                                    }

                                case PrintTicketErrorCodes.ePaperJam:
                                    {
                                        _FailureTickets++;
                                        //   MessageBox.ShowBox("MsgPromErr19", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Paper jammed.";
                                        return;
                                    }

                                case PrintTicketErrorCodes.eCurrentErr:
                                    {
                                        _FailureTickets++;
                                        // MessageBox.ShowBox("MsgPromErr20", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Current Error";
                                        return;
                                    }

                                case PrintTicketErrorCodes.eJournalPrint:
                                    {
                                        _FailureTickets++;
                                        //  MessageBox.ShowBox("MsgPromErr21", BMC_Icon.Error);
                                        lblErrorMsg.Content = "Journal Print Error";
                                        return;
                                    }

                                default:
                                    {
                                        _FailureTickets++;
                                        //   MessageBox.ShowBox("MessageID102", BMC_Icon.Warning);
                                        lblErrorMsg.Content = "Unable to Print Voucher";
                                        return;
                                    }
                                }
                            }), System.Windows.Threading.DispatcherPriority.Normal);


                            this.Dispatcher.Invoke(new Action(() =>
                            {
                                this.lblPrintedTicket.Content = _NoOfPrintedTickets.ToString();
                                this.lblTotalTicket.Content   = _NoOfTickets.ToString();
                                UpdateProgressBarDelegate updatePbDelegate = new UpdateProgressBarDelegate(pbPrint.SetValue);
                            }), System.Windows.Threading.DispatcherPriority.Normal);


                            this.Dispatcher.Invoke(new Action(() =>
                            {
                                btnCancel.IsEnabled = true;
                            }), System.Windows.Threading.DispatcherPriority.Normal);
                            System.Threading.Thread.Sleep(1000);
                        }
                        PromoTickAmt = Convert.ToDouble(_PromotionTicketAmount);
                        PromCount    = Convert.ToInt32(_NoOfTickets);

                        double TotalAmoount = PromCount * PromoTickAmt;
                        if (_NoOfPrintedTickets == _NoOfTickets)
                        {
                            int UpdateVoucherPrintSuccess = objPromotional.MarkPromotionalTicketsAsValid(this.PromotionID, 1);
                            this.Dispatcher.Invoke(new Action(() =>
                            {
                                this.lblErrorMsg.Content = string.Empty;
                                pbPrint.Value            = _NoOfPrintedTickets;
                                MessageBox.ShowBox("MessageID435", BMC_Icon.Information);
                            }), System.Windows.Threading.DispatcherPriority.Normal);

                            AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                            {
                                AuditModuleName    = ModuleName.Promotion,
                                Audit_Screen_Name  = "Promo Print",
                                Audit_Desc         = "Promo Name: " + PromoName + "; TicketAmount: " + _PromotionTicketAmount.ToString() + "; Number of Tickets: " + PromCount.ToString() + "; Total Promotion Amount: " + TotalAmoount.ToString() + "; Expiry Date: " + ExpiryDate,
                                AuditOperationType = OperationType.ADD,
                                Audit_New_Vl       = PromoName
                            });


                            this.Dispatcher.Invoke(new Action(() =>
                            {
                                IsPrintedCompleted = true;
                            }), System.Windows.Threading.DispatcherPriority.Normal);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ExceptionManager.Publish(ex);
                    LogManager.WriteLog("Promotional Print Tickets : " + ex.Message, LogManager.enumLogLevel.Error);
                }
                finally
                {
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
        protected void btnOrder_Click(object sender, EventArgs e)
        {
            cartItems    = (List <CartItem>)Session["items"];
            currentPromo = new Promotional();

            Promotional shirt1 = new Promotional();
            Promotional shirt2 = new Promotional();
            Promotional shirt3 = new Promotional();
            Promotional shirt4 = new Promotional();

            int productID = ProductsDA.GetLatestProductID();

            if (ddlQtyShirt1.SelectedValue != "0" && ddlSizeShirt1.SelectedValue != " ")
            {
                shirt1.ProductID       = productID;
                shirt1.ProductQty      = Convert.ToInt32(ddlQtyShirt1.SelectedValue);
                shirt1.ProductPrice    = 15.99 * shirt1.ProductQty;
                shirt1.PromotionalSize = ddlSizeShirt1.SelectedValue;
                shirt1.ProductType     = "Promotional";
                shirt1.ProductDetail   = "Let the Shenanigans begin female shirt";

                currentPromo = shirt1;
            }
            else
            {
                shirt1 = null;
            }
            if (ddlQtyShirt2.SelectedValue != "0" && ddlSizeShirt2.SelectedValue != " ")
            {
                shirt2.ProductID       = productID;
                shirt2.ProductQty      = Convert.ToInt32(ddlQtyShirt2.SelectedValue);
                shirt2.ProductPrice    = 15.99 * shirt2.ProductQty;
                shirt2.PromotionalSize = ddlSizeShirt2.SelectedValue;
                shirt2.ProductType     = "Promotional";
                shirt2.ProductDetail   = "Kiss me I'm a piza baker shirt";
                currentPromo           = shirt2;
            }
            else
            {
                shirt2 = null;
            }
            if (ddlQtyShirt3.SelectedValue != "0" && ddlSizeShirt3.SelectedValue != " ")
            {
                shirt3.ProductID       = productID;
                shirt3.ProductQty      = Convert.ToInt32(ddlQtyShirt3.SelectedValue);
                shirt3.ProductPrice    = 15.99 * shirt3.ProductQty;
                shirt3.PromotionalSize = ddlSizeShirt3.SelectedValue;
                shirt3.ProductType     = "Promotional";
                shirt3.ProductDetail   = "I shamrock Shenanigans shirt";
                currentPromo           = shirt3;
            }
            else
            {
                shirt3 = null;
            }
            if (ddlQtyShirt4.SelectedValue != "0" && ddlSizeShirt4.SelectedValue != " ")
            {
                shirt4.ProductID       = productID;
                shirt4.ProductQty      = Convert.ToInt32(ddlQtyShirt4.SelectedValue);
                shirt4.ProductPrice    = 15.99 * shirt4.ProductQty;
                shirt4.PromotionalSize = ddlSizeShirt4.SelectedValue;
                shirt4.ProductType     = "Promotional";
                shirt4.ProductDetail   = "I shamrock Shenanigans shirt";
                currentPromo           = shirt4;
            }
            else
            {
                shirt4 = null;
            }

            cartItems = Cart.AddItemToCart(currentPromo, cartItems);

            Session["items"] = cartItems;

            Response.Redirect("CartView.aspx");



            //double orderTotal = 0;

            //if(shirt1 != null)
            //{
            //    shirt1.ProductPrice += orderTotal;
            //}
            //if (shirt2 != null)
            //{
            //    shirt2.ProductPrice += orderTotal;
            //}
            //if (shirt3 != null)
            //{
            //    shirt3.ProductPrice += orderTotal;
            //}
            //if (shirt4 != null)
            //{
            //    shirt4.ProductPrice += orderTotal;
            //}
        }
Beispiel #6
0
        public void GetVoucherInformation()
        {
            try
            {
                Promotional objRedeemBusiness = new Promotional();

                var lstVoucherInfo = objRedeemBusiness.GetVoucherInfo(BarCode).ToList();

                if (lstVoucherInfo.Count > 0)
                {
                    foreach (var item in lstVoucherInfo)
                    {
                        txtSiteCode.Text      = item.SiteCode.ToString();
                        txtBarCode.Text       = item.BarCode;
                        txtVoucherType.Text   = item.TicketType;
                        txtPrintedDevice.Text = item.PrintDeviceName;
                        txtRedeemDevice.Text  = item.PayDeviceName;
                        txtVoidDevice.Text    = item.VoidDeviceName;
                        txtErrorDevice.Text   = item.ErrorDeviceName;
                        if (item.RedeemSiteCode.ToString() != "0")
                        {
                            txtRedeemSiteCode.Text = item.RedeemSiteCode.ToString();
                        }
                        else
                        {
                            txtRedeemSiteCode.Text = "-";
                        }
                        if (item.PrintedDate.Trim() == "-")
                        {
                            txtPrintedDate.Text = item.PrintedDate;
                        }
                        else
                        {
                            txtPrintedDate.Text = Convert.ToDateTime(item.PrintedDate).ToString(CultureInfo.CreateSpecificCulture(DateCulture));
                        }

                        if (item.RedeemedDate.Trim() == "-")
                        {
                            txtRedeemDate.Text = item.RedeemedDate;
                        }
                        else
                        {
                            txtRedeemDate.Text = Convert.ToDateTime(item.RedeemedDate).ToString(CultureInfo.CreateSpecificCulture(DateCulture));
                        }

                        if (item.VoidedDate.Trim() == "-")
                        {
                            txtVoidDate.Text = item.VoidedDate;
                        }
                        else
                        {
                            txtVoidDate.Text = Convert.ToDateTime(item.VoidedDate).ToString(CultureInfo.CreateSpecificCulture(DateCulture));
                        }


                        if (item.ExpiryDate.Trim() == "-")
                        {
                            txtExpiryDate.Text = item.ExpiryDate;
                        }
                        else
                        {
                            txtExpiryDate.Text = Convert.ToDateTime(item.ExpiryDate).ToString(CultureInfo.CreateSpecificCulture(DateCulture));
                        }


                        if (item.EffectiveDate.Trim() == "-")
                        {
                            txtEffectiveDate.Text = item.EffectiveDate;
                        }
                        else
                        {
                            txtEffectiveDate.Text = Convert.ToDateTime(item.EffectiveDate).ToString(CultureInfo.CreateSpecificCulture(DateCulture));
                        }


                        txtAmount.Text           = item.TicketAmount.ToString();
                        txtStatus.Text           = item.VoucherStatus;
                        txtErrorDescription.Text = item.ErrorDescription;
                        txtIssuedUserName.Text   = item.VoucherIssuedUser;
                        txtRedeemUser.Text       = item.VoucherRedeemedUser;
                        txtVoidUser.Text         = item.VoucherVoidUser;
                    }


                    this.IsVoucherFound = true;
                }
                else
                {
                    this.IsVoucherFound = false;
                }
            }
            catch (Exception ex)
            {
                this.IsVoucherFound = false;
                ExceptionManager.Publish(ex);
            }
        }
        private void btnPromotionalPrint_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //Promo Name validation
                string strPromoName = txtPromoName.Text.ToString();
                if (strPromoName == string.Empty || strPromoName.Length > 75)
                {
                    MessageBox.ShowBox("MessageID409", BMC_Icon.Warning); //Please Enter the Promotional Name
                    txtPromoName.Text = "";
                    txtPromoName.Focus();
                    return;
                }

                //Check whether the promo name already exists
                Promotional objPromotioal            = new Promotional();
                bool        blPromoNameAlreadyExists = (objPromotioal.BPromotionNameExist(strPromoName) > 0);
                if (blPromoNameAlreadyExists)
                {
                    MessageBox.ShowBox("MessageID407", BMC_Icon.Warning); // Promotion Name already Exist
                    txtPromoName.Text = "";
                    txtPromoName.Focus();
                    return;
                }


                //Ticket Count validation
                int intPromoTicketCount = 0;
                int.TryParse(txtNumPromoTicks.Text.ToString(), out intPromoTicketCount);
                int MaxPromoCount = Convert.ToInt32(Settings.MaximumPromotionalTicketsCount);
                if (MaxPromoCount != 0)
                {
                    if (intPromoTicketCount <= 0 || intPromoTicketCount > int.MaxValue)
                    {
                        MessageBox.ShowBox("MessageID410", BMC_Icon.Warning);//Please Enter the Number of Promotional Tickets
                        txtNumPromoTicks.Text = "";
                        txtNumPromoTicks.Focus();
                        return;
                    }
                    else if (intPromoTicketCount > MaxPromoCount)
                    {
                        MessageBox.ShowBox("MessageID554", BMC_Icon.Warning);
                        txtNumPromoTicks.Text = "";
                        txtNumPromoTicks.Focus();
                        return;
                    }
                }

                else if (MaxPromoCount == 0)
                {
                    if (intPromoTicketCount <= 0 || intPromoTicketCount > int.MaxValue)
                    {
                        MessageBox.ShowBox("MessageID410", BMC_Icon.Warning);//Please Enter the Number of Promotional Tickets
                        txtNumPromoTicks.Text = "";
                        txtNumPromoTicks.Focus();
                        return;
                    }
                }
                //Ticket Amount validation
                double dblPromoTicketAmount = 0.0;
                double MaxPromoTicketAmt    = Convert.ToDouble(Settings.MaximumPromotionalTicketAmount);
                Double.TryParse(txtPromoTickAmt.Text.ToString(), out dblPromoTicketAmount);
                if (MaxPromoTicketAmt != 0)
                {
                    if (dblPromoTicketAmount <= 0 || dblPromoTicketAmount > double.MaxValue)
                    {
                        MessageBox.ShowBox("MessageID411", BMC_Icon.Warning); //Please Enter the Promotional Ticket Amount

                        txtPromoTickAmt.Text = "";
                        txtPromoTickAmt.Focus();
                        return;
                    }
                    else if (dblPromoTicketAmount > MaxPromoTicketAmt)
                    {
                        MessageBox.ShowBox("MessageID555", BMC_Icon.Warning); //Please Enter the Promotional Ticket Amount
                        txtPromoTickAmt.Text = "";
                        txtPromoTickAmt.Focus();
                        return;
                    }
                }
                else if (MaxPromoTicketAmt == 0)
                {
                    if (dblPromoTicketAmount <= 0 || dblPromoTicketAmount > double.MaxValue)
                    {
                        MessageBox.ShowBox("MessageID411", BMC_Icon.Warning); //Please Enter the Promotional Ticket Amount
                        txtPromoTickAmt.Text = "";
                        txtPromoTickAmt.Focus();
                        return;
                    }
                }

                string txtTicketAmount = string.Empty;
                if (txtPromoTickAmt.Text != null)
                {
                    txtTicketAmount = txtPromoTickAmt.Text;
                }
                string intPart = string.Empty;
                string decPart = string.Empty;
                if (txtTicketAmount.Contains("."))
                {
                    string[] txtdecimal = txtTicketAmount.Split('.');
                    intPart = txtdecimal[0];
                    decPart = txtdecimal[1];
                    if (decPart.Length > 2)
                    {
                        MessageBox.ShowBox("MessageID557", BMC_Icon.Warning); //Please Enter the Promotional Ticket Amount
                        txtPromoTickAmt.Text = string.Empty;
                        txtPromoTickAmt.Focus();
                        return;
                    }
                }



                //  Expiry Date validation
                DateTime dtPromoExpDate = DateTime.Now;

                DateTime.TryParse(dtpPromoTickExp.SelectedDate.ToString(), out dtPromoExpDate);

                if (ExpiryDays > 0)
                {
                    if (dtpPromoTickExp.SelectedDate.ToString() == null)
                    {
                        MessageBox.ShowBox("MessageID412", BMC_Icon.Warning);
                        dtpPromoTickExp.Focus();
                        return;
                    }
                    else if (dtPromoExpDate > dtDefaultExpiryDate)
                    {
                        MessageBox.ShowBox("MessageID556", BMC_Icon.Warning);
                        dtpPromoTickExp.Focus();
                        return;
                    }
                    else if (dtpPromoTickExp.SelectedDate == DateTime.Now.Date && tmpPromoExpTime.SelectedTime < DateTime.Now.TimeOfDay)
                    {
                        MessageBox.ShowBox("MessageID879", BMC_Icon.Warning);
                        dtpPromoTickExp.Focus();
                        return;
                    }
                }
                else if (ExpiryDays == 0)
                {
                    if (dtpPromoTickExp.SelectedDate.ToString() == null)
                    {
                        MessageBox.ShowBox("MessageID412", BMC_Icon.Warning);//Please Enter the Valid Expiry Date
                        dtpPromoTickExp.Focus();
                        return;
                    }
                    else if (dtpPromoTickExp.SelectedDate == DateTime.Now.Date && tmpPromoExpTime.SelectedTime < DateTime.Now.TimeOfDay)
                    {
                        MessageBox.ShowBox("MessageID879", BMC_Icon.Warning);//Please Enter the Valid Expiry Date
                        dtpPromoTickExp.Focus();
                        return;
                    }
                }



                double dblTotalTicketAmount = 0.0;
                dblTotalTicketAmount = intPromoTicketCount * dblPromoTicketAmount;

                // setting
                int intPromoTicketType = 1;
                if (chkCash.IsChecked == true)
                {
                    intPromoTicketType = 0;
                }

                try
                {
                    //Insert data in Promotional Table
                    DateTime d = dtpPromoTickExp.SelectedDate.Value;

                    DateTime dtCombined = new DateTime(d.Year, d.Month, d.Day, tmpPromoExpTime.SelectedTime.Hours, tmpPromoExpTime.SelectedTime.Minutes, tmpPromoExpTime.SelectedTime.Seconds);
                    int      resultInsertPromotional = objPromotioal.BInsertPromotionalTicket(intPromoTicketType, strPromoName, intPromoTicketCount, dblPromoTicketAmount, dtCombined);
                    if (resultInsertPromotional == -1)
                    {
                        MessageBox.ShowBox("MessageID553", BMC_Icon.Information);
                        txtNumPromoTicks.Text = string.Empty;
                        txtPromoTickAmt.Text  = string.Empty;
                        txtNumPromoTicks.Focus();
                        return;
                    }
                    MessageBox.ShowBox("MessageID408", BMC_Icon.Information);

                    //Print Dialog Box

                    int PromotionTicketID = objPromotioal.BGetPromotionTicketID(strPromoName);
                    if (PromotionTicketID == 0)
                    {
                        MessageBox.ShowBox("MessageID552", BMC_Icon.Information);
                        return;
                    }

                    CPrintPromotionalTickets tickets = new CPrintPromotionalTickets();
                    MainScreen.ActiveInstance.PromotionActiveElement = tickets;
                    tickets.PrintValues(PromotionTicketID, dblPromoTicketAmount, dtCombined, intPromoTicketType, intPromoTicketCount);
                    //objPrintTickets.PrintValues(PromotionTicketID, dblPromoTicketAmount, dtCombined, intPromoTicketType, intPromoTicketCount);

                    //objPrintTickets.PromoName = strPromoName;
                    //if (intPromoTicketCount > 0)
                    //{
                    //    objPrintTickets.PromoTicketCount = intPromoTicketCount.ToString();
                    //}
                }
                catch (Exception ex)
                {
                    ExceptionManager.Publish(ex);
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }