コード例 #1
0
ファイル: frmMain.cs プロジェクト: smermod/TKDManager
        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);
            }
        }
コード例 #2
0
ファイル: frmPayments.cs プロジェクト: smermod/TKDManager
        private void btnMoveLeft_Click(object sender, EventArgs e)
        {
            var context = new TKDManagerEntities();
            int selectedPeriod = Convert.ToInt32(cboYear.SelectedValue) * 100 + Convert.ToInt32(cboMonth.SelectedValue);

            foreach (DataGridViewRow selectedRow in grdPaid.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 = new DateTime(1, 1, 1);
                        context.SaveChanges();
                    }
            }
            FillGrids();
        }
コード例 #3
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);
            }
        }
コード例 #4
0
ファイル: frmMemberEdit.cs プロジェクト: smermod/TKDManager
        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);
            }
        }