Exemplo n.º 1
0
 private static void OnIsPrintedCompletedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     try
     {
         CPrintPromotionalTickets source = d as CPrintPromotionalTickets;
         if ((bool)e.OldValue != (bool)e.NewValue &&
             (bool)e.NewValue)
         {
             MainScreen.ActiveInstance.PromotionActiveElement = null;
         }
     }
     catch (Exception ex)
     {
         ExceptionManager.Publish(ex);
     }
 }
 public PromoPrint(CPrintPromotionalTickets obj)
     : this()
 {
     this.objPrintTickets = obj;
 }
 public PromoPrint(CPrintPromotionalTickets obj)
     : this()
 {
     this.objPrintTickets = obj;
 }
        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);

            }
        }
        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);
            }
        }