Beispiel #1
0
        private void lnkAdd_Click(object sender, EventArgs e)
        {
            var mfBrick = new ManufacturedBrick();

            using (var frm = new ManufacturedBrickAddEditFrom(mfBrick))
            {
                frm.Theme = this.Theme;
                frm.Style = this.Style;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    db.ManufacturedBricks.Add(mfBrick);
                    db.SaveChanges();
                    manufacturedBrickBindingSource.DataSource = db.ManufacturedBricks.OrderByDescending(d => d.Id).ToList();
                    gridBricks.Refresh();
                }
            }
        }
Beispiel #2
0
        private void lnkEdit_Click(object sender, EventArgs e)
        {
            var mfBrick = (ManufacturedBrick)manufacturedBrickBindingSource.Current;
            //var bld_edit = (Building)db.Entry(bld).CurrentValues.ToObject();
            var mfBrick_edit = new ManufacturedBrick {
                Date = mfBrick.Date, BrickId = mfBrick.BrickId, Quantity = mfBrick.Quantity
            };

            using (var frm = new ManufacturedBrickAddEditFrom(mfBrick_edit))
            {
                frm.Theme = this.Theme;
                frm.Style = this.Style;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    mfBrick.Date     = mfBrick_edit.Date;
                    mfBrick.BrickId  = mfBrick_edit.BrickId;
                    mfBrick.Quantity = mfBrick_edit.Quantity;
                    db.SaveChanges();
                    manufacturedBrickBindingSource.DataSource = db.ManufacturedBricks.OrderByDescending(d => d.Id).ToList();
                    gridBricks.Refresh();
                }
            }
        }