private void EdClSebtn1_Click(object sender, EventArgs e)
 {
     SearchMo = EdClSetxtbox1.Text;
     ReadEntries.SearchMovie(SearchMo);
     if (ReadEntries.SearchMovies.Count() == 0)
     {
         MessageBox.Show("No Results Found");
         dataGridView1.DataSource = null;
     }
     else
     {
         dataGridView1.DataSource  = null;
         dataGridView1.DataSource  = ReadEntries.AllMovies();
         dataGridView1.CurrentCell = null;
         foreach (DataGridViewRow row in dataGridView1.Rows)
         {
             if (ReadEntries.SearchMovies.Contains(row.Index))
             {
                 row.Visible = true;
             }
             else
             {
                 row.Visible = false;
             }
         }
         dataGridView1.CellBeginEdit -= dataGridView1_CellBeginEdit;
         dataGridView1.CellBeginEdit += dataGridView1_CellBeginEdit;
         dataGridView1.CellEndEdit   -= dataGridView1_CellEndEdit;
         dataGridView1.CellEndEdit   += dataGridView1_CellEndEdit;
     }
 }
 private void AllMvbtn_Click(object sender, EventArgs e)
 {
     dataGridView1.DataSource     = ReadEntries.AllMovies();
     dataGridView1.CellBeginEdit -= dataGridView1_CellBeginEdit;
     dataGridView1.CellBeginEdit += dataGridView1_CellBeginEdit;
     dataGridView1.CellEndEdit   -= dataGridView1_CellEndEdit;
     dataGridView1.CellEndEdit   += dataGridView1_CellEndEdit;
 }
Exemple #3
0
        private void combobox()
        {
            DataGridViewComboBoxColumn namecol  = (DataGridViewComboBoxColumn)dataGridView1.Columns[0];
            DataGridViewComboBoxColumn titlecol = (DataGridViewComboBoxColumn)dataGridView1.Columns[2];

            namecol.DataSource  = ReadEntries.AllClients();
            titlecol.DataSource = ReadEntries.AllMovies();
            dataGridView1.Columns[4].ReadOnly = true;
            dataGridView1.Columns[1].ReadOnly = true;
        }
        public AddRental()
        {
            InitializeComponent();
            comboBox1.DataSource    = ReadEntries.AllClients();
            comboBox1.DisplayMember = "Name";
            comboBox1.ValueMember   = "Name";

            comboBox2.DataSource    = ReadEntries.AllMovies();
            comboBox2.DisplayMember = "Title";
            comboBox2.ValueMember   = "Title";
            comboBox3.Text          = 0.ToString();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this entry?", "", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                int delmo = dataGridView1.CurrentCell.RowIndex;
                DeleteEntries.DeleteMo(delmo);
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = ReadEntries.AllMovies();
            }
            else if (dialogResult == DialogResult.No)
            {
            }
        }
Exemple #6
0
 private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridView1.Columns[e.ColumnIndex].DataPropertyName == "Days")
     {
         string title = dataGridView1.Rows[e.RowIndex].Cells[2].FormattedValue.ToString();
         int    days  = int.Parse(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString());
         foreach (Movie m in ReadEntries.AllMovies())
         {
             if (m.Title == title)
             {
                 dataGridView1.Rows[e.RowIndex].Cells[4].Value = Rental.getAmount(m.Price, days);
                 MessageBox.Show("Rental data updated succesfully");
                 UpdateEntries.UpdateReJson("Days", dataGridView1.CurrentCell.Value.ToString(), dataGridView1.CurrentCell.RowIndex);
             }
         }
     }
     if (dataGridView1.Columns[e.ColumnIndex].DataPropertyName == "Name")
     {
         string name = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString();
         foreach (Client c in ReadEntries.AllClients())
         {
             if (c.Name == name)
             {
                 dataGridView1.Rows[e.RowIndex].Cells[1].Value = c.Tel;
                 MessageBox.Show("Rental data updated succesfully");
                 UpdateEntries.UpdateReJson("Name", dataGridView1.CurrentCell.Value.ToString(), dataGridView1.CurrentCell.RowIndex, dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString());
             }
         }
     }
     else if (dataGridView1.Columns[e.ColumnIndex].DataPropertyName == "Title")
     {
         string title = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString();
         int    days  = int.Parse(dataGridView1.Rows[e.RowIndex].Cells[3].FormattedValue.ToString());
         foreach (Movie m in ReadEntries.AllMovies())
         {
             if (m.Title == title)
             {
                 dataGridView1.Rows[e.RowIndex].Cells[4].Value = Rental.getAmount(m.Price, days);
                 MessageBox.Show("Rental data updated succesfully");
                 UpdateEntries.UpdateReJson("Title", dataGridView1.CurrentCell.Value.ToString(), dataGridView1.CurrentCell.RowIndex, dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString());
             }
         }
     }
 }