private void btn_add_card_Click(object sender, EventArgs e) { CardAmountType amountType = EnumHelper.StringToEnum <CardAmountType>(txbx_card_amoun.Text); DateTime expireDate = DateTime.Parse(txbx_card_expire_date.Text); Card card = new Card() { CreateDate = DateTime.Now, CardAmountType = amountType, ExpireDate = expireDate, Number = txbx_card_number.Text, Id = Identifier <Card> .GenerateIdentifier() }; DbContext.Cards.Add(card); DrawStatistics(); }
private void btn_generate_card_Click(object sender, EventArgs e) { string guid = Guid.NewGuid().ToString(); guid = guid.Substring(guid.IndexOf('-') + 1, 14); txbx_card_number.Text = guid.ToUpper(); Random random = new Random(); int number = random.Next(0, 4); CardAmountType[] enumValues = (CardAmountType[])Enum.GetValues(typeof(CardAmountType)); CardAmountType cardAmountType = enumValues[number]; txbx_card_amoun.Text = ((int)cardAmountType).ToString(); CardData cardData = new CardData(); MonthType monthType = cardData.GetDataByAmountType(cardAmountType); txbx_card_expire_date.Text = DateTime.Now.AddMonths((int)monthType).ToString(); }
public MonthType GetDataByAmountType(CardAmountType cardAmountType) { return(KeyValuePairs[cardAmountType]); }