private void gridDepartment_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e) { if (e.EditAction == GridViewEditAction.Cancel) { return; } if (e.EditOperationType == GridViewEditOperationType.Insert) { try { db.SaveChanges(); binddatagrid(); } catch { MessageBox.Show("already exist"); } } else if (e.EditOperationType == GridViewEditOperationType.Edit) { try { foreach (var data in gridDepartment.SelectedItems) { t_Department myData = data as t_Department; deptcode = myData.DeptCode; depdesc = myData.DeptName; t_Department dept = db.t_Department.First(p => p.DeptCode == deptcode); dept.DeptName = depdesc; db.SaveChanges(); binddatagrid(); } } catch { } } }
private void gridShuttleDestination_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e) { if (e.EditAction == GridViewEditAction.Cancel) { return; } if (e.EditOperationType == GridViewEditOperationType.Insert) { try { db.SaveChanges(); binddatagrid(); } catch { MessageBox.Show("Invalid"); } } else if (e.EditOperationType == GridViewEditOperationType.Edit) { try { foreach (var data in gridShuttleDestination.SelectedItems) { t_ShuttleDestination myData = data as t_ShuttleDestination; destid = myData.DestinationID; destin = myData.Destination; t_ShuttleDestination dest = db.t_ShuttleDestination.First(p => p.DestinationID == destid); dest.Destination = destin; db.SaveChanges(); binddatagrid(); } } catch { } } }
private void gridSection_RowEditEnded(object sender, Telerik.Windows.Controls.GridViewRowEditEndedEventArgs e) { if (e.EditAction == GridViewEditAction.Cancel) { return; } if (e.EditOperationType == GridViewEditOperationType.Insert) { try { db.SaveChanges(); binddatagrid(); } catch { MessageBox.Show("Invalid"); } } else if (e.EditOperationType == GridViewEditOperationType.Edit) { try { foreach (var data in gridSection.SelectedItems) { t_DepartmentalSection myData = data as t_DepartmentalSection; sectcode = myData.SectCode; sectname = myData.SectName; t_DepartmentalSection sec = db.t_DepartmentalSection.First(p => p.DeptCode == Department.SelectedValue.ToString() && p.SectCode == sectcode); sec.SectName = sectname; db.SaveChanges(); binddatagrid(); } } catch { } } }
private void gridPosition_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e) { if (e.EditAction == GridViewEditAction.Cancel) { return; } if (e.EditOperationType == GridViewEditOperationType.Insert) { try { db.SaveChanges(); binddatagrid(); } catch { MessageBox.Show("Invalid"); } } else if (e.EditOperationType == GridViewEditOperationType.Edit) { try { foreach (var data in gridPosition.SelectedItems) { t_Position myData = data as t_Position; code = myData.Code; desc = myData.Description; t_Position pos = db.t_Position.First(p => p.DeptCode == Department.SelectedValue.ToString() && p.Code == code); pos.Description = desc; db.SaveChanges(); binddatagrid(); } } catch { } } }
private void gridDependent_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e) { if (e.EditAction == GridViewEditAction.Cancel) { return; } if (e.EditOperationType == GridViewEditOperationType.Insert) { try { db.SaveChanges(); bindDependents(); } catch { } } else if (e.EditOperationType == GridViewEditOperationType.Edit) { // try //{ int ss = 0; foreach (var data in gridDependent.SelectedItems) { t_EmpDependents myData = data as t_EmpDependents; depName = myData.Name; depBirthDate = Convert.ToString(myData.BirthDate); depRelationship = myData.Relationship; depOccupation = myData.Occupation; depMaidenName = myData.MaidenName; ss = Convert.ToInt32(myData.DependentID); } var dep = db.t_EmpDependents.Where(x => x.DependentID == ss).FirstOrDefault(); dep.BirthDate = Convert.ToDateTime(depBirthDate); dep.Relationship = depRelationship; dep.Occupation = depOccupation; dep.MaidenName = depMaidenName; db.Entry(dep).State = EntityState.Modified; db.SaveChanges(); bindDependents(); // } //catch { } } }
private void RadButton_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(EmpName.Text)) { MessageBox.Show("Please Select Employee"); } else { try { t_EmpPrintID EmpforID = new t_EmpPrintID(); EmpforID.BatchNo = Convert.ToInt32(BatchNo); EmpforID.EmpID = EmpID.ToString(); EmpforID.EmployeeName = EmpFName.Text; EmpforID.Department = '(' + Dept.ToString() + ')'; EmpforID.Position = Position.Text; EmpforID.SSSno = SSSno.ToString(); EmpforID.TIN = TIN.ToString(); EmpforID.ContactPerson = ContactPerson.ToString(); EmpforID.ContactAddress = ContactAddress.ToString(); EmpforID.ContactPhone = ContactPhone.ToString(); EmpforID.Barcode = '*' + EmpID.ToString() + '*'; EmpforID.EmpPicture = empimage; db.t_EmpPrintID.Add(EmpforID); db.SaveChanges(); binddatagrid(); EmpName.Text = string.Empty; //EmpName.SelectedIndex = -1; EmpImage.Source = null; EmpFName.Text = ""; Position.Text = ""; Department.Text = ""; employeeID.Text = ""; } catch { MessageBox.Show("Already Exist"); } } }
private void gridWorkExp_PreviewKeyDown(object sender, KeyEventArgs e) { try { if (e.Key == Key.Delete) { foreach (var data in gridWorkExp.SelectedItems) { t_EmpWorkExperience myData = data as t_EmpWorkExperience; var delete = db.t_EmpWorkExperience.Where(p => p.EmpID == EmpID.Text && p.CompanyName == myData.CompanyName).FirstOrDefault(); db.t_EmpWorkExperience.Remove(delete); db.SaveChanges(); } bindWorkExp(); } else { return; } } catch { } }
private void gridUsers_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e) { if (e.EditAction == GridViewEditAction.Cancel) { return; } if (e.EditOperationType == GridViewEditOperationType.Insert) { try { db.SaveChanges(); binddatagrid(); } catch { MessageBox.Show("already exist"); } } else if (e.EditOperationType == GridViewEditOperationType.Edit) { try { foreach (var data in gridUsers.SelectedItems) { t_Users myData = data as t_Users; uid = myData.userid; uname = myData.username; upass = myData.userpass; utype = myData.usertype; t_Users us = db.t_Users.First(p => p.userid == uid); us.username = uname; us.userpass = upass; us.usertype = utype; db.SaveChanges(); binddatagrid(); } } catch { } } }
private void radEmployee1stMonth_RowActivated(object sender, Telerik.Windows.Controls.GridView.RowEventArgs e) { foreach (var data in radEmployee1stMonth.SelectedItems) { t_EmpMaster myData = data as t_EmpMaster; EmpIDs = myData.EmpID; } string sMessageBoxText = "Mark as Evaluated"; string sCaption = "Complete Evaluated? "; MessageBoxButton btnMessageBox = MessageBoxButton.YesNo; MessageBoxImage icnMessageBox = MessageBoxImage.Warning; MessageBoxResult rsltMessageBox = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox); switch (rsltMessageBox) { case MessageBoxResult.Yes: try { t_EmpMaster eval = db.t_EmpMaster.First(p => p.EmpID == EmpIDs.ToString()); eval.firstevaluation = true; db.SaveChanges(); fillgrid(); } catch { } break; case MessageBoxResult.No: /* ... */ break; } }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (DepartmentNew.SelectedValue == null || SectionNew.SelectedValue == null || PositionNew.SelectedValue == null || EmployementStatusNew.SelectedValue == null) { errormessage.Text = "Please complete classification"; } else { try { t_EmpMaster master = db.t_EmpMaster.First(p => p.EmpID == EmpName.SelectedValue); master.Department = DepartmentNew.SelectedValue.ToString(); master.Section = SectionNew.SelectedValue.ToString(); master.Position = PositionNew.SelectedValue.ToString(); master.EmploymentStatus = EmployementStatusNew.SelectedValue.ToString(); db.SaveChanges(); MessageBox.Show("Completed"); } catch { MessageBox.Show("Error"); } } }
private void btnsave_Click(object sender, RoutedEventArgs e) { var r = db.t_EmpMaster.SingleOrDefault(b => b.EmpID == EmpID.Text); if (r != null) { r.LastName = string.IsNullOrEmpty(LastName.Text) ? DBNull.Value.ToString() : LastName.Text; r.FirstName = string.IsNullOrEmpty(FirstName.Text) ? DBNull.Value.ToString() : FirstName.Text; r.MiddleName = string.IsNullOrEmpty(MiddleName.Text) ? DBNull.Value.ToString() : MiddleName.Text; r.Mobile = string.IsNullOrEmpty(Mobile.Text) ? DBNull.Value.ToString() : Mobile.Text; r.Phone = string.IsNullOrEmpty(Phone.Text) ? DBNull.Value.ToString() : Phone.Text; r.EmailAddress = string.IsNullOrEmpty(EmailAddress.Text) ? DBNull.Value.ToString() : EmailAddress.Text; r.ContactPerson = string.IsNullOrEmpty(ContactPerson.Text) ? DBNull.Value.ToString() : ContactPerson.Text; r.ContactAddress = string.IsNullOrEmpty(ContactAddress.Text) ? DBNull.Value.ToString() : ContactAddress.Text; r.ContactPhone = string.IsNullOrEmpty(ContactPhone.Text) ? DBNull.Value.ToString() : ContactPhone.Text; r.AppointmentPaperIssued = Convert.ToBoolean(AppointmentPaperIssued.IsChecked); r.IDissued = Convert.ToBoolean(IDissued.IsChecked); r.CivilStatus = string.IsNullOrEmpty(CivilStatus.SelectedValue.ToString()) ? DBNull.Value.ToString() : CivilStatus.SelectedValue.ToString(); r.SSSno = string.IsNullOrEmpty(SSSno.Text) ? DBNull.Value.ToString() : SSSno.Text; r.PHno = string.IsNullOrEmpty(PHno.Text) ? DBNull.Value.ToString() :PHno.Text; r.TIN = string.IsNullOrEmpty(TIN.Text) ? DBNull.Value.ToString() : TIN.Text; r.PagIbigNo = string.IsNullOrEmpty(PagIbigNo.Text) ? DBNull.Value.ToString() : PagIbigNo.Text; r.BatchNo = Convert.ToInt32(BatchNo.Text); r.ProximityCardID = string.IsNullOrEmpty(ProximityCardID.Text) ? DBNull.Value.ToString() :ProximityCardID.Text; if (HireDate.SelectedDate.HasValue) { r.HireDate = HireDate.SelectedDate.Value;//Convert.ToDateTime(EndDate.DateTimeText); } else { r.HireDate = null; } if (BirthDate.SelectedDate.HasValue) { r.BirthDate = BirthDate.SelectedDate.Value;//Convert.ToDateTime(EndDate.DateTimeText); } else { r.BirthDate = null; } r.Height = string.IsNullOrEmpty(Height.Text.Trim()) ? DBNull.Value.ToString() : Height.Text.Trim(); r.Weight = string.IsNullOrEmpty(Weight.Text.Trim()) ? DBNull.Value.ToString() : Weight.Text.Trim(); r.WeightUnit = string.IsNullOrEmpty(WeightUnit.SelectedValue.ToString().Trim()) ? DBNull.Value.ToString() : WeightUnit.SelectedValue.ToString().Trim(); r.HeightUnit = string.IsNullOrEmpty(HeightUnit.SelectedValue.ToString().Trim()) ? DBNull.Value.ToString() : HeightUnit.SelectedValue.ToString().Trim(); r.Religion = string.IsNullOrEmpty(Religion.SelectedValue.ToString().Trim()) ? DBNull.Value.ToString() : Religion.SelectedValue.ToString().Trim(); r.Sex = string.IsNullOrEmpty(Sex.SelectedValue.ToString().Trim()) ? DBNull.Value.ToString() : Sex.SelectedValue.ToString().Trim(); r.Nationality = string.IsNullOrEmpty(Nationality.SelectedValue.ToString().Trim()) ? DBNull.Value.ToString() : Nationality.SelectedValue.ToString().Trim(); if (ShuttleDestination.SelectedIndex != -1) { r.ShuttleDestination = Convert.ToInt32(ShuttleDestination.SelectedValue.ToString()); } else { } if (EndDate.SelectedDate.HasValue) { r.EndOfWork = EndDate.SelectedDate.Value;//Convert.ToDateTime(EndDate.DateTimeText); } else { r.EndOfWork = null; } r.Department = string.IsNullOrEmpty(Department.SelectedValue.ToString().Trim()) ? DBNull.Value.ToString() : Department.SelectedValue.ToString(); r.Section = string.IsNullOrEmpty(Section.SelectedValue.ToString().Trim()) ? DBNull.Value.ToString().Trim() : Section.SelectedValue.ToString(); r.Position = string.IsNullOrEmpty(Position.SelectedValue.ToString()) ? DBNull.Value.ToString() : Position.SelectedValue.ToString(); r.EmploymentStatus = string.IsNullOrEmpty(EmploymentStatus.SelectedValue.ToString()) ? DBNull.Value.ToString() : EmploymentStatus.SelectedValue.ToString(); if (data != null) { r.EmpPicture = data; } else { } db.SaveChanges(); btncancel.Visibility = Visibility.Hidden; btnedit.Visibility = Visibility.Visible; btnsave.IsEnabled = false; EmpData.IsEnabled = false; EmpData2.IsEnabled = false; getpersonalinfo(); MessageBox.Show("Updated!"); } }
private void gridDependent_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e) { if (e.EditAction == GridViewEditAction.Cancel) { return; } if (e.EditOperationType == GridViewEditOperationType.Insert) { try { db.SaveChanges(); bindDependents(); } catch { } } else if (e.EditOperationType == GridViewEditOperationType.Edit) { try { foreach (var data in gridDependent.SelectedItems) { t_TempEmpDependents myData = data as t_TempEmpDependents; depName = myData.Name; depBirthDate = Convert.ToString(myData.BirthDate); depRelationship = myData.Relationship; depOccupation = myData.Occupation; depMaidenName = myData.MaidenName; t_TempEmpDependents dep = db.t_TempEmpDependents.First(p => p.EmpID == adminusers.Text); dep.Name = depName; dep.BirthDate = Convert.ToDateTime(depBirthDate); dep.Relationship = depRelationship; dep.Occupation = depOccupation; dep.MaidenName = depMaidenName; db.SaveChanges(); bindDependents(); } } catch { } } ////try ////{ //foreach (var data in gridDependent.SelectedItems) //{ // //t_TempEmpDependents myData = data as t_TempEmpDependents; // //depName = myData.Name; // ////depBirthDate = Convert.ToString(myData.BirthDate); // //depRelationship = myData.Relationship; // //depOccupation = myData.Occupation; // //depMaidenName = myData.MaidenName; // t_TempEmpDependents dep = db.t_TempEmpDependents.First(p => p.EmpID == adminusers.Text); // dep.Name = depName; // //dep.BirthDate = Convert.ToDateTime(depBirthDate); // dep.Relationship = depRelationship; // dep.Occupation = depOccupation; // dep.MaidenName = depMaidenName; // db.SaveChanges(); //} ////} ////catch { } }
private void Button_Click(object sender, RoutedEventArgs e) { //MessageBox.Show("Confirm?", "Move to Archive", // MessageBoxButton.YesNo, MessageBoxImage.Warning); if (MessageBox.Show("Confirm?", "Move to Archive", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { try { t_EmpMaster emp = db.t_EmpMaster.First(p => p.EmpID == EmpIDActive); emp.IsDeleted = true; db.SaveChanges(); fillGrid(); } catch { MessageBox.Show("select employee"); } } else { } //try //{ // foreach (var xe in db.t_EmpMaster.Where(p => p.EmpID == EmpIDActive)) // { // var newarchive = new t_EmpMasterArchive(); // newarchive.BatchNo = xe.BatchNo; // newarchive.SerialID = xe.SerialID; // newarchive.EmpID = xe.EmpID; // newarchive.ProximityCardID = xe.ProximityCardID; // newarchive.LastName = xe.LastName; // newarchive.FirstName = xe.FirstName; // newarchive.MiddleName = xe.MiddleName; // newarchive.Phone = xe.Phone; // newarchive.Mobile = xe.Mobile; // newarchive.Sex = xe.Sex; // newarchive.BirthDate = xe.BirthDate; // newarchive.HireDate = xe.HireDate; // newarchive.EmploymentStatus = xe.EmploymentStatus; // newarchive.Nationality = xe.Nationality; // newarchive.Religion = xe.Religion; // newarchive.CivilStatus = xe.CivilStatus; // newarchive.Position = xe.Position; // newarchive.Department = xe.Department; // newarchive.Section = xe.Section; // newarchive.SSSno = xe.SSSno; // newarchive.PHno = xe.PHno; // newarchive.PagIbigNo = xe.PagIbigNo; // newarchive.TIN = xe.TIN; // newarchive.EmailAddress = xe.EmailAddress; // newarchive.ContactPerson = xe.ContactPerson; // newarchive.ContactPhone = xe.ContactPhone; // newarchive.ContactAddress = xe.ContactAddress; // newarchive.Height = xe.Height; // newarchive.HeightUnit = xe.HeightUnit; // newarchive.Weight = xe.Weight; // newarchive.WeightUnit = xe.WeightUnit; // newarchive.EndOfWork = xe.EndOfWork; // newarchive.ShuttleDestination = xe.ShuttleDestination; // newarchive.HighestEducationalAttainment = xe.HighestEducationalAttainment; // newarchive.IDissued = xe.IDissued; // newarchive.AppointmentPaperIssued = xe.AppointmentPaperIssued; // newarchive.EmpPicture = xe.EmpPicture; // //_maindata.InitialEntryBy = adminusers.Text; // db.t_EmpMasterArchive.Add(newarchive); // } // db.SaveChanges(); // removeEmpToActive(); // fillActive(); // fillHistory(); //} //catch { } }