Exemple #1
0
 /// <summary>
 /// 获取客户信息
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public static customer_info getcust_customer(customer_info entity, string where)
 {
     try
     {
         SqlParameter[] param =
         {
             new SqlParameter("@where", where)
         };
         SqlDataReader reader = SQLHelp.ExecuteReader("getcust_customer", CommandType.StoredProcedure, param);
         if (reader.HasRows)
         {
             PropertyInfo[] pros = entity.GetType().GetProperties();
             while (reader.Read())
             {
                 foreach (PropertyInfo item in pros)
                 {
                     item.SetValue(entity, reader.IsDBNull(reader.GetOrdinal(item.Name)) ? null : reader[item.Name]);
                 }
             }
         }
         else
         {
             entity = null;
         }
         return(entity);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
        // GET: customer_info/Edit/5
        public async Task <ActionResult> Edit(string id)
        {
            if (!IsLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            else
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                var           CurrentCustomer = (customer_info)Session["CurrentCustomer"];
                customer_info customer_info   = await CurrentCustomer.GetAccountById(id);

                if (customer_info == null)
                {
                    return(HttpNotFound());
                }

                customer_info.ComisionDelPadre = IMPUESTO;
                return(View(customer_info));
            }
        }
        public async Task <ErrorHandling> SetAccount(customer_info account)
        {
            Regex regex = new Regex(@"^(?=(.*[a-zA-Z].*){2,})(?=.*\d.*)(?=.*\W.*)[a-zA-Z0-9\S]{8,17}$");
            Match match = regex.Match(account.password);

            if (!match.Success)
            {
                return(new ErrorHandling
                {
                    faul = true,
                    faultstring = "La contraseña debe contener dígitos, al menos una letra miniscula y una mayuscula y un caracter especial"
                });
            }

            try
            {
                var now = DateTime.Now;

                var YY = now;
                var MM = now.Month.ToString();
                var DD = now.Day.ToString();

                if (MM.Length == 1)
                {
                    MM = "0" + MM;
                }
                if (DD.Length == 1)
                {
                    DD = "0" + DD;
                }

                var activationDate = now.Year + "-" + MM + "-" + DD;
                account.ComisionDelPadre = IMPUESTO;
                //id de la cuenta
                account.opening_balance = 0;
                account.iso_4217        = "USD";
                account.i_distributor   = await ID_DISTRIBUIDOR();

                account.i_customer_type = 1;  //Online customers
                account.batch_name      = ID_CUENTA + "-di-pinless";
                account.billing_model   = 1;
                account.i_time_zone     = 109;
                account.i_ui_time_zone  = 109;
                account.control_number  = 1;
                account.h323_password   = account.password;
                account.i_product       = 22791;
                account.activation_date = activationDate.Trim();
                account.phone1          = account.phone1;
                account.firstname       = account.firstname;
                account.name            = account.fullname;
                account.lastname        = account.lastname;
                account.email           = account.email;
                account.login           = account.phone1;
                account.password        = account.password;
                account.note            = account.note;
            }
            catch (Exception ex)
            {
                ;
            }

            var valid = await account.Validar();

            if (!valid.faul)
            {
                var result = await account.Crear();

                return(result);
            }
            else
            {
                return(valid);
            }
        }
        public async Task <ActionResult> Create(customer_info account)
        {
            if (!IsLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    //validar impuesto..................................

                    if (account.impuesto < IMPUESTO)
                    {
                        account.ErrorHandlingCrearCuenta.faul        = true;
                        account.ErrorHandlingCrearCuenta.faultstring = "El impuesto de la tienda tiene que ser mayor o igual que su impuesto(" + IMPUESTO + "%)";
                        return(View(account));
                    }

                    //validar fondos disponibles

                    //var fondos = await FONDOS();
                    //if (account.LimiteCredito > fondos)
                    //{
                    //    account.ErrorHandlingCrearCuenta.faul = true;
                    //    account.ErrorHandlingCrearCuenta.faultstring = "El credito que desea asignar es mayor que su fondo.";
                    //    return View(account);
                    //}

                    account.note = ":DISTRIB: 2:2:" + account.impuesto + ":";

                    ////CALCULAR DIFERENCIA DE SALDO

                    //var porcionDistrubuidor = account.LimiteCredito;
                    //var comisionDistribuidor = IMPUESTO;

                    //var TotalSegunComision = (float)_Global.ReglaDeTres(comisionDistribuidor,0,porcionDistrubuidor);

                    //var DineroFicticio = (float)_Global.ReglaDeTres(account.impuesto, TotalSegunComision, 0);
                    //account.credit_limit = DineroFicticio;

                    // //----------------------------

                    account.credit_limit = account.LimiteCredito;
                    var resul = await SetAccount(account);

                    if (!resul.faul)
                    {
                        //((customer_info)Session["CurrentCustomer"]).credit_limit -= account.LimiteCredito;
                        //await ((customer_info)Session["CurrentCustomer"]).Actualizar();
                        //Session["CurrentCustomer"] = await ((customer_info)Session["CurrentCustomer"]).Reload();
                        ShowSuccess(resul.faultstring);
                        await FONDOS();

                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        account.ErrorHandlingCrearCuenta = resul;
                        await FONDOS();

                        return(View(account));
                    }
                }
                else
                {
                    return(View(account));
                }
            }
        }
        public async Task <ActionResult> Historial()
        {
            if (!IsLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }

            //DateTime dt1 = DateTime.Now;
            //DateTime wkStDt = DateTime.MinValue;
            //wkStDt = dt1.AddDays(1 - Convert.ToDouble(dt1.DayOfWeek));
            //string inicioSemana = wkStDt.Date.ToString("yyyy/MM/dd HH:mm:ss");
            //var dt = DateTime.Parse(inicioSemana);
            var utc_from = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Parse(_Global.FromDate), "US Eastern Standard Time", "UTC").ToString("yyyy-MM-dd HH:mm:ss");

            //string finSemana = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
            //var to = DateTime.Parse(finSemana);
            var utc_to      = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Parse(_Global.ToDate), "US Eastern Standard Time", "UTC").ToString("yyyy-MM-dd HH:mm:ss");
            var facturacion = new Facturacion();

            Session["HistorialFromDate"] = _Global.FromDate;
            Session["HistorialToDate"]   = _Global.ToDate;


            GetRetailCustomerXDRListResponse XDRListResponse = new GetRetailCustomerXDRListResponse();
            var Xdrs = new List <CustomerXDRInfo>();

            if ((TipoTienda)Session["TipoTienda"] == TipoTienda.Padre)
            {
                XDRListResponse = await((customer_info)Session["CurrentCustomer"]).GetCustomerXDR(new GetRetailCustomerXDRListRequest {
                    from_date = utc_from, to_date = utc_to
                });
                Xdrs = XDRListResponse.xdr_list.ToList();
            }
            else
            {
                var account  = ((customer_info)Session["CurrentAccont"]);
                var customer = new customer_info
                {
                    i_customer = account.i_customer
                };

                XDRListResponse = await customer.GetCustomerXDR(new GetRetailCustomerXDRListRequest { from_date = utc_from, to_date = utc_to });

                Xdrs = XDRListResponse.xdr_list.ToList().Where(x => x.account_id == account.i_customer.ToString()).ToList();
            }

            var RecargaNautas = new List <RecargaNauta>();

            var listaCuentas = new List <customer_info>();


            foreach (var item in Xdrs)
            {
                if (item.XdrIsMovil())
                {
                    var nombreCuenta = "";
                    if (item.account_id != null)
                    {
                        if (listaCuentas.Where(x => x.i_customer.ToString() == item.XdrIdAsociado().ToString()).Any())
                        {
                            nombreCuenta = listaCuentas.Where(x => x.i_customer.ToString() == item.XdrIdAsociado().ToString()).First().firstname;
                        }
                        else
                        {
                            var accountInfo = await((customer_info)Session["CurrentCustomer"]).GetAccountById(item.XdrIdAsociado().ToString());
                            if (accountInfo != null)
                            {
                                nombreCuenta = accountInfo.fullname;
                                listaCuentas.Add(accountInfo);
                            }
                        }
                    }

                    var recarga = new RecargaNauta();
                    recarga.Numero   = item.XdrGetNumero();
                    recarga.Monto    = item.XdrGetMonto();
                    recarga.CostoXdr = item.XdrGetCosto();
                    recarga.Fecha    = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(item.bill_time, "UTC", "US Eastern Standard Time").ToString("yyyy-MM-dd HH:mm:ss");
                    recarga.Asociado = nombreCuenta;
                    RecargaNautas.Add(recarga);
                }
            }

            Session["ListaRecargasNautasHistorial"] = RecargaNautas;

            Session["Registros"] = ((List <RecargaNauta>)Session["ListaRecargasNautasHistorial"]).Count;
            var total = ((List <RecargaNauta>)Session["ListaRecargasNautasHistorial"]).Sum(x => x.CostoXdr);

            Session["Total"] = decimal.Round(Convert.ToDecimal(total), 2);

            return(View((List <RecargaNauta>)Session["ListaRecargasNautasHistorial"]));
        }
Exemple #6
0
 //获取客户信息
 public customer_info getcust_customer(customer_info entity, string where)
 {
     return(DALBaseCommon.getcust_customer(entity, where));
 }
Exemple #7
0
        public async Task <ErrorHandling> SetAccount(customer_info account)
        {
            try
            {
                var now = DateTime.Now;

                var YY = now;
                var MM = now.Month.ToString();
                var DD = now.Day.ToString();

                if (MM.Length == 1)
                {
                    MM = "0" + MM;
                }
                if (DD.Length == 1)
                {
                    DD = "0" + DD;
                }

                var activationDate = now.Year + "-" + MM + "-" + DD;
                account.ComisionDelPadre = IMPUESTO;
                //id de la cuenta
                account.opening_balance = 0;
                account.iso_4217        = "USD";
                account.i_distributor   = await ID_DISTRIBUIDOR();

                account.i_customer_type         = 3; //Online customers
                account.batch_name              = ID_CUENTA + "-di-pinless";
                account.billing_model           = 1;
                account.payment_commission_rate = 100;
                account.sale_commission_rate    = 100;
                account.i_time_zone             = 109;
                account.i_ui_time_zone          = 109;
                account.control_number          = 1;
                account.h323_password           = account.password;
                // account.i_product = 22791;
                account.activation_date = activationDate.Trim();
                account.phone1          = account.phone1;
                account.firstname       = account.firstname;
                account.name            = account.fullname;
                account.lastname        = account.lastname;
                account.email           = account.email;
                account.login           = account.phone1;
                account.password        = account.password;
                account.note            = account.note;
            }
            catch (Exception ex)
            {
                ;
            }

            var valid = await account.Validar();

            if (!valid.faul)
            {
                var result = await account.Crear();

                return(result);
            }
            else
            {
                return(valid);
            }
        }