private void btn_addkids_save_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(diseasse.Text)) { MessageBox.Show("Please type something!"); } else { try { db = new PreSchoolEntities1(); int userId = userClass.getUserId(); var newDisease = new tbl_disease_type() { name_disease = diseasse.Text, id_user_save = userId, }; db.tbl_disease_type.Add(newDisease); db.SaveChanges(); MessageBox.Show("New Disease Added"); } catch (Exception) { MessageBox.Show("Error Adding New Data"); } } }
private void btn_employee_delete_Click(object sender, EventArgs e) { try { if (gbEmpId > 0) { using (var context = new PreSchoolEntities1()) { var emplooye = context.tbl_employee.Where(item => item.id == gbEmpId).First(); var confirmation = MessageBox.Show("Are You Sure About Deleting This Emplooye ?", "Please Confirm", MessageBoxButtons.YesNo); if (confirmation == DialogResult.Yes) { context.tbl_employee.Remove(emplooye); context.SaveChanges(); } } view(); clear(); } else { MessageBox.Show("Please Select A Row To Delete"); } } catch (Exception) { MessageBox.Show("Error Deleting Room Data"); } }
private void btn_rooms_delete_Click_1(object sender, EventArgs e) { try { if (gbActivityId > 0) { using (var context = new PreSchoolEntities1()) { var activity = context.tbl_subject_activity.Where(item => item.id == gbActivityId).First(); var confirmation = MessageBox.Show("Are You Sure About Deleting This Child In This Activity ?", "Please Confirm", MessageBoxButtons.YesNo); if (confirmation == DialogResult.Yes) { context.tbl_subject_activity.Remove(activity); context.SaveChanges(); } } view(); clear(); } else { MessageBox.Show("Please Select A Row To Delete"); } } catch (Exception) { MessageBox.Show("Error Deleting Room Data"); } }
private void gunaAdvenceButton7_Click(object sender, EventArgs e) { try { if (!String.IsNullOrWhiteSpace(gunaLineTextBox1.Text) && gunaLineTextBox1.Text != "0") { int healthId = int.Parse(gunaLineTextBox1.Text); using (var context = new PreSchoolEntities1()) { var healthData = context.tbl_child_healthy.Where(item => item.id == healthId).First(); var confirmation = MessageBox.Show("Are You Sure About Deleting This Child In This Room ", "Please Confirm", MessageBoxButtons.YesNo); if (confirmation == DialogResult.Yes) { context.tbl_child_healthy.Remove(healthData); context.SaveChanges(); clear(); } } } else { MessageBox.Show("No Id In The Search Field"); } } catch (Exception) { MessageBox.Show("Error Deleting Health Data"); } }
private void btn_addkids_save_Click(object sender, EventArgs e) { try { if (userId > 0) { using (var context = new PreSchoolEntities1()) { var user = context.tbl_user.Where(item => item.id == userId).First(); var confirmation = MessageBox.Show("Are You Sure About Deleting " + user.User_fullname + "?", "Please Confirm", MessageBoxButtons.YesNo); if (confirmation == DialogResult.Yes) { context.tbl_user.Remove(user); context.SaveChanges(); } } view(); clear(); } } catch (Exception) { MessageBox.Show("Please Select A Field You Want To Delete"); } }
private void gunaAdvenceButton7_Click(object sender, EventArgs e) { try { if (!String.IsNullOrWhiteSpace(gunaLineTextBox1.Text) && gunaLineTextBox1.Text != "0") { int childId = int.Parse(gunaLineTextBox1.Text); using (var context = new PreSchoolEntities1()) { var childData = context.tbl_child_info.Where(item => item.id == childId).First(); var confirmation = MessageBox.Show("Are You Sure About Deleting This Child Data ", "Please Confirm", MessageBoxButtons.YesNo); if (confirmation == DialogResult.Yes) { context.tbl_child_info.Remove(childData); context.SaveChanges(); Clear(Controls); } } } else { MessageBox.Show("No Id In The Search Field"); } } catch (Exception) { MessageBox.Show("Before You Deeleting This Child Data You Should Remove It From The Room And Other References"); Clear(Controls); } }
private void gunaAdvenceButton2_Click(object sender, EventArgs e) { using (var context = new PreSchoolEntities1()) { if (userId > 0 && !String.IsNullOrWhiteSpace(txt_user_userFullname.Text) && !String.IsNullOrWhiteSpace(txt_user_username.Text) && !String.IsNullOrWhiteSpace(txt_user_username.Text)) { var user = context.tbl_user.Where(item => item.id == userId).First(); user.User_fullname = CapitalizeFirst(txt_user_userFullname.Text); user.User_Role = combo_role.Text; user.password = txt_user_password.Text; user.username = txt_user_username.Text; user.status = gunaCheckBox1.Checked; context.SaveChanges(); } else if (userId == 0 && !String.IsNullOrWhiteSpace(txt_user_userFullname.Text) && !String.IsNullOrWhiteSpace(txt_user_username.Text) && !String.IsNullOrWhiteSpace(txt_user_username.Text)) { var newUser = new tbl_user() { User_fullname = CapitalizeFirst(txt_user_userFullname.Text), User_Role = combo_role.Text, password = txt_user_password.Text, username = txt_user_username.Text, status = gunaCheckBox1.Checked, }; context.tbl_user.Add(newUser); context.SaveChanges(); } else { MessageBox.Show("Plese Enter Valid Fields"); } } view(); clear(); }
private void btn_rooms_save_Click(object sender, EventArgs e) { if (gbAttensId > 0) { db = new PreSchoolEntities1(); var attenData = db.tbl_attendance.Where(x => x.id == gbAttensId).FirstOrDefault(); var childId = db.tbl_child_info.Where(items => items.child_fullname == comboo_child_name.Text) .Select(a => a.id) .FirstOrDefault(); DateTime dt = dateTimePicker1.Value; TimeSpan incomeTime = new TimeSpan(dt.Hour, dt.Minute, dt.Second); DateTime dt2 = dateTimePicker2.Value; TimeSpan leftTime = new TimeSpan(dt2.Hour, dt2.Minute, dt2.Second); attenData.id_child = childId; attenData.time_income = incomeTime; attenData.time_left = leftTime; attenData.left_with = left_with.Text; attenData.date_save = DateTime.Now; db.SaveChanges(); view(); clear(); } else { db = new PreSchoolEntities1(); DateTime dt = dateTimePicker1.Value; TimeSpan incomeTime = new TimeSpan(dt.Hour, dt.Minute, dt.Second); DateTime dt2 = dateTimePicker2.Value; TimeSpan leftTime = new TimeSpan(dt2.Hour, dt2.Minute, dt2.Second); var childId = db.tbl_child_info.Where(items => items.child_fullname == comboo_child_name.Text) .Select(a => a.id) .FirstOrDefault(); var newAttendance = new tbl_attendance() { id_child = childId, id_user_save = userClass.getUserId(), time_income = incomeTime, time_left = leftTime, left_with = left_with.Text, date_save = DateTime.Now }; db.tbl_attendance.Add(newAttendance); db.SaveChanges(); view(); clear(); } }
private void btn_employee_save_Click(object sender, EventArgs e) { try { if (gbEmpId > 0) { db = new PreSchoolEntities1(); int userId = userClass.getUserId(); var emplooye = db.tbl_employee.Where(x => x.id == gbEmpId).FirstOrDefault(); emplooye.employee_fullname = txt_employee_employeeFullname.Text; emplooye.employee_gender = combo_employee_employeeGender.Text; emplooye.employee_job_title = job_title.Text; emplooye.salary = Math.Round(Convert.ToDecimal(txt_employee_salary.Text)); emplooye.employee_phone = txt_employee_employeePhone.Text; emplooye.datetime_save = DateTime.Now; emplooye.id_user_update = userId; db.SaveChanges(); view(); clear(); } else { db = new PreSchoolEntities1(); int userId = userClass.getUserId(); var newEmployee = new tbl_employee() { employee_fullname = txt_employee_employeeFullname.Text, employee_gender = combo_employee_employeeGender.Text, employee_job_title = job_title.Text, salary = Math.Round(Convert.ToDecimal(txt_employee_salary.Text)), employee_phone = txt_employee_employeePhone.Text, datetime_save = DateTime.Now, id_user_save = userId }; db.tbl_employee.Add(newEmployee); db.SaveChanges(); view(); clear(); } } catch (Exception) { MessageBox.Show("Eror"); } }
private void btn_addkids_save_Click_1(object sender, EventArgs e) { try { var confirmation = MessageBox.Show("Are You Sure To Save These Changes ?", "Submit Channges", MessageBoxButtons.YesNo); if (confirmation == DialogResult.Yes) { using (var context = new PreSchoolEntities1()) { context.SaveChanges(); } } else { db = new PreSchoolEntities1(); db.tbl_child_info.Load(); dataGridView1.DataSource = db.tbl_child_info.Local.ToBindingList(); } } catch (Exception) { MessageBox.Show("Error"); } }
private void btn_addkids_save_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(gunaLineTextBox1.Text) || gunaLineTextBox1.Text == "0") { db = new PreSchoolEntities1(); var childId = db.tbl_child_info.Where(items => items.child_fullname == combo_childHealth_child_name.Text) .Select(a => a.id).FirstOrDefault(); var diseaseId = db.tbl_disease_type.Where(items => items.name_disease == combo_childHealth_child_disease.Text) .Select(a => a.id).FirstOrDefault(); var newHealth = new tbl_child_healthy() { id_child = childId, id_child_disease_type = diseaseId, have_surgery = gunaWinSwitch1.Checked, drug_allergy = txt_childHealth_drug_allergy.Text, darmany_naxoshiya_drezhxayanaka = txt_childHealth_chronic_candition_cure.Text, general_clinic_test_disease_type = disease_type_txt.Text, general_clinic_test_disease_type_note = not_childHealth_surgery.Text, face_type = txt_childHealth_face_type.Text, food_eating_type = txt_childHealth_foot_eating_type.Text, child_height = txt_childHealth_child_height.Text, child_weight = txt_childHealth_child_weight.Text, note_of_surgery = not_childHealth_surgery.Text, id_user_save = userClass.getUserId(), datetime_save = DateTime.Now }; db.tbl_child_healthy.Add(newHealth); db.SaveChanges(); MessageBox.Show("New Health Data Added"); } else { db = new PreSchoolEntities1(); int healthId = int.Parse(gunaLineTextBox1.Text); var childId = db.tbl_child_info.Where(items => items.child_fullname == combo_childHealth_child_name.Text) .Select(a => a.id).FirstOrDefault(); var diseaseId = db.tbl_disease_type.Where(items => items.name_disease == combo_childHealth_child_disease.Text) .Select(a => a.id).FirstOrDefault(); var healthData = db.tbl_child_healthy.Where(items => items.id == healthId).FirstOrDefault(); healthData.id_child = childId; healthData.id_child_disease_type = diseaseId; healthData.have_surgery = gunaWinSwitch1.Checked; healthData.drug_allergy = txt_childHealth_drug_allergy.Text; healthData.darmany_naxoshiya_drezhxayanaka = txt_childHealth_chronic_candition_cure.Text; healthData.general_clinic_test_disease_type = disease_type_txt.Text; healthData.general_clinic_test_disease_type_note = not_childHealth_surgery.Text; healthData.face_type = txt_childHealth_face_type.Text; healthData.food_eating_type = txt_childHealth_foot_eating_type.Text; healthData.child_height = txt_childHealth_child_height.Text; healthData.child_weight = txt_childHealth_child_weight.Text; healthData.note_of_surgery = not_childHealth_surgery.Text; healthData.id_user_save = userClass.getUserId(); healthData.datetime_save = DateTime.Now; db.SaveChanges(); MessageBox.Show("Updated Successfully"); } }
private void btn_nurse_save_Click(object sender, EventArgs e) { try { if (gbNurseId > 0) { db = new PreSchoolEntities1(); var nurse = db.tbl_nurse.Where(item => item.id == gbNurseId).First(); int userId = userClass.getUserId(); var childId = db.tbl_child_info.Where(items => items.child_fullname == combo_nurse_child_name.Text) .Select(a => a.id) .FirstOrDefault(); var roomId = db.tbl_room_name .Where(items => items.room_name == combo_nurse_room_name.Text) .Select(a => a.id) .FirstOrDefault(); nurse.id_child = childId; nurse.id_user_update = userId; nurse.id_room_name = roomId; nurse.note = not_nurse.Text; nurse.datetime_update = DateTime.Now; db.SaveChanges(); view(); clear(); } else if (gbNurseId == 0 && combo_nurse_room_name.SelectedIndex != -1 && combo_nurse_room_name.SelectedIndex != -1) { db = new PreSchoolEntities1(); var childId = db.tbl_child_info.Where(items => items.child_fullname == combo_nurse_child_name.Text) .Select(a => a.id) .FirstOrDefault(); var roomId = db.tbl_room_name .Where(items => items.room_name == combo_nurse_room_name.Text) .Select(a => a.id) .FirstOrDefault(); int userId = userClass.getUserId(); var newNurse = new tbl_nurse() { id_child = childId, id_user_save = userId, id_room_name = roomId, note = not_nurse.Text, datetime_save = DateTime.Now }; db.tbl_nurse.Add(newNurse); db.SaveChanges(); view(); clear(); } else { MessageBox.Show("Please Select Some Data To Edit Or Add New Data"); } } catch (Exception ex) { MessageBox.Show("Error Adding New Data" + ex.Message); } }