Example #1
0
        public void Export(data.dsMain.tItemTypeDataTable typesTable)
        {
            long type = 0;
            var  q    = typesTable.Where(r => r.FOTypeId == Type);

            if (q.Count() > 0)
            {
                type = q.First().TypeId;
            }
            data.dsMainTableAdapters.TableAdapterManager ta = new AuctionAdminMK2.data.dsMainTableAdapters.TableAdapterManager();
            ta.Init();
            ta.Connection.Open();
            ta.tItemProtoTableAdapter.Insert(ProtoId, ProtoName, ProtoDescription, Alias, type);
            int newId = (int)(ta.tItemProtoTableAdapter.GetLastInsertedId());

            ta.tLotsTableAdapter.UpdateLotsNewProto(newId, ProtoId);
            ta.tItemProtoTableAdapter.DeleteByPidFiltered(ProtoId, newId);
            ta.Connection.Close();
        }
Example #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Подтвердите экспорт списка в базу данных.", "Экспорт", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                {
                    return;
                }
                data.dsMain ds = new AuctionAdminMK2.data.dsMain();
                data.dsMainTableAdapters.TableAdapterManager ta = new AuctionAdminMK2.data.dsMainTableAdapters.TableAdapterManager();
                ta.Init();
                ta.tItemTypeTableAdapter.Fill(ds.tItemType);
                var   q = (this.cm.DataSource as List <Fonline.FOProtoItem>);
                fBase f = this.MdiParent as fBase;
                int   c = 0;
                int   l = q.Count();
                f.ProgressBar.Maximum = q.Count();
                f.ProgressBar.Value   = 0;
                foreach (var i in q)
                {
                    c++;
                    if (f != null)
                    {
                        f.ProgressBar.Value = c;
                        f.StatusLabel.Text  = string.Format("Обработка записи {0} из {1}", c, l);
                        Application.DoEvents();
                    }

                    i.Export(ds.tItemType);
                }
                if (f != null)
                {
                    f.ProgressBar.Value = 0;
                    f.StatusLabel.Text  = "Выполнено";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }