public void GetSearchedList(string searchkey) { if (SystemClass.CheckConnection()) { try { SList = new List <StatusList>(); using (var db = new Model.ImusCityHallEntities()) { var get = db.EmployeeStatus.Where(m => m.EmployeeStatusName.Contains(searchkey)).OrderBy(m => m.EmployeeStatusName).ToList(); foreach (var item in get) { StatusList sl = new StatusList(); sl.StatusID = item.EmployeeStatusID; sl.StatusName = item.EmployeeStatusName; sl.StatusCode = item.EmployeeStatusCode; SList.Add(sl); } dgStatusList.ItemsSource = SList.OrderByDescending(m => m.StatusID); } } catch (Exception ex) { MessageBox.Show("Something went wrong." + Environment.NewLine + ex.Message, "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show(SystemClass.DBConnectionErrorMessage); } }
public void StatusAdd() { if (SystemClass.CheckConnection()) { try { using (var db = new Model.ImusCityHallEntities()) { if (!String.IsNullOrEmpty(txtName.Text) && !String.IsNullOrEmpty(txtCode.Text)) { if (db.EmployeeStatus.Any(m => m.EmployeeStatusCode == txtCode.Text)) { MessageBox.Show("Employee status code is already used"); } else { Model.EmployeeStatu es = new Model.EmployeeStatu(); es.EmployeeStatusName = txtName.Text; es.EmployeeStatusCode = txtCode.Text; db.EmployeeStatus.Add(es); db.SaveChanges(); var audit = new AuditTrailModel { Activity = "Added new employee status in the database. STAT CODE: " + txtCode.Text, ModuleName = this.GetType().Name, EmployeeID = App.EmployeeID }; SystemClass.InsertLog(audit); MessageBox.Show("Status added successfully", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information); TextClear(); } } else { MessageBox.Show("Fill up necessary fields.", "System Information!", MessageBoxButton.OK, MessageBoxImage.Information); } } } catch (Exception ex) { MessageBox.Show("Something went wrong." + Environment.NewLine + ex.Message, "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show(SystemClass.DBConnectionErrorMessage); } }
public void GetList() { if (SystemClass.CheckConnection()) { try { PList = new List <PositionList>(); using (var db = new Model.ImusCityHallEntities()) { var get = db.EmployeePositions.OrderBy(m => m.EmployeePositionName).ToList(); foreach (var item in get) { PositionList pl = new PositionList(); pl.PositionID = item.EmployeePositionID; pl.PositionName = item.EmployeePositionName; pl.Description = item.Description; pl.RankID = item.EmployeeRankID; if (item.EmployeeRank == null) { } else { pl.Rank = item.EmployeeRank.EmployeeRankName; } pl.IsActive = item.Active; PList.Add(pl); } if (!String.IsNullOrEmpty(txtSearch.Text)) { PList = PList.Where(m => m.PositionName.ToUpper().Contains(txtSearch.Text) || m.Description.ToUpper().Contains(txtSearch.Text)).ToList(); } dgPositionList.ItemsSource = PList.OrderByDescending(m => m.PositionID); } } catch (Exception ex) { MessageBox.Show("Something went wrong." + Environment.NewLine + ex.Message, "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show(SystemClass.DBConnectionErrorMessage); } }