if (e.Key == Key.Enter) { // string query = ""; dataGrid.Focus(); //dataGrid.CurrentColumn= dataGrid.Columns[2]; if (txtSearch.Text != "") { if (txtSearch.Text != null && txtSearch.Text != "") { //this.DataContext = txtSearch.Text; //dataGrid.ItemsSource = txtSearch.SelectedValue.ToString(); DataSet ds = Globalvariables.Globals.select_load("Select menu_id,foodname,rprice from add_food_menu where foodname like '%" + txtSearch.Text + "%'"); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string id = ds.Tables[0].Rows[i][0].ToString(); string name = ds.Tables[0].Rows[i][1].ToString(); string price = ds.Tables[0].Rows[i][2].ToString(); string qty = "1"; string total = price; //MenuList.Add(new menu(ds.Tables[0].Rows[i][0].ToString(), ds.Tables[0].Rows[i][1].ToString(), ds.Tables[0].Rows[i][2].ToString(), "1")); dataGrid.DisplayMemberPath = "foodname"; dataGrid.SelectedValuePath = "menu_id"; //dataGrid.ItemsSource = ds.Tables[0].DefaultView; dataGrid.Items.Add(new menu(id = ds.Tables[0].Rows[i][0].ToString(), name = ds.Tables[0].Rows[i][1].ToString(), price = ds.Tables[0].Rows[i][2].ToString(), "1",total)); dataGrid.BeginningEdit += (e, ee) => ee.Cancel = true; dataGrid.CurrentCell = new DataGridCellInfo( dataGrid.Items[0], dataGrid.Columns[2]); dataGrid.BeginEdit(); } //autoList = MenuList; } } } } }
public class menu : INotifyPropertyChanged { public static string id; public static string name; public static string price; public static string qty; public static string total; public menu(string id, string name, string price,string qty,string total) { this.Id = id; this.Name = name; this.Price = price; this.Qty = qty; this.Total = total; } public string Id { get { return id; } set { id = value; } } public string Name { get { return name; } set { name = value; } } public string Price { get { return price; } set { price = value; } } public string Qty { get { return qty; } set { qty = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Qty")); } } public string Total { get { return (float.Parse(this.Qty) * float.Parse(this.Price)).ToString(); } set { total = value; if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Total")); } } private void NotifyPropertyChanged(string total) { if(PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(total)); } } public event PropertyChangedEventHandler PropertyChanged; public class UpdateData { public ObservableCollection<menu> updata { get; set; } public UpdateData() { updata = new ObservableCollection<menu>(); } }
DataSet ds = Globalvariables.Globals.select_load("Select menu_id,foodname,rprice from add_food_menu where foodname like '%" + txtSearch.Text + "%'");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)