コード例 #1
0
        private void ELRTextBox_Leave(object sender, EventArgs e)
        {
            ELRUtils util   = new ELRUtils();
            string   NDecim = "N";

            try
            {
                NDecim += Decimales.ToString();

                if (EsBusqueda)
                {
                    GetById();
                }

                if ((Formato == tbFormato.Decimal) || (Formato == tbFormato.DecimalPositivo))
                {
                    this.Text = util.ConvertirANumero(Text.Trim()).ToString(NDecim);
                }
                if ((Formato == tbFormato.NumerosEnteros) || (Formato == tbFormato.NumerosEnterosPositivos))
                {
                    if (Text.Trim() == "")
                    {
                        Text = "0";
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                util = null;
            }
        }
コード例 #2
0
        public void Guardar()
        {
            if (Nombre.Trim() == "")
            {
                Helpers.Msg.Error("Campo [ Nombre Empaque/Medida ] No Puede Estar Vacio");
                return;
            }
            if (Decimales.Trim() == "")
            {
                Helpers.Msg.Error("Campo [ Decimales Empaque/Medida ] No Puede Estar Vacio");
                return;
            }

            if (isModoAgregar)
            {
                var msg = MessageBox.Show("Guardar Data ?", "*** ALERTA ***", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                if (msg == DialogResult.Yes)
                {
                    var xficha = new OOB.LibInventario.EmpaqueMedida.Agregar()
                    {
                        nombre    = Nombre,
                        decimales = Decimales,
                    };
                    var r01 = Sistema.MyData.EmpaqueMedida_Agregar(xficha);
                    if (r01.Result == OOB.Enumerados.EnumResult.isError)
                    {
                        Helpers.Msg.Error(r01.Mensaje);
                        return;
                    }
                    var r02 = Sistema.MyData.EmpaqueMedida_GetFicha(r01.Auto);
                    if (r02.Result == OOB.Enumerados.EnumResult.isError)
                    {
                        Helpers.Msg.Error(r02.Mensaje);
                        return;
                    }
                    ficha = r02.Entidad;
                    IsOk  = true;
                }
            }
            else
            {
                var msg = MessageBox.Show("Cambiar/Actualizar Data ?", "*** ALERTA ***", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                if (msg == DialogResult.Yes)
                {
                    var xficha = new OOB.LibInventario.EmpaqueMedida.Editar()
                    {
                        auto      = Id,
                        nombre    = Nombre,
                        decimales = Decimales,
                    };
                    var r01 = Sistema.MyData.EmpaqueMedida_Editar(xficha);
                    if (r01.Result == OOB.Enumerados.EnumResult.isError)
                    {
                        Helpers.Msg.Error(r01.Mensaje);
                        return;
                    }
                    var r02 = Sistema.MyData.EmpaqueMedida_GetFicha(Id);
                    if (r02.Result == OOB.Enumerados.EnumResult.isError)
                    {
                        Helpers.Msg.Error(r02.Mensaje);
                        return;
                    }
                    ficha = r02.Entidad;
                    IsOk  = true;
                }
            }
        }
コード例 #3
0
        private void Cliente(Persona persona, string abre, double rnd_Abre, double rnd_cliente, int desde, int hasta, int fila, int[] arreglo, int iteracion, int[] contador)//***********El contador************
        {
            double rnd_compra      = 0;
            double rnd_suscripcion = 0;
            int    cont            = 0; //***********El contador************


            if (abre == "Abre")
            {
                rnd_compra = random.NextDouble();

                if (rnd_compra <= persona.probCompra)
                {
                    persona.venta = "Compra";

                    rnd_suscripcion = random.NextDouble();
                    cont            = cont + 1; //***********El contador************
                    //*************************
                    //para contar cuantos abren
                    if (fila == 0)
                    {
                        contador[0] = cont;
                        contador[1] = cont;
                    }
                    else
                    {
                        contador[0] = contador[0] + cont;
                        if (cont > 0)
                        {
                            contador[1] = cont;
                        }
                    }
                    //hasta aca*****************



                    if (rnd_suscripcion < persona.numSuscrip1)
                    {
                        persona.suscripcion = 1;
                    }
                    else
                    {
                        if (rnd_suscripcion < persona.numSuscrip2)
                        {
                            persona.suscripcion = 2;
                        }
                        else
                        {
                            if (rnd_suscripcion < persona.numSuscrip3)
                            {
                                persona.suscripcion = 3;
                            }
                            else
                            {
                                persona.suscripcion = 4;
                            }
                        }
                    }
                }



                else
                {
                    persona.venta = "No compra";
                }
            }


            int nuevo = persona.suscripcion * 2;

            //arreglo[fila] = arreglo[fila - 1] + nuevo;

            if (fila == 0)
            {
                arreglo[0] = nuevo;
                arreglo[1] = nuevo;
            }
            else
            {
                arreglo[0] = arreglo[0] + nuevo;
                if (nuevo > 0)
                {
                    arreglo[1] = nuevo;
                }
            }



            if (fila >= desde && fila <= hasta)
            {
                //******* Aca agregue el ultimo parametro: Decimales.truncarA4Decimales(contador [0]

                dgv_datos.Rows.Add(fila, Decimales.truncarA4Decimales(rnd_Abre), abre, Decimales.truncarA4Decimales(rnd_cliente), persona.genero, Decimales.truncarA4Decimales(rnd_compra), persona.venta, Decimales.truncarA4Decimales(rnd_suscripcion), persona.suscripcion, nuevo, arreglo[0], Decimales.truncarA4Decimales(contador[0]));
            }
            if (fila == iteracion)
            {
                //******* Aca agregue el ultimo parametro: Decimales.truncarA4Decimales(contador [0]
                dgv_datos.Rows.Add(fila, Decimales.truncarA4Decimales(rnd_Abre), abre, Decimales.truncarA4Decimales(rnd_cliente), persona.genero, Decimales.truncarA4Decimales(rnd_compra), persona.venta, Decimales.truncarA4Decimales(rnd_suscripcion), persona.suscripcion, nuevo, arreglo[0], Decimales.truncarA4Decimales(contador[0]));
                //***********Esto para calcular y mostrar la prob
                double prob = Decimales.truncarA4Decimales(contador[0]) / iteracion;
                lblProb.Visible = true;
                lblProb.Text    = prob.ToString();
            }
        }
コード例 #4
0
ファイル: Menu.cs プロジェクト: DayMiszczuk/TP4_SIM
        private void Cliente(Persona persona, string abre, double rnd_Abre, double rnd_cliente, int desde, int hasta, int fila, int[] arreglo)
        {
            double rnd_compra      = 0;
            double rnd_suscripcion = 0;


            if (abre == "Abre")
            {
                rnd_compra = random.NextDouble();

                if (rnd_compra <= persona.probCompra)
                {
                    persona.venta   = "Compra";
                    rnd_suscripcion = random.NextDouble();

                    if (rnd_suscripcion < persona.numSuscrip1)
                    {
                        persona.suscripcion = 1;
                    }
                    else
                    {
                        if (rnd_suscripcion < persona.numSuscrip2)
                        {
                            persona.suscripcion = 2;
                        }
                        else
                        {
                            if (rnd_suscripcion < persona.numSuscrip3)
                            {
                                persona.suscripcion = 3;
                            }
                            else
                            {
                                persona.suscripcion = 4;
                            }
                        }
                    }
                }
                else
                {
                    persona.venta = "No compra";
                }
            }


            int nuevo = persona.suscripcion * 2;

            //arreglo[fila] = arreglo[fila - 1] + nuevo;

            if (fila == 0)
            {
                arreglo[0] = nuevo;
                arreglo[1] = nuevo;
            }
            else
            {
                arreglo[0] = arreglo[0] + nuevo;
                if (nuevo > 0)
                {
                    arreglo[1] = nuevo;
                }
            }

            if (fila >= desde && fila <= hasta)
            {
                dgv_datos.Rows.Add(fila, Decimales.truncarA4Decimales(rnd_Abre), abre, Decimales.truncarA4Decimales(rnd_cliente), persona.genero, Decimales.truncarA4Decimales(rnd_compra), persona.venta, Decimales.truncarA4Decimales(rnd_suscripcion), persona.suscripcion, nuevo, arreglo[0]);
            }
        }
コード例 #5
0
        public void GetValorFromDS(bool esNuevo, int posicion = 0)
        {
            DataColumn MyColumna;
            DataRow    MyFila;
            ELRUtils   util   = new ELRUtils();
            string     NDecim = "N";

            string valor = "";

            try
            {
                valor = ValorPorDefecto;

                if (DSData != null)
                {
                    if (NombreTabla.Trim() == "")
                    {
                        if (!DSData.Tables[0].Columns.Contains(CampoData))
                        {
                            throw new Exception("El Campo [" + CampoData + "] No Existe!!");
                        }

                        MyColumna = DSData.Tables[0].Columns[CampoData];
                        MyFila    = DSData.Tables[0].Rows[posicion];
                    }
                    else
                    {
                        if (!DSData.Tables[NombreTabla].Columns.Contains(CampoData))
                        {
                            throw new Exception("El Campo [" + CampoData + "] No Existe!!");
                        }

                        MyColumna = DSData.Tables[NombreTabla].Columns[CampoData];
                        MyFila    = DSData.Tables[NombreTabla].Rows[posicion];
                    }

                    if (MyColumna.MaxLength > 0)
                    {
                        MaxLength = MyColumna.MaxLength;
                    }

                    //APLICAMOS FORMATO DECIMAL
                    if ((MyColumna.DataType == typeof(Decimal)) || (MyColumna.DataType == typeof(Double)))
                    {
                        if (valor.Trim() == "")
                        {
                            valor = "0.0";
                        }

                        if ((Formato == null) || (Formato == tbFormato.Default))
                        {
                            Formato = tbFormato.DecimalPositivo;
                            if (Decimales <= 0)
                            {
                                Decimales = 2;
                            }
                        }

                        if (!esNuevo)
                        {
                            valor = util.GetAsString(CampoData, MyFila, "0");
                        }

                        NDecim   += Decimales.ToString();
                        this.Text = util.ConvertirANumero(valor).ToString(NDecim);
                    }
                    else if ((MyColumna.DataType == typeof(Int16)) || (MyColumna.DataType == typeof(Int32)) || (MyColumna.DataType == typeof(Int64)) || (MyColumna.DataType == typeof(Single)) || (MyColumna.DataType == typeof(SByte)))
                    {
                        if (valor.Trim() == "")
                        {
                            valor = "0";
                        }

                        if ((Formato == null) || (Formato == tbFormato.Default))
                        {
                            Formato = tbFormato.NumerosEnteros;
                        }

                        if (!esNuevo)
                        {
                            valor = util.GetAsString(CampoData, MyFila, "0");
                        }

                        this.Text = valor;
                    }
                    else if ((MyColumna.DataType == typeof(UInt16)) || (MyColumna.DataType == typeof(UInt32)) || (MyColumna.DataType == typeof(UInt64)))
                    {
                        if (valor.Trim() == "")
                        {
                            valor = "0";
                        }

                        if ((Formato == null) || (Formato == tbFormato.Default))
                        {
                            Formato = tbFormato.NumerosEnterosPositivos;
                        }

                        if (!esNuevo)
                        {
                            valor = util.GetAsString(CampoData, MyFila, "0");
                        }

                        this.Text = valor;
                    }
                    else
                    {
                        if (!esNuevo)
                        {
                            valor = util.GetAsString(CampoData, MyFila);
                        }

                        if (CampoData.ToUpper().Contains("CEDULA"))
                        {
                            valor = util.FormatearCedulaRNC(valor);
                        }
                        else if (CampoData.ToUpper().Contains("RNC"))
                        {
                            valor = util.FormatearCedulaRNC(valor);
                        }
                        else if (CampoData.ToUpper().Contains("TELEFONO"))
                        {
                            valor = util.FormatearTelefono(valor);
                        }
                        else if (CampoData.ToUpper().Contains("CELULAR"))
                        {
                            valor = util.FormatearTelefono(valor);
                        }


                        this.Text = valor.Trim();
                    }
                }

                if (EsAutoGenerado)
                {
                    this.Enabled = false;
                }
                if ((!esNuevo) && (this.Enabled))
                {
                    this.Enabled = EsEditable;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }