示例#1
0
        public void Delete(ObjectListView olv)
        {
            var obj = olv.SelectedObject as Machine;

            using (MachinesRepository repo = new MachinesRepository())
            {
                repo.Delete(obj);
                olv.RemoveObject(obj);
            }
        }
示例#2
0
        public ScheduleForm()
        {
            InitializeComponent();
            this.okΒutton.Click += okΒutton_Click;

            using (MachinesRepository repo = new MachinesRepository())
            {
                this.machineBindingSource.DataSource = repo.Get();
            }
            using (EmployeesRepository repo = new EmployeesRepository())
            {
                this.employeeBindingSource.DataSource = repo.Get();
            }
        }
示例#3
0
        public void New(ObjectListView olv)
        {
            TitleForm frm = new TitleForm();

            frm.Text = "Νέα Μηχανή";
            if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                using (MachinesRepository repo = new MachinesRepository())
                {
                    Machine obj = repo.New();
                    obj.Title = frm.UserInput;
                    repo.Insert(obj);
                    olv.AddObject(obj);
                }
            }
        }
示例#4
0
 public void Get(ObjectListView olv)
 {
     using (MachinesRepository repo = new MachinesRepository())
     {
         var list = repo.Get();
         olv.ModelFilter = null;
         olv.Columns.Clear();
         olv.Columns.Add(new BrightIdeasSoftware.OLVColumn()
         {
             Text         = "Μηχάνημα",
             AspectGetter = delegate(object row) { return(((Machine)row).Title); },
             TextAlign    = System.Windows.Forms.HorizontalAlignment.Left,
             Width        = 200
         });
         olv.SetObjects(list);
     }
 }
示例#5
0
        public void Edit(ObjectListView olv)
        {
            var obj = olv.SelectedObject as Machine;

            if (obj == null)
            {
                return;
            }
            TitleForm frm = new TitleForm();

            frm.Text      = obj.Title;
            frm.UserInput = obj.Title;
            if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                using (MachinesRepository repo = new MachinesRepository())
                {
                    obj.Title = frm.UserInput;
                    repo.Update(obj);
                    olv.RefreshObject(obj);
                }
            }
        }
示例#6
0
 public MachinesController(MachinesRepository repository)
 {
     this._repository = repository; /*?? throw new ArgumentNullException(nameof(repository));*/
 }