コード例 #1
0
        private void buttonInsertBand_Click(object sender, EventArgs e)
        {
            if (textBoxBandName.Text == "" || textBoxDescription.Text == "")
            {
                MessageBox.Show("Wrong input!");
                return;
            }

            IBandsRepository bandsRep = new BandsRepository();

            BandModel toPost = new BandModel();

            toPost.BandName          = textBoxBandName.Text;
            toPost.DiscriptionOfType = textBoxDescription.Text;

            bool flag = bandsRep.AddBand(toPost);

            if (flag)
            {
                MessageBox.Show("Posted!");
            }
            else
            {
                MessageBox.Show("Error!");
            }

            textBoxBandName.Text    = "";
            textBoxDescription.Text = "";
        }
コード例 #2
0
        private void buttonDeleteBand_Click(object sender, EventArgs e)
        {
            if (textBoxNameDelete.Text == "")
            {
                MessageBox.Show("Wrong input!");
                return;
            }

            IBandsRepository bandsRep = new BandsRepository();

            string toPost;

            toPost = textBoxNameDelete.Text;

            bool flag = bandsRep.DeleteBand(toPost);

            if (flag)
            {
                MessageBox.Show("Deleted!");
            }
            else
            {
                MessageBox.Show("Error!");
            }

            textBoxNameDelete.Text = "";
        }
コード例 #3
0
        private void buttonSeeBands_Click(object sender, EventArgs e)
        {
            IBandsRepository bandsRep = new BandsRepository();
            List <BandModel> bands    = bandsRep.GetAllBands().ToList();

            listBands.Items.Clear();

            foreach (BandModel band in bands)
            {
                string toList = "Id:" + band.BandId + ", Name:" + band.BandName
                                + ", Description:" + band.DiscriptionOfType;
                listBands.Items.Add(toList);
            }
        }
コード例 #4
0
        private void buttonExcel_Click(object sender, EventArgs e)
        {
            var workbook = new XLWorkbook();

            IXLWorksheet     worksheet = workbook.Worksheets.Add("Bands");
            IBandsRepository bandRep   = new BandsRepository();
            List <BandModel> bands     = bandRep.GetAllBands().ToList();

            worksheet.Cell(1, 1).Value = "Band Id";
            worksheet.Cell(1, 2).Value = "Type Id";
            worksheet.Cell(1, 3).Value = "Band name";
            worksheet.Cell(1, 4).Value = "DescriptionOfType";

            int i = 2;

            foreach (BandModel band in bands)
            {
                worksheet.Cell(i, 1).Value = band.BandId.ToString();
                worksheet.Cell(i, 2).Value = band.TypeId.ToString();
                worksheet.Cell(i, 3).Value = band.BandName;
                worksheet.Cell(i, 4).Value = band.DiscriptionOfType;
                i++;
            }


            using (FileStream fs = new FileStream("bands.xlsx", FileMode.OpenOrCreate))
            {
                workbook.SaveAs(fs);
            }

            //Excel.Application excelApp = new Excel.Application();

            //IBandsRepository bandRep = new BandsRepository();
            //List<BandModel> bands = bandRep.GetAllBands().ToList();

            //excelApp.Workbooks.Add();
            //Excel.Worksheet workSht = (Excel.Worksheet)excelApp.ActiveSheet;

            //int i = 0;
            //foreach (BandModel band in bands)
            //{
            //    workSht.Cells[i, 0] = band.BandId.ToString();
            //    workSht.Cells[i, 1] = band.TypeId.ToString();
            //    workSht.Cells[i, 2] = band.BandName;
            //    workSht.Cells[i, 3] = band.DiscriptionOfType;
            //}

            //excelApp.Visible = true;
        }
コード例 #5
0
        private void buttonUpdateBand_Click(object sender, EventArgs e)
        {
            if (textBoxBandName.Text == "" || textBoxNewBandName.Text == "")
            {
                MessageBox.Show("Wrong input!");
                return;
            }

            IBandsRepository bandsRep = new BandsRepository();

            bool flag = bandsRep.UpdateBandName(textBoxBandName.Text, textBoxNewBandName.Text);

            if (flag)
            {
                MessageBox.Show("Updated!");
            }
            else
            {
                MessageBox.Show("Error!");
            }

            textBoxBandName.Text    = "";
            textBoxNewBandName.Text = "";
        }
コード例 #6
0
 // Entries constructor w/declared entries list for Home page
 public EntriesController()
 {
     _entriesRepository = new EntriesRepository();
     _bandsRepository   = new BandsRepository();
 }
コード例 #7
0
 // Entries constructor w/declared entries list for Home page
 public HomeController()
 {
     _bandsRepository = new BandsRepository();
 }