Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ModelLayer
- {
- //слой моделей
- public class Plavka
- {
- public Guid id { get; set; }
- public int plavka { get; set; }
- public DateTime? dataPrig { get; set; }
- public int? smena { get; set; }
- public string masterFIO { get; set; }
- public int? catMetal { get; set; }
- public int? nKonveera { get; set; }
- public string otkFIO { get; set; }
- public bool status { get; set; }
- public double? mBrak { get; set; }
- public bool? brak { get; set; }
- public string comments { get; set; }
- public DateTime? dataPered { get; set; }
- public string masterFIOPered { get; set; }
- public int? smenaPered { get; set; }
- public int? nSteluga { get; set; }
- public double? mSteluga { get; set; }
- public double? mBrutto { get; set; }
- public double? mNetto { get; set; }
- //справочники
- public ArrayList metalCategory { get; set; }
- public Plavka() { }
- public Plavka(Guid ID, int _Plavka, DateTime DataPrig, int Smena, string MasterFIO, int NKonveera,
- string OtkFIO, bool Status, double MBrak, string Comments, DateTime DataPered,
- string MasterFIOPered, int CatMetal, int NSteluga, double MSteluga, double MBrutto, double MNetto,
- bool Brak, int SmenaPered, ArrayList MetalCategory)
- {
- this.id = ID;
- this.plavka = _Plavka;
- this.dataPrig = DataPrig;
- this.smena = Smena;
- this.masterFIO = MasterFIO;
- this.nKonveera = NKonveera;
- this.otkFIO = OtkFIO;
- this.status = Status;
- this.mBrak = MBrak;
- this.comments = Comments;
- this.dataPered = DataPered;
- this.masterFIOPered = MasterFIOPered;
- this.catMetal = CatMetal;
- this.nSteluga = NSteluga;
- this.mSteluga = MSteluga;
- this.mBrutto = MBrutto;
- this.mNetto = MNetto;
- this.brak = Brak;
- this.smenaPered = SmenaPered;
- this.metalCategory = MetalCategory;
- }
- }
- }
- //..............
- namespace DataLayer
- {
- //слой где идут все обращения к базе данных
- public partial class DAL
- {
- public AlloyMGDataSet.plavkaDataTable GetAllPlavka() //получить все данные о плавках
- {
- AlloyMGDataSetTableAdapters.plavkaTableAdapter plavkaAda = new AlloyMGDataSetTableAdapters.plavkaTableAdapter();
- AlloyMGDataSet.plavkaDataTable table = new AlloyMGDataSet.plavkaDataTable();
- table = plavkaAda.GetData();
- return table;
- }
- }
- }
- //..................
- namespace ControllerLayer
- {
- //слой где я получаю данные от слоя DataLayer и обрабатываю их
- public partial class Cont
- {
- /// <summary>
- /// Получить список плавок
- /// </summary>
- /// <returns></returns>
- public List<Plavka> GetAllPlavka()
- {
- DataLayer.DAL dal = new DataLayer.DAL();
- AlloyMGDataSet.plavkaDataTable table = new AlloyMGDataSet.plavkaDataTable();
- List<Plavka> plavkaList = new List<Plavka>();
- table = dal.GetAllPlavka();
- ArrayList metCat = GetCatMetal();
- foreach (AlloyMGDataSet.plavkaRow row in table)
- {
- //запись в объект класса и проверки на Null
- Plavka tmp = new Plavka();
- tmp.id = row.id;
- tmp.plavka = row.plavka;
- tmp.smena = row.smena;
- tmp.dataPrig = row.dataPrig;
- tmp.masterFIO = row.masterFIO;
- tmp.catMetal = row.IscatMetalNull() == true ? new Nullable<int>(): row.catMetal-1;
- tmp.nKonveera = row.IsnKonveeraNull() == true ? new Nullable<int>() : row.nKonveera; //row.nKonveera;
- tmp.otkFIO = row.IsotkFIONull() == true? String.Empty: row.otkFIO;
- tmp.status = row.IsstatusNull() == true ? true : row.status;
- tmp.comments = row.IscommentsNull() == true ? String.Empty : row.comments;
- tmp.brak = row.IsbrakNull() == true? false: row.brak;
- tmp.dataPered = row.IsdataPeredNull() == true? new Nullable<DateTime>(): row.dataPered;
- tmp.masterFIOPered = row.IsmasterFIOPeredNull() == true ? String.Empty : row.masterFIOPered;
- tmp.nSteluga = row.IsnStelugaNull() == true? new Nullable<int>() : row.nSteluga;
- tmp.mSteluga = row.IsmStelugaNull() == true ? new Nullable<double>() : row.mSteluga;
- tmp.mBrutto = row.IsmBruttoNull() == true ? new Nullable<double>() : row.mBrutto;
- tmp.mNetto = row.IsmNettoNull() == true ? new Nullable<double>() : row.mNetto; //mNetto;
- tmp.metalCategory = metCat;
- plavkaList.Add(tmp);
- }
- return plavkaList;
- }
- }
- }
- //........................
- namespace Magnesium
- {
- //собственно сами окна
- public partial class MainWindow : Window
- {
- public List<Plavka> plavkaList { get; set; }
- // public ObservableCollection<PlavkaList> PlavkaItems { get; set; }
- public MainWindow()
- {
- InitializeComponent();
- plavkaList = new List<Plavka>();
- ControllerLayer.Cont cont = new ControllerLayer.Cont();
- //получаем список плавок
- plavkaList = cont.GetAllPlavka();
- //заполняем таблицы
- plavkaDataGrid.ItemsSource = plavkaList;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement