示例#1
0
 private void CreateItem()
 {
     DataAccess da = new DataAccess();
     brand item = new brand();
     item.name = edtName.Text;
     item.description = edtDescr.Text;
     da.BrandCreate(item);
 }
示例#2
0
        private void ImportBrands()
        {
            string FilePath = "";

            // вызов диалога выбора файла для импорта
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.DefaultExt = ".xml"; // Default file extension
            dlg.Filter = "Office 2003 XML Tables (.xml)|*.xml"; // Filter files by extension

            // Show open file dialog box
            Nullable<bool> result = dlg.ShowDialog();

            // Process open file dialog box results
            if (result == true)
            {
                // Open document
                FilePath = dlg.FileName;
                List<brand> items = null;
                items = Office2003XmlTable.getBrands(FilePath);

                int count = items.Count;

                // перенос списка полученных брендов в БД
                if (items != null)
                {
                    DataAccess da = new DataAccess();
                    foreach (brand i in items)
                    {
                        da.BrandCreate(i);
                    }
                    MessageBox.Show("Импортировано " + count + " записей.");
                }
            }
        }