123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- using System;
- using System.Windows;
- using System.Windows.Media.Imaging;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- using InABox.WPF;
- using PRSDesktop.Panels.Jobs;
- namespace PRSDesktop
- {
- internal class JobDesignGrid : DynamicDataGrid<Setout>, IJobControl
- {
- private BitmapImage barcode = PRSDesktop.Resources.barcode.AsBitmapImage();
- private BitmapImage design = PRSDesktop.Resources.design.AsBitmapImage();
- private BitmapImage qacheck = PRSDesktop.Resources.checklist.AsBitmapImage();
- private BitmapImage tick = PRSDesktop.Resources.tick.AsBitmapImage();
- public JobDesignGrid()
- {
- Options.AddRange(DynamicGridOption.RecordCount, DynamicGridOption.SelectColumns, DynamicGridOption.FilterRows, DynamicGridOption.ImportData);
-
- //ActionColumns.Add(
- // new DynamicTickColumn<Setout>(PRSDesktop.Resources.design.AsBitmapImage(), x => x.Designed)
- // {
- // Action = DesignedClick
- // }
- // );
- //ActionColumns.Add(new DynamicTickColumn<Setout>(PRSDesktop.Resources.checklist.AsBitmapImage(), x => x.Checked));
- //ActionColumns.Add(new DynamicTickColumn<Setout>(PRSDesktop.Resources.factory.AsBitmapImage(), x => x.Issued));
- //ActionColumns.Add(new DynamicImageColumn() { Image = DesignedImage, Action = DesignedClick });
- //ActionColumns.Add(new DynamicImageColumn() { Image = CheckedImage, Action = CheckedClick });
- //ActionColumns.Add(new DynamicImageColumn() { Image = BarcodeImage, Action = BarcodeClick });
- //HiddenColumns.Add(x => x.Designed);
- //HiddenColumns.Add(x => x.Checked);
- //HiddenColumns.Add(x => x.Issued);
- //OnAddItem += DoAddItem;
- //OnEditItem += DoEditItem;
- }
- public CoreTable Setouts { get; private set; }
- public Guid ParentID { get; set; }
- public JobPanelSettings Settings { get; set; }
-
- protected override void DoImport()
- {
- var window = new JobDesignImportWindow();
- if (window.ShowDialog() == true)
- Refresh(false,true);
- }
- protected override void Reload(Filters<Setout> criteria, Columns<Setout> columns, ref SortOrder<Setout> sort,
- Action<CoreTable, Exception> action)
- {
- criteria.Add(new Filter<Setout>(x => x.JobLink.ID).IsEqualTo(ParentID));
- sort = new SortOrder<Setout>(x => x.Number, SortDirection.Descending);
- base.Reload(criteria, columns, ref sort, action);
- }
- protected override void DoAdd(bool OpenEditorOnDirectEdit = false)
- {
- if (ParentID.Equals(Guid.Empty) || ParentID.Equals(CoreUtils.FullGuid))
- MessageBox.Show("Please select a Job first!");
- else
- base.DoAdd();
- }
- protected override Setout CreateItem()
- {
- var setout = base.CreateItem();
- setout.JobLink.ID = ParentID;
- //setout.Job = new Client<Job>().Load(new Filter<Job>(x => x.ID).IsEqualTo(CurrentJobID)).FirstOrDefault();
- return setout;
- }
- //public override bool EditItems(Setout[] items)
- //{
- // Setout item = items.FirstOrDefault();
- // if (item == null)
- // return false;
- // SetoutDetails form = new SetoutDetails(item);
- // return form.ShowDialog() == true;
- //}
- //private BitmapImage DesignedImage(DataRow row)
- //{
- // if (row == null)
- // return design;
- // DateTime designed = row.Get<Setout, DateTime>(x => x.Designed);
- // //DateTime qachecked = row.Get<Setout, DateTime>(x => x.Checked);
- // //DateTime issued = row.Get<Setout, DateTime>(x => x.Issued);
- // return designed.IsEmpty() /* && qachecked.IsEmpty() && issued.IsEmpty() */ ? null : tick;
- //}
- //private bool DesignedClick(CoreRow row)
- //{
- // Setout setout = LoadItem(row);
- // bool designed = setout.Designed.IsEmpty();
- // setout.Designed = designed ? DateTime.Now : DateTime.MinValue;
- // //setout.Checked = DateTime.MinValue;
- // //setout.Issued = DateTime.MinValue;
- // //foreach (SetoutStage stage in setout.Stages)
- // //{
- // // stage.Started = DateTime.MinValue;
- // // stage.Completed = DateTime.MinValue;
- // //}
- // new Client<Setout>().Save(setout,"Setout Designed Flag set to " + (setout.Designed.IsEmpty()? "false" : "true"));
- // return true;
- //}
- //private BitmapImage CheckedImage(DataRow row)
- //{
- // if (row == null)
- // return qacheck;
- // DateTime qachecked = row.Get<Setout, DateTime>(x => x.Checked);
- // //DateTime issued = row.Get<Setout, DateTime>(x => x.Issued);
- // return qachecked.IsEmpty() /* && issued.IsEmpty() */ ? null : tick;
- //}
- //private bool CheckedClick(DataRow row)
- //{
- // //Setout setout = LoadItem(row);
- // //bool qachecked = setout.Checked.IsEmpty();
- // //setout.Designed = qachecked ? setout.Designed.IsEmpty() ? DateTime.Now : setout.Designed : setout.Designed;
- // //setout.Checked = qachecked ? DateTime.Now : DateTime.MinValue;
- // //setout.Issued = DateTime.MinValue;
- // //foreach (SetoutStage stage in setout.Stages)
- // //{
- // // stage.Started = DateTime.MinValue;
- // // stage.Completed = DateTime.MinValue;
- // //}
- // ////if (issue)
- // //// setout.MoveNext();
- // //new Client<Setout>().Save(setout, "Setout QA Flag set to " + (setout.Designed.IsEmpty() ? "false" : "true"));
- // //return true;
- // return false;
- //}
- //private BitmapImage BarcodeImage(DataRow row)
- //{
- // if (row == null)
- // return barcode;
- // DateTime issued = row.Get<Setout, DateTime>(x => x.Issued);
- // return issued.IsEmpty() ? null : barcode;
- //}
- //private bool BarcodeClick(DataRow row)
- //{
- // //DateTime issued = row.Get<Setout, DateTime>(x => x.Issued);
- // //if (issued.IsEmpty())
- // // return false;
- // return false;
- //}
- }
- }
|