コード例 #1
0
        private void EditGrant(object sender, MouseButtonEventArgs e)
        {
            var db = new FCS_DBModel();

            try
            {
                DataGrid dg = sender as DataGrid;

                GrantsDataGrid p  = (GrantsDataGrid)dg.SelectedItems[0];                // OR:  Patient p = (Patient)dg.SelectedItem;
                UpdateGrant    up = new UpdateGrant(p);
                //Grant prop ID & donation ID with expense
                //p.DonationID
                var expenseTotal = (from ex in db.Expenses
                                    where ex.DonationID == p.DonationID
                                    select ex).Count();
                if (expenseTotal > 0)
                {
                    up.DonAmount.IsEnabled = false; up.AmountRem.IsEnabled = false;
                }
                up.DonationDate.SelectedDate       = p.DonationDate;
                up.DonationExpiration.SelectedDate = p.ExpirationDate;
                up.ShowDialog();
            }
            catch (Exception error)
            {
            }

            Refresh_GrantGrid(sender, e);
        }
コード例 #2
0
        private void getSessionData()
        {
            List <Session> GrantSessionList = new List <Session>();
            int            GID = 0;

            //db = new FCS_DBModel();
            System.Windows.Controls.DataGrid dg = Grant_DataGridReport as System.Windows.Controls.DataGrid;
            if (dg.SelectedItems.Count != 0)
            {
                GrantsDataGrid p = (GrantsDataGrid)dg.SelectedItems[0];                 // OR:  Patient p = (Patient)dg.SelectedItem;
                label2.Content = "List of sessions for: " + p.GrantName;
                GID            = p.GrantProposalID;

                if (grantReportFrom_datepicker.SelectedDate != null && grantReportFrom_datepicker.SelectedDate.GetValueOrDefault() != DateTime.MinValue && grantReportTo_datepicker.SelectedDate != null && grantReportTo_datepicker.SelectedDate.GetValueOrDefault() != DateTime.MinValue && GID != 0)
                {
                    DateTime requestedDateStart = (DateTime)grantReportFrom_datepicker.SelectedDate;
                    DateTime requestedDateEnd   = (DateTime)grantReportTo_datepicker.SelectedDate;

                    decimal remainingBalance = p.DonationAmount;
                    var     join             = from g in db.GrantProposals
                                               join d in db.Donations on g.GrantProposalID equals d.GrantProposalID
                                               join ex in db.Expenses on d.DonationID equals ex.DonationID
                                               join pa in db.Patients on ex.PatientID equals pa.PatientID
                                               join ap in db.Appointments on ex.AppointmentID equals ap.AppointmentID
                                               where g.GrantProposalID == GID && ap.AppointmentEndDate > requestedDateStart && ap.AppointmentEndDate < requestedDateEnd
                                               orderby ap.AppointmentEndDate
                                               select new SessionsDataGrid
                    {
                        ClientName = pa.PatientLastName + ", " + pa.PatientFirstName,
                        Sessions   = 1,
                        Amount     = ex.DonorBill,
                        Date       = ap.AppointmentEndDate,
                        Balance    = 0                                          //All balance calculations are done after collection is generated
                    };

                    //Clear list of previous sessions
                    GrantSessionList.Clear();

                    //Loop over join collection generated above to calculate the correct remaining balance for each row
                    foreach (var joint in join)
                    {
                        remainingBalance = remainingBalance - joint.Amount;
                        GrantSessionList.Add(new Session()
                        {
                            ClientName = joint.ClientName,
                            Sessions   = joint.Sessions,
                            Amount     = joint.Amount,
                            Date       = joint.Date,
                            Balance    = remainingBalance
                        });
                        //GrantSessionList.AddRange(GrantSessionList);
                        //GrantSessionList.AddRange(GrantSessionList);
                        //GrantSessionList.AddRange(GrantSessionList);
                    }
                }
            }
            GrantSessions_DataGridReport.ItemsSource = GrantSessionList;
            //gGrantSessionList = GrantSessionList;
        }
コード例 #3
0
        public UpdateGrant(GrantsDataGrid g)
        {
            FCS_DBModel db = new FCS_DBModel();
            Donation    d  = new Donation();

            foreach (var item in db.Purposes)
            {
                purpose.Add(item.PurposeName);
            }
            DataContext = purpose;

            GrantName               = g.GrantName;
            DonationAmount          = g.DonationAmount;
            DonationAmountRemaining = g.DonationAmountRemaining;
            PurposeName             = g.PurposeName;
            PurposeDescription      = g.PurposeDescription;
            PurposeID               = g.PurposeID;
            DonationID              = g.DonationID;
            DonorID         = g.DonorID;
            GrantProposalID = g.GrantProposalID;
            InitializeComponent();
            DonAmount.Focus();

            var restricted = (from item in db.Donations where item.DonationID == DonationID select item.Restricted).First();

            if (restricted == true)
            {
                var donationTable = (from don in db.Donations
                                     join dp in db.DonationPurposes
                                     on don.DonationID equals dp.DonationID
                                     join p in db.Purposes
                                     on dp.PurposeID equals p.PurposeID
                                     where don.DonationID == DonationID
                                     select new
                {
                    don.DonationID,
                    don.DonationExpirationDate,
                    don.Restricted,
                    dp.PurposeID
                }).First();
                DonationDate.IsEnabled          = false;
                DonationExpiration.SelectedDate = donationTable.DonationExpirationDate;
                restrictedCheckBox.IsChecked    = true;
                PurposeComboBox.SelectedItem    = (from p in db.Purposes
                                                   join dp in db.DonationPurposes
                                                   on p.PurposeID equals dp.PurposeID
                                                   join don in db.Donations
                                                   on dp.DonationID equals don.DonationID
                                                   where dp.PurposeID == donationTable.PurposeID
                                                   select p.PurposeName).First();
            }
        }
コード例 #4
0
        private void generate_Report()
        {
            System.Windows.Controls.DataGrid dg = Grant_DataGridReport as System.Windows.Controls.DataGrid;
            if (dg.SelectedItems.Count != 0)
            {
                GrantsDataGrid p = (GrantsDataGrid)dg.SelectedItems[0];
                System.Windows.Forms.WebBrowser newBrowser = new System.Windows.Forms.WebBrowser();
                newBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(PrintDocument);
                int    pCount        = 1;
                int    rCount        = 1;
                String browserString = "<!DOCTYPE html>"
                                       + "<html>"
                                       + "<head>"
                                       + "<style>"
                                       + "header nav, footer {"
                                       + "    display: none;"
                                       + "}"
                                       + "body {"
                                       + "    white-space: nowrap;"
                                       + "}"
                                       + "div.titlepage {"
                                       + "  page: blank; "
                                       + "}"
                                       + ".table {"
                                       + "   margin-top: 50px;"
                                       + "}"
                                       + ".break {"
                                       + "   page-break-after: always;"
                                       + "}"
                                       + ".cell {"
                                       + "   font-size:20px;"
                                       + "   text-align: left;"
                                       + "   border: 1px solid black;"
                                       + "}"
                                       + ".left {"
                                       + "   color:#000000;"
                                       + "   font-weight:bold;"
                                       + "   font-size:20px;"
                                       + "   text-align: left;"
                                       + "}"
                                       + ".right {"
                                       + "   color:#000000;"
                                       + "   font-weight:bold;"
                                       + "   font-size:20px;"
                                       + "   text-align: right;"
                                       + "}"
                                       + ".center {"
                                       + "   color:#FF0000;"
                                       + "   font-weight:bold;"
                                       + "   font-size:20px;"
                                       + "   text-align: center;"
                                       + "}"
                                       + "</style>"
                                       + "</head>"
                                       + "<body>";
                System.Windows.Controls.DataGrid ds = GrantSessions_DataGridReport as System.Windows.Controls.DataGrid;
                int itemCount = GrantSessions_DataGridReport.Items.Count;
                if (itemCount == 0)
                {
                    System.Windows.MessageBox.Show("There are no sessions to print for this Grant/Donation.");
                }
                else
                {
                    foreach (Session row in GrantSessions_DataGridReport.Items)
                    {
                        if (rCount == 1)
                        {
                            if (pCount == 1)
                            {
                                browserString += "    <div class='left' width='1229px' style='margin-top:10px;'>Grant Name: " + p.GrantName + "</div>"
                                                 + "    <div class='left' width='1229px' style='margin-top:10px;'>Amount Received: " + Math.Round(p.DonationAmount, 2).ToString() + "</div>"
                                                 + "    <div class='left' width='1229px' style='margin-top:10px;'>Date: " + p.DonationDate.ToString("MM/dd/yyyy") + "</div>"
                                                 + "    <div class='left' width='1229px' style='margin-top:10px;'>Description: " + p.PurposeDescription + "</div>"
                                                 + "    <div class='right' width='1229px' style='margin-top:10px;'>Grant Total: " + Math.Round(p.DonationAmountRemaining, 2).ToString() + "</div>";
                            }
                            else
                            {
                                browserString += "    <div class='left' width='1229px' style='margin-top:10px;'>Grant Name: " + p.GrantName + "</div>";
                            }

                            browserString += "    <div class='table'><table width='100%' border='0.5' bordercolor='black' bgcolor='black'>"
                                             + "        <tr border='0'>"
                                             + "            <td border='0.5' style='width:656px; padding-left: 4px; text-align: center;' bgcolor='white' bordercolor='black' class='cell'>Client Name</td>"
                                             + "            <td border='0.5' style='width:95px; padding-left: 4px; text-align: center;' bgcolor='white' bordercolor='black' class='cell'>Sessions</td>"
                                             + "            <td border='0.5' style='width:91px; padding-left: 4px; text-align: center;' bgcolor='white' bordercolor='black' class='cell'>Amount</td>"
                                             + "            <td border='0.5' style='width:91px; padding-left: 4px; text-align: center;' bgcolor='white' bordercolor='black' class='cell'>Date</td>"
                                             + "            <td border='0.5' style='width:96px; padding-left: 4px; text-align: center;' bgcolor='white' bordercolor='black' class='cell'>Balance</td>"
                                             + "        </tr>";
                        }
                        browserString += "        <tr>"
                                         + "            <td style='width:656px; padding-left: 4px;' bgcolor='white' bordercolor='black' class='cell'>" + row.ClientName + "</td>"
                                         + "            <td style='width:95px; padding-left: 4px;' bgcolor='white' bordercolor='black' class='cell'>" + row.Sessions + "</td>"
                                         + "            <td style='width:91px; padding-left: 4px;' bgcolor='white' bordercolor='black' class='cell'>" + Math.Round(row.Amount, 2) + "</td>"
                                         + "            <td style='width:91px; padding-left: 4px;' bgcolor='white' bordercolor='black' class='cell'>" + row.Date.ToString("MM/dd/yyyy") + "</td>"
                                         + "            <td style='width:96px; padding-left: 4px;' bgcolor='white' bordercolor='black' class='cell'>" + Math.Round(row.Balance, 2) + "</td>"
                                         + "        </tr>";
                        if ((pCount == 1 && rCount % 22 == 0) || rCount == itemCount + 1 || (pCount >= 2 && rCount % 27 == 0))
                        {
                            browserString += "    </table></div>";
                            if (pCount != rCount)
                            {
                                browserString += "    <div class='break'></div>";
                            }
                            rCount = 1;
                            pCount++;
                        }
                        else
                        {
                            rCount++;
                        }
                    }
                    browserString += "</body>"
                                     + "</html>";
                    newBrowser.DocumentText = browserString;
                }
            }
        }