示例#1
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            if (txtGameTypeTitle.Text.Trim().Length == 0)
            {
                Javascript.GoHistory(-1, "请填写活动类型名称:)", Page);
                return;
            }

            int groupCapability = 0;
            if (!(CommonUtility.SafeCheckByParams<String>(txtGroupCapability.Text.Trim(), ref groupCapability) && groupCapability > 0))
            {
                Javascript.GoHistory(-1, "每组人数必须为大于0的整数,请修改:)", Page);
                return;
            }

            try
            {
                DalOperationAboutGameType dal = new DalOperationAboutGameType();
                dal.Add(new GameType { gameTypeTitle = txtGameTypeTitle.Text.Trim(), updateTime = DateTime.Now, allowSexType = rblTeacher.SelectedValue, groupCapability = groupCapability, gameCategoryId = int.Parse(ddlGameCategory.SelectedValue) });

                Javascript.RefreshParentWindow("添加活动类型成功:)", "/Administrator/DrawManage.aspx?fragment=2&page=" + pageIndex, Page);
            }
            catch (Exception ex)
            {
                MongoDBLog.LogRecord(ex);
                Javascript.GoHistory(-1, "添加活动类型失败:(", Page);
                return;
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DalOperationAboutGameCategory dalGC = new DalOperationAboutGameCategory();
                DataTable dtGC = dalGC.GetList().Tables[0];

                for (int i = 0; i < dtGC.Rows.Count; i++)
                {
                    ddlGameCategory.Items.Add(new ListItem(dtGC.Rows[i]["gameTitle"].ToString().Trim(), dtGC.Rows[i]["gameCategoryId"].ToString().Trim()));
                }

                DalOperationAboutGameType dal = new DalOperationAboutGameType();
                DataTable dt = dal.Get(gameTypeId).Tables[0];

                if (dt.Rows.Count > 0)
                {
                    txtGameTypeTitle.Text = dt.Rows[0]["gameTypeTitle"].ToString().Trim();

                    string _allowSexType = dt.Rows[0]["allowSexType"].ToString().Trim();

                    txtGroupCapability.Text = dt.Rows[0]["groupCapability"].ToString().Trim();
                    hidGroupCapability.Value = dt.Rows[0]["groupCapability"].ToString().Trim();

                    for (int i = 0; i < ddlGameCategory.Items.Count; i++)
                    {
                        if (ddlGameCategory.Items[i].Value == dt.Rows[0]["gameCategoryId"].ToString().Trim())
                        {
                            ddlGameCategory.SelectedIndex = i;
                            break;
                        }
                    }

                    foreach (ListItem rbt in rblTeacher.Items)
                    {
                        if (rbt.Value == _allowSexType)
                        {
                            rbt.Selected = true;
                        }
                    }
                }
            }
        }
示例#3
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            if (txtGameTypeTitle.Text.Trim().Length == 0)
            {
                Javascript.GoHistory(-1, "请填写活动类型名称:)", Page);
                return;
            }

            int groupCapability = 0;
            if (!(CommonUtility.SafeCheckByParams<String>(txtGroupCapability.Text.Trim(), ref groupCapability) && groupCapability > 0))
            {
                Javascript.GoHistory(-1, "每组人数必须为大于0的整数,请修改:)", Page);
                return;
            }

            try
            {
                DalOperationAboutGameType dal = new DalOperationAboutGameType();

                //如果修改了组容量值,则首先判断是否已经有人开始抽签,如果有的话,则不允许修改组容量,但是可以修改其他内容
                if (txtGroupCapability.Text.Trim() != hidGroupCapability.Value.Trim())
                {
                    DalOperationAboutGameDrawList _dal = new DalOperationAboutGameDrawList();
                    if (_dal.CheckIsDrawByGameCategoryId(int.Parse(ddlGameCategory.SelectedValue), gameTypeId).Tables[0].Rows.Count > 0)
                    {
                        Javascript.GoHistory(-1, "当有已有教师参加抽签,禁止修改分组人数,因为这样会造成抽签数据错误,\\n,请重新发布活动届次!", Page);
                        return;
                    }
                }

                dal.Update(new GameType { gameTypeTitle = txtGameTypeTitle.Text.Trim(), updateTime = DateTime.Now, allowSexType = rblTeacher.SelectedValue, gameTypeId = gameTypeId, groupCapability = groupCapability, gameCategoryId = int.Parse(ddlGameCategory.SelectedValue) });

                Javascript.RefreshParentWindow("修改活动类型成功:)", "/Administrator/DrawManage.aspx?fragment=2", Page);
            }
            catch (Exception ex)
            {
                MongoDBLog.LogRecord(ex);
                Javascript.GoHistory(-1, "修改活动类型失败:(", Page);
                return;
            }
        }
示例#4
0
        public void DataBindGameCategoryAndType(DropDownList ddlGameCategory, DropDownList ddlGameType)
        {
            UserCookiesInfo user = BllOperationAboutUser.GetUserCookiesInfo();

            DalOperationAboutGameCategory dalGameCategory = new DalOperationAboutGameCategory();

            DataTable dtGameCategory =  dalGameCategory.GetList().Tables[0];

            for (int i = 0; i < dtGameCategory.Rows.Count; i++)
            {
                ddlGameCategory.Items.Add(new ListItem(dtGameCategory.Rows[i]["gameTitle"].ToString().Trim(), dtGameCategory.Rows[i]["gameCategoryId"].ToString().Trim()));
            }

            DalOperationAboutGameType dalGameType = new DalOperationAboutGameType();

            DataTable dtGameType = dalGameType.GetGameTypeByGameCategoryId(int.Parse(ddlGameCategory.SelectedValue)).Tables[0];

            for (int i = 0; i < dtGameType.Rows.Count; i++)
            {
                ddlGameType.Items.Add(new ListItem(dtGameType.Rows[i]["gameTypeTitle"].ToString().Trim(), dtGameType.Rows[i]["gameTypeId"].ToString().Trim()));
            }
        }
示例#5
0
 protected void dlGameType_ItemCommand(object source, DataListCommandEventArgs e)
 {
     DalOperationAboutGameType doan = new DalOperationAboutGameType();
     if (e.CommandName == "delete")
     {
         string gameTypeId = dlGameType.DataKeys[e.Item.ItemIndex].ToString();//取选中行公告编号
         doan.Delete(int.Parse(gameTypeId));
         Javascript.AlertAndRedirect("删除成功!", "/Administrator/DrawManage.aspx?fragment=2&page=" + pageIndex, Page);
     }
 }
示例#6
0
        //第1个标签;开始
        protected void ddlGameCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            while (ddlGameType.Items.Count > 0)
            {
                ddlGameType.Items.RemoveAt(0);
            }

            DalOperationAboutGameType dal = new DalOperationAboutGameType();

            DataTable dt = dal.GetGameTypeByGameCategoryId(int.Parse(ddlGameCategory.SelectedValue)).Tables[0];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ddlGameType.Items.Add(new ListItem(dt.Rows[i]["gameTypeTitle"].ToString().Trim(), dt.Rows[i]["gameTypeId"].ToString().Trim()));
            }

            DataListBindEnrollList();
        }
示例#7
0
        //绑定信息
        public void DataListBindGameType()
        {
            DalOperationAboutGameType doan = new DalOperationAboutGameType();
            DataTable dt = doan.GetGameTypeByGameCategoryId(int.Parse(ddlGameCategoryAboutGameType.SelectedValue)).Tables[0];

            this.dlGameType.DataSource = dt;
            this.dlGameType.DataBind();

            if (dt.Rows.Count == 0)
            {
                this.dlGameType.ShowFooter = true;
            }
            else
            {
                this.dlGameType.ShowFooter = false;
            }
        }
示例#8
0
        public void DataBindGameCategoryAndType(DropDownList ddlGameCategory, DropDownList ddlGameType)
        {
            UserCookiesInfo user = BllOperationAboutUser.GetUserCookiesInfo();

            DalOperationAboutGameCategory dalGameCategory = new DalOperationAboutGameCategory();

            DataTable dtGameCategory = (ddlGameCategory.ID == "ddlEnrollGameCategory" ? dalGameCategory.GetGameCategoryIng(DateTime.Now).Tables[0] : dalGameCategory.GetList().Tables[0]);

            for (int i = 0; i < dtGameCategory.Rows.Count; i++)
            {
                ddlGameCategory.Items.Add(new ListItem(dtGameCategory.Rows[i]["gameTitle"].ToString().Trim(), dtGameCategory.Rows[i]["gameCategoryId"].ToString().Trim()));
            }

            //检查是否有活动届次数据

            if (ddlGameCategory.Items.Count == 0)
            {
                Javascript.AlertAndRedirect("当前暂无需要报名的活动届次信息:(", "/Administrator/EnrollManage.aspx?fragment=2", Page);
                return;
            }

            if (CommonUtility.SafeCheckByParams<String>(gameCategoryId, ref _gameCategoryId))
            {
                for (int i = 0; i < ddlGameCategory.Items.Count; i++)
                {
                    if (ddlGameCategory.Items[i].Value == gameCategoryId)
                    {
                        ddlGameCategory.SelectedIndex = i;
                        break;
                    }
                }
            }

            DalOperationAboutGameType dalGameType = new DalOperationAboutGameType();

            DataTable dtGameType = (ddlGameType.ID == "ddlEnrollGameType" || ddlGameType.ID == "ddlGameType" ? dalGameType.GetListByGameCategoryIdAndSex(int.Parse(ddlGameCategory.SelectedValue), user.Sex == "男" ? "1" : "2").Tables[0] : dalGameType.GetGameTypeByGameCategoryId(int.Parse(ddlGameCategory.SelectedValue)).Tables[0]);

            for (int i = 0; i < dtGameType.Rows.Count; i++)
            {
                ddlGameType.Items.Add(new ListItem(dtGameType.Rows[i]["gameTypeTitle"].ToString().Trim(), dtGameType.Rows[i]["gameTypeId"].ToString().Trim()));
            }

            if (CommonUtility.SafeCheckByParams<String>(gameTypeId, ref _gameCategoryId))
            {
                for (int i = 0; i < ddlGameType.Items.Count; i++)
                {
                    if (ddlGameType.Items[i].Value == gameTypeId)
                    {
                        ddlGameType.SelectedIndex = i;
                        break;
                    }
                }
            }

            //检查是否有活动届次和活动类型数据

            if (!(ddlGameCategory.Items.Count > 0 && ddlGameType.Items.Count > 0))
            {
                Javascript.AlertAndRedirect("当前暂无需要报名的活动届次信息:(", "/Administrator/EnrollManage.aspx?fragment=2", Page);
                return;
            }
        }
示例#9
0
        protected void dlEnroll_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                UserCookiesInfo user = BllOperationAboutUser.GetUserCookiesInfo();

                DalOperationAboutGameDrawList dal = new DalOperationAboutGameDrawList();
                if (e.CommandName == "draw")
                {
                    int gameCategoryId = int.Parse(e.CommandArgument.ToString().Split(",".ToCharArray())[0]);
                    int gameTypeId = int.Parse(e.CommandArgument.ToString().Split(",".ToCharArray())[1]);

                    DalOperationAboutGameCategory dalgc = new DalOperationAboutGameCategory();
                    DataTable _dt = dalgc.CheckIsOpenDrawByGameCategoryId(gameCategoryId).Tables[0];
                    //首先判断当前届次和活动类型是否已经开放抽签
                    if (_dt.Rows.Count == 0)
                    {
                        Javascript.GoHistory(-1, "参数错误:(", Page);
                        return;
                    }

                    if (_dt.Rows[0]["isOpenDraw"].ToString().Trim() != "1")
                    {
                        Javascript.GoHistory(-1, "当前活动届次和活动类型暂未开放抽签:(", Page);
                        return;
                    }

                    //其次判断是否已经抽过签
                    if (dal.Exists(user.userNo, gameCategoryId, gameTypeId) > 0)
                    {
                        Javascript.GoHistory(-1, "当前活动届次和活动类型已经抽过签,请勿重复抽签哟:)", Page);
                        return;
                    }
                    //使用事务进行抽签控制
                    using (TransactionScope scope = new TransactionScope())
                    {
                        try
                        {
                            DalOperationAboutGameType dalgt = new DalOperationAboutGameType();
                            //首先获取组容量
                            int _groupCapability = int.Parse(dalgt.GetGroupCapabilityByGameTypeId(gameCategoryId, gameTypeId).Tables[0].Rows[0]["groupCapability"].ToString().Trim());
                            //其次获取总报名人数
                            DalOperationAboutGameEnrollList dalel = new DalOperationAboutGameEnrollList();
                            int _enrollListCount = int.Parse(dalel.GetEnrollListCountByGameCategoryIdAndGameTypeId(gameCategoryId, gameTypeId).Tables[0].Rows[0][0].ToString().Trim());

                            //获取分组数
                            int groupMod = _enrollListCount % _groupCapability;

                            int groupCount = 0;

                            if (groupMod == 0)
                            {
                                groupCount = _enrollListCount / _groupCapability;
                            }
                            else
                            {
                                groupCount = (_enrollListCount / _groupCapability) + 1;
                            }

                            //先判断需要几个字母
                            string characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                            //所需要使用的字母个数
                            string usedCharacters = characters.Substring(0, groupCount);
                            //Response.Write(usedCharacters.Length);

                            List<string> listGroupNumAndIndex = new List<string>();

                            List<string> listNotUsedGroupNumAndIndex = new List<string>();

                            for (int i = 0; i < usedCharacters.Length; i++)
                            {
                                for (int j = 0; j < _groupCapability; j++)
                                {
                                    //最后一组编号需要连续,因此需要进行特殊处理
                                    if (groupMod != 0)
                                    {
                                        //访问到最后一组
                                        if (i == usedCharacters.Length - 1)
                                        {
                                            if (groupMod >= j + 1)
                                            {
                                                //Response.Write(usedCharacters.Substring(i, 1) + (j + 1).ToString() + "ss<br/>");
                                                listGroupNumAndIndex.Add(usedCharacters.Substring(i, 1) + (j + 1).ToString());
                                            }
                                        }
                                        else
                                        {
                                            listGroupNumAndIndex.Add(usedCharacters.Substring(i, 1) + (j + 1).ToString());
                                        }
                                    }
                                    else
                                    {
                                        //Response.Write(usedCharacters.Substring(i, 1) + (j + 1).ToString() + "aa<br/>");
                                        listGroupNumAndIndex.Add(usedCharacters.Substring(i, 1) + (j + 1).ToString());
                                    }
                                }
                            }
                            //Response.Write(listGroupNumAndIndex.Count + "<br/>");

                            //获取已经使用的编号列表
                            DataTable _dtGroupNumAndIndex = dal.GetGroupNumAndIndexByGameCategoryIdAndGameTypeId(gameCategoryId, gameTypeId).Tables[0];

                            List<string> listGroupNumAndIndexCopy = new List<string>();

                            foreach (string _item in listGroupNumAndIndex)
                            {
                                //Response.Write(_item + "<br/>");
                                listGroupNumAndIndexCopy.Add(_item);
                            }

                            foreach (string _item in listGroupNumAndIndex)
                            {
                                for (int j = 0; j < _dtGroupNumAndIndex.Rows.Count; j++)
                                {
                                    if (_dtGroupNumAndIndex.Rows[j]["groupNumAndIndex"].ToString().Trim() == _item)
                                    {
                                        //Response.Write(_item + "<br/>");
                                        //移除已使用的编号
                                        listGroupNumAndIndexCopy.Remove(_item);
                                    }
                                }
                            }

                            //Response.Write(listGroupNumAndIndexCopy.Count + "<br/>");

                            //为使效果更随机,再次对编号数组使用随机方法打乱
                            while (listGroupNumAndIndexCopy.Count > 0)
                            {
                                Random random = new Random();
                                int _index = int.Parse(random.NextDouble().ToString().Substring(2, 4)) % listGroupNumAndIndexCopy.Count;

                                listNotUsedGroupNumAndIndex.Insert(0, listGroupNumAndIndexCopy[_index]);

                                listGroupNumAndIndexCopy.RemoveAt(_index);
                            }

                            //Response.Write(groupMod + "groupMod<br/>");

                            //Response.Write(groupCount + "groupCount<br/>");

                            //Response.Write(listNotUsedGroupNumAndIndex.Count + "listNotUsedGroupNumAndIndex<br/>");

                            Random random1 = new Random();

                            int _index1 = int.Parse(random1.NextDouble().ToString().Substring(2, 4)) % listNotUsedGroupNumAndIndex.Count;
                            //Response.Write(_index1 + "<br/>");
                            //Response.End();

                            //得到随机取到的编号值
                            string _result = string.Empty;

                            _result = listNotUsedGroupNumAndIndex[_index1];

                            if (string.IsNullOrEmpty(_result))
                            {
                                Javascript.GoHistory(-1, "抽签失败:(,请重试", Page);
                                return;
                            }

                            dal.Add(new GameDrawList { gameCategoryId = gameCategoryId, gameTypeId = gameTypeId, groupIndex = int.Parse(_result.Substring(1, 1)), groupNum = _result.Substring(0, 1), updateTime = DateTime.Now, teacherNo = user.userNo });
                            scope.Complete();
                            Javascript.AlertAndRedirect("抽签成功!", "/Administrator/EnrollManage.aspx?fragment=2&page=" + pageIndex + "&gameCategoryId=" + gameCategoryId + "&gameTypeId=" + gameTypeId, Page);
                        }
                        catch (System.Exception ex)
                        {
                            MongoDBLog.LogRecord(ex);
                            Javascript.GoHistory(-1, "抽签失败:(,请重试", Page);
                        }
                    }
                }
            }
        }
示例#10
0
        //第1个标签;开始
        protected void ddlEnrollGameCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            UserCookiesInfo user = BllOperationAboutUser.GetUserCookiesInfo();

            while (ddlEnrollGameType.Items.Count > 0)
            {
                ddlEnrollGameType.Items.RemoveAt(0);
            }
            DalOperationAboutGameType dalGameType = new DalOperationAboutGameType();

            DataTable dtGameType = dalGameType.GetListByGameCategoryIdAndSex(int.Parse(ddlEnrollGameCategory.SelectedValue), user.Sex == "男" ? "1" : "2").Tables[0];

            for (int i = 0; i < dtGameType.Rows.Count; i++)
            {
                ddlEnrollGameType.Items.Add(new ListItem(dtGameType.Rows[i]["gameTypeTitle"].ToString().Trim(), dtGameType.Rows[i]["gameTypeId"].ToString().Trim()));
            }

            //检查是否有活动届次和活动类型数据

            if (!(ddlEnrollGameCategory.Items.Count > 0 && ddlEnrollGameType.Items.Count > 0))
            {
                Javascript.AlertAndRedirect("当前暂无需要报名的活动届次信息:(", "/Administrator/EnrollManage.aspx?fragment=2", Page);
                return;
            }
        }