Ejemplo n.º 1
0
 public DeliveryCostAddEditForm(DeliveryCost obj)
 {
     DeliveryInfo = obj;
     InitializeComponent();
     deliveryCostBindingSource.DataSource = DeliveryInfo;
     this.mdtDate.Select();
 }
Ejemplo n.º 2
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();
                }
            }
        }
Ejemplo n.º 3
0
        private void lnkDelete_Click(object sender, EventArgs e)
        {
            if (MetroFramework.MetroMessageBox.Show(this, "Вы дейсвительно хотите удалить цену?",
                                                    "Подтверждение удаления", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                int rows = costGrid.RowCount;
                for (int i = rows - 1; i >= 0; i--)
                {
                    if (costGrid.Rows[i].Selected)
                    {
                        DateTime     dt = (DateTime)costGrid.Rows[i].Cells[0].Value;
                        DeliveryCost dc = db.DeliveryCosts.FirstOrDefault(o => o.Date == dt);
                        db.DeliveryCosts.Remove(dc);
                        deliveryCostBindingSource.RemoveAt(costGrid.Rows[i].Index);
                    }
                }

                db.SaveChanges();
            }
        }
Ejemplo n.º 4
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();
                }
            }
        }