Exemple #1
0
        /// <summary>
        /// delete item(s)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Delete_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure to delete the record?", "Dialog", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                LeaveDetailsService service = new LeaveDetailsService();
                for (int i = 0; i < RequestHistory.Rows.Count;)
                {
                    if (Convert.ToBoolean(RequestHistory.Rows[i].Cells[0].Value) == true)
                    {
                        LeaveDetails detail = new LeaveDetails();
                        detail = detailsBindingList.ElementAt(i);
                        detailsBindingList.RemoveAt(i);
                        service.RemoveDetails(detail);
                    }
                    else
                    {
                        i++;
                    }
                }
                RequestHistory.DataSource = null;
                allDetails.Clear();
                detailsBindingList.Clear();
                AssignDatatoList();
                AddLeavingsAttributetoList(allDetails);
                BindVactionDetails();
                nCurrent    = 0;
                pageCurrent = 0;
                InitPagingList();
                MessageBox.Show("Submit Successfully !");
            }
        }
Exemple #2
0
        protected void Application_Start()
        {
            objFileLog.WriteLine(LogType.Info, "App start", "Global.asax", "App_Start", string.Empty);
            XmlConfigurator.Configure();
            log.Info("Vibrant Web Application started.");
            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorViewEngine());
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();

            //timer.AutoReset = true;
            //timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
            //timer.Enabled = true;

            var SEM = new SEMController();

            SEM.SetTimerValue();

            //Resource Allocation Auto mail
            var resource = new ResourceController();
            // resource.SetTimerValue();
            var travel = new TravelController();

            travel.SetTimerValue();

            //Confirmation Process Auto mail
            var Confirmation = new ConfirmationProcessController();

            Confirmation.SetTimerValue();

            Application["LeaveBalanceWF"] = "";
            Application["AttendanceWF"]   = "";
            Application["LeaveUpLoadWF"]  = "";
            Application["WokflowRuntime"] = "";

            var workflowRuntime = Application["WokflowRuntime"] as WorkflowRuntime;

            if (workflowRuntime == null)
            {
                workflowRuntime = new WorkflowRuntime();

                workflowRuntime.WorkflowIdled      += workflowRuntime_WorkflowIdled;
                workflowRuntime.WorkflowLoaded     += workflowRuntime_WorkflowLoaded;
                workflowRuntime.WorkflowUnloaded   += workflowRuntime_WorkflowUnloaded;
                workflowRuntime.WorkflowPersisted  += workflowRuntime_WorkflowPersisted;
                workflowRuntime.WorkflowCompleted  += delegate { };
                workflowRuntime.WorkflowTerminated +=
                    delegate(object sender1, WorkflowTerminatedEventArgs e1) { Debug.WriteLine(e1.Exception.Message); };

                // Add the Persistance Service

                //WorkflowPersistenceService workflowPersistanceService = new SqlWorkflowPersistenceService(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
                //workflowRuntime.AddService(workflowPersistanceService);

                WorkflowSchedulerService workflowSchedulerService = new DefaultWorkflowSchedulerService();
                workflowRuntime.AddService(workflowSchedulerService);

                //System.Workflow.Runtime.Hosting. SqlTrackingService trackingService = new SqlTrackingService(connectionString2);

                //System.Workflow.Runtime.Tracking.SqlTrackingService workflowTrackingService = new System.Workflow.Runtime.Tracking.SqlTrackingService(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
                //workflowRuntime.AddService(workflowTrackingService);

                // Add the External Data Exchange Service
                var dataExchangeService = new ExternalDataExchangeService();
                workflowRuntime.AddService(dataExchangeService);

                LeaveBalanceService      objLeaveBalanceService;
                LeaveDetailsService      objLeaveDetailsService;
                OutOfOfficeService       objOutOfOfficeService;
                CompensationService      objCompensationService;
                SignInSignOutService     objSignInSignOutService;
                AttendanceCheckerService objAttendanceCheckerService;
                LeaveUploadService       objLeaveUploadService;
                // Add a new instance of the LeaveBalanceService to the External Data Exchange Service
                objLeaveBalanceService      = new LeaveBalanceService();
                objLeaveDetailsService      = new LeaveDetailsService();
                objOutOfOfficeService       = new OutOfOfficeService();
                objCompensationService      = new CompensationService();
                objSignInSignOutService     = new SignInSignOutService();
                objAttendanceCheckerService = new AttendanceCheckerService();
                objLeaveUploadService       = new LeaveUploadService();

                //Adding our services to  ExternalDataExchangeService

                dataExchangeService.AddService(objLeaveBalanceService);
                dataExchangeService.AddService(objLeaveDetailsService);
                dataExchangeService.AddService(objOutOfOfficeService);
                dataExchangeService.AddService(objCompensationService);
                dataExchangeService.AddService(objSignInSignOutService);
                dataExchangeService.AddService(objAttendanceCheckerService);
                dataExchangeService.AddService(objLeaveUploadService);

                // Start the Workflow services
                //workflowRuntime.UnloadOnIdle = true;
                workflowRuntime.StartRuntime();
                Application["WokflowRuntime"] = workflowRuntime;
                //System.Web.HttpContext.Current.Cache["WokflowRuntime"]=workflowRuntime;
                //System.Web.HttpContext.Current.Cache["WokflowRuntime"]=workflowRuntime;
                objFileLog.WriteLine(LogType.Info, "App start finished", "Global.asax", "App_Start", string.Empty);
            }
        }
Exemple #3
0
        /// <summary>
        /// Gets the vocatin details.
        /// </summary>
        /// <param name="staffId">The staff id.</param>
        public List <LeaveDetails> GetVacationDetails(int staffId)
        {
            int                 yearNow       = currentDate.Year;
            DateTime            startDate     = Convert.ToDateTime("1990-1-1");
            DateTime            endDate       = Convert.ToDateTime(yearNow + 1 + "-12-31");
            LeaveDetailsService detailService = new LeaveDetailsService();
            LeaveDetails        ld            = new LeaveDetails
            {
                StaffId   = staffId,
                StartDate = startDate,
                EndDate   = endDate
            };

            allDetails = detailService.ObtainLeaveDetailsByStaffId(ld);

            thisyearUALF         = 0;
            thisyearUALS         = 0;
            sickLeaveCounter     = 0;
            nopayLeaveCounter    = 0;
            marriageLeaveCounter = 0;
            maternityCounter     = 0;
            compassionateCounter = 0;
            paternityCounter     = 0;
            othersCounter        = 0;

            for (int i = 0; i < allDetails.Count; i++)
            {
                int      ID        = allDetails.ElementAt(i).LeaveTypeId;
                Single   dur       = allDetails.ElementAt(i).Duration;
                DateTime startdate = allDetails.ElementAt(i).StartDate;
                switch (ID)
                {
                case 1:
                    if (startdate >= janOneYear && startdate < MarOneYear)
                    {
                        thisyearUALF += dur;
                    }
                    else if (startdate >= MarOneYear && startdate < janOneYearAfter)
                    {
                        thisyearUALS += dur;
                    }
                    break;

                case 2:
                    if (startdate >= janOneYear && startdate < janOneYearAfter)
                    {
                        sickLeaveCounter += dur;
                    }
                    else if (startdate >= janOneLastYear && startdate < janOneYear)
                    {
                        lastyearUSL += dur;
                    }
                    break;

                case 3:
                    if (startdate >= janOneYear && startdate < janOneYearAfter)
                    {
                        nopayLeaveCounter += dur;
                    }
                    break;

                case 4:
                    marriageLeaveCounter += dur;
                    break;

                case 5:
                    maternityCounter += dur;
                    break;

                case 6:
                    compassionateCounter += dur;
                    break;

                case 7:
                    paternityCounter += dur;
                    break;

                case 8:
                    othersCounter += dur;
                    break;

                default:
                    break;
                }
            }
            return(allDetails);
        }
Exemple #4
0
        /// <summary>
        /// Prints all.
        /// </summary>
        /// <param name="dt">The dt.</param>
        public void printAll()
        {
            if (showStaffInfo.StaffId != 0)
            {
                try
                {
                    string         saveFileName = "";
                    SaveFileDialog saveDialog   = new SaveFileDialog();
                    saveDialog.DefaultExt = "xlsx";
                    saveDialog.FileName   = showStaffInfo.EmployeeId + "(" + showStaffInfo.StaffName + ")" + " Vacation Details" + DateTime.Today.ToString("yyyy-MM-dd");
                    saveDialog.ShowDialog();
                    saveFileName = saveDialog.FileName;
                    if (saveFileName.IndexOf(":") < 0)
                    {
                        return;
                    }

                    LeaveDetailsService leaveDetailsService = new LeaveDetailsService();

                    Excel.Application myExcel = new Excel.Application();
                    if (myExcel == null)
                    {
                        MessageBox.Show("Can not Create a Sheet! Make Sure your computer has installed the Excel!");
                        return;
                    }

                    myExcel.Application.Workbooks.Add(true);
                    myExcel.Visible = false;

                    Excel.Workbook  myBook  = myExcel.Workbooks[1];
                    Excel.Worksheet mySheet = myBook.Worksheets[1];
                    mySheet.Name = "Vacation Details";

                    for (int i = 1; i <= 5; i++)
                    {
                        mySheet.Columns[i].ColumnWidth         = 20;
                        mySheet.Columns[i].HorizontalAlignment = Excel.Constants.xlCenter;
                        mySheet.Columns[i].VerticalAlignment   = Excel.Constants.xlCenter;
                    }

                    mySheet.Range[mySheet.Cells[1, 1], mySheet.Cells[2, 5]].MergeCells = true;
                    mySheet.Range[mySheet.Cells[3, 4], mySheet.Cells[3, 5]].MergeCells = true;
                    mySheet.Range[mySheet.Cells[4, 4], mySheet.Cells[4, 5]].MergeCells = true;
                    mySheet.Cells[1, 1]           = showStaffInfo.StaffName + "'s Vacation Details";
                    mySheet.Cells[1, 1].Font.Size = 18;

                    mySheet.Cells[3, 1] = "EmployeeID:";
                    mySheet.Cells[3, 2] = showStaffInfo.EmployeeId;
                    mySheet.Cells[3, 3] = "Staff Name:";
                    mySheet.Cells[3, 4] = showStaffInfo.StaffName + "(" + showStaffInfo.ChineseName + ")";

                    mySheet.Cells[4, 1] = "Onboard Date:";
                    mySheet.Cells[4, 2] = showStaffInfo.OnboardDate;
                    mySheet.Cells[4, 3] = "Title:";
                    mySheet.Cells[4, 4] = showStaffInfo.Title;

                    int row = 5;
                    for (int i = yearNow; i >= showStaffInfo.OnboardDate.Year; i--)
                    {
                        Excel.Range range = mySheet.Range[mySheet.Cells[row, 1], mySheet.Cells[row + 1, 5]];
                        range.MergeCells                = true;
                        mySheet.Cells[row, 1]           = "Detailed records in " + i;
                        mySheet.Cells[row, 1].Font.Size = 16;


                        row = row + 2;

                        mySheet.Cells[row, 1] = "Leaving Type";
                        mySheet.Cells[row, 2] = "Start Date";
                        mySheet.Cells[row, 3] = "End Date";
                        mySheet.Cells[row, 4] = "Days Taken";
                        mySheet.Cells[row, 5] = "Remark";

                        DateTime     startDate = Convert.ToDateTime(i + "-1-1");
                        DateTime     endDate   = Convert.ToDateTime(i + 1 + "-1-1");
                        LeaveDetails ld        = new LeaveDetails
                        {
                            StaffId   = CurrentStaffId,
                            StartDate = startDate,
                            EndDate   = endDate
                        };

                        OneYearDetails = leaveDetailsService.ObtainLeaveDetailsByStaffId(ld);
                        AddLeavingsAttributetoList(OneYearDetails);

                        for (int j = 0; j < OneYearDetails.Count; j++)
                        {
                            int      ID        = OneYearDetails.ElementAt(j).LeaveTypeId;
                            Single   dur       = OneYearDetails.ElementAt(j).Duration;
                            DateTime startdate = OneYearDetails.ElementAt(j).StartDate;
                            DateTime enddate   = OneYearDetails.ElementAt(j).EndDate;
                            string   remarks   = OneYearDetails.ElementAt(j).Remark;
                            string   name      = OneYearDetails.ElementAt(j).Leavings.LeaveTypeName;

                            row += 1;
                            mySheet.Cells[row, 1] = name;
                            mySheet.Cells[row, 2] = startdate;
                            mySheet.Cells[row, 3] = enddate;
                            mySheet.Cells[row, 4] = dur;
                            mySheet.Cells[row, 5] = remarks;
                        }
                        row += 1;
                    }

                    myBook.SaveCopyAs(saveFileName);
                    myBook.Close(false, Type.Missing, Type.Missing);

                    myExcel.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(myBook);
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(myExcel);
                    mySheet = null;
                    myBook  = null;
                    myExcel = null;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "error" + ex);
                }
                finally
                {
                    GC.Collect();
                }
            }
            else
            {
                MessageBox.Show("StaffId error!");
            }
        }
Exemple #5
0
        /// <summary>
        /// add new item
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddOthers_Click(object sender, EventArgs e)
        {
            int    vacationId = 0;
            string vacationName;
            int    otherVacationId = Convert.ToInt32(this.OthersCombo.SelectedValue);
            int    commonVactionId = Convert.ToInt32(this.CommonCombo.SelectedValue);

            if ((otherVacationId >= 0 && commonVactionId < 0) || (commonVactionId >= 0 && otherVacationId < 0))
            {
                if (otherVacationId >= 0)
                {
                    vacationId   = Convert.ToInt32(this.OthersCombo.SelectedValue);
                    vacationName = this.OthersCombo.Text.ToString();
                }
                else
                {
                    vacationId   = Convert.ToInt32(this.CommonCombo.SelectedValue);
                    vacationName = this.CommonCombo.Text.ToString();
                }

                double   startCounter;
                double   endCounter;
                string   startDate = PickerforStart.Value.Date.ToShortDateString();
                string   endDate   = PickerforEnd.Value.Date.ToShortDateString();
                DateTime start     = Convert.ToDateTime((startDate + " " + StartTimeCombo.Text).ToString());
                DateTime end       = Convert.ToDateTime((endDate + " " + EndTimeCombo.Text).ToString());
                if (StartTimeCombo.SelectedIndex == 0)
                {
                    startCounter = 0;
                }
                else
                {
                    startCounter = -0.5;
                }

                if (EndTimeCombo.SelectedIndex == 0)
                {
                    endCounter = 0.5;
                }
                else
                {
                    endCounter = 1;
                }
                Single   day           = Convert.ToSingle(endCounter + startCounter);// LeaveDetails.Duration
                TimeSpan duration      = end.Date.Subtract(start.Date);
                Single   span          = 0;
                Single   totalday      = day + Convert.ToSingle(duration.TotalDays);
                Single   inputDuration = Convert.ToSingle(numericUpDownDuration.Value);
                Single   testForAnnualLeaveRemainDay = annualLeaveRemainDay;
                Single   testForSickLeaveRemainDay   = sickLeaveRemainDay;
                if (totalday > 0 || inputDuration != 0)
                {
                    switch (vacationId)
                    {
                    case 1:
                        if (inputDuration == 0)
                        {
                            testForAnnualLeaveRemainDay = annualLeaveRemainDay - totalday;
                            span = totalday;
                        }
                        else
                        {
                            testForAnnualLeaveRemainDay = annualLeaveRemainDay - inputDuration;
                            span = inputDuration;
                        }
                        break;

                    case 2:
                        if (inputDuration == 0)
                        {
                            testForSickLeaveRemainDay = sickLeaveRemainDay - totalday;
                            span = totalday;
                        }
                        else
                        {
                            testForSickLeaveRemainDay = sickLeaveRemainDay - inputDuration;
                            span = inputDuration;
                        }
                        break;

                    case 3:
                        if (inputDuration == 0)
                        {
                            span = totalday;
                        }
                        else
                        {
                            span = inputDuration;
                        }
                        showStaffInfo.Married = true;
                        StaffService staffService = new StaffService();
                        staffService.UpdateStaffInfor(showStaffInfo);
                        break;

                    case 4:
                    case 5:
                    case 6:
                    case 7:
                    case 8:
                    default:
                        if (inputDuration == 0)
                        {
                            span = totalday;
                        }
                        else
                        {
                            span = inputDuration;
                        }
                        break;
                    }
                    if (testForAnnualLeaveRemainDay < -5 || testForSickLeaveRemainDay < 0)
                    {
                        MessageBox.Show("The vacation exceeds its limit", "Warning");
                    }
                    else
                    {
                        annualLeaveRemainDay = testForAnnualLeaveRemainDay;
                        sickLeaveRemainDay   = testForSickLeaveRemainDay;
                        LeaveType vacation = new LeaveType {
                            LeaveTypeId = vacationId, LeaveTypeName = vacationName
                        };
                        LeaveDetails newDetail = new LeaveDetails
                        {
                            StaffId     = showStaffInfo.StaffId,
                            LeaveTypeId = vacationId,
                            StartDate   = start,
                            EndDate     = end,
                            Duration    = span,
                            Remark      = textBoxRemark.Text.ToString(),
                            Leavings    = vacation,
                        };
                        LeaveDetailsService detailService = new LeaveDetailsService();
                        detailService.AddNewDetails(newDetail);
                        RequestHistory.DataSource = null;
                        allDetails.Clear();
                        detailsBindingList.Clear();

                        AssignDatatoList();
                        AddLeavingsAttributetoList(allDetails);
                        BindVactionDetails();
                        nCurrent    = 0;
                        pageCurrent = 0;
                        InitPagingList();
                    }
                }
                else
                {
                    MessageBox.Show("Please adjust the interval to fit with the requirement", "Error");
                }
            }
            else
            {
                MessageBox.Show("Please select a vacation type", "Warning");
            }
        }