Пример #1
0
        void sc_ClickApproveButton(object sender, EventArgs e)
        {
            foreach (LeaveItem leaveItem in source)
            {
                // check frozen date
                if (leaveItem.IsSelect && leaveItem.Start < currentFrozenDate)
                {
                    Message.Information("You cannot approve " + leaveItem.Submitter + "'s " + leaveItem.TypeValue + " leave." + Environment.NewLine + "Because its Start Time:" + leaveItem.StartValue + " is before: " + currentFrozenDate.ToString("yyyy-MM-dd"));
                    return;
                }
            }

            bool noneSelection       = true;
            CARSServiceClient client = CARSServiceClientFactory.CreateCARSServiceClient();// leave this line, we cannot use a public static object here. Because it may already has handler of ApproveLeaveCompleted

            client.ApproveLeaveCompleted += new EventHandler <ApproveLeaveCompletedEventArgs>(client_ApproveLeaveCompleted);

            foreach (LeaveItem item in source)
            {
                // If the record is already approved, we don't need to approve it again.  Go to the next record.
                if (item.IsSelect && item.Status != LeaveStatus.Accepted)
                {
                    noneSelection = false;
                    client.ApproveLeaveAsync(mUser.Employee.PKEmployeeID.ToString(), item.LeaveInfo.PKLeaveInfoID.ToString(), LeaveStatus.Accepted);
                    count++;
                }
            }

            if (noneSelection)
            {
                sc.Busy = false;
            }
        }
Пример #2
0
        public GenerateReport(User pUser)
        {
            InitializeComponent();

            InitializeUI();

            user = pUser;

            if (pUser.Employee.IsAdmin && pUser.Employee.IsManager)             // admin and supervisor
            {
                reportTypeCom.SelectedIndex = 0;
                reportTypeCom.IsEnabled     = true;
            }
            else if (pUser.Employee.IsAdmin && !pUser.Employee.IsManager)             // admin only
            {
                reportTypeCom.SelectedIndex = 0;
                reportTypeCom.IsEnabled     = false;
            }
            else             // supervisor only
            {
                reportTypeCom.SelectedIndex = 1;
                reportTypeCom.IsEnabled     = false;
            }

            CARSServiceClient client = CARSServiceClientFactory.CreateCARSServiceClient();

            client.GetReportPeriodsCompleted += new EventHandler <GetReportPeriodsCompletedEventArgs>(GenerateReport_GetReportPeriodsCompleted);
            client.GetReportPeriodsAsync();
        }
Пример #3
0
        void GenerateReport_GetReportPeriodsCompleted(object sender, GetReportPeriodsCompletedEventArgs e)
        {
            Logger.Instance().Log(MessageType.Information, "Get Report Periods Completed");
            if (ErrorHandler.Handle(e.Error))
            {
                return;
            }

            lockingFlag = true;

            List <ReportPeriod> list = e.Result.ToList <ReportPeriod>();

            if (list != null)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    int        index = (int)list[i].Month;
                    DatePicker start = null;
                    DatePicker end   = null;
                    //if (index > 1)
                    //{
                    start = (DatePicker)dateGrid.FindName("month" + index.ToString() + "Start");
                    end   = (DatePicker)dateGrid.FindName("month" + index.ToString() + "End");

                    start.SelectedDate = list[i].StartTime;
                    end.SelectedDate   = list[i].EndTime;
                    //}
                    //else if (index == 1)
                    //{
                    //    end = (DatePicker)dateGrid.FindName("month" + index.ToString() + "End");
                    //    end.SelectedDate = list[i].EndTime;
                    //}
                }
            }

            CARSServiceClient client = CARSServiceClientFactory.CreateCARSServiceClient();

            if (user.Employee.IsManager)
            {
                client.GetAnnualLeaveReportForSupervisorAddressCompleted += new EventHandler <GetAnnualLeaveReportForSupervisorAddressCompletedEventArgs>(client_GetAnnualLeaveReportForSupervisorAddressCompleted);
                client.GetSickLeaveReportForSupervisorAddressCompleted   += new EventHandler <GetSickLeaveReportForSupervisorAddressCompletedEventArgs>(client_GetSickLeaveReportForSupervisorAddressCompleted);

                client.GetAnnualLeaveReportForSupervisorAddressAsync();
                client.GetSickLeaveReportForSupervisorAddressAsync();
            }

            client.GetAnnualLeaveReportForAdminAddressCompleted += new EventHandler <GetAnnualLeaveReportForAdminAddressCompletedEventArgs>(client_GetAnnualLeaveReportForAdminAddressCompleted);
            client.GetAnnualLeaveReportForAdminAddressAsync();

            client.GetSickLeaveReportForAdminAddressCompleted += new EventHandler <GetSickLeaveReportForAdminAddressCompletedEventArgs>(client_GetSickLeaveReportForAdminAddressCompleted);
            client.GetSickLeaveReportForAdminAddressAsync();
        }
Пример #4
0
        public SearchControl(CARSPage page, User rootManager)
        {
            InitializeComponent();

            SetPageAndUser(page, rootManager);

            chkShowAll.IsChecked = CarsConfig.Instance().ShowAllRecords;

            CARSServiceClient client = CARSServiceClientFactory.CreateCARSServiceClient();// leave this line, we cannot use a public static object here. Because it may already has handler of GetLeaveTypesCompleted

            client.GetLeaveTypesCompleted += new EventHandler <GetLeaveTypesCompletedEventArgs>(client_GetLeaveTypesCompleted);
            client.GetLeaveTypesAsync();
        }
Пример #5
0
        public Login(bool firstTime)
        {
            InitializeComponent();

            isLoading = true;

            if (firstTime)
            {
                ClientInstance.Get().LoginCompleted                += new EventHandler <LoginCompletedEventArgs>(client_LoginCompleted);
                ClientInstance.Get().ForgetPasswordCompleted       += new EventHandler <ForgetPasswordCompletedEventArgs>(client_ForgetPasswordCompleted);
                ClientInstance.Get().GetUserManualAddressCompleted += new EventHandler <GetUserManualAddressCompletedEventArgs>(Login_GetUserManualAddressCompleted);
                ClientInstance.Get().GetReportBugAddressCompleted  += new EventHandler <GetReportBugAddressCompletedEventArgs>(Login_GetReportBugAddressCompleted);
                //animblur.Begin();
            }

            savePW.IsChecked = CarsConfig.Instance().DoSavePW;
            if (savePW.IsChecked == true)
            {
                autoLogin.IsEnabled = true;
                autoLogin.IsChecked = CarsConfig.Instance().DoAutoLogin;
            }
            else
            {
                autoLogin.IsEnabled = false;
            }

            //forgetButton.Height =
            loginButton.Height = registryButton.Height = 30;
            //forgetButton.Width =
            loginButton.Width          = registryButton.Width = 100;
            registryButton.ActiveColor = Colors.Black;
            loginButton.ActiveColor    = Colors.Black;

            CARSServiceClient client = CARSServiceClientFactory.CreateCARSServiceClient();

            client.GetVersionCompleted += new EventHandler <GetVersionCompletedEventArgs>(client_GetVersionCompleted);
            client.GetVersionAsync();

            if (ClientInstance.UserManualAddress != string.Empty)
            {
                userManualButton.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                ClientInstance.Get().GetUserManualAddressAsync();
            }

            ClientInstance.Get().GetReportBugAddressAsync();
        }
Пример #6
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            CARSServiceClient client = CARSServiceClientFactory.CreateCARSServiceClient();            // leave this line, we cannot use a public static object here. Because this reject reason window will be created may times.

            client.RejectLeaveCompleted += new EventHandler <RejectLeaveCompletedEventArgs>(client_RejectLeaveCompleted);
            string reasonValue = reason.Text.Replace("&", "&amp;")
                                 .Replace(" ", "&nbsp;")
                                 .Replace("\"", "&quot;")
                                 .Replace(">", "&gt;")
                                 .Replace("<", "&lt;");

            foreach (LeaveItem leave in leaves)
            {
                client.RejectLeaveAsync(mUser.Employee.PKEmployeeID.ToString(), leave.LeaveInfo.PKLeaveInfoID.ToString(), LeaveStatus.Rejected, reasonValue);
                count++;
            }

            this.DialogResult = true;
        }
Пример #7
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckValidation())
            {
                return;
            }

            urlSB = new StringBuilder();
            ObservableCollection <ReportPeriod> list = new ObservableCollection <ReportPeriod>();

            for (int i = 1; i <= 12; i++)
            {
                DatePicker start = (DatePicker)dateGrid.FindName("month" + i.ToString() + "Start");
                DatePicker end   = (DatePicker)dateGrid.FindName("month" + i.ToString() + "End");
                if (start.SelectedDate.HasValue && end.SelectedDate.HasValue)
                {
                    ReportPeriod rp = new ReportPeriod();
                    rp.Month     = (MonthRank)i;
                    rp.StartTime = new DateTime(start.SelectedDate.Value.Year, start.SelectedDate.Value.Month, start.SelectedDate.Value.Day, 0, 0, 0);
                    rp.EndTime   = new DateTime(end.SelectedDate.Value.Year, end.SelectedDate.Value.Month, end.SelectedDate.Value.Day, 23, 59, 59);
                    list.Add(rp);

                    urlSB.Append("&month");
                    urlSB.Append(i.ToString());
                    urlSB.Append("start=");
                    urlSB.Append(rp.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                    urlSB.Append("&month");
                    urlSB.Append(i.ToString());
                    urlSB.Append("end=");
                    urlSB.Append(rp.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                else
                {
                    ReportPeriod rp = new ReportPeriod();
                    rp.Month     = (MonthRank)i;
                    rp.StartTime = null;
                    rp.EndTime   = null;
                    list.Add(rp);
                }
            }

            urlARAnnual += urlSB.ToString();
            urlARSick   += urlSB.ToString();

            // Add parameter supervisorID
            urlSB.Append(string.Format("&supervisorID={0}", user.PKEmployeeID.ToString()));

            if (reportTypeCom.SelectedIndex == 0)             // administrator report, save data to DB.
            {
                CARSServiceClient client = CARSServiceClientFactory.CreateCARSServiceClient();
                client.UpdateReportPeriodsCompleted += new EventHandler <UpdateReportPeriodsCompletedEventArgs>(GenerateReport_UpdateReportPeriodsCompleted);
                client.UpdateReportPeriodsAsync(list);
            }
            else             // supervisor report, do NOT save data to DB.
            {
                HtmlWindow srAnnual = HtmlPage.Window;
                HtmlWindow srSick   = HtmlPage.Window;
                if (urlSRAnnual.ToLower().Contains("commingsoon"))
                {
                    srAnnual.Navigate(new Uri(urlSRAnnual), "_blank");
                    srSick.Navigate(new Uri(urlSRSick), "_blank");
                }
                else
                {
                    urlSRAnnual += urlSB.ToString();
                    urlSRSick   += urlSB.ToString();
                    srAnnual.Navigate(new Uri(urlSRAnnual), "_blank");
                    srSick.Navigate(new Uri(urlSRSick), "_blank");
                }
            }
            this.DialogResult = true;
        }