public static void HucreClick(object sender, MouseButtonEventArgs e, HucreModel hm) { Label lbl = (Label)sender; Data data = new Data(); DataTable dt = new DataTable(); dt = data.HucreBilgiGetir(hm); if (dt.Rows.Count > 0) { List <UrunModel> u = new List <UrunModel>(); int paletMiktar = dt.AsEnumerable() .Sum(r => r["PaletMiktar"].ToString().ToInt()); int toplamMiktar = 0; foreach (DataRow row in dt.Rows) { Guid id = new Guid(row["StokId"].ToString()); int miktar = row["Miktar"].ToInt(); string kod = row["Kod"].ToString(); string isim = row["Isim"].ToString(); toplamMiktar += miktar; u.Add(new UrunModel(id, isim, kod, miktar)); } HucreModel h = new HucreModel(hm.Id, hm.Name, hm.Tip, hm.TipIsim, u); WindowHucre wh = new WindowHucre { Topmost = true }; wh.Init(h, paletMiktar, hm.Oran, toplamMiktar); wh.Show(); wh.CreateUrun(); } }
public DataTable HucreBilgiGetir(HucreModel h) { try { string cmdText = " select " + "ISNULL(s.Kod, '-----') as Kod, " + " ISNULL(s.Isim, '-----') as Isim, " + " ISNUll(dsm.Miktar, -1) as Miktar, " + " ISNUll(sp.Miktar, dsm.Miktar) as PaletMiktar , " + " ISNULL(s.Id, '00000000-0000-0000-0000-000000000000') as StokId " + " from ne_DepoXStokMiktar as dsm " + "left join ne_Stok as s on dsm.StokId = s.Id " + " left join ne_StokPaletMiktar sp on dsm.StokId = sp.StokId " + " left join ne_V_DepoAdresListe as da on dsm.AdresId = da.AdresId " + " where " + "da.DepoId =@DepoId " + "and da.DepoKatId = @KatId " + "and da.RafId = @RafId " + "and da.AdresId = @AdresId"; return(DBDataTable(cmdText, new List <SqlParameter>() { new SqlParameter() { ParameterName = "@DepoId", Value = h.DepoId }, new SqlParameter() { ParameterName = "@KatId", Value = h.KatId }, new SqlParameter() { ParameterName = "@RafId", Value = h.UlId }, new SqlParameter() { ParameterName = "@AdresId", Value = h.Id } })); } catch (Exception ex) { throw new Exception("\nHucreBilgiGetir\n" + ex.Message); } }
public void Init(HucreModel hm, int paletMiktar, double oran, int toplamMiktar) { _hm = hm; this.KeyDown += Windows_KeyDown; WindowStartupLocation = WindowStartupLocation.CenterScreen; LblAdres.Content = hm.Name; // oran =(Double)toplamMiktar / paletMiktar*100; LblOran.Content = "% " + Math.Round(oran, 1).ToString(); if (oran >= 75) { LblOran.Foreground = Brushes.White; } else { LblOran.Foreground = Brushes.Black; } LblOran.Background = UIOperation.GetScaleColor(oran); LblTipIsim.Content = hm.TipIsim; LblMiktar.Content = toplamMiktar.ToString() + " / " + paletMiktar.ToString(); }
/// <summary> /// Bir sıraya ait bilgileri içeren bir Window oluşturur /// </summary> /// <param name="list"></param> /// <param name="oran"></param> /// <returns></returns> public static Window CreateRafSıra(List <HucreModel> list, double oran) { try { string windowName = "RAF " + list[0].Raf + " - KOY " + list[0].Koy + " - SİRA " + list[0].Sira.ToString() + ""; int height = 500; int width = 374; Window window = new Window { Height = height, Width = width, Title = windowName, MaxHeight = height, MaxWidth = width, MinHeight = height, MinWidth = width, FontSize = 18, FontWeight = FontWeights.Bold }; Grid mainGrid = new Grid(); mainGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(70) }); mainGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(10) }); mainGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(420) }); mainGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(width / 2) }); mainGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(width / 2) }); mainGrid.VerticalAlignment = VerticalAlignment.Stretch; mainGrid.HorizontalAlignment = HorizontalAlignment.Stretch; mainGrid.Background = Brushes.DarkBlue; Label lbl1 = new Label(); lbl1.SetLabelIntoGrid("GENEL ORAN", 0, 0, width / 2, 70); lbl1.Background = Brushes.LightBlue; mainGrid.Children.Add(lbl1); Label lbl2 = new Label(); lbl2.SetLabelIntoGrid("% " + Math.Round(oran, 1) + "", 0, 1, width / 2, 70); lbl2.Background = GetScaleColor(oran); if (oran >= 75) { lbl2.Foreground = Brushes.White; } else { lbl2.Foreground = Brushes.Black; } mainGrid.Children.Add(lbl2); Grid grid = new Grid(); grid.CreateGridRowsColoums(list.Count, 2, width / 2, 420 / (list.Count + 1)); for (int i = 0; i < list.Count(); i++) { Label lblAdres = new Label(); lblAdres.SetLabelIntoGrid(list[i].Name, i, 0, width / 2, 420 / (list.Count + 1)); lblAdres.Background = Brushes.Wheat; grid.Children.Add(lblAdres); HucreModel hm = list[i]; double HucreOran = list[i].Oran; Label lblOran = new Label(); if (list[i].Tip == 100) { lblOran.SetLabelIntoGrid("TÜNEL", i, 1, width / 2, 420 / (list.Count + 1)); lblOran.Background = Brushes.Aqua; } else if (list[i].Tip == 255) { lblOran.SetLabelIntoGrid("KULLANILMAZ", i, 1, width / 2, 420 / (list.Count + 1)); lblOran.Background = Brushes.DarkGray; lblOran.Foreground = Brushes.White; } else { lblOran.SetLabelIntoGrid("% " + list[i].Oran.ToString() + "", i, 1, width / 2, 420 / (list.Count + 1)); lblOran.Background = GetScaleColor(list[i].Oran); if (list[i].Oran >= 75) { lblOran.Foreground = Brushes.White; } else { lblOran.Foreground = Brushes.Black; } } if (true) { lblAdres.MouseDoubleClick += delegate(object sender, MouseButtonEventArgs e) { HucreClick(sender, e, hm); }; lblOran.MouseDoubleClick += delegate(object sender, MouseButtonEventArgs e) { HucreClick(sender, e, hm); }; } grid.Children.Add(lblOran); } Grid.SetRow(grid, 2); Grid.SetColumn(grid, 0); Grid.SetColumnSpan(grid, 2); mainGrid.Children.Add(grid); window.Content = mainGrid; return(window); } catch (Exception ex) { throw new Exception("\nCreateRafSıra\n" + ex.Message); } }
private void CreateHucre() { try { int counter = 0; for (int i = 0; i < _hucreColCount; i++) { int oranCounter = 0; double toplam = 0; double Or = 0; int yukseklikControl = _hucreRowCount; for (int j = 0; j < _hucreRowCount; j++) { Label lblHucre = new Label(); DataRow row = _dt.Rows[counter]; int yukseklik = row["Yukseklik"].ToInt(); if (yukseklikControl != yukseklik) { yukseklikControl--; continue; } yukseklikControl--; string adres = row["Adres"].ToString(); int tip = row["Tip"].ToInt(); string tipIsim = row["TipIsim"].ToString(); Guid id = new Guid(row["AdresId"].ToString()); Guid ulId = new Guid(row["RafId"].ToString()); string koy = row["Koy"].ToString(); int sira = row["Sira"].ToInt(); string raf = row["Raf"].ToString(); double oran = Convert.ToDouble(row["Oran"].ToString()); HucreModel hm = new HucreModel(_Kdm.KatId, _Kdm.DepoId, id, ulId, adres, koy, sira, yukseklik, raf, oran, tip, tipIsim); lblHucre.Tag = hm; lblHucre.SetLabelIntoGrid(j, i, _width, _height); lblHucre.FontSize = 12; if (tip == 100) { lblHucre.Background = Brushes.Transparent; lblHucre.Content = ""; } else if (tip == 255) { lblHucre.Background = Brushes.Black; lblHucre.Content = "K"; lblHucre.Foreground = Brushes.White; } else { lblHucre.MouseDoubleClick += delegate(object sender, MouseButtonEventArgs e) { UIOperation.HucreClick(sender, e, ((HucreModel)lblHucre.Tag)); }; lblHucre.Background = UIOperation.GetScaleColor(oran); lblHucre.Content = "%" + Math.Round(oran, 0).ToString(); if (oran >= 75) { lblHucre.Foreground = Brushes.White; } else { lblHucre.Foreground = Brushes.Black; } oranCounter++; toplam += oran; } GridHucre.Children.Add(lblHucre); counter++; } if (oranCounter > 0) { Or = (double)toplam / oranCounter; } else { Or = -1; } Label lblOran = new Label(); lblOran.SetLabelIntoGrid(0, i, _width, _height); lblOran.FontSize = 13; lblOran.FontWeight = FontWeights.Bold; if (Or == -1) { lblOran.Content = " "; lblOran.Background = Brushes.DarkGray; } else { lblOran.Content = "%" + Math.Round(Or, 0).ToString(); lblOran.Background = UIOperation.GetScaleColor(Or); } if (Or >= 75) { lblOran.Foreground = Brushes.White; } else { lblOran.Foreground = Brushes.Black; } Grid.SetRow(lblOran, 0); Grid.SetColumn(lblOran, i); GridOran.Children.Add(lblOran); } } catch (Exception ex) { MessageBox.Show("CreateHucre\n" + ex.Message); } }