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 (CMSEntities db = new CMSEntities()) { 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; } }
private void button4_Click(object sender, EventArgs e) { model3.FUsername = FamilyUser; model3.NUsername = NannyUser; using (CMSEntities db = new CMSEntities()) { if (model3.UserID == 0) { db.AdmintoNannyReqs.Add(model3); MessageBox.Show("request accepted!"); } db.SaveChanges(); } }
private void btn_haire_Click(object sender, EventArgs e) { using (CMSEntities db = new CMSEntities()) { model4.FUsername = fuser; model4.NUsername = userName; model4.WorkStatus = "proccessing"; if (model3.UserID == 0) { db.WorkTables.Add(model4); MessageBox.Show("Haire ruquest sent"); } db.SaveChanges(); } }
private void button6_Click(object sender, EventArgs e) { checkBox3.Enabled = false; checkBox4.Enabled = false; checkBox5.Enabled = false; checkBox6.Enabled = false; try { using (CMSEntities db = new CMSEntities()) { 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; } }
private void button8_Click(object sender, EventArgs e) { try { model5.NUsername = Log.recby; using (CMSEntities db = new CMSEntities()) { model5 = db.WorkTables.Where(x => x.NUsername == model5.NUsername).FirstOrDefault(x => x.FUsername == requF); model5.WorkStatus = "Booked"; db.SaveChanges(); MessageBox.Show("Congratulation ! you are haired!"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } }
private void btn_fri_CheckedChanged(object sender, EventArgs e) { model1.Username = Log.recby; using (CMSEntities db = new CMSEntities()) { 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 (CMSEntities db = new CMSEntities()) { 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(); }