Example #1
0
        public Type Compile(string type, string key, string value)
        {
            if (string.IsNullOrEmpty(type))
            {
                return(null);
            }

            if (Beans.TryGetValue(type, out var bean))
            {
                return(bean);
            }

            // 除了Bean,其他基本类型和容器类型都动态创建。
            if (BasicTypes.TryGetValue($"{type}:{key}:{value}", out var o))
            {
                return(o);
            }

            var n = new Type()
            {
                Name      = type,
                KeyName   = key,
                ValueName = value,
            };

            BasicTypes.Add($"{type}:{key}:{value}", n);
            n.Compile(this); // 容器需要编译。这里的时机不是太好。
            return(n);
        }
Example #2
0
        private Bean GetBeanFromInput()
        {
            if (Bean.SelectedIndex > -1)
            {
                return(Gender.Text == "Ж"
                    ? Beans.Where(x => x.Type == "2").ToList()[Bean.SelectedIndex]
                    : Beans[Bean.SelectedIndex]);
            }

            return(null);
        }
Example #3
0
 public Taco(IngredientFactory ingredientFactory)
 {
     _poultry     = ingredientFactory.GetPoultry();
     _meat        = ingredientFactory.GetMeat();
     _vegetation  = ingredientFactory.GetVegetation();
     _cheese      = ingredientFactory.GetCheese();
     _guacomole   = ingredientFactory.GetGuacomole();
     _rice        = ingredientFactory.GetRice();
     _beans       = ingredientFactory.GetBeans();
     _creamCheese = ingredientFactory.GetCreamCheese();
     _tomato      = ingredientFactory.GetTomato();
     _chili       = ingredientFactory.GetChili();
 }
Example #4
0
        private void SortListBox()
        {
            ClearInputs();
            Beans = Beans.OrderBy(x => x.Name).ToList();
            Beans = TypeSort.Checked == true && TeamSort.Checked == true
                ? Beans.OrderBy(x => x.Type).ThenBy(x => x.Team).ToList()
                : TeamSort.Checked == true
                ? Beans.OrderBy(x => x.Team).ToList()
                : TypeSort.Checked == true
                ? Beans.OrderBy(x => int.Parse(x.Type)).ToList()
                : Beans;

            CreateListBeans();
        }
Example #5
0
        private void ButtonSave_Click(object sender, EventArgs e)
        {
            if (ActionInput.Text != "Удалить" && ActionInput.Text != "Редактировать")
            {
                MessageBox.Show("Выберете действие Редактировать или Удалить", "Неизвестное действие!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (listBox.SelectedIndex > -1)
            {
                if (ActionInput.Text == "Удалить")
                {
                    int index = listBox.SelectedIndex;
                    MessageBox.Show($"Боб под с названием {Beans[index].Name} успешно удален!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    listBox.Items.RemoveAt(index);
                    Beans.RemoveAt(index);
                    _iOData.SaveData(Beans);
                    ClearInputs();
                }
                else
                {
                    try
                    {
                        if (!ValidInputs())
                        {
                            var bean = GetDataFromInputs();
                            Beans[listBox.SelectedIndex]         = bean;
                            listBox.Items[listBox.SelectedIndex] = $"{string.Format("{0}{4}{1}\t{2}\t{3}", bean.Name, bean.Team, bean.Type, bean.DateTime, bean.Name.Length < 8 ? "\t\t" : "\t")}";
                            MessageBox.Show($"Данные боба: \"{bean.Name}\"\n успешно изменены!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            _iOData.SaveData(Beans);
                        }
                        else
                        {
                            throw new Exception();
                        }
                    }
                    catch
                    {
                        MessageBox.Show($"Некорректные данные!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            else
            {
                MessageBox.Show($"Выберете боб который хотите {ActionInput.Text}", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #6
0
 private void InitBeans()
 {
     if (Gender.Text == "Ж")
     {
         foreach (var bean in Beans.Where(x => x.Type == "2"))
         {
             Bean.Items.Add($"{bean.Name}\t ( {bean.Type} )");
         }
     }
     else if (Gender.Text == "М")
     {
         foreach (var bean in Beans)
         {
             Bean.Items.Add($"{bean.Name}\t ( {bean.Type} )");
         }
     }
 }
Example #7
0
        public static void Run()
        {
            Beans ingredient1 = new Beans();

            ingredient1.Weight = 0.3;
            Rice ingredient2 = new Rice();

            ingredient2.Weight = 0.25;
            Meat ingredient3 = new Meat();

            ingredient3.Weight = 0.3;
            Person customer = new Person();

            customer.Weight = 80.2;
            customer.Eat(ingredient1);
            customer.Eat(ingredient2);
            customer.Eat(ingredient3);
            System.Console.WriteLine($"Now, the customer weight is {customer.Weight}kg!");
        }
Example #8
0
 public void AddBean(Bean bean)
 {
     Beans.Add(bean.Name, bean);
 }
        private void btn_Beans_Click(object sender, RoutedEventArgs e)
        {
            Beans beans = new Beans();

            beans.Show();
        }
 public IMakeBeverage AddBeans(Beans beans)
 {
     Bean = beans.ToString();
     return(this);
 }
 public void addBeans(Beans beans)
 {
     Beans.BeanAmount = beans.BeanAmount;
     Beans.BeanType   = beans.BeanType;
 }
    public IEspressoMachine AddBeans(Beans beans)
    {
        Ingredients.Add(beans);

        return(this);
    }
Example #13
0
        public bool ChangePassword( Beans.LocalPasswordModel model , string  username , out string msg  )
        {
            msg = "";
            string sql = "select count(1) from t_user where username=@username and password=@password";
            MySqlParameter[] parameters = {
                                              new MySqlParameter("@password" ,MySqlDbType.VarChar ),
					new MySqlParameter("@username", MySqlDbType.VarChar )
                                          };
            parameters[0].Value = model.OldPassword;
            parameters[1].Value = username;

            object obj = MySqlHelper.GetSingle(sql, parameters);
            if (obj == null || int.Parse ( obj.ToString() ) <1 )
            {
                msg = "用户名或密码错误。";
                return false;
            }

            sql = "update t_user set password=@password where username =@username";
            MySqlParameter[] parameters2 =  {
                                              new MySqlParameter("@password" ,MySqlDbType.VarChar ),
					new MySqlParameter("@username", MySqlDbType.VarChar )
                                          };
            parameters2[0].Value = model.NewPassword;
            parameters2[1].Value = username ;

            int result = MySqlHelper.ExecuteSql(sql , parameters2 );
            return result > 0 ? true : false;
        }
Example #14
0
 public void Add(Types.Bean bean)
 {
     Program.AddNamedObject(Path(".", bean.Name), bean);
     Beans.Add(bean.Name, bean);
 }