Exemplo n.º 1
0
        /// <summary>
        /// 添加按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BT_Add_Click(object sender, EventArgs e)
        {
            if (CB_Province.SelectedIndex <= 0 || CB_City.SelectedIndex <= 0)
            {
                MessageBox.Show("您必须先选择一个省份以及城市以定位您的店铺!");
                return;
            }
            foreach (Object ShopName in LB_Shop.Items)
            {
                if (ShopName.ToString() == TB_ShopName.Text)
                {
                    MessageBox.Show("您不能再一个城市建立两个完全相同名字的店铺!", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            DialogResult res = MessageBox.Show("您确定要在" + CB_Province.SelectedItem.ToString() + CB_City.SelectedItem.ToString() + "设立" + TB_ShopName.Text + "吗?", "确认!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);

            if (res == DialogResult.OK)
            {
                int CityID = List_ShopInfo.Where(P => P.City_Name == CB_City.SelectedItem.ToString()).First().City_ID;
                if (Shop_Client.AddShop(new Car_Shop()
                {
                    Shop_Name = TB_ShopName.Text.Trim(),
                    Shop_Phone = TB_ShopPhone.Text.Trim(),
                    Shop_Info = TB_ShopInfo.Text.Trim(),
                    Shop_City = CityID
                }))
                {
                    MessageBox.Show("店铺添加成功!");
                    List_ShopInfo = UserManager_Client.GetAllShops(null, null, null).ToList();
                    LB_ShopBind();
                }
            }
        }
Exemplo n.º 2
0
        public void UpdatericeComparisonList(string itemName)
        {
            foreach (var tempItem in PriceComparisonList)
            {
                if (tempItem.Name == itemName)
                {
                    PriceComparisonList.Remove(tempItem);
                    UpdateGraph();
                    return;
                }
            }

            PriceComparisonItem priceComparisonItem = new PriceComparisonItem();
            Item item = PriceComparisonModel.GetItemsByName(itemName).FirstOrDefault();

            priceComparisonItem.Name            = itemName;
            priceComparisonItem.Description     = item.Description;
            priceComparisonItem.ImagePath       = item.ImagePath;
            priceComparisonItem.PriceComparison = PriceComparisonModel.GetPriceComparison(itemName).OrderBy(ShopName => ShopName.Split('\n')[1]);
            PriceComparisonList.Add(priceComparisonItem);
            UpdateGraph();
        }