Пример #1
0
        private void updateSubmit_Click(object sender, EventArgs e)
        {
            //Validate search
            if (!Validation.ValidateTypeName(txtType.Text))
            {
                MessageBox.Show("Search invalid", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtType.Clear();
                txtType.Focus();
                return;
            }
            else
            {
                //Search
                DataSet ds   = new DataSet();
                DVDType type = new DVDType();

                String searched = txtType.Text;

                grdSearch.DataSource = type.getSearchTypes(ds, searched.ToUpper()).Tables["stk"];

                if (ds.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("No results found, please try again", "No Results!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                //reset UI
                txtType.Clear();

                txtType.Focus();
            }
        }
Пример #2
0
        private void submit_Click(object sender, EventArgs e)
        {
            if (type.Equals(""))
            {
                MessageBox.Show("No TypeOfDVD set", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                //Save to DB
                String desc  = txtDescription.Text.ToUpper();
                double price = Convert.ToDouble(nudPrice.Value);

                DVDType up = new DVDType(type, desc, price);


                up.UpdateType();

                //reset UI
                txtType.Clear();
                nudPrice.ResetText();
                txtDescription.Clear();

                txtType.Focus();
            }
        }
Пример #3
0
        private void frmUpdateDVDType_Load(object sender, EventArgs e)
        {
            DVDType type = new DVDType();
            //Fill DataGridView
            DataSet ds = new DataSet();

            grdSearch.DataSource         = type.GetTypesFromDatabase().Tables["stk"];
            grdSearch.AllowUserToAddRows = false;
        }
Пример #4
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            DataTable numberOfEachTypeRentedDuringTimePeriod = new DataTable();
            DVDType   type = new DVDType();

            numberOfEachTypeRentedDuringTimePeriod = type.GetRentalsPerType(dtpStart.Text, dtpEnd.Text).Tables[0];

            //Array for each value per month
            int[] amounts = new int[type.GetNumTypes()];

            for (int i = 0; i < numberOfEachTypeRentedDuringTimePeriod.Rows.Count; i++)
            {
                amounts[i] = Convert.ToInt32(numberOfEachTypeRentedDuringTimePeriod.Rows[i][1]);
            }

            //Array for each TypeOfDVD
            string[] types = new string[type.GetNumTypes()];

            DataSet ds = type.GetTypesFromDatabase();

            DataTable dt1 = new DataTable();

            dt1 = ds.Tables[0];

            numberOfEachTypeRentedDuringTimePeriod = type.GetRentalsPerType(dtpStart.Text, dtpEnd.Text).Tables[0];

            for (int i = 0; i < types.Length; i++)
            {
                types[i] = dt1.Rows[i][0].ToString();
            }

            chtData.ChartAreas[0].AxisX.MajorGrid.LineWidth = 0;
            chtData.ChartAreas[0].AxisY.MajorGrid.LineWidth = 0;
            chtData.Series[0].LegendText = "Income in €";

            chtData.Series["Series1"]["PointWidth"] = ".5";

            chtData.Series["Series1"]["PixelPointWidth"] = "20";
            chtData.Series[0].Points.DataBindXY(types, amounts);
            chtData.ChartAreas["ChartArea1"].AxisX.LabelStyle.Format = "C";

            chtData.Series[0].Label = "#VALY";

            chtData.Titles.Clear();
            chtData.Titles.Add("Types rented over time");
            chtData.ChartAreas[0].AxisX.Title   = "DVDType";
            chtData.ChartAreas[0].AxisY.Title   = "Number of Times Rented";
            chtData.Series[0].IsVisibleInLegend = false;


            chtData.Visible = true;
        }
Пример #5
0
        private void frmUpdateDVD_Load(object sender, EventArgs e)
        {
            DVDType type = new DVDType();
            //Get types for drop down
            DataSet ds = type.GetTypesFromDatabase();


            DataTable dt = new DataTable();

            dt = ds.Tables[0];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cboType.Items.Add(dt.Rows[i][0].ToString());
            }
        }
Пример #6
0
        private void submit_Click(object sender, EventArgs e)
        {
            //validate input
            if (txtType.Text.Equals(""))
            {
                MessageBox.Show("DVD DVDType must be entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtType.Focus();
                return;
            }

            if (nudPrice.Value == 0)
            {
                MessageBox.Show("DVDType Price must be entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                nudPrice.Focus();
                return;
            }


            //add to database
            DVDType type = new DVDType(txtType.Text.ToUpper(), txtDescription.Text.ToUpper(), Convert.ToDouble(nudPrice.Value));

            if (!type.AlreadyExists())
            {
                type.AddType();

                //reset UI
                txtType.Clear();
                nudPrice.Value = 0;
                txtDescription.Clear();

                txtType.Focus();
            }
            else
            {
                txtType.Focus();
            }
        }