Ejemplo n.º 1
0
        private void itemComboBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            SearchableTextbox itemComboBox = (SearchableTextbox)sender;

            try
            {
                AddData(itemComboBox);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        private void itemComboBox_KeyDown(object sender, KeyEventArgs e)
        {
            SearchableTextbox itemComboBox = (SearchableTextbox)sender;

            try
            {
                if (e.Key == Key.Enter || e.Key == Key.Tab)
                {
                    AddData(itemComboBox);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
        public void AddData(SearchableTextbox itemComboBox)
        {
            if (itemComboBox.Data != null)
            {
                // Data = itemComboBox.Data;

                int id = Convert.ToInt32(((item_tag)itemComboBox.Data).id_tag);

                if (id > 0)
                {
                    if (_item.item_tag_detail.Count > 0)
                    {
                        ((item_tag_detail)ItemsSource.View.CurrentItem).id_tag   = id;
                        ((item_tag_detail)ItemsSource.View.CurrentItem).item_tag = ((item_tag)itemComboBox.Data);
                        item_tagViewSource.View.Refresh();
                        ItemsSource.View.Refresh();
                    }
                    else
                    {
                        item_tag_detail item_tag_detail = new item_tag_detail();
                        item_tag_detail.id_tag   = id;
                        item_tag_detail.item_tag = ((item_tag)itemComboBox.Data);
                        _item.item_tag_detail.Add(item_tag_detail);
                        ItemsSource.View.Refresh();
                    }
                }
            }
            else
            {
                db       db       = new db();
                item_tag item_tag = new item_tag();
                item_tag.name = itemComboBox.TxtSearched.Text;

                db.item_tag.Add(item_tag);
                db.SaveChanges();
                entity.item_tag.Where(x => x.id_company == _settings_entity.company_ID && x.is_active == true).OrderBy(x => x.name).Load();
                itemComboBox.Data = item_tag;


                int id_tag = item_tag.id_tag;

                ((item_tag_detail)ItemsSource.View.CurrentItem).item_tag = entity.item_tag.Where(x => x.id_tag == id_tag).FirstOrDefault();

                ItemsSource.View.Refresh();
            }
        }