Beispiel #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (SGrid.ActiveFilterPanel != null)
            {
                return;
            }

            Cursor.Current = Cursors.WaitCursor;

            var grid = SGrid.PrimaryGrid;


            var deleteMessage = ItemData.DateCovered.ToShortDateString();


            var ret = MessageDialog.AskToDelete("<b>" + deleteMessage.ToUpper() + "</b>");

            if (ret != MessageDialogResult.Yes)
            {
                return;
            }


            ItemData.RowStatus = RecordStatus.DeletedRecord;
            var writer = new PayrollPeriodDataWriter(App.CurrentUser.User.Username, ItemData);

            writer.SaveChanges();


            App.LogAction("Payroll", "Deleted Payroll Period: " + ItemData.DateCovered.ToString("dd MMM yyyy"));

            Close();
        }
        private bool FileSave()
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                if (!DataIsValid())
                {
                    return(false);
                }


                // Update MANDATORY COMPUTATIONS
                foreach (var emp in ListOfEmployees)
                {
                    emp.Deductions.LoadAllItemsWithDeduction();
                    DeductionGenerator.UpdateMandatoryDeductions(emp);
                    var mandatoryWriter = new PayrollEmployeeDataWriter(App.CurrentUser.User.Username, emp);
                    mandatoryWriter.SaveChanges();
                }


                //ItemData.Id =  ;
                ItemData.PayrollType = "Regular";
                ItemData.DateCovered = dtPeriod.Value;
                ItemData.Remarks     = txtRemarks.Text;


                var generator = new PayrollGenerator();

                pbStatus.Maximum = ListOfEmployees.Count();
                pbStatus.Text    = "";
                pbStatus.Visible = true;

                pbStatus.Refresh();

                generator.Generate(ItemData, ListOfEmployees, OnProgress);


                var writer = new PayrollPeriodDataWriter(App.CurrentUser.User.Username, ItemData);
                writer.SaveChanges();

                App.LogAction("Payroll", "Generated New Payroll :" + dtPeriod.Value.ToString("yyyy MMMM dd"));
                return(true);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowError(ex, this);
                return(false);
            }
        }