コード例 #1
0
ファイル: BrickCostAddEditForm.cs プロジェクト: rusich/uir2
 public BrickCostAddEditForm(BrickCost obj)
 {
     InitializeComponent();
     BrickCostInfo = obj;
     db            = new BrickWorksModel();
     if (BrickCostInfo.Id == 0)
     {
         BrickCostInfo.BrickId = db.Bricks.First().Id;
     }
     brickCostBindingSource.DataSource = BrickCostInfo;
     this.mdtDate.Select();
     brickBindingSource.DataSource = db.Bricks.ToList();
 }
コード例 #2
0
ファイル: BricksCostForm.cs プロジェクト: rusich/uir2
        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();
                }
            }
        }
コード例 #3
0
ファイル: BricksCostForm.cs プロジェクト: rusich/uir2
        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;
                        BrickCost dc = db.BrickCosts.FirstOrDefault(o => o.Date == dt);
                        db.BrickCosts.Remove(dc);
                        brickCostBindingSource.RemoveAt(costGrid.Rows[i].Index);
                    }
                }

                db.SaveChanges();
            }
        }
コード例 #4
0
ファイル: BricksCostForm.cs プロジェクト: rusich/uir2
        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();
                }
            }
        }
コード例 #5
0
ファイル: DbInitializer.cs プロジェクト: rusich/uir2
        private static void InitBricksAndCosts(BrickWorksModel db)
        {
            var bricks = new List <Brick>
            {
                new Brick
                {
                    Mark       = "Кирпич керамический пустотелый одинарный рядовой",
                    Lenght     = 0.25F,
                    Width      = 0.12F,
                    Height     = 0.065F,
                    Parameters = "Цвет: красный"
                }
            };

            var bc = new BrickCost {
                Date = new DateTime(2017, 01, 01), Cost = 8, Brick = bricks.Last()
            };

            db.BrickCosts.Add(bc);

            bricks.Add(new Brick
            {
                Mark       = "Кирпич керамический пустотелый утолщенный",
                Lenght     = 0.25F,
                Width      = 0.12F,
                Height     = 0.065F,
                Parameters = "Цвет: оранжевый"
            });

            bc = new BrickCost {
                Date = new DateTime(2017, 01, 01), Cost = 10.2F, Brick = bricks.Last()
            };
            db.BrickCosts.Add(bc);

            bricks.Add(new Brick
            {
                Mark       = "Кирпич полнотелый одинарный М200",
                Lenght     = 0.25F,
                Width      = 0.12F,
                Height     = 0.065F,
                Parameters = "Цвет: серый"
            });

            bc = new BrickCost {
                Date = new DateTime(2017, 01, 01), Cost = 10.2F, Brick = bricks.Last()
            };
            db.BrickCosts.Add(bc);

            bricks.Add(new Brick
            {
                Mark       = "Кирпич полнотелый утолщенный М200",
                Lenght     = 0.25F,
                Width      = 0.12F,
                Height     = 0.14F,
                Parameters = "Цвет: коричневый"
            });

            bc = new BrickCost {
                Date = new DateTime(2017, 01, 01), Cost = 18.92F, Brick = bricks.Last()
            };
            db.BrickCosts.Add(bc);

            db.Bricks.AddRange(bricks);
            db.SaveChanges();
        }