Advertisement
Guest User

Untitled

a guest
Nov 25th, 2013
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.83 KB | None | 0 0
  1. namespace ModelLayer
  2. {
  3.     //слой моделей
  4.     public class Plavka
  5.     {
  6.         public Guid id { get; set; }
  7.         public int plavka { get; set; }
  8.         public DateTime? dataPrig { get; set; }
  9.         public int? smena { get; set; }
  10.         public string masterFIO { get; set; }
  11.         public int? catMetal { get; set; }
  12.         public int? nKonveera { get; set; }
  13.         public string otkFIO { get; set; }
  14.         public bool status { get; set; }
  15.         public double? mBrak { get; set; }
  16.         public bool? brak { get; set; }
  17.         public string comments { get; set; }
  18.         public DateTime? dataPered { get; set; }
  19.         public string masterFIOPered { get; set; }
  20.         public int? smenaPered { get; set; }
  21.         public int? nSteluga { get; set; }
  22.         public double? mSteluga { get; set; }
  23.         public double? mBrutto { get; set; }
  24.         public double? mNetto { get; set; }
  25.         //справочники
  26.         public ArrayList metalCategory { get; set; }
  27.        
  28.         public Plavka() { }
  29.  
  30.         public Plavka(Guid ID, int _Plavka, DateTime DataPrig, int Smena, string MasterFIO, int NKonveera,
  31.             string OtkFIO, bool Status, double MBrak, string Comments, DateTime DataPered,
  32.             string MasterFIOPered, int CatMetal, int NSteluga, double MSteluga, double MBrutto, double MNetto,
  33.             bool Brak, int SmenaPered, ArrayList MetalCategory)
  34.         {
  35.             this.id = ID;
  36.             this.plavka = _Plavka;
  37.             this.dataPrig = DataPrig;
  38.             this.smena = Smena;
  39.             this.masterFIO = MasterFIO;
  40.             this.nKonveera = NKonveera;
  41.             this.otkFIO = OtkFIO;
  42.             this.status = Status;
  43.             this.mBrak = MBrak;
  44.             this.comments = Comments;
  45.             this.dataPered = DataPered;
  46.             this.masterFIOPered = MasterFIOPered;
  47.             this.catMetal = CatMetal;
  48.             this.nSteluga = NSteluga;
  49.             this.mSteluga = MSteluga;
  50.             this.mBrutto = MBrutto;
  51.             this.mNetto = MNetto;
  52.             this.brak = Brak;
  53.             this.smenaPered = SmenaPered;
  54.  
  55.             this.metalCategory = MetalCategory;
  56.         }
  57.     }
  58. }
  59.  
  60. //..............
  61. namespace DataLayer
  62. {
  63.     //слой где идут все обращения к базе данных
  64.     public partial class DAL
  65.     {
  66.    
  67.         public AlloyMGDataSet.plavkaDataTable GetAllPlavka() //получить все данные о плавках
  68.         {
  69.             AlloyMGDataSetTableAdapters.plavkaTableAdapter plavkaAda = new AlloyMGDataSetTableAdapters.plavkaTableAdapter();
  70.             AlloyMGDataSet.plavkaDataTable table = new AlloyMGDataSet.plavkaDataTable();
  71.             table = plavkaAda.GetData();
  72.             return table;
  73.         }
  74.     }
  75. }
  76.  
  77. //..................
  78.  
  79. namespace ControllerLayer
  80. {
  81.     //слой где я получаю данные от слоя DataLayer и обрабатываю их
  82.     public partial class Cont
  83.     {
  84.         /// <summary>
  85.         /// Получить список плавок
  86.         /// </summary>
  87.         /// <returns></returns>
  88.         public List<Plavka> GetAllPlavka()
  89.         {
  90.             DataLayer.DAL dal = new DataLayer.DAL();
  91.  
  92.             AlloyMGDataSet.plavkaDataTable table = new AlloyMGDataSet.plavkaDataTable();
  93.             List<Plavka> plavkaList = new List<Plavka>();
  94.             table = dal.GetAllPlavka();
  95.  
  96.             ArrayList metCat = GetCatMetal();
  97.             foreach (AlloyMGDataSet.plavkaRow row in table)
  98.             {
  99.                 //запись в объект класса и проверки на Null
  100.                 Plavka tmp = new Plavka();
  101.                 tmp.id = row.id;
  102.                 tmp.plavka = row.plavka;
  103.                 tmp.smena = row.smena;
  104.                 tmp.dataPrig = row.dataPrig;
  105.                 tmp.masterFIO = row.masterFIO;
  106.                 tmp.catMetal = row.IscatMetalNull() == true ? new Nullable<int>(): row.catMetal-1;
  107.                 tmp.nKonveera = row.IsnKonveeraNull() == true ? new Nullable<int>() : row.nKonveera; //row.nKonveera;
  108.                 tmp.otkFIO =  row.IsotkFIONull() == true? String.Empty: row.otkFIO;
  109.                 tmp.status = row.IsstatusNull() == true ? true : row.status;
  110.                 tmp.comments = row.IscommentsNull() == true ? String.Empty : row.comments;
  111.                 tmp.brak = row.IsbrakNull() == true? false: row.brak;
  112.                 tmp.dataPered = row.IsdataPeredNull() == true? new Nullable<DateTime>(): row.dataPered;
  113.                 tmp.masterFIOPered = row.IsmasterFIOPeredNull() == true ? String.Empty : row.masterFIOPered;
  114.                 tmp.nSteluga = row.IsnStelugaNull() == true? new Nullable<int>() : row.nSteluga;
  115.                 tmp.mSteluga = row.IsmStelugaNull() == true ? new Nullable<double>() : row.mSteluga;
  116.                 tmp.mBrutto = row.IsmBruttoNull() == true ? new Nullable<double>() : row.mBrutto;
  117.                 tmp.mNetto = row.IsmNettoNull() == true ? new Nullable<double>() : row.mNetto;  //mNetto;
  118.  
  119.  
  120.                 tmp.metalCategory = metCat;
  121.  
  122.                 plavkaList.Add(tmp);
  123.             }
  124.  
  125.             return plavkaList;
  126.         }
  127.     }
  128. }
  129.  
  130. //........................
  131. namespace Magnesium
  132. {
  133.     //собственно сами окна
  134.     public partial class MainWindow : Window
  135.     {
  136.         public List<Plavka> plavkaList { get; set; }
  137.  
  138.        // public ObservableCollection<PlavkaList> PlavkaItems { get; set; }
  139.  
  140.         public MainWindow()
  141.         {
  142.             InitializeComponent();            
  143.  
  144.             plavkaList = new List<Plavka>();
  145.            
  146.            
  147.             ControllerLayer.Cont cont = new ControllerLayer.Cont();
  148.  
  149.             //получаем список плавок
  150.             plavkaList = cont.GetAllPlavka();
  151.             //заполняем таблицы
  152.             plavkaDataGrid.ItemsSource = plavkaList;
  153.         }
  154.     }
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement