Exemple #1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                var checkCell = (DataGridViewCheckBoxCell)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
                dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
                var t = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[6].Value);

                var v = mc.GetVare(t);
                v.CurrentlyInUse = (bool)checkCell.Value;
                mc.UpdateVare(v);
                mc.UpdateMainButtons();
            }
            if (e.ColumnIndex == 3)
            {
                var t = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[6].Value);
                var v = mc.GetVare(t);
                mc.PushVareUp(v);
                InitializeList();
                mc.UpdateMainButtons();
            }
            if (e.ColumnIndex == 4)
            {
                var t = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[6].Value);
                var v = mc.GetVare(t);
                mc.PushVareDown(v);
                InitializeList();
                mc.UpdateMainButtons();
            }
            BringToFront();
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (navn.Text.Length < 2)
                {
                    label1.ForeColor = System.Drawing.Color.Red;
                    return;
                }
                else
                {
                    label1.ForeColor = System.Drawing.Color.Black;
                }

                if (pris.Text.Length == 0)
                {
                    label2.ForeColor = System.Drawing.Color.Red;
                    return;
                }
                else
                {
                    label2.ForeColor = System.Drawing.Color.Black;
                }


                Vare vare = new Vare()
                {
                    Navn = navn.Text,
                    Pris = int.Parse(pris.Text)
                };
                mc.SaveVare(vare);
                try
                {
                    mc.UpdateMainButtons();
                }
                catch (Exception ew)
                {
                }

                settingsWindow.ReactivateSettingsWindow();
                settingsWindow.InitializeList();
                Dispose();
            }
            catch (Exception ee)
            {
                label2.ForeColor = System.Drawing.Color.Red;
            }
        }