示例#1
0
        private void lnkAdd_Click(object sender, EventArgs e)
        {
            var cost = new BrickCost();

            using (var frm = new BrickCostAddEditForm(cost))
            {
                frm.Theme = this.Theme;
                frm.Style = this.Style;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    db.BrickCosts.Add(cost);
                    db.SaveChanges();
                    brickCostBindingSource.DataSource = db.BrickCosts.OrderByDescending(d => d.Date).ToList();
                    costGrid.Refresh();
                }
            }
        }
示例#2
0
        private void lnkEdit_Click(object sender, EventArgs e)
        {
            var cost      = (BrickCost)brickCostBindingSource.Current;
            var cost_edit = new BrickCost {
                Id = cost.Id, BrickId = cost.BrickId, Date = cost.Date, Cost = cost.Cost
            };

            using (var frm = new BrickCostAddEditForm(cost_edit))
            {
                frm.Theme = this.Theme;
                frm.Style = this.Style;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    cost.BrickId = cost_edit.BrickId;
                    cost.Date    = cost_edit.Date;
                    cost.Cost    = cost_edit.Cost;
                    db.SaveChanges();
                    brickCostBindingSource.DataSource = db.BrickCosts.OrderByDescending(d => d.Date).ToList();
                    costGrid.Refresh();
                }
            }
        }