private void button1_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtuser.Text))
     {
         MessageBox.Show("Please Enter Username and Password", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtuser.Focus();
         return;
     }
     try
     {
         using (CMSEntities db = new CMSEntities())
         {
             var query = from u in db.logins
                         where u.Username == txtuser.Text && u.Password == txtpass.Text && u.Type == comboBox1.Text
                         select u;
             if (query.SingleOrDefault() != null)
             {
                 recby = txtuser.Text;
                 MessageBox.Show("Welcome! ", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 lg.Username = recby;
                 lg          = db.logins.Where(x => x.Username == lg.Username).FirstOrDefault();
                 if (lg.Type == "Family")
                 {
                     this.Hide();
                     FamilyView fv = new FamilyView();
                     fv.Show();
                 }
                 if (lg.Type == "Nanny")
                 {
                     this.Hide();
                     NannyView fv = new NannyView();
                     fv.Show();
                 }
                 if (lg.Type == "Admin")
                 {
                     this.Hide();
                     AdminView fv = new AdminView();
                     fv.Show();
                 }
             }
             else
             {
                 MessageBox.Show("Please enter correct username and password ", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
         throw;
     }
 }
        private void button9_Click(object sender, EventArgs e)
        {
            model.Username = Log.recby;
            using (CCareMSEntities db = new CCareMSEntities())
            {
                model            = db.FamilyDBs.Where(x => x.Username == model.Username).FirstOrDefault();
                model.Name       = txtName.Text.Trim();
                model.NationalID = txtNID.Text.Trim();
                model.NIDPic     = ConvertFiltoByte(this.picbox.ImageLocation);
                model.Gander     = gen;
                model.Email      = txtEmail.Text.Trim();
                model.Address    = txtAddress.Text.Trim();

                db.Entry(model).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                MessageBox.Show("Changes saved successfully");
            }
            redioFemale.Hide();
            redioMale.Hide();
            this.Hide();
            FamilyView fv = new FamilyView();

            fv.Show();
        }