Example #1
0
        private void PrintDiploma()
        {
            var context = new TKDManagerEntities();

            PrintDialog pd = new PrintDialog();
            PrintDocument pdoc = new PrintDocument();
            DialogResult result;

            pdoc.PrintPage += pdoc_PrintPage;

            result = pd.ShowDialog();

            if (result == DialogResult.OK)
            {
                // Normally there should be only one cf the grid settings
                foreach (DataGridViewRow selectedRow in grdMembers.SelectedRows)
                {
                    int currentMemberID = Convert.ToInt32(selectedRow.Cells[0].Value.ToString());

                    _selectedMember = context.Member.First(m => m.MemberID == currentMemberID);

                    pdoc.PrinterSettings = pd.PrinterSettings;
                    pdoc.Print();

                }
            }
        }
Example #2
0
        private void GenerateBills(bool print)
        {
            try
            {

                var context = new TKDManagerEntities();
                DateTime dueDate = new DateTime(Convert.ToInt32(cboYear.SelectedValue), Convert.ToInt32(cboMonth.SelectedValue), 1);
                int selectedPeriod = Convert.ToInt32(cboYear.SelectedValue) * 100 + Convert.ToInt32(cboMonth.SelectedValue);

                PrintDialog pd = new PrintDialog();
                PrintDocument pdoc = new PrintDocument();
                DialogResult result = DialogResult.OK;

                pdoc.PrintPage += pdoc_PrintPage;

                if (print)
                {
                    result = pd.ShowDialog();
                }

                if (result == DialogResult.OK)
                {

                    foreach (DataGridViewRow selectedRow in grdMembers.SelectedRows)
                    {
                        int currentMemberID = Convert.ToInt32(selectedRow.Cells[0].Value.ToString());

                        _selectedMember = context.Member.First(m => m.MemberID == currentMemberID);
                        Fee fee = context.Fee.First(m => m.FeeID == _selectedMember.FeeID);

                        var bills = from bill in context.Bill
                                    where bill.MemberID == currentMemberID
                                    && bill.DueDate.Year * 100 + bill.DueDate.Month == selectedPeriod
                                    select bill;

                        if (!bills.Any())
                        {
                            context.Bill.Add(new Bill() { Amount = fee.FeeAmount, MemberID = currentMemberID, DueDate = dueDate });
                        }
                        else
                        {
                            bills.First().Amount = fee.FeeAmount;
                            bills.First().DueDate = dueDate;
                        }
                        context.SaveChanges();

                        if (print)
                        {
                            pdoc.PrinterSettings = pd.PrinterSettings;
                            pdoc.Print();
                        }
                    }
                }
                MessageBox.Show(this, "Factures générées avec succès.");
            }
            catch (Exception ex)
            {

                MessageBox.Show(this, ex.Message);
            }
        }
Example #3
0
        private void SaveMember()
        {
            var context = new TKDManagerEntities();
            Member member = new Member();

            try
            {
                if (CurrentMemberID == -1)
                {
                    member.ClubID = CurrentClubID;
                    context.Member.Add(member);
                }
                else
                {
                    member = context.Member.First(m => m.MemberID == CurrentMemberID);
                }

                member.FirstName = txtFirstName.Text;
                member.LastName = txtLastName.Text;
                member.ResponsiblePerson = txtResponsiblePerson.Text;
                member.BirthDate = dtpBirthDate.Value.Date;
                member.Gender = Convert.ToInt32(cboGender.SelectedValue.ToString());
                member.Address1 = txtAddress1.Text;
                member.NPA = txtNPA.Text;
                member.Town = txtTown.Text;
                member.HomePhoneNb = txtHomePhoneNb.Text;
                member.MobilePhoneNb = txtMobilePhoneNb.Text;
                member.EntryDate = dtpEntryDate.Value.Date;
                member.BeltID = Convert.ToInt32(cboBelt.SelectedValue.ToString());
                member.FeeID = Convert.ToInt32(cboFee.SelectedValue.ToString());
                member.AnnualLicensePaidUntil = Convert.ToInt32(cboLicensePaidUntil.SelectedValue.ToString());
                context.SaveChanges();

                ((frmMain)(Owner)).RefreshGrid(CurrentMemberID);

                MessageBox.Show(this, "Données sauvées avec succès.");
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message);
            }
        }