/// <summary> /// 删除按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BT_DeletCity_Click(object sender, EventArgs e) { if (CB_Province.SelectedIndex <= 0) { MessageBox.Show("请先指定省份!"); return; } if (LB_City.SelectedIndex < 0) { MessageBox.Show("请选择您要删除的城市!"); return; } DialogResult res = MessageBox.Show("该操作会将您选定的城市信息连同该城市的所有店铺等信息全部删除,该操作是不可逆的,是否继续进行?", "警告!!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 0); if (res == DialogResult.OK) { UserManager_Client = (UserManagerClient)ClientFactory.GetClient(ClientType.Type.UserManager); Shop_Client = (ShopClient)ClientFactory.GetClient(ClientType.Type.Shop); int ProvinceID = Province_Client.SelectProvince_Name(CB_Province.SelectedItem.ToString()).Province_ID; int CityID = City_Client.SelectCity_Name(LB_City.SelectedItem.ToString(), ProvinceID).City_ID; if (Shop_Client.SelectShop_CityID(CityID).Count() != 0) { List <WFpart.ShopService.Car_Shop> List_Shop = Shop_Client.SelectShop_CityID(CityID).ToList(); //删除店铺和店铺关系 foreach (WFpart.ShopService.Car_Shop temp in List_Shop) { UserManager_Client.UserDropShop_ShopID(temp.Shop_ID); Shop_Client.DeleteShop(temp.Shop_ID); } } City_Client.DeleteCity(CityID); } List_City = City_Client.SelectAllCitys().ToList(); LB_CityBind(); }