Esempio n. 1
0
        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Are you sure to delete ?", "EF CRUID Operation", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    using (CCareMSEntities db = new CCareMSEntities())
                    {
                        var entry = db.Entry(model);
                        if (entry.State == System.Data.Entity.EntityState.Detached)
                        {
                            db.WorkTables.Attach(model);
                            db.WorkTables.Remove(model);
                            db.SaveChanges();
                            populateDataGridView();

                            MessageBox.Show("Item Deleted");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
Esempio n. 2
0
        private void button6_Click(object sender, EventArgs e)
        {
            checkBox3.Enabled = false;
            checkBox4.Enabled = false;
            checkBox5.Enabled = false;
            checkBox6.Enabled = false;
            try
            {
                using (CCareMSEntities db = new CCareMSEntities())
                {
                    model.Name       = txtname.Text.Trim();
                    model.NationalID = txtNID.Text.Trim();
                    model.NIDPic     = ConvertFiltoByte(this.picbox.ImageLocation);

                    model.Email   = txtNID.Text.Trim();
                    model.Address = txtAddress.Text.Trim();


                    model.UserPic    = ConvertFiltoByte(this.userpic.ImageLocation);
                    model.Type       = type;
                    model.Experience = txtexperience.Text.Trim();
                    model.ExSalary   = txtexsal.Text.Trim();
                    model.Education  = txtedu.Text.Trim();
                    model.Mobile     = txtmobile.Text.Trim();
                    model.BirthDate  = datePicker.Value;
                    model.Status     = "Free";

                    model1.Username = Log.recby;


                    model1 = db.WorkCharts.Where(x => x.Username == model1.Username).FirstOrDefault();


                    db.Entry(model1).State = System.Data.Entity.EntityState.Modified;
                    db.Entry(model).State  = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    MessageBox.Show("your profile is successfully updated");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please change once more");
                throw;
            }
        }
Esempio n. 3
0
        private void btn_fri_CheckedChanged(object sender, EventArgs e)
        {
            model1.Username = Log.recby;
            using (CCareMSEntities db = new CCareMSEntities())
            {
                model1 = db.WorkCharts.Where(x => x.Username == model1.Username).FirstOrDefault();
                if (btn_sun.Checked)
                {
                    model1.Friday = "Booked";
                }
                else
                {
                    model1.Friday = "Free";
                }

                db.Entry(model1).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }
        }
        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();
        }