public void InitializeCustomControls()
        {
            MEAPSDbEntities     context   = new MEAPSDbEntities();
            List <ComboBoxItem> cbListEmp = new List <ComboBoxItem>();

            foreach (Employee item in context.Employees)
            {
                ComboBoxItem cbiEmp = new ComboBoxItem();
                cbiEmp.Content = item.EmpId;
                cbiEmp.Tag     = item.EmpId;
                cbListEmp.Add(cbiEmp);
            }
            cbEmp.ItemsSource = cbListEmp;
            cbEmp.ItemsSource = cbListEmp;

            for (int i = 0; i < 24; i++)
            {
                cbInHrs.Items.Add(i);
                cbOutHrs.Items.Add(i);
            }
            for (int i = 0; i < 60; i++)
            {
                cbInMins.Items.Add(i);
                cbOutMins.Items.Add(i);
            }
            dataGrid.ItemsSource = context.Attendances.ToList();
            dataGrid.Items.Refresh();
        }
        private void btnUpload_Click(object sender, RoutedEventArgs e)
        {
            string    filepath    = txtPath.Text;
            DataTable csvFileData = new DataTable();

            if (chkClear.IsChecked == true)
            {
                MEAPSDbEntities context = new MEAPSDbEntities();
                context.Database.ExecuteSqlCommand("TRUNCATE TABLE [CSVDatas]");
                LogString("Cleared old records.");
            }
            LogString("Converting CSV to DataTable...");
            try
            {
                csvFileData = CsvToDb.CsvToDataTable.ConvertCsvtoDataTable(filepath);
            }
            catch (Exception ex)
            {
                LogString(ex.Message);
            }

            LogString("Inserting DataTable to Database...");
            try
            {
                CsvToDb.DataTabletoDB.InsertDataIntoSQLServerUsingSQLBulkCopy(csvFileData);
            }
            catch (Exception ex)
            {
                LogString(ex.Message);
            }
            LogString("Done!");
        }
Exemplo n.º 3
0
        private void btnLeaveStatTruncate_Click(object sender, RoutedEventArgs e)
        {
            MEAPSDbEntities context = new MEAPSDbEntities();

            context.Database.ExecuteSqlCommand("TRUNCATE TABLE[LeaveStatuses]");
            context.SaveChanges();
            RefreshDataGrids();
        }
Exemplo n.º 4
0
        private void InitializeComboBoxes()
        {
            //initialize employee list
            MEAPSDbEntities     context   = new MEAPSDbEntities();
            List <ComboBoxItem> cbListEmp = new List <ComboBoxItem>();

            foreach (Employee item in context.Employees)
            {
                ComboBoxItem cbiEmp = new ComboBoxItem();
                cbiEmp.Content = item.EmpId;
                cbiEmp.Tag     = item.EmpId;
                cbListEmp.Add(cbiEmp);
            }
            cbAEEmp.ItemsSource     = cbListEmp;
            cbLEEmp.ItemsSource     = cbListEmp;
            cbReportEmp.ItemsSource = cbListEmp;

            //initialize time selectors
            for (int i = 0; i < 24; i++)
            {
                cbInHrs.Items.Add(i);
                cbOutHrs.Items.Add(i);
            }
            for (int i = 0; i < 60; i++)
            {
                cbInMins.Items.Add(i);
                cbOutMins.Items.Add(i);
            }
            cbInHrs.SelectedIndex   = 9;
            cbInMins.SelectedIndex  = 50;
            cbOutHrs.SelectedIndex  = 17;
            cbOutMins.SelectedIndex = 25;

            //initialize year selectors
            int lastyear  = Int32.Parse(System.DateTime.Now.Year.ToString()) + 5;
            int firstyear = Int32.Parse(System.DateTime.Now.Year.ToString()) - 5;

            for (int i = firstyear; i <= lastyear; i++)
            {
                cbLeaveStatMonthlyYear.Items.Add(i);
                cbReportYears.Items.Add(i);
            }
            cbLeaveStatMonthlyYear.SelectedIndex = 5;
            cbReportMonths.SelectedIndex         = 1;
            cbReportYears.SelectedIndex          = 5;
            try
            {
                cbAEEmp.SelectedIndex     = 0;
                cbLEEmp.SelectedIndex     = 0;
                cbLeaveType.SelectedIndex = 0;
                cbReportEmp.SelectedIndex = 0;
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 5
0
        private void btnAEDel_Click(object sender, RoutedEventArgs e)
        {
            ExceptionAttendance ae        = (ExceptionAttendance)dataGridExcepHolidays.SelectedItem;
            MEAPSDbEntities     context   = new MEAPSDbEntities();
            ExceptionAttendance deletable = context.ExceptionAttendances.SingleOrDefault(x => ((x.EmpId == ae.EmpId) && (x.Date == ae.Date)));

            context.ExceptionAttendances.Remove(deletable);
            context.SaveChanges();
            RefreshDataGrids();
        }
Exemplo n.º 6
0
        private void btnLEDel_Click(object sender, RoutedEventArgs e)
        {
            LeaveApplication la        = (LeaveApplication)dataGridLeaveApp.SelectedItem;
            MEAPSDbEntities  context   = new MEAPSDbEntities();
            LeaveApplication deletable = context.LeaveApplications.SingleOrDefault(x => x.Date == la.Date);

            context.LeaveApplications.Remove(deletable);
            context.SaveChanges();
            RefreshDataGrids();
        }
Exemplo n.º 7
0
        private void btnHolidaysDel_Click(object sender, RoutedEventArgs e)
        {
            Holiday         h         = (Holiday)dataGridHolidays.SelectedItem;
            MEAPSDbEntities context   = new MEAPSDbEntities();
            Holiday         deletable = context.Holidays.SingleOrDefault(x => x.Date == h.Date);

            context.Holidays.Remove(deletable);
            context.SaveChanges();
            RefreshDataGrids();
        }
Exemplo n.º 8
0
        private void btnEmpDelSelected_Click(object sender, RoutedEventArgs e)
        {
            MEAPSDbEntities context   = new MEAPSDbEntities();
            Employee        em        = (Employee)dataGridEmployees.SelectedItem;
            Employee        deletable = context.Employees.SingleOrDefault(x => x.EmpId == em.EmpId);

            context.Employees.Remove(deletable);
            context.SaveChanges();
            RefreshDataGrids();
        }
Exemplo n.º 9
0
        private void btnTEDel_Click(object sender, RoutedEventArgs e)
        {
            TimeException   te        = (TimeException)dataGridExcepTime.SelectedItem;
            MEAPSDbEntities context   = new MEAPSDbEntities();
            TimeException   deletable = context.TimeExceptions.SingleOrDefault(x => x.Date == te.Date);

            context.TimeExceptions.Remove(deletable);
            context.SaveChanges();
            RefreshDataGrids();
        }
Exemplo n.º 10
0
        private void btnHolidaysAdd_Click(object sender, RoutedEventArgs e)
        {
            MEAPSDbEntities context = new MEAPSDbEntities();
            Holiday         h       = new Holiday();

            h.Date    = (DateTime)calHolidays.SelectedDate;
            h.Comment = txtHolidayComment.Text;
            context.Holidays.Add(h);
            context.SaveChanges();
            RefreshDataGrids();
        }
        private void btnDel_Click(object sender, RoutedEventArgs e)
        {
            Attendance      at        = (Attendance)dataGrid.SelectedItem;
            MEAPSDbEntities context   = new MEAPSDbEntities();
            Attendance      deletable = context.Attendances.SingleOrDefault(x => x.SISOId == at.SISOId);

            context.Attendances.Remove(deletable);
            context.SaveChanges();
            dataGrid.ItemsSource = context.Attendances.ToList();
            dataGrid.Items.Refresh();
        }
Exemplo n.º 12
0
        private void btnAEAdd_Click(object sender, RoutedEventArgs e)
        {
            MEAPSDbEntities     context = new MEAPSDbEntities();
            ExceptionAttendance ae      = new ExceptionAttendance();
            ComboBoxItem        EmpId   = (ComboBoxItem)cbAEEmp.SelectedItem;

            ae.EmpId   = Convert.ToInt32(EmpId.Content);
            ae.Date    = Convert.ToDateTime(dtAEDate.Text);
            ae.Remarks = txtAERemarks.Text;
            context.ExceptionAttendances.Add(ae);
            context.SaveChanges();
            RefreshDataGrids();
        }
Exemplo n.º 13
0
        private void btnLEAdd_Click(object sender, RoutedEventArgs e)
        {
            LeaveApplication la = new LeaveApplication();

            la.Date          = Convert.ToDateTime(dtLEDate.Text);
            la.EmployeeEmpId = Int32.Parse(cbLEEmp.Text);
            la.Type          = cbLeaveType.Text;
            la.Remarks       = txtLERemarks.Text;
            MEAPSDbEntities context = new MEAPSDbEntities();

            context.LeaveApplications.Add(la);
            context.SaveChanges();
            RefreshDataGrids();
        }
Exemplo n.º 14
0
        private void btnTEAdd_Click(object sender, RoutedEventArgs e)
        {
            MEAPSDbEntities context = new MEAPSDbEntities();
            TimeException   te      = new TimeException();

            te.Date = Convert.ToDateTime(dtTEDate.Text);
            string entryTime = cbInHrs.Text + ":" + cbInMins.Text;
            string exitTime  = cbOutHrs.Text + ":" + cbOutMins.Text;

            te.InTime  = TimeSpan.Parse(entryTime);
            te.OutTime = TimeSpan.Parse(exitTime);
            context.TimeExceptions.Add(te);
            context.SaveChanges();
            RefreshDataGrids();
        }
Exemplo n.º 15
0
        private void btnEmpAdd_Click(object sender, RoutedEventArgs e)
        {
            MEAPSDbEntities context = new MEAPSDbEntities();
            Employee        em      = new Employee();

            em.EmpId       = Int32.Parse(txtEmpId.Text);
            em.Name        = txtEmpName.Text;
            em.Dept        = txtDept.Text;
            em.CL          = Double.Parse(txtCL.Text);
            em.ML          = Double.Parse(txtML.Text);
            em.EL          = Double.Parse(txtEL.Text);
            em.LWP         = Double.Parse(txtLWP.Text);
            em.JoiningDate = Convert.ToDateTime(dtJoiningDate.Text);
            context.Employees.Add(em);
            context.SaveChanges();
            RefreshDataGrids();
        }
Exemplo n.º 16
0
        private void btnEmpUpdate_Click(object sender, RoutedEventArgs e)
        {
            MEAPSDbEntities context   = new MEAPSDbEntities();
            Employee        em        = (Employee)dataGridEmployees.SelectedItem;
            Employee        updatable = context.Employees.SingleOrDefault(x => x.EmpId == em.EmpId);

            updatable.EmpId       = int.Parse(txtEmpId.Text);
            updatable.Name        = txtEmpName.Text;
            updatable.Dept        = txtDept.Text;
            updatable.CL          = Double.Parse(txtCL.Text);
            updatable.ML          = Double.Parse(txtML.Text);
            updatable.EL          = Double.Parse(txtEL.Text);
            updatable.JoiningDate = Convert.ToDateTime(dtJoiningDate.Text);
            updatable.LWP         = Double.Parse(txtLWP.Text);
            context.SaveChanges();
            RefreshDataGrids();
        }
Exemplo n.º 17
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            MEAPSDbEntities  context = new MEAPSDbEntities();
            TabCtrl          t       = context.TabCtrls.First();
            MessageBoxResult result  = MessageBox.Show("Save position?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                t.selectedIndex = tabCtrlMain.SelectedIndex.ToString();
            }
            else
            {
                t.selectedIndex = "0";
            }
            context.SaveChanges();
            Application.Current.Shutdown();
        }
Exemplo n.º 18
0
        public MainWindow()
        {
            InitializeComponent();
            RefreshDataGrids();
            MEAPSDbEntities context = new MEAPSDbEntities();
            TabCtrl         t       = context.TabCtrls.FirstOrDefault();

            if (t == null)
            {
                t = new TabCtrl();
                t.selectedIndex = "0";
                context.TabCtrls.Add(t);
                context.SaveChanges();
            }
            btnLaunchViewer.Visibility = Visibility.Hidden;
            tabCtrlMain.SelectedIndex  = Int32.Parse(t.selectedIndex);
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            Attendance   at        = new Attendance();
            string       entryTime = cbInHrs.Text + ":" + cbInMins.Text;
            string       exitTime  = cbOutHrs.Text + ":" + cbOutMins.Text;
            ComboBoxItem EmpId     = (ComboBoxItem)cbEmp.SelectedItem;

            at.Employee_EmpId = Convert.ToInt32(EmpId.Content);
            at.InTime         = TimeSpan.Parse(entryTime);
            at.OutTime        = TimeSpan.Parse(exitTime);
            at.Date           = Convert.ToDateTime(dtDate.Text);
            MEAPSDbEntities context = new MEAPSDbEntities();

            context.Attendances.Add(at);
            context.SaveChanges();
            dataGrid.ItemsSource = context.Attendances.ToList();
            dataGrid.Items.Refresh();
        }
Exemplo n.º 20
0
        //end of global declarations
        private void RefreshDataGrids()
        {
            MEAPSDbEntities context = new MEAPSDbEntities();

            dataGridEmployees.ItemsSource = context.Employees.ToList();
            dataGridEmployees.Items.Refresh();
            dataGridHolidays.ItemsSource = context.Holidays.ToList();
            dataGridHolidays.Items.Refresh();
            dataGridExcepHolidays.ItemsSource = context.ExceptionAttendances.ToList();
            dataGridExcepHolidays.Items.Refresh();
            dataGridExcepTime.ItemsSource = context.TimeExceptions.ToList();
            dataGridExcepTime.Items.Refresh();
            dataGridLeaveApp.ItemsSource = context.LeaveApplications.ToList();
            dataGridLeaveApp.Items.Refresh();
            dataGridLeaveStat.ItemsSource = context.LeaveStatuses.ToList();
            dataGridLeaveStat.Items.Refresh();
            InitializeComboBoxes();
        }
Exemplo n.º 21
0
        private void btnShowMessage_Click(object sender, RoutedEventArgs e)
        {
            int c = 0;

            if (rdChoice1.IsChecked == true)
            {
                c = 1;
            }
            if (rdChoice2.IsChecked == true)
            {
                c = 2;
            }

            int             EmpId   = Int32.Parse(cbReportEmp.Text);
            MEAPSDbEntities context = new MEAPSDbEntities();
            Employee        em      = context.Employees.SingleOrDefault(x => x.EmpId == EmpId);

            switch (c)
            {
            case 1:
                string           result = "Employee Id: " + em.EmpId + "\nEmployee Name: " + em.Name + "\nRemaining CL: " + em.CL + "\nRemaining ML: " + em.ML + "\nRemaining EL: " + em.EL + "\nLeaves without Pay: " + em.LWP;
                MessageBoxResult res    = MessageBox.Show(result, "Result", MessageBoxButton.OK, MessageBoxImage.Information);
                break;

            case 2:
                double sumCL = 0, sumML = 0, sumEL = 0, sumLWP = 0;
                if (dataGridLeaveStat.Items.Count <= 1)
                {
                    MessageBoxResult alertbox = MessageBox.Show("Please generate daily attendance reports first.", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
                else
                {
                    List <LeaveStatus> ls_emp = (from x in context.LeaveStatuses where x.EmployeeEmpId == em.EmpId select x).ToList();
                    if (cbReportMonths.SelectedIndex == 0)
                    {
                        List <LeaveStatus> ls_emp_mon = (from x in ls_emp where x.Date.Year == int.Parse(cbReportYears.Text) select x).ToList();
                        sumCL  = ls_emp_mon.Sum(x => ((x.FCL ?? 0) + (0.5 * (x.HCL ?? 0)) + (0.25 * ((x.QCL_In ?? 0) + (x.QCL_Out ?? 0)))));
                        sumML  = ls_emp_mon.Sum(x => ((x.FML ?? 0) + (0.5 * (x.HML ?? 0))));
                        sumEL  = ls_emp_mon.Sum(x => (x.EL ?? 0));
                        sumLWP = ls_emp_mon.Sum(x => x.LWP);
                        string           result2 = "Employee Id: " + em.EmpId + "\nEmployee Name: " + em.Name + "\nTotal CL: " + sumCL + "\nTotal ML: " + sumML + "\nTotal EL: " + sumEL + "\nTotal Leaves without Pay: " + sumLWP;
                        MessageBoxResult res2    = MessageBox.Show(result2, "Result", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        int month = cbReportMonths.SelectedIndex;
                        List <LeaveStatus> ls_emp_mon = (from x in ls_emp where x.Date.Month == month && x.Date.Year == int.Parse(cbReportYears.Text) select x).ToList();
                        sumCL  = ls_emp_mon.Sum(x => ((x.FCL ?? 0) + (0.5 * (x.HCL ?? 0)) + (0.25 * ((x.QCL_In ?? 0) + (x.QCL_Out ?? 0)))));
                        sumML  = ls_emp_mon.Sum(x => ((x.FML ?? 0) + (0.5 * (x.HML ?? 0))));
                        sumEL  = ls_emp_mon.Sum(x => (x.EL ?? 0));
                        sumLWP = ls_emp_mon.Sum(x => x.LWP);
                        string           result2 = "Employee Id: " + em.EmpId + "\nEmployee Name: " + em.Name + "\nTotal CL: " + sumCL + "\nTotal ML: " + sumML + "\nTotal EL: " + sumEL + "\nTotal Leaves without Pay: " + sumLWP;
                        MessageBoxResult res2    = MessageBox.Show(result2, "Result", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
                break;

            default:
                break;
            }
        }