/// <summary>
 /// Muestra resumen de la regla que se desea activar asi como las demas reglas pertenecientes
 /// al mismo corporativo si es que existen
 /// </summary>
 private void ShowInformation()
 {
     listInfoFeeRule = GetInfoFeeRuleByAttribute1BL.GetInfoFeeRule(null, Convert.ToInt32(txtRuleNumber.Text), Login.OrgId);
     if (listInfoFeeRule.Count == 0)
     {
         MessageBox.Show("EL NÚMERO DE REGLA DE CARGO POR SERVICIO NO EXISTE", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
         txtRuleNumber.Focus();
     }
     else if (listInfoFeeRule.Count > 1)
     {
         for (int i = 0; i < listInfoFeeRule.Count; i++)
         {
             if (listInfoFeeRule[i].RuleNumber.Equals(Convert.ToInt32(txtRuleNumber.Text)))
             {
                 aux   = i;
                 agent = listInfoFeeRule[i].Agent;
                 corp  = listInfoFeeRule[i].Attribute1;
                 break;
             }
         }
         if (listInfoFeeRule[aux].ActivationSatate)
         {
             MessageBox.Show("EL NÚMERO DE REGLA DE CARGO POR SERVICIO YA SE ENCUENTRA ACTIVA", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
             Loader.AddToPanel(Loader.Zone.Middle, this, Resources.Constants.UCWELCOME);
         }
         else
         {
             btnAccept.Visible           = false;
             lblInfoRuleByAttribute.Text = string.Concat("La regla ", txtRuleNumber.Text, " pertenece al corporativo ", listInfoFeeRule[0].Attribute1,
                                                         " el cual contiene las siguientes\nreglas:");
             attribute1 = listInfoFeeRule[0].Attribute1;
             string info            = string.Empty;
             int    indexRuleNumber = 0;
             for (int i = 0; i < listInfoFeeRule.Count; i++)
             {
                 if (listInfoFeeRule[i].RuleNumber == Convert.ToInt32(txtRuleNumber.Text))
                 {
                     indexRuleNumber = i;
                 }
                 info = string.Concat(info, "Regla: ", listInfoFeeRule[i].RuleNumber);
                 info = string.Concat(info, "\n", "Descripción: ", listInfoFeeRule[i].Description);
                 info = string.Concat(info, "\n", "Prioridad: ", listInfoFeeRule[i].Priority);
                 info = string.Concat(info, "\n", "% De Tarifa Base: ", listInfoFeeRule[i].DefaultFee);
                 info = string.Concat(info, "\n", "Cantidad Fija: ", listInfoFeeRule[i].DefaultMount.ToString("0.00"));
                 info = string.Concat(info, "\n", "Monto: ", (listInfoFeeRule[i].Mandatory) ? "No Negociable" : "Negociable");
                 info = string.Concat(info, "\n", "Status: ", (listInfoFeeRule[i].ActivationSatate == true) ? "Activa" : "Inactiva", "\n");
                 if (listInfoFeeRule[i].StartDate != Types.DateNullValue)
                 {
                     info = string.Concat(info, "Inicio de regla: ", listInfoFeeRule[i].StartDate.ToString("dd-MM-yyyy"), "\n");
                 }
                 if (listInfoFeeRule[i].ExpirationDate != Types.DateNullValue)
                 {
                     info = string.Concat(info, "Fin de regla: ", listInfoFeeRule[i].ExpirationDate.ToString("dd-MM-yyyy"), "\n");
                 }
                 info = string.Concat(info, "\n");
             }
             string[] infoList = info.Split(new char[] { '\n' });
             txtInfoRuleByAttribute1.Lines   = infoList;
             lblInfoRuleByAttribute.Visible  = true;
             txtInfoRuleByAttribute1.Visible = true;
             lblInfoActivationRule.Text      = string.Concat("La regla ", txtRuleNumber.Text, " aplica bajo los siguientes criterios:");
             listInformationRule             = GetInformationRuleAppliedBL.GetInfoRule(Convert.ToInt32(txtRuleNumber.Text), false);
             string info2 = string.Empty;
             info2 = string.Concat("% DE LA TARIFA BASE: ", listInformationRule[0].DefaultFee, "\n");
             info2 = string.Concat(info2, "Cantidad Fija: $", listInformationRule[0].DefaultMount.ToString("0.00"), "\n");
             info2 = string.Concat(info2, "Monto: ", (listInformationRule[0].Mandatory) ? "No Negociable" : "Negociable", "\n");
             if (listInfoFeeRule[indexRuleNumber].StartDate != Types.DateNullValue)
             {
                 info2 = string.Concat(info2, "Inicio de regla: ", listInfoFeeRule[indexRuleNumber].StartDate.ToString("dd-MM-yyyy"), "\n");
             }
             if (listInfoFeeRule[indexRuleNumber].ExpirationDate != Types.DateNullValue)
             {
                 info2 = string.Concat(info2, "Fin de regla: ", listInfoFeeRule[indexRuleNumber].ExpirationDate.ToString("dd-MM-yyyy"), "\n");
             }
             if (!string.IsNullOrEmpty(listInformationRule[0].Value2) && !string.IsNullOrEmpty(listInformationRule[0].Target))
             {
                 for (int i = 0; i < listInformationRule.Count; i++)
                 {
                     info2 = string.Concat(info2,
                                           listInformationRule[i].Target,
                                           ": ",
                                           listInformationRule[i].Value2,
                                           "\n");
                 }
             }
             listLocationDK = SetLocationDKNotAcceptedBL.SetLocationDKNotAccepted(Convert.ToInt32(txtRuleNumber.Text), null);
             string locationDKNotAccepted = string.Empty;
             if (listLocationDK.Count > 0)
             {
                 for (int j = 0; j < listLocationDK.Count; j++)
                 {
                     locationDKNotAccepted = string.Concat(locationDKNotAccepted, listLocationDK[j].LocationDK, ", ");
                 }
                 locationDKNotAccepted = locationDKNotAccepted.Trim().TrimEnd(new char[] { ',' });
                 info2 = string.Concat(info2, "LocationDK Excluyente: ", locationDKNotAccepted, "\n");
             }
             string[] infoList2 = info2.Split(new char[] { '\n' });
             txtInfoRuleNumber.Lines       = infoList2;
             txtInfoRuleNumber.Visible     = true;
             lblInfoActivationRule.Visible = true;
             if (statusButtons)
             {
                 btnActivation.Location = new Point(btnActivation.Location.X, btnActivation.Location.Y + 180);
                 btnClear.Location      = new Point(btnClear.Location.X, btnClear.Location.Y + 180);
                 statusButtons          = false;
             }
             btnActivation.Visible  = true;
             btnClear.Visible       = true;
             txtRuleNumber.ReadOnly = true;
             btnActivation.Focus();
         }
     }
     else if (listInfoFeeRule.Count == 1)
     {
         if (listInfoFeeRule[0].ActivationSatate)
         {
             MessageBox.Show("EL NÚMERO DE REGLA DE CARGO POR SERVICIO YA SE ENCUENTRA ACTIVA", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
             Loader.AddToPanel(Loader.Zone.Middle, this, Resources.Constants.UCWELCOME);
         }
         else
         {
             agent                       = listInfoFeeRule[0].Agent;
             corp                        = listInfoFeeRule[0].Attribute1;
             btnAccept.Visible           = false;
             lblInfoRuleByAttribute.Text = string.Concat("La regla ", txtRuleNumber.Text, " pertenece al corporativo ", listInfoFeeRule[0].Attribute1,
                                                         " y se aplica bajo los siguientes\ncriterios:");
             attribute1          = listInfoFeeRule[0].Attribute1;
             listInformationRule = GetInformationRuleAppliedBL.GetInfoRule(Convert.ToInt32(txtRuleNumber.Text), false);
             string info = string.Empty;
             info = string.Concat("% DE LA TARIFA BASE: ", listInformationRule[0].DefaultFee, "\n");
             info = string.Concat(info, "Cantidad Fija: $", listInformationRule[0].DefaultMount.ToString("0.00"), "\n");
             info = string.Concat(info, "Monto: ", (listInformationRule[0].Mandatory) ? "No Negociable" : "Negociable", "\n");
             if (listInfoFeeRule[0].StartDate != Types.DateNullValue)
             {
                 info = string.Concat(info, "Inicio de regla: ", listInfoFeeRule[0].StartDate.ToString("dd-MM-yyyy"), "\n");
             }
             if (listInfoFeeRule[0].ExpirationDate != Types.DateNullValue)
             {
                 info = string.Concat(info, "Fin de regla: ", listInfoFeeRule[0].ExpirationDate.ToString("dd-MM-yyyy"), "\n");
             }
             if (!string.IsNullOrEmpty(listInformationRule[0].Value2) && !string.IsNullOrEmpty(listInformationRule[0].Target))
             {
                 for (int i = 0; i < listInformationRule.Count; i++)
                 {
                     info = string.Concat(info,
                                          listInformationRule[i].Target,
                                          ": ",
                                          listInformationRule[i].Value2,
                                          "\n");
                 }
             }
             listLocationDK = SetLocationDKNotAcceptedBL.SetLocationDKNotAccepted(Convert.ToInt32(txtRuleNumber.Text), null);
             string locationDKNotAccepted = string.Empty;
             if (listLocationDK.Count > 0)
             {
                 for (int j = 0; j < listLocationDK.Count; j++)
                 {
                     locationDKNotAccepted = string.Concat(locationDKNotAccepted, listLocationDK[j].LocationDK, ", ");
                 }
                 locationDKNotAccepted = locationDKNotAccepted.Trim().TrimEnd(new char[] { ',' });
                 info = string.Concat(info, "LocationDK Excluyente: ", locationDKNotAccepted, "\n");
             }
             string[] infoList = info.Split(new char[] { '\n' });
             txtInfoRuleByAttribute1.Lines   = infoList;
             lblInfoRuleByAttribute.Visible  = true;
             txtInfoRuleByAttribute1.Visible = true;
             if (!statusButtons)
             {
                 btnActivation.Location = new Point(btnActivation.Location.X, btnActivation.Location.Y - 180);
                 btnClear.Location      = new Point(btnClear.Location.X, btnClear.Location.Y - 180);
                 statusButtons          = true;
             }
             btnActivation.Visible  = true;
             btnClear.Visible       = true;
             txtRuleNumber.ReadOnly = true;
             btnActivation.Focus();
         }
     }
 }
        /// <summary>
        /// Agrega una nueva regla de cargo por servicio y sus targets
        /// correspondientes
        /// </summary>
        private void AddTargets()
        {
            ListTargetsRules = new List <Targets>();
            foreach (Control txt in this.Controls)
            {
                if (txt is SmartTextBox && !string.IsNullOrEmpty(txt.Text) &&
                    !(txt.TabIndex.Equals(22) || txt.TabIndex.Equals(23) || txt.TabIndex.Equals(17)))
                {
                    Targets t = new Targets();
                    t.IDTE   = txt.TabIndex;
                    t.Value2 = txt.Text;
                    ListTargetsRules.Add(t);
                }
            }
            if (cmbOriginOfSale.SelectedIndex > 0)
            {
                Targets t = new Targets();
                t.IDTE   = cmbOriginOfSale.TabIndex;
                t.Value2 = Convert.ToString(cmbOriginOfSale.Text);
                ListTargetsRules.Add(t);
            }

            if (cmbOperativeUnit.SelectedIndex > 0)
            {
                Targets t = new Targets();
                t.IDTE   = 23;
                t.Value2 = Convert.ToString(cmbOperativeUnit.Text);
                ListTargetsRules.Add(t);
            }
            if (cmbPayForm.SelectedIndex > 0)
            {
                Targets t = new Targets();
                t.IDTE   = cmbPayForm.TabIndex;
                t.Value2 = Convert.ToString(cmbPayForm.SelectedItem);
                ListTargetsRules.Add(t);
            }
            if (!string.IsNullOrEmpty(txtHora1.Text) && !string.IsNullOrEmpty(txtHora2.Text))
            {
                Targets t1 = new Targets();
                t1.IDTE   = 22;
                t1.Value2 = string.Concat(txtHora1.Text, " - ", txtHora2.Text);
                ListTargetsRules.Add(t1);
            }

            if (!string.IsNullOrEmpty(txtBaseFare2.Text) && !string.IsNullOrEmpty(txtBaseFare.Text))
            {
                Targets t17 = new Targets();
                t17.IDTE   = 17;
                t17.Value2 = string.Concat(txtBaseFare.Text, " a ", txtBaseFare2.Text);
                ListTargetsRules.Add(t17);
            }


            string corp              = string.Empty;
            string descripcion       = string.Empty;
            string extendDescripcion = string.Empty;
            string porcentaje        = string.Empty;
            string cantidad          = string.Empty;
            string priority          = string.Empty;
            string fechaInicio       = string.Empty;
            string fechaFin          = string.Empty;
            int    numberRule        = 0;

            for (int i = 0; i < ucNewFeeRule.Criterios.Count; i++)
            {
                if (ucNewFeeRule.Criterios[i].numberCritery == 1)
                {
                    corp = ucNewFeeRule.Criterios[i].criterio;
                }
                else if (ucNewFeeRule.Criterios[i].numberCritery == 2)
                {
                    descripcion = ucNewFeeRule.Criterios[i].criterio;
                }
                else if (ucNewFeeRule.Criterios[i].numberCritery == 3)
                {
                    extendDescripcion = ucNewFeeRule.Criterios[i].criterio;
                }
                else if (ucNewFeeRule.Criterios[i].numberCritery == 4)
                {
                    porcentaje = ucNewFeeRule.Criterios[i].criterio;
                }
                else if (ucNewFeeRule.Criterios[i].numberCritery == 5)
                {
                    cantidad = ucNewFeeRule.Criterios[i].criterio;
                }
                else if (ucNewFeeRule.Criterios[i].numberCritery == 6)
                {
                    priority = ucNewFeeRule.Criterios[i].criterio;
                }
                else if (ucNewFeeRule.Criterios[i].numberCritery == 7)
                {
                    fechaInicio = ucNewFeeRule.Criterios[i].criterio;
                }
                else if (ucNewFeeRule.Criterios[i].numberCritery == 8)
                {
                    fechaFin = ucNewFeeRule.Criterios[i].criterio;
                }
            }
            DialogResult yesNo = MessageBox.Show("¿SEGURO QUE DESEA CREAR ESTA NUEVA REGLA PARA EL CORPORATIVO " + corp + "?", Resources.Constants.MYCTS, MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (yesNo.Equals(DialogResult.Yes))
            {
                if (!string.IsNullOrEmpty(ucNewFeeRule.Attribute1))
                {
                    UpdatePriorityByAttribute1BL.UpdatePriorities(ucNewFeeRule.NewPriority, ucNewFeeRule.Attribute1);
                }
                List <SetNewFeeRule> ListNumberRule = new List <SetNewFeeRule>();
                ListNumberRule = NewFeeRuleBL.SetNewFeeRule(corp, Convert.ToInt32(priority), descripcion, extendDescripcion,
                                                            (!string.IsNullOrEmpty(porcentaje)) ? Convert.ToDecimal(porcentaje) : 0, (!string.IsNullOrEmpty(cantidad)) ? Convert.ToDecimal(cantidad) : 0,
                                                            (ucNewFeeRule.MontoFijo) ? true : false, false, fechaInicio, fechaFin, Login.Agent);
                if (ListNumberRule.Count > 0)
                {
                    numberRule = ListNumberRule[0].IDRuleNumber;
                    if (ucDefinitionTargetElements.ListTargetsRules != null)
                    {
                        for (int i = 0; i < ucDefinitionTargetElements.ListTargetsRules.Count; i++)
                        {
                            if (ucDefinitionTargetElements.ListTargetsRules[i].IDTE == 3 ||
                                ucDefinitionTargetElements.ListTargetsRules[i].IDTE == 8)
                            {
                                ucDefinitionTargetElements.ListTargetsRules[i].Value2 = BuildDate(ucDefinitionTargetElements.ListTargetsRules[i].Value2);
                            }
                            SetNewTargetFeeRuleBL.AddNewTargetFeeRule(numberRule, ucDefinitionTargetElements.ListTargetsRules[i].IDTE,
                                                                      ucDefinitionTargetElements.ListTargetsRules[i].Value2);
                        }
                    }
                    if (ListTargetsRules != null)
                    {
                        for (int j = 0; j < ListTargetsRules.Count; j++)
                        {
                            SetNewTargetFeeRuleBL.AddNewTargetFeeRule(numberRule, ListTargetsRules[j].IDTE,
                                                                      ListTargetsRules[j].Value2);
                        }
                    }
                    if (!string.IsNullOrEmpty(ucDefinitionTargetElements.LocationDKNotAccepted))
                    {
                        SetLocationDKNotAcceptedBL.SetLocationDKNotAccepted(numberRule, ucDefinitionTargetElements.LocationDKNotAccepted);
                    }
                }

                ucDefinitionTargetElements.PaxNum = 0;
                ucNewFeeRule.Criterios.Clear();
                ucDefinitionTargetElements.ListTargetsRules.Clear();
                ucNewFeeRule.listAttribute1.Clear();
                ListTargetsRules.Clear();

                //GetMailByUser userMail = GetMailByUserBL.GetMail(Login.Agent);
                Parameter mailToValidate   = ParameterBL.GetParameterValue("MailToValidateFeeRule");
                Parameter mailToSend       = ParameterBL.GetParameterValue("MailThatSendFeeRule");
                Parameter mailPassword     = ParameterBL.GetParameterValue("PasswordThatMailToSend");
                Parameter ccMailToValidate = ParameterBL.GetParameterValue("CC-MailToValidateFeeRule");
                Parameter displyName       = ParameterBL.GetParameterValue("NameSendEmail");
                string    body             = string.Concat("Solicitud de Activación de Nueva Regla - Cargo por Servicio\n\n",
                                                           "Número de regla:  ", numberRule, "\n",
                                                           "Nombre:           ", descripcion, "\n",
                                                           "Solicitado por:  	", Login.Agent, " (", Login.NombreCompleto, ")", "\n",
                                                           "Corporativo:   	", corp, "\n",
                                                           "Fecha Sol.:    	", Convert.ToString(DateTime.Now).Substring(0, 10), "\n",
                                                           "Prioridad:        ", priority, "\n");
                List <GetInformationRuleApplied> listInfoRule = GetInformationRuleAppliedBL.GetInfoRule(numberRule, true);
                string targets = string.Empty;

                targets = "Los criterios para aplicación de la regla son los siguientes:\n\n";
                targets = string.Concat(targets, " -", "Porcentaje de la Tarifa Base: ".ToUpper().PadRight(35, ' '), (string.IsNullOrEmpty(porcentaje)) ? "0" : porcentaje, "\n\n");
                targets = string.Concat(targets, " -", "Cantidad fija: ".ToUpper().PadRight(35, ' '), "$", (string.IsNullOrEmpty(cantidad)) ? "0.00" : Convert.ToDecimal(cantidad).ToString("0.00"), "\n\n");
                targets = string.Concat(targets, " -", "Monto: ".ToUpper().PadRight(35, ' '), (ucNewFeeRule.MontoFijo) ? "No Negociable" : "Negociable", "\n\n");
                ucNewFeeRule.MontoFijo = false;
                if (!string.IsNullOrEmpty(fechaInicio))
                {
                    targets = string.Concat(targets, " -", "Fecha de Inicio de la Regla: ".ToUpper().PadRight(35, ' '), fechaInicio, "\n\n");
                }
                if (!string.IsNullOrEmpty(fechaFin))
                {
                    targets = string.Concat(targets, " -", "Fecha de Expiración de la Regla: ".ToUpper().PadRight(35, ' '), fechaFin, "\n\n");
                }
                for (int i = 0; i < listInfoRule.Count; i++)
                {
                    targets = string.Concat(targets, " -", string.Concat(listInfoRule[i].Target, ": ").ToUpper().PadRight(35, ' '), listInfoRule[i].Value2, "\n\n");
                }
                if (!string.IsNullOrEmpty(ucDefinitionTargetElements.LocationDKNotAccepted))
                {
                    targets = string.Concat(targets, " -", "Location(DK) Excluyente: ".ToUpper().PadRight(35, ' '), ucDefinitionTargetElements.LocationDKNotAccepted, "\n\n");
                }
                ucDefinitionTargetElements.LocationDKNotAccepted = string.Empty;
                body = string.Concat(body, "\n", targets);

                body = string.Concat(body, "\nFavor de evaluar dicha regla y activarla si es conveniente.");
                try
                {
                    SendMailAync(mailToSend.Values, mailPassword.Values, displyName.Values, mailToValidate.Values,
                                 ccMailToValidate.Values, "Nueva regla de cargo por servicio", body);
                    SendMailAync(mailToSend.Values, mailPassword.Values, displyName.Values, Login.Mail, "", "Solucitud Nueva Regla Cargo por Servicio",
                                 "Hola " + Login.NombreCompleto + "\n\nMyCTS te da las gracias por haber creado una nueva regla de Cargo por Servicio, " +
                                 "te informamos que dicha regla fue creada con éxito con el número de regla " + numberRule + " para el corporativo " + corp +
                                 "\n\nUna vez que sea evaluada por la Dirección de Operaciones estará disponible para su uso." +
                                 "\n\nGracias");
                }
                catch { }
                MessageBox.Show("LA REGLA " + numberRule + " DE CARGO POR SERVICIO SE CREO CON EXITO, Y SE ENCUENTRA INACTIVA\n" +
                                "HASTA QUE SEA SUJETA A AUTORIZACIÓN POR LA DIRECIÓN DE OPERACIONES", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (ucNewFeeRule.LoadUserWelcome)
                {
                    Loader.AddToPanel(Loader.Zone.Middle, this, Resources.Constants.UCWELCOME);
                }
                else
                {
                    Loader.AddToPanel(Loader.Zone.Middle, this, Resources.TicketEmission.Constants.UC_TICKETEMISSION_CONFIRMATION);
                }
            }
            else
            {
                cmbOriginOfSale.Focus();
            }
        }