Beispiel #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;
            }
        }