Example #1
0
        public bool AddIncome()
        {
            using (_context = new DigitalPocketContext())
            {
                var obj = _context.UWallet.FirstOrDefault(x => x.UserId == id);
                obj.Ammount += Convert.ToDecimal(textBox2.Text);
                Transaction tr = new Transaction()
                {
                    Ammount         = Convert.ToDecimal(textBox2.Text),
                    Category        = comboBox1.Text,
                    DateTime        = Datetoenter,
                    Note            = richTextBox1.Text,
                    OriginAccount   = comboBox2.Text,
                    UserId          = id,//pass user id
                    TransactionName = textBox1.Text,
                    Type            = type1
                };
                _context.Transaction.Add(tr);
                _context.SaveChanges();

                TransacModel.Ammount         = tr.Ammount.Value;
                TransacModel.TransactionName = tr.TransactionName;
                TransacModel.Category        = tr.Category;
                TransacModel.Type            = tr.Type;
                TransacModel.Allow           = true;
                TransacModel.Type            = type1;
                return(true);
            }
        }
Example #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            using (_context = new DigitalPocketContext())
            {
                if (_context.PocketUser.Any(x => x.Username == textBox1.Text))
                {
                    MessageBox.Show("User already exsist");
                }
                else
                {
                    if (String.IsNullOrEmpty(textBox1.Text) || String.IsNullOrEmpty(textBox2.Text) || String.IsNullOrEmpty(textBox3.Text) || String.IsNullOrEmpty(textBox4.Text))
                    {
                        MessageBox.Show("One of the required field is missing");
                    }
                    else
                    {
                        PocketUser pu = new PocketUser()
                        {
                            Email    = textBox3.Text,
                            Password = textBox2.Text,
                            Username = textBox1.Text
                        };
                        _context.PocketUser.Add(pu);
                        _context.SaveChanges();
                        UWallet uw = new UWallet()
                        {
                            Ammount = Convert.ToDecimal(textBox4.Text),
                            Date    = DateTime.Now,
                            UserId  = pu.Id
                        };
                        _context.UWallet.Add(uw);
                        _context.SaveChanges();

                        MessageBox.Show("Account Created please login with your login details");
                        this.Close();
                    }
                }
            }
        }