Esempio n. 1
0
        private void uxButtonInsertProduction_Click(object sender, EventArgs e)
        {
            repo = new SqlProductionRepository("Data Source=mssql.cs.ksu.edu;" +
                                               "Initial Catalog=phyo;" +
                                               "User id=username;" +
                                               "Password=password;");
            if (uxButtonInsertProduction.Text == "Insert")
            {
                var name     = uxProductionName.Text;
                var location = uxProductionLocation.Text;
                try
                {
                    var createdPH = repo.AddProductionHouse(name, location);
                    MessageBox.Show("Production house succesfully added.");
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Sorry, the production company already exists.");
                }
                dataGridView1.DataSource = null;

                dataGridView1.DataSource = repo.RetrieveProduction2();
            }
            else
            {
                var name     = uxProductionName.Text;
                var location = uxProductionLocation.Text;

                //Should be modify stored procedure
                var createdPH = repo.UpdateProduction(name, location, ProductionId);
                dataGridView1.DataSource = null;

                dataGridView1.DataSource = repo.RetrieveProduction2();
            }
        }
Esempio n. 2
0
        private void uxViewButton_Click(object sender, EventArgs e)
        {
            repo = new SqlProductionRepository("Data Source=mssql.cs.ksu.edu;" +
                                               "Initial Catalog=phyo;" +
                                               "User id=username;" +
                                               "Password=password;");
            dataGridView1.DataSource = null;
            dataGridView1.Rows.Clear();
            dataGridView1.DataSource = repo.RetrieveProduction2();

            dataGridView1.Refresh();
        }
Esempio n. 3
0
        private void uxDeleteProduction_Click(object sender, EventArgs e)
        {
            repo = new SqlProductionRepository("Data Source=mssql.cs.ksu.edu;" +
                                               "Initial Catalog=phyo;" +
                                               "User id=username;" +
                                               "Password=password;");
            var id        = repo.GetProductionHouse(uxProductionName.Text);
            var createdPH = repo.DeleteProduction(uxProductionName.Text, uxProductionLocation.Text, id.ProductionId);

            MessageBox.Show("Production sucessfully deleted.");

            dataGridView1.DataSource = null;

            dataGridView1.DataSource = repo.RetrieveProduction2();
        }