Example #1
0
        private void frmMemberEdit_Load(object sender, EventArgs e)
        {
            LoadGenders();
            ComboBoxHelper.LoadBelts(cboBelt);
            LoadFees();
            ComboBoxHelper.PopulateYears(cboLicensePaidUntil, true);
            dtpBirthDate.Value = DateTime.Now;
            dtpEntryDate.Value = DateTime.Now;

            var context = new TKDManagerEntities();
            txtFirstName.Focus();

            if (CurrentMemberID != -1)
            {
                // Retrieve the user whose ID matches with the ID textbox
                Member member = context.Member.First(m => m.MemberID == CurrentMemberID);

                txtMemberID.Text = member.MemberID.ToString();
                txtFirstName.Text = member.FirstName;
                txtLastName.Text = member.LastName;
                txtResponsiblePerson.Text = member.ResponsiblePerson;
                dtpBirthDate.Value = member.BirthDate ?? DateTime.Now.Date;
                cboGender.SelectedValue = member.Gender;
                txtAddress1.Text = member.Address1;
                txtNPA.Text = member.NPA;
                txtTown.Text = member.Town;
                txtHomePhoneNb.Text = member.HomePhoneNb;
                txtMobilePhoneNb.Text = member.MobilePhoneNb;
                dtpEntryDate.Value = member.EntryDate;
                cboBelt.SelectedValue = member.BeltID;
                cboFee.SelectedValue = member.FeeID;
                cboLicensePaidUntil.SelectedValue = member.AnnualLicensePaidUntil;
            }
        }
Example #2
0
        public static string SetBeltLookup(string value)
        {
            string retval;

            var context = new TKDManagerEntities();

            Belt belt = context.Belt.First(b => b.BeltID.ToString() == value);

            retval = belt.BeltDescription;

            return retval;
        }
Example #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int currentMemberID  = Convert.ToInt32(grdMembers.SelectedRows[0].Cells[0].Value);

            if (MessageBox.Show(string.Format("Supprimer définitivement le membre no: {0}?", grdMembers.SelectedRows[0].Cells[0].Value), "Suppression", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                var context = new TKDManagerEntities();
                Member member = context.Member.First(m => m.MemberID == currentMemberID);
                context.Member.Remove(member);
                context.SaveChanges();
                RefreshGrid(-1);
            }
        }
Example #4
0
        private void btnMoveRight_Click(object sender, EventArgs e)
        {
            var context = new TKDManagerEntities();
            int selectedPeriod = Convert.ToInt32(cboYear.SelectedValue) * 100 + Convert.ToInt32(cboMonth.SelectedValue);

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

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

                    if (bills.Any())
                    {
                        bills.First().PaidDate = DateTime.Now.Date;
                        context.SaveChanges();
                    }
            }
            FillGrids();
        }
Example #5
0
        private void FillGrid(string column, SortOrder order)
        {
            var context = new TKDManagerEntities();

            var members = from member in context.Member
                            where member.ClubID == CurrentClubID
                            select new SimpleMember {MemberID = member.MemberID, FirstName = member.FirstName, LastName = member.LastName};

            var param = column;
            var pi = typeof(SimpleMember).GetProperty(param);
            var orderedMembers = order == SortOrder.Descending ? members.ToList().OrderBy(x => pi.GetValue(x, null)) : members.ToList().OrderByDescending(x => pi.GetValue(x, null));

            grdMembers.DataSource = orderedMembers.ToList();

            DataGridViewHelper.SetSimpleMemberColumnName(grdMembers);

            grdMembers.Columns[0].Width = 60;
            grdMembers.Columns[1].Width = 140;
            grdMembers.Columns[2].Width = 140;

            var dataGridViewColumn = grdMembers.Columns[column];
            if (dataGridViewColumn != null) dataGridViewColumn.HeaderCell.SortGlyphDirection = order;
        }
Example #6
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 #7
0
        private void PrintPage(PrintPageEventArgs e)
        {
            var			context		= new TKDManagerEntities();
            string		titre		= _selectedMember.Gender == 0 ? "Monsieur" : "Madame";

            Graphics	graphics	= e.Graphics;
            Font		font		= new Font("Tahoma", 10, FontStyle.Regular);
            SolidBrush	brush		= new SolidBrush(Color.Black);
            int			posX		= 50;
            int			posY		= 140;
            int			offsetY		= 20;
            Image		logoImage	= new Bitmap("LogoTKDleman.jpg");

            graphics.DrawImage(logoImage, posX, 40);

            // Title
            graphics.DrawString("Ecoles de Taekwondo", new Font("Tahoma", 16, FontStyle.Underline | FontStyle.Bold), brush, 270, 50);
            graphics.DrawString("Association de Taekwondo du Léman", new Font("Tahoma", 12, FontStyle.Underline | FontStyle.Bold), brush, 240, 80);

            // Owner address
            graphics.DrawString("Rte de la Gare 32", font, brush, posX, posY);
            posY += offsetY;
            graphics.DrawString("1305 Penthalaz", font, brush, posX, posY);
            posY += offsetY;
            graphics.DrawString("Tel. : 021.861.49.30", font, brush, posX, posY);
            posY += offsetY;
            graphics.DrawString("Nat. : 079.206.76.47", font, brush, posX, posY);

            // Member address and date
            posX = 480;
            posY = 200;

            if (string.IsNullOrEmpty(_selectedMember.ResponsiblePerson))
            {
                graphics.DrawString(titre, font, brush, posX, posY);
                posY += offsetY;
                graphics.DrawString(_selectedMember.FirstName + " " + _selectedMember.LastName, font, brush, posX, posY);
            }
            else
            {
                posY += offsetY;
                graphics.DrawString(_selectedMember.ResponsiblePerson, font, brush, posX, posY);
            }
            posY += offsetY;
            graphics.DrawString(_selectedMember.Address1, font, brush, posX, posY);
            if (_selectedMember.Address2 != string.Empty)
            {
                posY += offsetY;
                graphics.DrawString(_selectedMember.Address2, font, brush, posX, posY);
            }
            posY += offsetY;
            graphics.DrawString(_selectedMember.NPA + " " + _selectedMember.Town, font, brush, posX, posY);
            posY += offsetY;
            posY += offsetY;
            posY += offsetY;
            posY += offsetY;
            posY += offsetY;
            posY += offsetY;
            graphics.DrawString("Penthalaz, le " + DateTime.Now.Date.ToShortDateString(), font, brush, posX, posY);

            // Content begin
            posX = 50;
            posY = 380;

            graphics.DrawString("Membre: " + _selectedMember.MemberID + " " + _selectedMember.FirstName + " " + _selectedMember.LastName, font, brush, posX, posY);
            posY += offsetY;
            font = new Font("Tahoma", 10, FontStyle.Bold);

            posY += offsetY;
            posY += offsetY;
            Fee fee = context.Fee.First(m => m.FeeID == _selectedMember.FeeID);
            graphics.DrawString("Concerne: Paiement de la cotisation mensuelle de: CHF " + fee.FeeAmount + ".-", font, brush, posX, posY);
            posY += offsetY;
            posY += offsetY;
            posY += offsetY;
            posY += offsetY;
            posY += offsetY;

            font = new Font("Tahoma", 10, FontStyle.Regular);
            graphics.DrawString("Cher(ère) membre,", font, brush, posX, posY);
            posY += offsetY;
            graphics.DrawString("Nous vous remercions de votre confiance et espérons que le Taekwondo vous convient!", font, brush, posX, posY);
            posY += offsetY;
            graphics.DrawString("N'hésitez pas à nous contacter si nécessaire.", font, brush, posX, posY);
            posY += offsetY;
            posY += offsetY;
            font = new Font("Tahoma", 10, FontStyle.Bold);
            graphics.DrawString("N'oubliez pas de mentionner sur le paiement le prénom et le nom de l'élève.", font, brush, posX, posY);
            font = new Font("Tahoma", 10, FontStyle.Regular);
            posY += offsetY;
            posY += offsetY;
            graphics.DrawString("Il ne vous sera pas envoyé d'autres factures. Veuilez trouver ci-joint les bulletins de versement", font, brush, posX, posY);
            posY += offsetY;
            graphics.DrawString("pour le reste de l'année scolaire", font, brush, posX, posY);
            posY += offsetY;
            posY += offsetY;
            graphics.DrawString(txtMessage.Text, font, brush, posX, posY);
            posY += offsetY;
            posY += offsetY;
            posY += offsetY;
            posY += offsetY;
            posY += offsetY;
            posY += offsetY;
            posY += offsetY;
            posY += offsetY;
            posY += offsetY;
            graphics.DrawString("Taekwondosement vôtre, ", font, brush, posX, posY);
            posY += offsetY;
            graphics.DrawString("Le service comptable.", font, brush, 480, posY);
        }
Example #8
0
        private void PrintPage(PrintPageEventArgs e)
        {
            PrintCoordinatesSection config = (PrintCoordinatesSection)ConfigurationManager.GetSection("PrintCoordinates");
            int largeFontSize = int.Parse(ConfigurationManager.AppSettings["DiplLargeFontSize"]);
            int smallFontSize = int.Parse(ConfigurationManager.AppSettings["DiplSmallFontSize"]);
            float x = config.Instances["DiplNameCoordinates"].X;
            float y = config.Instances["DiplNameCoordinates"].Y;

            var			context		= new TKDManagerEntities();
            Graphics	graphics	= e.Graphics;
            Font		font		= new Font("Arial Narrow", largeFontSize, FontStyle.Regular);
            SolidBrush	brush		= new SolidBrush(Color.Black);

            string		keupFrom	= cboBeltFrom.SelectedValue.ToString();
            string		beltFrom	= cboBeltFrom.Text;

            graphics.DrawString(_selectedMember.FirstName + " " + _selectedMember.LastName, font, brush, x, y);

            x = config.Instances["DiplBirthDateCoordinates"].X;
            y = config.Instances["DiplBirthDateCoordinates"].Y;
            if (_selectedMember.BirthDate != null)
                graphics.DrawString(_selectedMember.BirthDate.Value.ToShortDateString(), font, brush, x, y);

            x = config.Instances["DiplKeupCoordinates"].X;
            y = config.Instances["DiplKeupCoordinates"].Y;
            graphics.DrawString(keupFrom, font, brush, x, y);

            x = config.Instances["DiplBeltCoordinates"].X;
            y = config.Instances["DiplBeltCoordinates"].Y;
            graphics.DrawString(beltFrom, font, brush, x, y);

            font		= new Font("Arial Narrow", smallFontSize, FontStyle.Regular);
            x = config.Instances["DiplDateCoordinates"].X;
            y = config.Instances["DiplDateCoordinates"].Y;
            graphics.DrawString(dtpDate.Value.ToShortDateString(), font, brush, x, y);
        }
Example #9
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 #10
0
        private void FillGrid(string column, SortOrder order)
        {
            var context = new TKDManagerEntities();

            CurrentClubID = StringHelper.GetClubNumberFromConcat(cboClubs.SelectedItem.ToString());

            var members = from member in context.Member
                            where member.ClubID == CurrentClubID
                            select member;

            var param = column;
            var pi = typeof(Member).GetProperty(param);
            var orderedMembers = order == SortOrder.Descending ? members.ToList().OrderBy(x => pi.GetValue(x, null)) : members.ToList().OrderByDescending(x => pi.GetValue(x, null));

            grdMembers.DataSource = orderedMembers.ToList();

            DataGridViewHelper.SetMainColumnName(grdMembers);

            grdMembers.Columns[6].Visible = false;
            grdMembers.Columns[9].Visible = false;
            grdMembers.Columns[11].Visible = false;
            grdMembers.Columns[14].Visible = false;
            grdMembers.Columns[16].Visible = false;
            grdMembers.Columns[17].Visible = false;

            var dataGridViewColumn = grdMembers.Columns[column];
            if (dataGridViewColumn != null) dataGridViewColumn.HeaderCell.SortGlyphDirection = order;
        }
Example #11
0
        private void FillClubList()
        {
            var context = new TKDManagerEntities();

            var clubs = from club in context.Club
                        orderby club.ClubID
                        select club;

            foreach (var club in clubs)
            {
                cboClubs.Items.Add(club.ClubID + " - " + club.ClubName);
            }
        }
Example #12
0
        private void FillUnPaidGrid(string column, SortOrder order)
        {
            if (cboYear.SelectedValue != null && cboYear.SelectedValue != null)
            {
                int selectedPeriod = Convert.ToInt32(cboYear.SelectedValue) * 100 + Convert.ToInt32(cboMonth.SelectedValue);

                var context = new TKDManagerEntities();

                var unpaid = from member in context.Member
                                join bill in context.Bill on member.MemberID equals bill.MemberID
                                where member.ClubID == CurrentClubID
                                && bill.DueDate.Year * 100 + bill.DueDate.Month == selectedPeriod
                                && bill.PaidDate < new DateTime(1900, 1, 1)
                                select new PaymentMember
                                    { MemberID = member.MemberID
                                    , FirstName = member.FirstName
                                    , LastName = member.LastName
                                    , Amount = bill.Amount
                                    };

                var param = column;
                var pi = typeof(PaymentMember).GetProperty(param);
                var orderedMembers = order == SortOrder.Descending ? unpaid.ToList().OrderBy(x => pi.GetValue(x, null)) : unpaid.ToList().OrderByDescending(x => pi.GetValue(x, null));

                grdUnPaid.DataSource = orderedMembers.ToList();

                DataGridViewHelper.SetSimpleMemberColumnName(grdUnPaid);

                grdUnPaid.Columns[0].Width = 60;
                grdUnPaid.Columns[1].Width = 110;
                grdUnPaid.Columns[2].Width = 110;
                grdUnPaid.Columns[3].Width = 60;

                var dataGridViewColumn = grdUnPaid.Columns[column];
                if (dataGridViewColumn != null) dataGridViewColumn.HeaderCell.SortGlyphDirection = order;

            }
        }
Example #13
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);
            }
        }
Example #14
0
        private void LoadFees()
        {
            var context = new TKDManagerEntities();

            var fees = from fee in context.Fee
                        orderby fee.FeeID
                        select fee;

            cboFee.DataSource = fees.ToList();
            cboFee.DisplayMember = "FeeAmount";
            cboFee.ValueMember = "FeeID";
        }