//one of the many ways to describe a sale public void PrintSale() { if (BucketType != BucketTypes.Single) { Console.WriteLine(date.ToString() + " : Bucket : " + BucketType.ToString() + " cost : " + cost.ToString()); } else { Console.WriteLine(date.ToString() + " : Flower : " + FlowerType.ToString() + " cost : " + cost.ToString()); } }
public override string ToString() { if (Colors.Color1 == Colors.Color2) { return("Flower: " + FlowerType.ToString() + " SAME Color"); } else { return("Flower: " + FlowerType.ToString() + " NOT SAME Color"); } }
/// <summary> /// 获取部分花朵 /// </summary> /// <param name="ft">花的种类</param> /// <returns>花朵列表</returns> public static List <MyFlower> GetFlowerPart(FlowerType ft) { string ftName = ft.ToString(); List <MyFlower> rList = new List <MyFlower>(); foreach (var cd in GlobalTool.FlowerAll) { if (cd.Type == ftName) { rList.Add(cd); } } return(rList); }
private void btnAdd_Click(object sender, RoutedEventArgs e) { if (ValidateQuantity(selectedFlower) > 0) { lstOrder.Items.Add(txtQuantity.Text + " " + selectedFlower.ToString() + ":" + txtPrice.Text + "=" + double.Parse(txtQuantity.Text) * double.Parse(txtPrice.Text)); Total = 0 + double.Parse(txtQuantity.Text) * double.Parse(txtPrice.Text); txtTotal.Text = Total.ToString(); } else { MessageBox.Show("Cantitatea introdusa nu este disponibila in stoc!"); } }
private void GroupChanged(object sender, SelectionChangedEventArgs e) { GlobalTool.ChangeZajiaoComboBox(sender); ComboBox cb = sender as ComboBox; string senderName = cb.Name; switch (senderName) { case "ComboBoxChoose": { SelectedFlower = (FlowerType)cb.SelectedIndex + 1; TextBlockTypeL.Text = FlowerHelper.FlowerNameShow[SelectedFlower]; TextBlockTypeR.Text = TextBlockTypeL.Text; ListColorDic = new List <MyFlower>(); ListColorDic = FlowerHelper.GetFlowerPart(SelectedFlower); ListColor = new List <string>(); ListColorName = new List <string>(); ListColor.Add(""); ListColorName.Add("无"); foreach (var a in ListColorDic) { if (!ListColor.Contains(a.Color) && a.Color != "Unknown") { ListColor.Add(a.Color); MyColor mc = (MyColor)Enum.Parse(typeof(MyColor), a.Color); ListColorName.Add(FlowerHelper.ColorNameShow[mc]); } } ComboBoxColorL.SelectionChanged -= GroupChanged; ComboBoxColorR.SelectionChanged -= GroupChanged; ComboBoxColorL.ItemsSource = ListColorName; ComboBoxColorR.ItemsSource = ListColorName; ComboBoxColorL.SelectedIndex = 0; ComboBoxColorR.SelectedIndex = 0; ComboBoxColorL.SelectionChanged += GroupChanged; ComboBoxColorR.SelectionChanged += GroupChanged; ComboBoxColorL.SelectedIndex = 1; ComboBoxColorR.SelectedIndex = 1; CheckBoxColorL.IsChecked = true; CheckBoxColorR.IsChecked = true; //需要在选定花朵之后绑定种子 BindSeed(); } break; case "ComboBoxColorL": { if (cb.SelectedIndex == 0) { return; } SelectedColorL = (MyColor)Enum.Parse(typeof(MyColor), ListColor[cb.SelectedIndex]); TextBlockColorL.Text = FlowerHelper.ColorNameShow[SelectedColorL]; TextBlockColorL.Foreground = new SolidColorBrush(FlowerHelper.ColorShow[SelectedColorL]); ImageFlowerL.Source = new BitmapImage(new Uri("/Assets/" + SelectedFlower.ToString() + SelectedColorL.ToString() + ".png", UriKind.Relative)); string s = ""; SelectedColorDicL = new List <MyFlower>(); foreach (var a in ListColorDic) { if (a.Color == ListColor[cb.SelectedIndex]) { SelectedColorDicL.Add(a); string n = a.GetGeneName(); if (!s.Contains(n)) { s += n + " "; } } } TextBlockGeneL.Text = s; } break; case "ComboBoxColorR": { if (cb.SelectedIndex == 0) { return; } SelectedColorR = (MyColor)Enum.Parse(typeof(MyColor), ListColor[cb.SelectedIndex]); TextBlockColorR.Text = FlowerHelper.ColorNameShow[SelectedColorR]; TextBlockColorR.Foreground = new SolidColorBrush(FlowerHelper.ColorShow[SelectedColorR]); ImageFlowerR.Source = new BitmapImage(new Uri("/Assets/" + SelectedFlower.ToString() + SelectedColorR.ToString() + ".png", UriKind.Relative)); string s = ""; SelectedColorDicR = new List <MyFlower>(); foreach (var a in ListColorDic) { if (a.Color == ListColor[cb.SelectedIndex]) { SelectedColorDicR.Add(a); string n = a.GetGeneName(); if (!s.Contains(n)) { s += n + " "; } } } TextBlockGeneR.Text = s; } break; case "ComboBoxA1L": case "ComboBoxA2L": case "ComboBoxA3L": case "ComboBoxA4L": { if (CheckBoxGeneL.IsChecked == false) { return; } int a1 = ComboBoxA1L.SelectedIndex; int a2 = ComboBoxA2L.SelectedIndex; int a3 = ComboBoxA3L.SelectedIndex; int a4 = ComboBoxA4L.SelectedIndex; int aa1 = (int)(Gene)Enum.Parse(typeof(Gene), ComboBoxA1L.SelectedItem.ToString()); int aa2 = (int)(Gene)Enum.Parse(typeof(Gene), ComboBoxA2L.SelectedItem.ToString()); int aa3 = (int)(Gene)Enum.Parse(typeof(Gene), ComboBoxA3L.SelectedItem.ToString()); int aa4 = (int)(Gene)Enum.Parse(typeof(Gene), ComboBoxA4L.SelectedItem.ToString()); if ( (a1 > 0 && a2 > 0 && a3 > 0 && SelectedFlower != FlowerType.Roses) || (a1 > 0 && a2 > 0 && a3 > 0 && a4 > 0) ) { MyFlower cd = new MyFlower(); foreach (var a in ListColorDic) { if (SelectedFlower == FlowerType.Roses) { if (a.A1 == aa1.ToString() && a.A2 == aa2.ToString() && a.A3 == aa3.ToString() && a.A4 == aa4.ToString()) { cd = a; break; } } else { if (a.A1 == aa1.ToString() && a.A2 == aa2.ToString() && a.A3 == aa3.ToString()) { cd = a; break; } } } TextBlockGeneL.Text = cd.GetGeneName(); TextBlockColorL.Text = FlowerHelper.ColorNameShow[cd.GetColor()]; TextBlockColorL.Foreground = new SolidColorBrush(FlowerHelper.ColorShow[cd.GetColor()]); string path = cd.GetImagePath(); ImageFlowerL.Source = new BitmapImage(new Uri(path, UriKind.Relative)); } } break; case "ComboBoxA1R": case "ComboBoxA2R": case "ComboBoxA3R": case "ComboBoxA4R": { if (CheckBoxGeneR.IsChecked == false) { return; } int a1 = ComboBoxA1R.SelectedIndex; int a2 = ComboBoxA2R.SelectedIndex; int a3 = ComboBoxA3R.SelectedIndex; int a4 = ComboBoxA4R.SelectedIndex; int aa1 = (int)(Gene)Enum.Parse(typeof(Gene), ComboBoxA1R.SelectedItem.ToString()); int aa2 = (int)(Gene)Enum.Parse(typeof(Gene), ComboBoxA2R.SelectedItem.ToString()); int aa3 = (int)(Gene)Enum.Parse(typeof(Gene), ComboBoxA3R.SelectedItem.ToString()); int aa4 = (int)(Gene)Enum.Parse(typeof(Gene), ComboBoxA4R.SelectedItem.ToString()); if ( (a1 > 0 && a2 > 0 && a3 > 0 && SelectedFlower != FlowerType.Roses) || (a1 > 0 && a2 > 0 && a3 > 0 && a4 > 0) ) { MyFlower cd = new MyFlower(); foreach (var a in ListColorDic) { if (SelectedFlower == FlowerType.Roses) { if (a.A1 == aa1.ToString() && a.A2 == aa2.ToString() && a.A3 == aa3.ToString() && a.A4 == aa4.ToString()) { cd = a; break; } } else { if (a.A1 == aa1.ToString() && a.A2 == aa2.ToString() && a.A3 == aa3.ToString()) { cd = a; break; } } } TextBlockGeneR.Text = cd.GetGeneName(); TextBlockColorR.Text = FlowerHelper.ColorNameShow[cd.GetColor()]; TextBlockColorR.Foreground = new SolidColorBrush(FlowerHelper.ColorShow[cd.GetColor()]); string path = cd.GetImagePath(); ImageFlowerR.Source = new BitmapImage(new Uri(path, UriKind.Relative)); } } break; case "ComboBoxSeedL": { if (cb.SelectedIndex == 0) { return; } int index = cb.SelectedIndex - 1; TextBlockGeneL.Text = ListSeed[index].GetGeneName(); TextBlockColorL.Text = FlowerHelper.ColorNameShow[ListSeed[index].GetColor()]; TextBlockColorL.Foreground = new SolidColorBrush(FlowerHelper.ColorShow[ListSeed[index].GetColor()]); string path = ListSeed[index].GetImagePath(); ImageFlowerL.Source = new BitmapImage(new Uri(path, UriKind.Relative)); } break; case "ComboBoxSeedR": { if (cb.SelectedIndex == 0) { return; } int index = cb.SelectedIndex - 1; TextBlockGeneR.Text = ListSeed[index].GetGeneName(); TextBlockColorR.Text = FlowerHelper.ColorNameShow[ListSeed[index].GetColor()]; TextBlockColorR.Foreground = new SolidColorBrush(FlowerHelper.ColorShow[ListSeed[index].GetColor()]); string path = ListSeed[index].GetImagePath(); ImageFlowerR.Source = new BitmapImage(new Uri(path, UriKind.Relative)); } break; } }