void tvShopList_AfterSelect(object sender, TreeViewEventArgs e) { int shoplistid = (int)e.Node.Tag; if (shoplistid == App.AppVariables.INVALID_TREENODE) { return;//如果是根节点,则退出 } if (shoplistid < 0) { //清理控件值 dgvShopItems.Rows.Clear(); txtShopConfigFile.Text = ""; txtShopName.Text = e.Node.Text; lblShopID.Text = ""; } ShopList shop = ShopListLogic.GetOneShopList(shoplistid); if (null != shop) { this.txtShopConfigFile.Text = shop.ConfigFile; this.chkShopCanFix.Checked = shop.CanRepair; this.txtShopName.Text = shop.ShopName; lblShopID.Text = shop.ShopTemplateID.ToString(); _initShopItems(shop.ShopTemplateID, true); } }
private void _doRemoveShopList() { bool bRet = false; DialogResult dr = MessageBox.Show("确认删除选择的商店吗?", "警告!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (dr == DialogResult.Yes) { if ((int)tvShopList.SelectedNode.Tag == -1) //如果是新创建的商店,则直接删除 { this.txtShopName.Text = string.Empty; this.txtShopConfigFile.Text = string.Empty; this.tvShopList.SelectedNode.Remove(); } else { ShopItemLogic.DeleteShopItemsByShopTemplateID(Int32.Parse(this.lblShopID.Text)); bRet = ShopListLogic.DeleteShopList((int)tvShopList.SelectedNode.Tag); if (bRet) { this.tvShopList.SelectedNode.Remove(); } else { dr = MessageBox.Show("删除操作失败,原因可能是数据库操作出错.", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
/// <summary> /// 保存新商店列表 /// </summary> private void _saveNewShopList() { if (txtShopName.Text != "" && txtShopConfigFile.Text != "") { ShopList shoplist = new ShopList(); shoplist.ShopName = this.tvShopList.SelectedNode.Text; shoplist.CanRepair = this.chkShopCanFix.Checked; shoplist.ConfigFile = this.txtShopConfigFile.Text; ShopList retobj = ShopListLogic.AddShopList(shoplist); if (null != retobj) { MessageBox.Show("新商店创建成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } _initShopList(); } }
/// <summary> /// 保存商店列表的设置 /// </summary> private void _saveShopListSettings() { if (null == m_shopitems || m_shopitems.Count <= 0) { return; } int shopid = -1; Int32.TryParse(lblShopID.Text, out shopid); if (shopid >= 0) { ShopList shoplist = ShopListLogic.GetOneShopList(shopid); if (null != shoplist) { shoplist.ShopName = this.tvShopList.SelectedNode.Text; shoplist.CanRepair = this.chkShopCanFix.Checked; shoplist.ConfigFile = this.txtShopConfigFile.Text; ShopListLogic.UpdateShopList(shoplist); } } }