コード例 #1
0
        public FormLoanProperties(DataBase dataBase, LoanedCDDataSet.LoanedCDRow loanedCD)
            : this()
        {
            loanedCDRow = loanedCD;

            CDTableAdapter          cdta          = new CDTableAdapter(dataBase);
            PersonGroupTableAdapter personGroupta = new PersonGroupTableAdapter(dataBase);

            CDDataSet.CDDataTable cd = cdta.GetDataById(loanedCDRow.CDID);
            PersonGroupDataSet.PersonGroupDataTable personGroup = personGroupta.GetDataById(cd[0].ArtistID);

            textBoxArtist.Text = personGroup[0].Name;
            textBoxTitle.Text  = cd[0].Title;

            comboBoxLoanedTo.Text = loanedCDRow.LoanedTo;

            checkBoxActivateBringBack.Checked = !loanedCDRow.IsReturnDateNull();
            if (!loanedCDRow.IsReturnDateNull())
            {
                dateTimePickerBringBack.Value = loanedCDRow.ReturnDate;
            }

            if (!loanedCDRow.IsLoanedDateNull())
            {
                dateTimePickerLoaned.Value = loanedCDRow.LoanedDate;
            }
            textBoxComment.Text = loanedCDRow.Comment;
        }
コード例 #2
0
        private void FillList()
        {
            LoanedCDTableAdapter ta = new LoanedCDTableAdapter(dataBase);

            LoanedCDDataSet.LoanedCDDataTable dt = ta.GetData();

            CDTableAdapter          cdta          = new CDTableAdapter(dataBase);
            PersonGroupTableAdapter personGroupta = new PersonGroupTableAdapter(dataBase);

            tableLoanedCDs.TableModel.Rows.Clear();

            foreach (LoanedCDDataSet.LoanedCDRow loanedCDRow in dt)
            {
                string artist;
                string title;

                CDDataSet.CDDataTable cd = cdta.GetDataById(loanedCDRow.CDID);
                if (cd.Count == 0)      // CD wurde wohl gelöscht
                {
                    artist = "<" + StringTable.Deleted + ">";
                    title  = "<" + StringTable.Deleted + ">";
                }
                else
                {
                    PersonGroupDataSet.PersonGroupDataTable personGroup = personGroupta.GetDataById(cd[0].ArtistID);

                    artist = personGroup[0].Name;
                    title  = cd[0].Title;
                }

                XPTable.Models.Row newRow = new XPTable.Models.Row();
                newRow.Cells.Add(new XPTable.Models.Cell(artist));
                newRow.Cells.Add(new XPTable.Models.Cell(title));
                newRow.Cells.Add(new XPTable.Models.Cell(loanedCDRow.LoanedTo));
                newRow.Cells.Add(new XPTable.Models.Cell(loanedCDRow.LoanedDate.ToShortDateString()));
                if (!loanedCDRow.IsReturnDateNull())
                {
                    if (loanedCDRow.ReturnDate <= DateTime.Now)
                    {
                        newRow.ForeColor = Color.Red;
                    }

                    newRow.Cells.Add(new XPTable.Models.Cell(loanedCDRow.ReturnDate.ToShortDateString()));
                }
                else
                {
                    newRow.Cells.Add(new XPTable.Models.Cell(""));
                }
                newRow.Cells.Add(new XPTable.Models.Cell(loanedCDRow.Comment));

                newRow.Tag = loanedCDRow;

                tableLoanedCDs.TableModel.Rows.Add(newRow);
            }

            UpdateWindowState();
        }