Esempio n. 1
0
        private void lnkAdd_Click(object sender, EventArgs e)
        {
            var cost = new DeliveryCost();

            using (var frm = new DeliveryCostAddEditForm(cost))
            {
                frm.Theme = this.Theme;
                frm.Style = this.Style;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    db.DeliveryCosts.Add(cost);
                    db.SaveChanges();
                    deliveryCostBindingSource.DataSource = db.DeliveryCosts.OrderByDescending(d => d.Date).ToList();
                    costGrid.Refresh();
                }
            }
        }
Esempio n. 2
0
        private void lnkEdit_Click(object sender, EventArgs e)
        {
            var cost = (DeliveryCost)deliveryCostBindingSource.Current;
            //var bld_edit = (Building)db.Entry(bld).CurrentValues.ToObject();
            var cost_edit = new DeliveryCost {
                Date = cost.Date, CostPerKm = cost.CostPerKm
            };

            using (var frm = new DeliveryCostAddEditForm(cost_edit))
            {
                frm.Theme = this.Theme;
                frm.Style = this.Style;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    cost.Date      = cost_edit.Date;
                    cost.CostPerKm = cost_edit.CostPerKm;
                    db.SaveChanges();
                    deliveryCostBindingSource.DataSource = db.DeliveryCosts.OrderByDescending(d => d.Date).ToList();
                    costGrid.Refresh();
                }
            }
        }