Пример #1
0
        // Get MatchTickets by Arsenal Matchs
        public static List <MatchTicket> All()
        {
            var mlist = Arsenal_Match.Cache.MatchList;

            if (mlist != null && mlist.Count > 0)
            {
                // Get DataSet of iArsenal_MatchTicket
                var attr = Repository.GetTableAttr <MatchTicket>();
                var sql  = $"SELECT * FROM {attr.Name} ORDER BY {attr.Sort}";
                var ds   = DataAccess.ExecuteDataset(sql);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    var dt = ds.Tables[0];
                    dt.PrimaryKey = new[] { dt.Columns["MatchGuid"] };
                }

                var list = new List <MatchTicket>();

                foreach (var m in mlist)
                {
                    var mt = new MatchTicket {
                        ID = m.ID
                    };

                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        var dr = ds.Tables[0].Rows.Find(m.ID);
                        mt.Init(dr);
                    }
                    else
                    {
                        mt.Init();
                    }

                    list.Add(mt);
                }

                return(list);
            }
            return(null);
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (MatchGuid != Guid.Empty)
                {
                    var mt = new MatchTicket { ID = MatchGuid };
                    mt.Delete();

                    ClientScript.RegisterClientScriptBlock(typeof(string), "succeed", "alert('删除成功');window.location.href='AdminMatchTicket.aspx'", true);
                }
                else
                {
                    throw new Exception("选定的比赛不存在");
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterClientScriptBlock(typeof(string), "failed", $"alert('{ex.Message}')", true);
            }
        }
Пример #3
0
        // Get MatchTickets by Arsenal Matchs
        public static List<MatchTicket> All()
        {
            var mlist = Arsenal_Match.Cache.MatchList;

            if (mlist != null && mlist.Count > 0)
            {
                // Get DataSet of iArsenal_MatchTicket
                var attr = Repository.GetTableAttr<MatchTicket>();
                var sql = $"SELECT * FROM {attr.Name} ORDER BY {attr.Sort}";
                var ds = DataAccess.ExecuteDataset(sql);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    var dt = ds.Tables[0];
                    dt.PrimaryKey = new[] { dt.Columns["MatchGuid"] };
                }

                var list = new List<MatchTicket>();

                foreach (var m in mlist)
                {
                    var mt = new MatchTicket { ID = m.ID };

                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        var dr = ds.Tables[0].Rows.Find(m.ID);
                        mt.Init(dr);
                    }
                    else
                    {
                        mt.Init();
                    }

                    list.Add(mt);
                }

                return list;
            }
            return null;
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                var mt = new MatchTicket { ID = MatchGuid };
                mt.Single();

                DateTime deadline;
                if (!string.IsNullOrEmpty(tbDeadline.Text.Trim()) && DateTime.TryParse(tbDeadline.Text.Trim(), out deadline))
                {
                    mt.Deadline = deadline;
                }
                else
                {
                    mt.Deadline = mt.PlayTime.AddMonths(-2).AddDays(-7);
                }

                if (!string.IsNullOrEmpty(tbWaitingDeadline.Text.Trim()) &&
                    DateTime.TryParse(tbWaitingDeadline.Text.Trim(), out deadline))
                {
                    mt.WaitingDeadline = deadline;
                }
                else
                {
                    mt.WaitingDeadline = mt.PlayTime.AddMonths(-1).AddDays(+7);
                }

                if (!string.IsNullOrEmpty(ddlAllowMemberClass.SelectedValue))
                {
                    mt.AllowMemberClass = Convert.ToInt16(ddlAllowMemberClass.SelectedValue);
                }
                else
                {
                    mt.AllowMemberClass = null;
                }

                mt.IsActive = cbIsActive.Checked;
                mt.Remark = tbRemark.Text.Trim();

                mt.ProductCode = ddlProductCode.SelectedValue;

                // Check whether MatchTicket Instance in DB
                if (mt.Any())
                {
                    mt.Update();

                    MatchTicket.Cache.RefreshCache();

                    ClientScript.RegisterClientScriptBlock(typeof(string), "succeed",
                        "alert('更新成功');window.location.href=window.location.href", true);
                }
                else
                {
                    mt.Create();

                    MatchTicket.Cache.RefreshCache();

                    ClientScript.RegisterClientScriptBlock(typeof(string), "succeed",
                        "alert('添加成功');window.location.href = 'AdminMatchTicket.aspx'", true);
                }
            }
            catch (Exception ex)
            {
                ClientScript.RegisterClientScriptBlock(typeof(string), "failed", $"alert('{ex.Message}')", true);
            }
        }
        private void InitForm()
        {
            if (MatchGuid != Guid.Empty)
            {
                var mt = new MatchTicket { ID = MatchGuid };
                mt.Single();

                // Get Match Info

                lblMatchGuid.Text = mt.ID.ToString();

                if (mt.LeagueGuid.HasValue && !string.IsNullOrEmpty(mt.LeagueName))
                    lblLeagueName.Text = $"<em>{mt.LeagueName}</em>";
                else
                    lblLeagueName.Text = "无";

                lblTeamName.Text = !string.IsNullOrEmpty(mt.TeamName) ? $"<em>{mt.TeamName}</em>" : "无";

                lblIsHome.Text = mt.IsHome ? "主场" : "客场";

                lblRound.Text = mt.Round?.ToString() ?? "/";

                lblPlayTime.Text = $"<em>{mt.PlayTimeLocal.ToString("yyyy-MM-dd HH:mm")}</em>";
                lblResultInfo.Text = $"<em>{mt.ResultInfo}</em>";

                // Get Ticket Info

                ddlProductCode.SelectedValue = mt.ProductCode;
                tbDeadline.Text = mt.Deadline.ToString("yyyy-MM-dd");
                tbWaitingDeadline.Text = mt.WaitingDeadline.ToString("yyyy-MM-dd");

                ddlAllowMemberClass.SelectedValue = mt.AllowMemberClass?.ToString() ?? string.Empty;

                cbIsActive.Checked = mt.IsActive;
                tbRemark.Text = mt.Remark;

                //Bind MatchOrder data of this MatchTicket
                BindItemData();

                //gvMatchOrder.DataSource = mt.OrderTicketList;
                //gvMatchOrder.DataBind();
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(typeof(string), "succeed",
                    "alert('选定的比赛不存在');window.location.href = 'AdminMatchTicket.aspx'", true);
            }
        }