private void btnSave_Click(object sender, EventArgs e)
        {
            CtrAuction ctrAuction = new CtrAuction();

            DateTime dateCreated = dtpDate.Value;

            string     description = txtDecs.Text;
            List <Art> artList     = lbxSelectedArt.Items.OfType <Art>().ToList();

            if (dateCreated < DateTime.Now)
            {
                MessageBox.Show("Vælg en kommende dato", "Fejl", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (artList.Count == 0)
            {
                MessageBox.Show("Der skal vælges kunstgenstande", "Fejl", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (auction == null)
                {
                    ctrAuction.CreateAuction(dateCreated, description, artList);
                    MessageBox.Show("Auktionen er oprettet", "Succes", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    auction.Date        = dtpDate.Value;
                    auction.Description = txtDecs.Text;
                    auction.Arts        = artList;
                    ctrAuction.UpdateAuction(auction);
                    MessageBox.Show("Auktionen er nu redigeret", "Succes", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                btnCancel_Click(null, null);
            }
        }
示例#2
0
        public void TestCreateAndInsertAuction()
        {
            Art        art     = artCtr.RetrieveById(27);
            List <Art> artList = new List <Art>();

            artList.Add(art);

            Auction auction = ctrAuction.CreateAuction(DateTime.Now, "Test description", artList);

            Assert.IsNotNull(auction.Date, "Date created");
            Assert.IsTrue(0 < auction.Description.Length, "Description is set");
            Assert.IsNotNull(auction.Arts, "Art list is set");
            ctrAuction.DeleteAuction(auction);
        }