Пример #1
0
        private void btSave_Click(object sender, EventArgs e)
        {
            algorythmList al = new algorythmList();

            al.Name        = this.txtName.Text;
            al.Description = this.txtDescription.Text;
            al.Syntax      = this.txtSyntax.Text;
            try
            {
                var db = new AlgorythmEntities3();
                db.algorythmLists.Add(al);
                db.SaveChanges();
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btDelete_Click(object sender, EventArgs e)
        {
            var db = new AlgorythmEntities3();

            if (MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                for (int i = 0; i < this.lstAlgorythm.SelectedRows.Count; i++)
                {
                    var row  = this.lstAlgorythm.SelectedRows[i];
                    var item = (algorythmList)row.DataBoundItem;
                    try
                    {
                        algorythmList al = db.algorythmLists.Find(item.Id);
                        db.algorythmLists.Remove(al);
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Cannot delete student" + item);
                    }
                }
            }
            this.ShowAlgorythmList();
        }
Пример #3
0
 public FormEdit(algorythmList al)
 {
     InitializeComponent();
     this.al = al;
 }