예제 #1
0
        public void GetRmb_Test()
        {
            var expected1 = "壹佰玖拾玖元捌角伍分";
            var actual1   = MoneyUtil.GetRmb(199.85M);

            Assert.Equal(expected1, actual1);

            var expected2 = "玖拾捌亿零伍仟元整";
            var actual2   = MoneyUtil.GetRmb(9800005000M);

            Assert.Equal(expected2, actual2);

            var expected3 = "玖拾万零捌仟捌佰捌拾捌元贰角整";
            var actual3   = MoneyUtil.GetRmb("908888.2");

            Assert.Equal(expected3, actual3);

            var expected4 = "玖万元整";
            var actual4   = MoneyUtil.GetRmb(90000);

            Assert.Equal(expected4, actual4);

            var expected5 = "贰拾万零伍拾元整";
            var actual5   = MoneyUtil.GetRmb(200050);

            Assert.Equal(expected5, actual5);

            Assert.Equal("零元整", MoneyUtil.GetRmb(0M));
            Assert.Equal("溢出", MoneyUtil.GetRmb(1234567890123456M));
        }
예제 #2
0
        public void ShouldGetRateMoney()
        {
            MoneyUtil moneyUtil = new MoneyUtil();
            int       x         = moneyUtil.GetMoneyRate("usd");

            Assert.AreNotEqual(x, 1);
        }
예제 #3
0
        private void calculator2()
        {
            double quantity = Convert.ToDouble(nudQuantity2.Value);
            double rate     = Convert.ToDouble(nudRate2.Value);

            if (quantity == 0 || rate == 0)
            {
                return;
            }

            double realQuantity = Math.Ceiling(quantity * rate / 100.0);

            tbQuantity2.Text = Convert.ToInt32(realQuantity).ToString("N0");

            long quantity2 = Convert.ToInt64(tbQuantity2.Text.Replace(",", ""));

            lbQuantity2.Text = MoneyUtil.Number2Hangle(quantity2) + "개";
        }
예제 #4
0
        private void calculator()
        {
            double fund  = Convert.ToDouble(nudFund.Value);
            double rate  = Convert.ToDouble(nudRate.Value);
            double price = Convert.ToDouble(nudPrice.Value);

            if (fund == 0 || rate == 0 || price == 0)
            {
                return;
            }

            double realFund     = Math.Ceiling(fund * rate / 100.0);
            double realQuantity = Math.Ceiling(realFund / price);

            tbQuantity.Text = Convert.ToInt32(realQuantity).ToString("N0");

            long fund2 = Convert.ToInt64(fund);

            lbMoney.Text = MoneyUtil.Number2Hangle(fund2) + "원";

            long quantity = Convert.ToInt64(tbQuantity.Text.Replace(",", ""));

            lbQuantity.Text = MoneyUtil.Number2Hangle(quantity) + "개";
        }
예제 #5
0
        public void GivenParse_WhenNonDefaultCultureInput_ValueIsReturned(string input, decimal expected)
        {
            decimal value = new MoneyUtil(CultureInfo.CreateSpecificCulture("da-DK")).Parse(input);

            Assert.Equal(expected, value);
        }
예제 #6
0
        public void GivenParse_WhenValidInput_ValueIsReturned(string input, decimal expected)
        {
            decimal value = new MoneyUtil().Parse(input);

            Assert.Equal(expected, value);
        }
예제 #7
0
 public bool ProcessZhuanPanChouJiangCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         if (!CheckHelper.CheckCmdLengthAndRole(client, nID, cmdParams, 2))
         {
             return(false);
         }
         int      roleID                    = Convert.ToInt32(cmdParams[0]);
         int      awardType                 = Convert.ToInt32(cmdParams[1]);
         DateTime now                       = TimeUtil.NowDateTime();
         ZhuanPanChouJiangData data         = new ZhuanPanChouJiangData();
         List <ZhuanPanItem>   zhuanPanList = new List <ZhuanPanItem>();
         int awardID = 0;
         int binding = 1;
         data.AwardType = awardType;
         lock (ZhuanPanManager.ZhuanPanRunTimeData.Mutex)
         {
             int addHours       = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanFree;
             int moneyTypeIndex = awardType - 1;
             if (moneyTypeIndex < 0 || moneyTypeIndex >= ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanConstArray.Count)
             {
                 data.Result = -200;
                 client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                 return(true);
             }
             int moneyType = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanConstArray[moneyTypeIndex][0];
             int subMoney  = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanConstArray[moneyTypeIndex][1];
             if (moneyType <= 0 || subMoney <= 0)
             {
                 data.Result = -200;
                 client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                 return(true);
             }
             int fuLiCount = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanZuanShiFuLi;
             Dictionary <int, Dictionary <int, ZhuanPanAwardItem> > zhuanPanAwardDict = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanAwardXmlDict;
             zhuanPanList = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanItemXmlList;
             if (now < ZhuanPanManager.ZhuanPanRunTimeData.BeginTime || now > ZhuanPanManager.ZhuanPanRunTimeData.EndTime)
             {
                 data.Result = -100;
                 client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                 return(true);
             }
             DateTime chouJiangTime = Global.GetRoleParamsDateTimeFromDB(client, "10165");
             if (chouJiangTime < ZhuanPanManager.ZhuanPanRunTimeData.BeginTime)
             {
                 chouJiangTime = ZhuanPanManager.ZhuanPanRunTimeData.BeginTime;
                 Global.SaveRoleParamsDateTimeToDB(client, "10165", chouJiangTime, true);
                 Global.SaveRoleParamsInt32ValueToDB(client, "10162", 0, true);
             }
             DateTime nextChouJiang = DateTime.MaxValue;
             if (addHours > 0)
             {
                 nextChouJiang = Global.GetRoleParamsDateTimeFromDB(client, "10155").AddHours((double)addHours);
             }
             if (!Global.CanAddGoodsNum(client, 1) || !RebornEquip.CanAddGoodsNum(client, 1))
             {
                 data.Result = -4;
                 client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                 return(true);
             }
             awardID = Global.GetRoleParamsInt32FromDB(client, "10162");
             if (awardID > 0)
             {
                 data.Result = -202;
                 client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                 return(true);
             }
             Dictionary <int, ZhuanPanAwardItem> zhuanPanAwardItemDict = null;
             if (!zhuanPanAwardDict.TryGetValue(awardType, out zhuanPanAwardItemDict))
             {
                 data.Result = -101;
                 client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                 return(true);
             }
             int roleFuliCout = Global.GetRoleParamsInt32FromDB(client, "10156");
             data.LeftFuLiCount = roleFuliCout;
             data.FreeTime      = nextChouJiang;
             bool free = false;
             if (awardType == 3)
             {
                 if (!zhuanPanAwardDict.ContainsKey(4))
                 {
                     data.Result = -101;
                     client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                     return(true);
                 }
                 if (now > nextChouJiang)
                 {
                     data.FreeTime = now.AddHours((double)addHours);
                     free          = true;
                 }
             }
             if (!free)
             {
                 if (!MoneyUtil.CheckHasMoney(client, moneyType, subMoney))
                 {
                     data.Result = -awardType;
                     client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                     return(true);
                 }
                 string strCostList = "";
                 if (!MoneyUtil.CostMoney(client, moneyType, subMoney, ref strCostList, "转盘抽奖", true))
                 {
                     data.Result = -awardType;
                     client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                     return(true);
                 }
             }
             if (awardType == 3)
             {
                 if (now > nextChouJiang)
                 {
                     Global.SaveRoleParamsDateTimeToDB(client, "10155", now, true);
                     data.FreeTime = now.AddHours((double)addHours);
                 }
                 else
                 {
                     binding = 0;
                     roleFuliCout--;
                     if (roleFuliCout < 1)
                     {
                         if (!zhuanPanAwardDict.TryGetValue(4, out zhuanPanAwardItemDict))
                         {
                             data.Result = -101;
                             client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                             return(true);
                         }
                         roleFuliCout = fuLiCount;
                         awardType    = 4;
                     }
                     if (roleFuliCout > ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanZuanShiFuLi)
                     {
                         roleFuliCout = ZhuanPanManager.ZhuanPanRunTimeData.ZhuanPanZuanShiFuLi;
                     }
                     Global.SaveRoleParamsInt32ValueToDB(client, "10156", roleFuliCout, true);
                     data.LeftFuLiCount = roleFuliCout;
                 }
             }
             int random = Global.GetRandomNumber(1, 100000);
             foreach (KeyValuePair <int, ZhuanPanAwardItem> item in zhuanPanAwardItemDict)
             {
                 if (random >= item.Value.StartValue && random <= item.Value.EndValue)
                 {
                     awardID = item.Key;
                 }
             }
             if (zhuanPanList.Count < awardID || awardID <= 0)
             {
                 LogManager.WriteLog(LogTypes.Fatal, string.Format("转盘抽奖随机出的awardID={0}找不到对应的奖励配置", awardID), null, true);
                 data.Result = -201;
                 client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                 return(true);
             }
             data.Result = 1;
             ZhuanPanItem  award       = zhuanPanList[awardID - 1];
             SystemXmlItem systemGoods = null;
             int           goodID      = Convert.ToInt32(award.GoodsID.Split(new char[]
             {
                 ','
             })[0]);
             if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(goodID, out systemGoods))
             {
                 LogManager.WriteLog(LogTypes.Fatal, string.Format("转盘抽奖随机出的goodID={0}道具表中不存在", goodID), null, true);
                 string strinfo = string.Format("系统中不存在{0}", goodID);
                 GameManager.ClientMgr.SendSystemChatMessageToClient(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, strinfo);
                 data.Result = -201;
                 client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
                 return(true);
             }
             string goodName = systemGoods.GetStringValue("Title");
             if (awardType == 3 && binding > 0)
             {
                 awardType = 4;
             }
             GameManager.logDBCmdMgr.AddDBLogInfo(-1, goodName, "转盘抽奖_类型:" + awardType, client.ClientData.RoleName, "系统", "修改", -1, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, null);
             string[] goods = award.GoodsID.Split(new char[]
             {
                 ','
             });
             goods[2]       = binding.ToString();
             data.GoodsItem = new ZhuanPanItem
             {
                 ID         = award.ID,
                 GoodsID    = string.Join(",", goods),
                 AwardLevel = award.AwardLevel,
                 GongGao    = award.GongGao,
                 AwardLabel = award.AwardLevel
             };
         }
         Global.SaveRoleParamsInt32ValueToDB(client, "10162", awardID, true);
         Global.SaveRoleParamsDateTimeToDB(client, "10165", now, true);
         Global.SaveRoleParamsInt32ValueToDB(client, "10166", binding, true);
         data.AwardType = awardType;
         client.sendCmd <ZhuanPanChouJiangData>(nID, data, false);
         client._IconStateMgr.CheckFreeZhuanPanChouState(client);
         client._IconStateMgr.SendIconStateToClient(client);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
예제 #8
0
        private void LoadServerConsultingSummary()
        {
            DataTable dtSummary = this.srvServerConsulting.SearchByParameters(
                "ServerConsulting.ServerConsultingSummary", null);

            this.frmServerConsulting.grdDetSummary.DataSource = null;
            this.frmServerConsulting.grdDetSummary.DataSource = dtSummary;

            dtSummary.Rows.Clear();

            if (this.serverConsulting.OrganizationName != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Organización";
                row["Description"] = this.serverConsulting.OrganizationName;
            }

            if (this.serverConsulting.Contact != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Contacto";
                row["Description"] = this.serverConsulting.Contact;
            }

            if (this.serverConsulting.Email != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = this.frmServerConsulting.ulblDetEmail.Text;
                row["Description"] = this.serverConsulting.Email;
            }

            if (this.serverConsulting.PhoneNumber != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Teléfono";
                row["Description"] = this.serverConsulting.PhoneNumber;
            }

            if (this.serverConsulting.ExtensionNumber != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Extensión";
                row["Description"] = this.serverConsulting.ExtensionNumber;
            }

            if (Convert.ToBoolean(this.serverConsulting.HasServer))
            {
                ServerConsultingOldServerComputer serverConsultingOldServerComputer
                    = this.serverConsulting.ServerConsultingOldServerComputers.First();

                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = this.frmServerConsulting.utabDetOldServerDetail.Tabs["ActualServer"].Text;
                row["Description"] = string.Format(@"
Tipo:   {0}
Marca:  {1}
Modelo: {2}
Sistema Operativo: {3}
Especificaciones: {4}
                    ", serverConsultingOldServerComputer.ServerComputerType,
                                                   serverConsultingOldServerComputer.ServerComputerBrand,
                                                   serverConsultingOldServerComputer.ServerModel,
                                                   serverConsultingOldServerComputer.OperativeSystem,
                                                   serverConsultingOldServerComputer.ServerSpecs).Trim();
            }
            else
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Cuentan con un Servidor?";
                row["Description"] = this.frmServerConsulting.uosDetHasServer.Text;

                row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = this.frmServerConsulting.ulblDetFirstServer.Text;
                row["Description"] = this.frmServerConsulting.uosDetFirstServer.Text;
            }

            if (this.serverConsulting.ServerUsage != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Uso del Servidor";
                row["Description"] = this.serverConsulting.ServerUsage;
            }

            if (this.serverConsulting.CurrentProblem != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Necesidad/Problematica Actual";
                row["Description"] = this.serverConsulting.CurrentProblem;
            }

            if (this.serverConsulting.NumberOfUsers != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Número de Usuarios";
                row["Description"] = this.serverConsulting.NumberOfUsers;
            }

            if (this.serverConsulting.FutureNumberOfUsers != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Número de Usuarios en 3 a 5 Años";
                row["Description"] = this.serverConsulting.FutureNumberOfUsers;
            }

            if (this.serverConsulting.CurrentStorageVolume != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Tamaño de la Información Actual";
                row["Description"] = Math.Round(this.serverConsulting.CurrentStorageVolume.Value, 2) + " GB";
            }

            if (this.serverConsulting.FutureStorageVolume != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Tamaño de la Información en 3 a 5 Años";
                row["Description"] = Math.Round(this.serverConsulting.FutureStorageVolume.Value, 2) + " GB";
            }

            if (this.serverConsulting.BrandPreference != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Marca Preferida";
                row["Description"] = this.serverConsulting.BrandPreference;
            }

            if (this.serverConsulting.FullServerUptimeRequired.Value)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Alta Disponibilidad (24/7)";
                row["Description"] = this.frmServerConsulting.uosDetFullServerUptimeRequired.Text;
            }

            if (this.serverConsulting.RedundantPowerSupply.Value)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = this.frmServerConsulting.uchkDetRedundantPowerSupply.Text;
                row["Description"] = this.serverConsulting.RedundantPowerSupply.Value ? "Si" : "No";
            }

            if (this.serverConsulting.ArrayDisks != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = this.frmServerConsulting.ugbxDetArrayDisks.Text;
                row["Description"] = this.serverConsulting.ArrayDisks;
            }

            if (this.serverConsulting.Budget != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Presupuesto";
                row["Description"] = MoneyUtil.Round(this.serverConsulting.Budget.Value);
            }

            if (this.serverConsulting.HaveSite.Value)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Cuentan con Site?";
                row["Description"] = this.frmServerConsulting.uosDetHaveSite.Text;
            }

            if (this.serverConsulting.ServerComputerType != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Tipo de Servidor Preferido";
                row["Description"] = this.serverConsulting.ServerComputerType.Name;
            }

            if (this.serverConsulting.OtherServerComputerTypePreference != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Tipo de Servidor Preferido";
                row["Description"] = this.serverConsulting.OtherServerComputerTypePreference;
            }

            if (this.serverConsulting.DataMigration != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Requiere Migración de Datos";
                row["Description"] = this.serverConsulting.DataMigration.Value ? "Si" : "No";
            }

            if (this.serverConsulting.DataBackup != null)
            {
                DataRow row = dtSummary.NewRow();
                dtSummary.Rows.Add(row);

                row["Data"]        = "Requiere Respaldo de Datos";
                row["Description"] = this.serverConsulting.DataBackup.Value ? "Si" : "No";
            }

            dtSummary.AcceptChanges();

            foreach (UltraGridRow row in this.frmServerConsulting.grdDetSummary.Rows)
            {
                row.PerformAutoSize();
            }
        }