private void button2_Click(object sender, EventArgs e)
        {
            bankmanagement_dbEntities2 con = new bankmanagement_dbEntities2();
            decimal no         = Convert.ToDecimal(fromaccounttxt.Text);
            var     item       = (from u in con.userAccounts where u.Account_no == no select u).FirstOrDefault();
            decimal b1         = Convert.ToDecimal(item.balance);
            decimal totalbal   = Convert.ToDecimal(tranfertxt.Text);
            decimal trasferacc = Convert.ToDecimal(desaccounttxt.Text);

            if (b1 > totalbal)
            {
                userAccount item2 = (from u in con.userAccounts where u.Account_no == trasferacc select u).FirstOrDefault();
                item2.balance = item2.balance + totalbal;
                item.balance  = item.balance - totalbal;
                //on.SaveChanges();
                Transfer trans = new Transfer();
                trans.Account_no = Convert.ToDecimal(fromaccounttxt.Text);
                trans.Totransfer = Convert.ToDecimal(desaccounttxt.Text);
                trans.Date       = DateTime.UtcNow.ToString();
                trans.Name       = nametxt.Text;
                trans.Balance    = Convert.ToDecimal(tranfertxt.Text);
                con.Transfers.Add(trans);
                con.SaveChanges();
                MessageBox.Show("transfer complete");
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            b1.RemoveAt(dataGridView1.SelectedRows[0].Index);
            bs = new bankmanagement_dbEntities2();
            decimal     a   = Convert.ToDecimal(accnotxt.Text);
            userAccount acc = bs.userAccounts.First(s => s.Account_no.Equals(a));

            bs.userAccounts.Remove(acc);
            bs.SaveChanges();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            bs = new bankmanagement_dbEntities2();
            decimal     accno = Convert.ToDecimal(accnotxt.Text);
            userAccount us    = bs.userAccounts.First(s => s.Account_no.Equals(accnotxt));

            us.Account_no = Convert.ToDecimal(accnotxt.Text);
            us.Name       = nametxt.Text;
            us.Date       = dateTimePicker1.Value.ToString();
            us.mothername = mothertxt.Text;
            us.fathername = fathertxt.Text;
            us.Phoneno    = phonetxt.Text;
            if (maleradio.Checked == true)
            {
                us.Gender = "male";
            }
            else if (femaleradio.Checked == true)
            {
                us.Gender = "female";
            }
            if (marriedradio.Checked == true)
            {
                us.m_status = "married";
            }
            else if (singleradio.Checked == true)
            {
                us.m_status = "single";
            }
            Image img = pictureBox1.Image;

            if (img.RawFormat != null)
            {
                if (ms != null)
                {
                    img.Save(ms, img.RawFormat);
                    us.picture = ms.ToArray();
                }
            }
            us.Address  = addresstxt.Text;
            us.District = distxt.Text;
            us.state    = statetxt.Text;
            bs.SaveChanges();
            MessageBox.Show("record updated");
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (maleradio.Checked)
            {
                gender = "male";
            }
            else if (femaleradio.Checked)
            {
                gender = "female";
            }
            if (marriedradio.Checked)
            {
                m_status = "married";
            }
            else if (singleradio.Checked)
            {
                m_status = "single";
            }
            bmd = new bankmanagement_dbEntities2();
            userAccount acc = new userAccount();

            acc.Account_no = Convert.ToDecimal(accnotxt.Text);
            acc.Name       = nametxt.Text;
            acc.Dob        = dateTimePicker1.Value.ToString();
            acc.Phoneno    = phonetxt.Text;
            acc.Address    = addresstxt.Text;
            acc.District   = disttxt.Text;
            acc.state      = comboBox1.SelectedItem.ToString();
            acc.Gender     = gender;
            acc.m_status   = m_status;
            acc.fathername = fathertxt.Text;
            acc.mothername = mothertxt.Text;
            acc.balance    = Convert.ToDecimal(balancetxt.Text);
            acc.Date       = datelal.Text;
            acc.picture    = ms.ToArray();
            _ = bmd.userAccounts.Add(acc);
            _ = bmd.SaveChanges();
            _ = MessageBox.Show("succesfull");
            this.Hide();
        }