Esempio n. 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtAward.Text))
            {
                MessageBox.Show("Vui lòng nhập tên giải thưởng!。", "Lời nhắn");
                return;
            }

            try {
                if (awardDal.IsExist(txtAward.Text))
                {
                    if (MessageBox.Show("Giải Thưởng đã tồn tại!,Bạn muốn cập nhật?", "Lời nhắn", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
                    {
                        return;
                    }
                }

                int tcount = 0;
                int.TryParse(nudtcount.Value.ToString(), out tcount);

                int oncecount = 0;
                int.TryParse(nudonce.Value.ToString(), out oncecount);

                int seq = 0;
                int.TryParse(nudSort.Value.ToString(), out seq);

                awardDal.AddAward(txtAward.Text, tcount, oncecount, seq);
                BindAward();
                //txtAward.Text = "";
                txtAward.Focus();
            } catch (Exception ex) {
                MessageBox.Show(ex.Message, "Lời nhắn");
            }
        }
Esempio n. 2
0
        public async Task AddUserAward(IUser user = null, string aCategory = null, string aText = null)
        {
            if (user == null || aCategory == null || aText == null)
            {
                EmbedBuilder eb = new EmbedBuilder
                {
                    Title       = "Invalid Syntax",
                    Description = "**Syntax:** " + Guild.Load(Context.Guild.Id).Prefix + "giveaward [user] [award category] [award name]",
                    Color       = new Color(210, 47, 33)
                };

                eb.AddField("Notes", "Be sure to use speech marks (\"\") when specifying an award category or name!");
                eb.WithCurrentTimestamp();

                await ReplyAsync("", false, eb.Build());

                return;
            }

            Award.AddAward(user.Id, aCategory, aText);

            AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id, user.Id);

            EmbedBuilder replyEmbed = new EmbedBuilder()
            {
                Title       = "Congratulations " + user.Username + "!",
                Color       = new Color(0, 255, 0),
                Description = user.Mention + " earned an award!",
                Footer      = new EmbedFooterBuilder()
                {
                    Text = "Awarded by " + Context.User.Username + " (AID: " + Award.Awards[Award.Awards.Count - 1].AwardId + ")"
                }
            }
            .AddField("Award Category", aCategory)
            .AddField("Award", aText)
            .WithCurrentTimestamp();

            await ReplyAsync("", false, replyEmbed.Build());

            replyEmbed = new EmbedBuilder()
            {
                Title       = "New Award",
                Description = user.Mention + " was given an award by " + Context.User.Mention,
                Footer      = new EmbedFooterBuilder()
                {
                    Text = "ID: " + Award.Awards[Award.Awards.Count - 1].AwardId
                }
            }
            .AddField("Award Category", aCategory)
            .AddField("Award", aText)
            .WithCurrentTimestamp();

            await Configuration.Load().LogChannelId.GetTextChannel().SendMessageAsync("", false, replyEmbed.Build());
        }