private void button2_Click(object sender, EventArgs e)
        {
            banking_dbEntities dbe = new banking_dbEntities();
            decimal            b   = Convert.ToDecimal(fromacctxt.Text);
            var     item           = (from u in dbe.userAccount where u.Account_No == b select u).FirstOrDefault();
            decimal b1             = Convert.ToDecimal(item.balance);
            decimal totalbalance   = Convert.ToDecimal(amounttxt.Text);
            decimal transferacc    = Convert.ToDecimal(destinationacctxt.Text);

            if (b1 > totalbalance)
            {
                userAccount item2 = (from u in dbe.userAccount where u.Account_No == transferacc select u).FirstOrDefault();
                item2.balance = item2.balance + totalbalance;
                item.balance  = item.balance - totalbalance;
                Transfer transfer = new Transfer();
                transfer.Account_No = Convert.ToDecimal(fromacctxt.Text);
                transfer.ToTransfer = Convert.ToDecimal(destinationacctxt.Text);
                transfer.Date       = DateTime.UtcNow.ToString("dd/MM/yyyy");
                transfer.Name       = nametxt.Text;
                transfer.balance    = Convert.ToDecimal(amounttxt.Text);

                dbe.Transfer.Add(transfer);
                dbe.SaveChanges();
                MessageBox.Show("Transfer Money Sucessfully");
            }
            else
            {
                MessageBox.Show("Not enough money");
            }
        }
        private void button4_Click(object sender, EventArgs e)
        {
            bi.RemoveAt(dataGridView1.CurrentCell.RowIndex);
            dbe = new banking_dbEntities();
            decimal     a   = Convert.ToDecimal(acctxt.Text);
            userAccount acc = dbe.userAccount.First(s => s.Account_No.Equals(a));

            dbe.userAccount.Remove(acc);
            dbe.SaveChanges();
        }
        private void button3_Click(object sender, EventArgs e)
        {
            dbe = new banking_dbEntities();
            decimal     accountno   = Convert.ToDecimal(acctxt.Text);
            userAccount useraccount = dbe.userAccount.First(s => s.Account_No.Equals(accountno));

            useraccount.Account_No  = Convert.ToDecimal(acctxt.Text);
            useraccount.Name        = nametxt.Text;
            useraccount.Date        = dateTimePicker1.Value.ToString();
            useraccount.Mother_Name = mothertxt.Text;
            useraccount.Father_Name = fathertxt.Text;
            useraccount.PhoneNo     = phonetxt.Text;
            if (maleradio.Checked == true)
            {
                useraccount.Gender = "male";
            }
            else
            {
                if (femaleradio.Checked)
                {
                    useraccount.Gender = "female";
                }
            }
            if (marriedradio.Checked == true)
            {
                useraccount.maritial_status = "married";
            }
            else
            {
                if (unmarriedradio.Checked == true)
                {
                    useraccount.maritial_status = "Un-married";
                }
            }
            Image img = pictureBox1.Image;

            if (img.RawFormat != null)
            {
                if (ms != null)
                {
                    img.Save(ms, img.RawFormat);
                    useraccount.Picture = ms.ToArray();
                }
            }
            useraccount.Address  = addtxt.Text;
            useraccount.District = distxt.Text;
            useraccount.State    = statetxt.Text;
            dbe.SaveChanges();
            MessageBox.Show("Record Updated");
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (maleradio.Checked)
            {
                gender = "male";
            }
            else if (femaleradio.Checked)
            {
                gender = "female";
            }
            else if (otherradio.Checked)
            {
                gender = "other";
            }
            if (marriedradio.Checked)
            {
                m_status = "married";
            }
            else if (unmarriedradio.Checked)
            {
                m_status = "unmarried";
            }
            BSE = new banking_dbEntities();
            userAccount acc = new userAccount();

            acc.Account_No = Convert.ToDecimal(textBox1.Text);
            acc.Name       = nametxt.Text;
            acc.DOB        = dateTimePicker1.Value.ToString();

            try
            {
                int  temp;
                bool isnum = int.TryParse(phonetxt.Text, out temp);
                if (isnum)
                {
                    acc.PhoneNo = phonetxt.Text;
                }
                else
                {
                    throw new NullReferenceException();
                }
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Please correct <phonebox> type to number instead of laters  ");
                acc.PhoneNo = null;
            }



            acc.Address         = addtxt.Text;
            acc.District        = disttxt.Text;
            acc.State           = comboBox1.SelectedItem.ToString();
            acc.Gender          = gender;
            acc.maritial_status = m_status;
            acc.Mother_Name     = mothertxt.Text;
            acc.Father_Name     = fathertxt.Text;

            try
            {
                int  temp1;
                bool isnum1 = int.TryParse(blctxt.Text, out temp1);
                if (isnum1)
                {
                    acc.balance = Convert.ToDecimal(blctxt.Text);
                }
                else
                {
                    throw new NullReferenceException();
                }
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Please  correct < balancebox > type to number instead of laters");
                acc.balance = null;
            }

            acc.Date = datalbl.Text;

            try
            {
                acc.Picture = ms.ToArray();
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("The PictureBox was null");
                OpenFileDialog opendlg = new OpenFileDialog();
                if (opendlg.ShowDialog() == DialogResult.OK)
                {
                    Image img = Image.FromFile(opendlg.FileName);
                    pictureBox1.Image = img;
                    ms = new MemoryStream();
                    img.Save(ms, img.RawFormat);
                }
                acc.Picture = ms.ToArray();
            }

            if (acc.balance != null && acc.PhoneNo != null)
            {
                BSE.userAccount.Add(acc);
                BSE.SaveChanges();
                MessageBox.Show("file saved");
            }
            else
            {
                MessageBox.Show("Correct Forms");
            }
        }