예제 #1
0
        private async void tsm_AddMoney_Click(object sender, EventArgs e)
        {
            PasswordForm password = new PasswordForm();

            if (password.ShowDialog(this) == DialogResult.OK)
            {
                if (_currentCard == null)
                {
                    return;
                }
                var addMoneyForm = new AddMoneyForm(_currentCard.CardId);
                addMoneyForm.ShowDialog(this);
                await Search();
            }
        }
예제 #2
0
        private async void tsm_Delete_Click(object sender, EventArgs e)
        {
            PasswordForm password = new PasswordForm();

            if (password.ShowDialog(this) == DialogResult.OK)
            {
                if (_currentCard == null)
                {
                    return;
                }
                if (FrmDialog.ShowDialog(this, $"确定删除:{_currentCard.CardId}({_currentCard.PhoneNumber},{_currentCard.UserName})及相关消费记录?", "提示", true) == DialogResult.OK)
                {
                    using (var db = new MemberCardContext())
                    {
                        var cards = db.Cards.Where(item => item.CardId == _currentCard.CardId);
                        var logs  = db.BuyRecords.Where(item => item.CardId == _currentCard.CardId);
                        db.Cards.RemoveRange(cards);
                        db.BuyRecords.RemoveRange(logs);
                        await db.SaveChangesAsync();
                    }
                    await Search();
                }
            }
        }