public void AddAutoDrop(int gameplayway, double dropValue, decimal amount, CompanyType companyType)
 {
     //if (num.IsBatterNum() || num.IsRangeNum() || num.IsNumArray())
     //{
     //    AddAutoDrop(GetRangeNum(num), gameplayway, dropValue, amount, companyType);
     //    return;
     //}
     var gpw = LotterySystem.Current.FindGamePlayWay(gameplayway);
     //var drop = DaDropWater.GetDropWater(num, gameplayway, amount, DropType.Auto, (int)companyType);
     var drop = DaDropWater.GetDropWater(gameplayway, amount, DropType.Auto, companyType);
     if (drop != null)
         throw new BusinessException(Resource.AlreadyExist);
     drop = new DropWater
     {
         Num = GetNumArrange(gpw.GameType),
         GamePlayWayId = gameplayway,
         DropValue = dropValue,
         Amount = amount,
         DropType = DropType.Auto,
         CompanyType = (int)companyType
     };
     DaDropWater.Insert(drop);
 }
 public void Insert(DropWater dropWater, int companyId)
 {
     string sql = string.Format(@"INSERT INTO {0} ({1},{2}) VALUES (@{1},@{2})", DropInCompany.TABLENAME, DropInCompany.DROPID, DropInCompany.COMPANYID);
     base.ExecuteNonQuery(sql, new SqlParameter(DropInCompany.DROPID, dropWater.DropId),
         new SqlParameter(DropInCompany.COMPANYID, companyId));
 }
        public void AddTodayDrop(string num, int gameplaywayId, double dropValue, decimal amount, params int[] companys)
        {
            if (num.IsRangeNum() || num.IsBatterNum() || num.IsNumArray() || num.IsStartBatterNum())
            {
                foreach (var n in Extended.GetRangeNum(num))
                    AddTodayDrop(n, gameplaywayId, dropValue, amount, companys);

                return;
            }
            var dws = DaDropWater.ListDropWater(num, DateTime.Today);
            var dw = dws.Find(it => it.Num == num && it.GamePlayWayId == gameplaywayId && it.Amount == amount && it.DropValue == dropValue && it.DropType == DropType.Manual);

            foreach (var company in companys)
            {
                if (dw != null)
                {
                    if (DaDropWater.CountDropWater(dw.DropId, company) > 0)        //公司已添加该跌水的
                        throw new BusinessException(Resource.AlreadyExist);
                    DaDropWater.Insert(dw, company);
                }
                else
                {
                    //同种玩法,同个跌水金额,不同跌水率
                    dw = dws.Find(it => it.Num == num && it.GamePlayWayId == gameplaywayId && it.Amount == amount && it.CompanyId == company);
                    if (dw != null)
                    {
                        throw new BusinessException(Resource.AlreadyExist);
                    }
                    dw = new DropWater
                    {
                        Num = num,
                        DropType = DropType.Manual,
                        DropValue = dropValue,
                        Amount = amount,
                        GamePlayWayId = gameplaywayId
                    };
                    DaDropWater.ExecuteWithTransaction(() =>
                    {
                        DaDropWater.Insert(dw);
                        DaDropWater.Insert(dw, company);
                    });
                }
            }
            UpperLimitManager.GetManager().RefreshLimitNextLimit(num, gameplaywayId);
        }
 public void Insert(DropWater dropWater, DateTime date)
 {
     string sql = string.Format(@"INSERT INTO {0} ({1},{2},{3},{4},{5},{6},{7}) VALUES (@{1},@{2},@{3},@{4},@{5},@{6},@{7}) SELECT SCOPE_IDENTITY()",
         DropWater.TABLENAME, DropWater.NUM, DropWater.GAMEPLAYWAYID, DropWater.DROPVALUE, DropWater.AMOUNT, DropWater.DROPTYPE, DropWater.COMPANYTYPE, DropWater.CREATETIME);
     object id = base.ExecuteScalar(sql, new SqlParameter(DropWater.NUM, dropWater.Num),
         new SqlParameter(DropWater.GAMEPLAYWAYID, dropWater.GamePlayWayId),
         new SqlParameter(DropWater.DROPVALUE, dropWater.DropValue),
         new SqlParameter(DropWater.AMOUNT, dropWater.Amount),
         new SqlParameter(DropWater.DROPTYPE, (int)dropWater.DropType),
         new SqlParameter(DropWater.COMPANYTYPE, dropWater.CompanyType ?? 0),
         new SqlParameter(DropWater.CREATETIME, date));
     dropWater.DropId = Convert.ToInt32(id);
 }