using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using POSV.Entity; using POSV.MessageEvent; using System.Threading.Tasks; namespace POSV.Tabs { [ToolboxItem(false)] public partial class DishMenuItem : AbstractTabItem { private Table _table = null; public DishMenuItem(Table table = null) { InitializeComponent(); this._table = table; this.BackColor = Color.Transparent; this.categoryControl.CategoryCheckedChanged += OnCategoryCheckedChanged; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (this.DesignMode) return; Task.Factory.StartNew(() => { this.Invoke(new Action(() => { string sql = SqlConstant.ProductExtAll; PreLoadProduct(sql); })); }); } private void OnCategoryCheckedChanged(object sender , Component.CategoryEventArgs e) { var productType = e.Data; string template = SqlConstant.ProductExtAll; if (!Constant.ALL_PRODUCT_TAG.Equals(productType.No)) { template = SqlConstant.ProductExtAll + " and typePath like '{0}%';"; } string sql = string.Format(template , productType.Path); this.PreLoadProduct(sql); } private void PreLoadProduct(string sql , KeyboardAction action = KeyboardAction.None) { try { var lists = new List(); using (var db = Global.Instance.OpenDataBase) { lists = db.Fetch(sql); } this.productControl.PageNumber = 1; this.productControl.BindDataSource(lists , action); } catch (Exception ex) { LOGGER.Error(ex , "加载菜品信息异常"); } } private void OnBackClick(object sender , EventArgs e) { bool isGo = true; if (isGo) { MsgEvent.Send(Constant.TABLE_ORDER_DISHS_NOTIFY , null); } } } }