예제 #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            FormName formName = new FormName();

            formName.Text          = StringTable.AddNewCategory;
            formName.NameValue     = "";
            formName.AllowEmpty    = false;
            formName.ValidateName += delegate(object sender1, ValidateNameEventArgs e1)
            {
                if (dataBase.AllCategories.Names.Contains(e1.Name) && e1.Name != e1.OriginalName)
                {
                    MessageBox.Show(string.Format(StringTable.CategoryAlreadyExists, e1.Name), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    e1.Cancel = true;
                }
            };
            if (formName.ShowDialog(this) == DialogResult.OK)
            {
                CategoryTableAdapter cta = new CategoryTableAdapter(dataBase);
                CategoryDataSet.CategoryDataTable cdt = cta.GetData();
                cdt.AddCategoryRow(formName.NameValue, listBoxCategories.Items.Count + 1);
                cta.Update(cdt);

                FillList();
            }

            UpdateWindowState();
        }
예제 #2
0
        public int GetIdByName(string name, bool createIfNew)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(0);
            }

            Category category = GetByName(name);

            if (category != null)
            {
                return(category.CategoryID);
            }
            else
            {
                // Nicht vorhanden, also neue Kategorie anlegen
                CategoryTableAdapter cta = new CategoryTableAdapter(dataBase);
                CategoryDataSet.CategoryDataTable cdt = cta.GetData();
                cdt.AddCategoryRow(name, cdt.Rows.Count);
                cta.Update(cdt);

                int categoryid = (int)(decimal)dataBase.ExecuteScalar("SELECT @@IDENTITY");

                dataBase.UpdateCategories();

                return(categoryid);
            }
        }
예제 #3
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = StringTable.FilterHitbase;
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                DataBase dbImport = new DataBase();
                dbImport.Open(openFileDialog.FileName);

                CategoryTableAdapter cta = new CategoryTableAdapter(dataBase);
                CategoryDataSet.CategoryDataTable cdt = cta.GetData();

                int count = listBoxCategories.Items.Count + 1;
                foreach (Category category in dbImport.AllCategories)
                {
                    if (dataBase.GetIdByCategory(category.Name) < 0)
                    {
                        cdt.AddCategoryRow(category.Name, count++);
                    }
                }

                cta.Update(cdt);

                dbImport.Close();

                FillList();
                UpdateWindowState();
            }
        }
예제 #4
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listBoxCategories.SelectedItem == null)
            {
                return;
            }

            ListBoxItem item = (ListBoxItem)listBoxCategories.SelectedItem;

            FormName formName = new FormName();

            formName.Text      = StringTable.EditCategory;
            formName.NameValue = item.Category.Name;
            if (formName.ShowDialog(this) == DialogResult.OK)
            {
                int oldId = dataBase.GetIdByCategory(item.Category.Name);

                CategoryTableAdapter cta = new CategoryTableAdapter(dataBase);
                CategoryDataSet.CategoryDataTable cdt = cta.GetDataById(item.Category.CategoryID);
                cdt[0].Name = formName.NameValue;
                cta.Update(cdt);

                listBoxCategories.Items[listBoxCategories.SelectedIndex] = new ListBoxItem(cdt[0]);

                UpdateSoundfiles(oldId, item.Category.Name, formName.NameValue, false);
            }

            UpdateWindowState();
        }
예제 #5
0
        public void AddNew(string category)
        {
            // Nicht vorhanden, also neue Kategorie anlegen
            CategoryTableAdapter cta = new CategoryTableAdapter(dataBase);

            CategoryDataSet.CategoryDataTable cdt = cta.GetData();
            cdt.AddCategoryRow(category, GetNextOrder());
            cta.Update(cdt);

            dataBase.UpdateCategories();
        }
예제 #6
0
        protected void Update_Click(object sender, EventArgs e)
        {
            tblCategory          = adpCategory.GetData();
            Cache["tblCategory"] = tblCategory;

            int id = 0;

            string categ = txtCategName.Text;

            if (string.IsNullOrEmpty(txtCategNumber.Text))
            {
                lblErrorMessage.Text      = "Please Insert the Category Number";
                lblErrorMessage.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (string.IsNullOrEmpty(categ))
                {
                    lblErrorMessage.Text      = "Please Enter a Category Name";
                    lblErrorMessage.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    try
                    {
                        id = int.Parse(txtCategNumber.Text);
                    }
                    catch (Exception ex)
                    {
                        lblErrorMessage.Text      = "Please Enter a Category Number";
                        lblErrorMessage.ForeColor = System.Drawing.Color.Red;
                        txtCategNumber.Focus();
                    }
                    int result = adpCategory.Update(categ, id);

                    if (result == 1)
                    {
                        lblErrorMessage.Text      = "Department Update ";
                        lblErrorMessage.ForeColor = System.Drawing.Color.Yellow;
                        txtCategName.Text         = "";
                        txtCategNumber.Text       = "";
                        refresh();
                    }
                    else
                    {
                        lblErrorMessage.Text      = "Department NOT Update";
                        lblErrorMessage.ForeColor = System.Drawing.Color.Red;
                    }
                }
            }
        }
예제 #7
0
        /// <summary>
        /// Aktualisiert die Order aus der Liste in die Datenbank.
        /// </summary>
        private void SetOrderByList()
        {
            int index = 1;

            foreach (ListBoxItem item in listBoxCategories.Items)
            {
                CategoryTableAdapter cta             = new CategoryTableAdapter(dataBase);
                CategoryDataSet.CategoryDataTable dt = cta.GetDataById(item.Category.CategoryID);
                dt[0].Order = index;

                cta.Update(dt);

                index++;
            }
        }
        void saveButton_Click(object sender, EventArgs e)
        {
            categoryId = Int32.Parse(idHidden.Value);

            String name = nameBox.Text.Trim();

            if (name == String.Empty)
            {
                ErrorMessage = "Name cannot be blank";
                return;
            }

            CategoryTableAdapter categoryAdapter = new CategoryTableAdapter();

            if (categoryId > 0)
            {
                category = categoryAdapter.GetCategory(categoryId)[0];


                category.Name = name;

                categoryAdapter.Update(category);

                parentCategoryId = category.ParentCategoryId;
            }
            else if (isNew == true && isSubCategory == false && Request.QueryString["parent_id"] == "NEW")
            {
                categoryAdapter.Insert(StationId, null, name, -1);
            }
            else
            {
                parentCategoryId = Int32.Parse(parentIdHidden.Value);

                // SeqNo of -1 will assign it the next highest SeqNo for the category

                categoryAdapter.Insert(StationId, parentCategoryId, name, -1);
            }

            InfoMessage = "Category Updated";
            if (parentCategoryId > 0)
            {
                Response.Redirect("~/admin/CategoryEdit.aspx?id=" + parentCategoryId);
            }
            else
            {
                Response.Redirect("~/admin/CategoryList.aspx");
            }
        }
예제 #9
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            try
            {
                this.BindingContext[this.categoryDetailDataSet, CATEGORY].EndCurrentEdit();
                this.BindingContext[this.categoryDetailDataSet, LOCALIZED_CATEGORY_NAME].EndCurrentEdit();

                DataRowView view = this.BindingContext[categoryDetailDataSet, CATEGORY].Current as DataRowView;
                CategoryDetailDataSet.CategoryRow row = view.Row as CategoryDetailDataSet.CategoryRow;

                if (row.IsImageNull())
                {
                    this.DialogResult = DialogResult.None;

                    // Initializes the variables to pass to the MessageBox.Show method.

                    string message = Resources.ImageNotSetMessage;
                    string caption = Resources.ErrorCaption;

                    // Displays the MessageBox.

                    MessageBox.Show(this, message, caption, MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);

                    return;
                }

                foreach (CategoryDetailDataSet.LocalizedCategoryNameRow localizedNameRow in this.categoryDetailDataSet.LocalizedCategoryName.Rows)
                {
                    if (localizedNameRow.CultureName == this.cultureName)
                    {
                        if (localizedNameRow.IsNameNull() || localizedNameRow.Name.Trim().Length == 0)
                        {
                            this.DialogResult = DialogResult.None;

                            // Initializes the variables to pass to the MessageBox.Show method.

                            string message = string.Format(Resources.CannotBeEmptyMessage, localizedNameRow.Language);
                            string caption = Resources.ErrorCaption;

                            // Displays the MessageBox.

                            MessageBox.Show(this, message, caption, MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);

                            return;
                        }

                        break;
                    }
                }

                CategoryDetailDataSet changes = (CategoryDetailDataSet)categoryDetailDataSet.GetChanges();
                if (changes != null)
                {
                    CategoryTableAdapter categoryAdapter = new CategoryTableAdapter();
                    categoryAdapter.Connection.Open();
                    categoryAdapter.Update(changes);

                    SqlCommand sqlUpdateCommand = new SqlCommand();
                    sqlUpdateCommand.Connection  = categoryAdapter.Connection;
                    sqlUpdateCommand.CommandText = @"UPDATE Resource SET [Text] = @Text "
                                                   + "WHERE (ResourceId = @ResourceId AND CultureId = @CultureId) ";

                    sqlUpdateCommand.Parameters.Add(new SqlParameter("@Text", System.Data.SqlDbType.NText, 0, "Text"));
                    sqlUpdateCommand.Parameters.Add(new SqlParameter("@ResourceId", System.Data.SqlDbType.UniqueIdentifier, 0, "ResourceId"));
                    sqlUpdateCommand.Parameters.Add(new SqlParameter("@CultureId", System.Data.SqlDbType.Int, 0, "CultureId"));

                    SqlCommand sqlInsertCommand = new SqlCommand();
                    sqlInsertCommand.Connection  = categoryAdapter.Connection;
                    sqlInsertCommand.CommandText = @"INSERT INTO Resource([Text], ResourceId, CultureId) VALUES(@Text, @ResourceId, @CultureId) ";

                    sqlInsertCommand.Parameters.Add(new SqlParameter("@Text", System.Data.SqlDbType.NText, 0, "Text"));
                    sqlInsertCommand.Parameters.Add(new SqlParameter("@ResourceId", System.Data.SqlDbType.UniqueIdentifier, 0, "ResourceId"));
                    sqlInsertCommand.Parameters.Add(new SqlParameter("@CultureId", System.Data.SqlDbType.Int, 0, "CultureId"));

                    Guid resourceId = row.Name;

                    DataRow[] rows = this.categoryDetailDataSet.LocalizedCategoryName.Select("", "", DataViewRowState.ModifiedCurrent);

                    foreach (DataRow modifiedRow in rows)
                    {
                        if (modifiedRow.IsNull("ResourceId"))
                        {
                            sqlInsertCommand.Parameters["@Text"].Value       = modifiedRow["Name"];
                            sqlInsertCommand.Parameters["@ResourceId"].Value = resourceId;
                            sqlInsertCommand.Parameters["@CultureId"].Value  = modifiedRow["CultureId"];
                            sqlInsertCommand.ExecuteNonQuery();
                        }
                        else
                        {
                            sqlUpdateCommand.Parameters["@Text"].Value       = modifiedRow["Name"];
                            sqlUpdateCommand.Parameters["@ResourceId"].Value = resourceId;
                            sqlUpdateCommand.Parameters["@CultureId"].Value  = modifiedRow["CultureId"];
                            sqlUpdateCommand.ExecuteNonQuery();
                        }
                    }

                    categoryAdapter.Connection.Close();
                }
            }
            catch (Exception ex)
            {
                ReportError(ex.Message.ToString());
                this.DialogResult = DialogResult.Cancel;
            }
        }
예제 #10
0
        private void Convert()
        {
            string sql;

            formConvertProgress.MaximumValue = 15;
            formConvertProgress.CurrentTable = "Master";

            ConvertMasterTable();

            #region CD
            formConvertProgress.CurrentTable = "CD";
            formConvertProgress.Value++;

            List <FieldConvert> fieldsCD = new List <FieldConvert>();

            fieldsCD.Add(new FieldConvert("IDCD", "CDID"));
            fieldsCD.Add(new FieldConvert("dwGesamtlaenge", "Length"));
            fieldsCD.Add(new FieldConvert("cAnzahlLieder", "NumberOfTracks"));
            fieldsCD.Add(new FieldConvert("bCDSampler", "IsSampler"));
            fieldsCD.Add(new FieldConvert("wNummerImSet", "SetNumber"));
            fieldsCD.Add(new FieldConvert("IDCDSet", "SetID"));
            fieldsCD.Add(new FieldConvert("IDArtist", "ArtistID"));
            fieldsCD.Add(new FieldConvert("IDKategorie", "CategoryID"));
            fieldsCD.Add(new FieldConvert("IDMedium", "MediumID"));
            fieldsCD.Add(new FieldConvert("szTitel", "Title"));
            fieldsCD.Add(new FieldConvert("szDatum", "Date"));
            fieldsCD.Add(new FieldConvert("szArchivNummer", "ArchiveNumber"));
            fieldsCD.Add(new FieldConvert("szPfadBitmap", "FrontCover"));
            fieldsCD.Add(new FieldConvert("szKennzeichen", "Codes"));
            fieldsCD.Add(new FieldConvert("szKommentar", "Comment"));
            fieldsCD.Add(new FieldConvert("szFeld1", "User1"));
            fieldsCD.Add(new FieldConvert("szFeld2", "User2"));
            fieldsCD.Add(new FieldConvert("szFeld3", "User3"));
            fieldsCD.Add(new FieldConvert("szFeld4", "User4"));
            fieldsCD.Add(new FieldConvert("szFeld5", "User5"));
            fieldsCD.Add(new FieldConvert("C_Type", "Type"));
            fieldsCD.Add(new FieldConvert("C_YearRecorded", "YearRecorded"));
            fieldsCD.Add(new FieldConvert("C_Copyright", "Copyright"));
            fieldsCD.Add(new FieldConvert("C_BackCoverBitmap", "BackCover"));
            fieldsCD.Add(new FieldConvert("C_CDLabelBitmap", "CDLabelCover"));
            fieldsCD.Add(new FieldConvert("C_Rating", "Rating"));
            fieldsCD.Add(new FieldConvert("C_Label", "Label"));
            fieldsCD.Add(new FieldConvert("C_URL", "URL"));
            fieldsCD.Add(new FieldConvert("C_Price", "Price"));
            fieldsCD.Add(new FieldConvert("C_UPC", "UPC"));
            fieldsCD.Add(new FieldConvert("C_Original", "IsOriginal"));
            fieldsCD.Add(new FieldConvert("C_IDComposer", "ComposerID"));
            fieldsCD.Add(new FieldConvert("C_Location", "Location"));
            fieldsCD.Add(new FieldConvert("C_Language", "Language"));

            CDTableAdapter             cdAdap = new CDTableAdapter(sdfDatabase);
            ConvertDataSet.CDDataTable cd     = new ConvertDataSet.CDDataTable();
            cdAdap.Fill(cd);

            // Alle Identities einlesen
            Dictionary <int, string> identites = ReadIdentities();

            CopyData("CD", fieldsCD, cd, identites);

            SqlCeCommand cmd = new SqlCeCommand("SET IDENTITY_INSERT CD ON", sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            int count = 0;
            foreach (DataRow row in cd.Rows)
            {
                try
                {
                    cdAdap.Update(row);
                }
                catch (Exception e)
                {
                    FormUnhandledException formUnhandledException = new FormUnhandledException(e);

                    formUnhandledException.ShowDialog();
                }

                if ((count % 100) == 0)
                {
                    formConvertProgress.CurrentTable = string.Format("{0} ({1} Einträge)", "Track", count);
                    formConvertProgress.Refresh();
                    Application.DoEvents();
                }

                count++;
            }


            cmd = new SqlCeCommand("SET IDENTITY_INSERT CD OFF", sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            cmd = new SqlCeCommand("SELECT MAX(CDID) FROM CD", sdfDatabase.Connection);
            int maxId = (int)cmd.ExecuteScalar() + 1;

            cmd = new SqlCeCommand(string.Format("ALTER TABLE CD ALTER COLUMN CDID IDENTITY({0},1)", maxId), sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            #endregion

            #region Track
            formConvertProgress.CurrentTable = "Track";
            formConvertProgress.Value++;

            List <FieldConvert> fieldsTrack = new List <FieldConvert>();
            fieldsTrack.Add(new FieldConvert("IDLied", "TrackID"));
            fieldsTrack.Add(new FieldConvert("IDCD", "CDID"));
            fieldsTrack.Add(new FieldConvert("IDArtist", "ArtistID"));
            fieldsTrack.Add(new FieldConvert("wLiedNummer", "TrackNumber"));
            fieldsTrack.Add(new FieldConvert("szTitel", "Title"));
            fieldsTrack.Add(new FieldConvert("dwLaenge", "Length"));
            fieldsTrack.Add(new FieldConvert("wBpm", "Bpm"));
            fieldsTrack.Add(new FieldConvert("szNameRecDatei", "SoundFile"));
            fieldsTrack.Add(new FieldConvert("szKennzeichen", "Codes"));
            fieldsTrack.Add(new FieldConvert("szKommentar", "Comment"));
            fieldsTrack.Add(new FieldConvert("szLiedtext", "Lyrics"));
            fieldsTrack.Add(new FieldConvert("szFeld1", "User1"));
            fieldsTrack.Add(new FieldConvert("szFeld2", "User2"));
            fieldsTrack.Add(new FieldConvert("szFeld3", "User3"));
            fieldsTrack.Add(new FieldConvert("szFeld4", "User4"));
            fieldsTrack.Add(new FieldConvert("szFeld5", "User5"));
            fieldsTrack.Add(new FieldConvert("L_TrackFormat", "TrackFormat"));
            fieldsTrack.Add(new FieldConvert("L_BitRate", "BitRate"));
            fieldsTrack.Add(new FieldConvert("L_SampleRate", "SampleRate"));
            fieldsTrack.Add(new FieldConvert("L_Channels", "Channels"));
            fieldsTrack.Add(new FieldConvert("L_YearRecorded", "YearRecorded"));
            fieldsTrack.Add(new FieldConvert("L_Checksum", "Checksum"));
            fieldsTrack.Add(new FieldConvert("L_Rating", "Rating"));
            fieldsTrack.Add(new FieldConvert("L_IDCategory", "CategoryID"));
            fieldsTrack.Add(new FieldConvert("L_IDComposer", "ComposerID"));
            fieldsTrack.Add(new FieldConvert("L_Language", "Language"));
            TrackTableAdapter             trackAdap = new TrackTableAdapter(sdfDatabase);
            ConvertDataSet.TrackDataTable track     = new ConvertDataSet.TrackDataTable();
            trackAdap.Fill(track);

            CopyData("Lied", fieldsTrack, track);

            sql = string.Format("SET IDENTITY_INSERT Track ON");
            cmd = new SqlCeCommand(sql, sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            count = 0;
            foreach (DataRow row in track.Rows)
            {
                try
                {
                    trackAdap.Update(row);
                }
                catch (Exception e)
                {
                    FormUnhandledException formUnhandledException = new FormUnhandledException(e);

                    formUnhandledException.ShowDialog();
                }

                if ((count % 100) == 0)
                {
                    formConvertProgress.CurrentTable = string.Format("{0} ({1} Einträge)", "Track", count);
                    formConvertProgress.Refresh();
                    Application.DoEvents();
                }

                count++;
            }

            sql = string.Format("SET IDENTITY_INSERT Track OFF");
            cmd = new SqlCeCommand(sql, sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            cmd   = new SqlCeCommand("SELECT MAX(TrackID) FROM Track", sdfDatabase.Connection);
            maxId = (int)cmd.ExecuteScalar() + 1;

            cmd = new SqlCeCommand(string.Format("ALTER TABLE Track ALTER COLUMN TrackID IDENTITY({0},1)", maxId), sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            #endregion

            #region Artist
            formConvertProgress.CurrentTable = "Artist";
            formConvertProgress.Value++;

            List <FieldConvert> fieldsPersonGroup = new List <FieldConvert>();
            fieldsPersonGroup.Add(new FieldConvert("IDArtist", "PersonGroupID"));
            fieldsPersonGroup.Add(new FieldConvert("szArtistName", "Name"));
            fieldsPersonGroup.Add(new FieldConvert("sSortKey", "SaveAs"));
            fieldsPersonGroup.Add(new FieldConvert("nGroup", "Type"));
            fieldsPersonGroup.Add(new FieldConvert("nSex", "Sex"));
            fieldsPersonGroup.Add(new FieldConvert("sComment", "Comment"));
            fieldsPersonGroup.Add(new FieldConvert("A_URL", "URL"));
            fieldsPersonGroup.Add(new FieldConvert("A_Country", "Country"));
            fieldsPersonGroup.Add(new FieldConvert("A_BirthDay", "BirthDay", true));
            fieldsPersonGroup.Add(new FieldConvert("A_DayOfDeath", "DayOfDeath", true));
            fieldsPersonGroup.Add(new FieldConvert("A_ImageFilename", "ImageFilename"));
            PersonGroupTableAdapter             personGroupAdap = new PersonGroupTableAdapter(sdfDatabase);
            ConvertDataSet.PersonGroupDataTable personGroup     = new ConvertDataSet.PersonGroupDataTable();
            personGroupAdap.Fill(personGroup);

            CopyData("Artist", fieldsPersonGroup, personGroup);

            sql = string.Format("SET IDENTITY_INSERT PersonGroup ON");
            cmd = new SqlCeCommand(sql, sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            count = 0;
            foreach (DataRow row in personGroup.Rows)
            {
                try
                {
                    personGroupAdap.Update(row);
                }
                catch (Exception e)
                {
                    FormUnhandledException formUnhandledException = new FormUnhandledException(e);

                    formUnhandledException.ShowDialog();
                }
                if ((count % 100) == 0)
                {
                    formConvertProgress.CurrentTable = string.Format("{0} ({1} Einträge)", "Artist", count);
                    formConvertProgress.Refresh();
                    Application.DoEvents();
                }
                count++;
            }

            sql = string.Format("SET IDENTITY_INSERT PersonGroup OFF");
            cmd = new SqlCeCommand(sql, sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            cmd   = new SqlCeCommand("SELECT MAX(PersonGroupID) FROM PersonGroup", sdfDatabase.Connection);
            maxId = (int)cmd.ExecuteScalar() + 1;

            cmd = new SqlCeCommand(string.Format("ALTER TABLE PersonGroup ALTER COLUMN PersonGroupID IDENTITY({0},1)", maxId), sdfDatabase.Connection);
            cmd.ExecuteNonQuery();
            #endregion

            #region Category
            formConvertProgress.CurrentTable = "Category";
            formConvertProgress.Value++;

            List <FieldConvert> fieldsCategory = new List <FieldConvert>();
            fieldsCategory.Add(new FieldConvert("IDKategorie", "CategoryID"));
            fieldsCategory.Add(new FieldConvert("szKategorieName", "Name"));
            fieldsCategory.Add(new FieldConvert("wOrder", "Order"));
            CategoryTableAdapter             categoryAdap = new CategoryTableAdapter(sdfDatabase);
            ConvertDataSet.CategoryDataTable categories   = new ConvertDataSet.CategoryDataTable();
            categoryAdap.Fill(categories);

            CopyData("Kategorie", fieldsCategory, categories);

            sql = string.Format("SET IDENTITY_INSERT Category ON");
            cmd = new SqlCeCommand(sql, sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            categoryAdap.Update(categories);

            sql = string.Format("SET IDENTITY_INSERT Category OFF");
            cmd = new SqlCeCommand(sql, sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            cmd   = new SqlCeCommand("SELECT MAX(CategoryID) FROM Category", sdfDatabase.Connection);
            maxId = (int)cmd.ExecuteScalar() + 1;

            cmd = new SqlCeCommand(string.Format("ALTER TABLE Category ALTER COLUMN CategoryID IDENTITY({0},1)", maxId), sdfDatabase.Connection);
            cmd.ExecuteNonQuery();
            #endregion

            #region Medium
            formConvertProgress.CurrentTable = "Medium";
            formConvertProgress.Value++;

            List <FieldConvert> fieldsMedium = new List <FieldConvert>();
            fieldsMedium.Add(new FieldConvert("IDMedium", "MediumID"));
            fieldsMedium.Add(new FieldConvert("szMedium", "Name"));
            fieldsMedium.Add(new FieldConvert("wOrder", "Order"));
            MediumTableAdapter             mediumAdap = new MediumTableAdapter(sdfDatabase);
            ConvertDataSet.MediumDataTable mediums    = new ConvertDataSet.MediumDataTable();
            mediumAdap.Fill(mediums);

            CopyData("Medium", fieldsMedium, mediums);

            sql = string.Format("SET IDENTITY_INSERT Medium ON");
            cmd = new SqlCeCommand(sql, sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            mediumAdap.Update(mediums);

            sql = string.Format("SET IDENTITY_INSERT Medium OFF");
            cmd = new SqlCeCommand(sql, sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            cmd   = new SqlCeCommand("SELECT MAX(MediumID) FROM Medium", sdfDatabase.Connection);
            maxId = (int)cmd.ExecuteScalar() + 1;

            cmd = new SqlCeCommand(string.Format("ALTER TABLE Medium ALTER COLUMN MediumID IDENTITY({0},1)", maxId), sdfDatabase.Connection);
            cmd.ExecuteNonQuery();
            #endregion

            #region CDSet
            formConvertProgress.CurrentTable = "CDSet";
            formConvertProgress.Value++;

            List <FieldConvert> fieldsSet = new List <FieldConvert>();
            fieldsSet.Add(new FieldConvert("IDCDSet", "SetID"));
            fieldsSet.Add(new FieldConvert("szCDSetName", "Name"));
            SetTableAdapter             setAdap = new SetTableAdapter(sdfDatabase);
            ConvertDataSet.SetDataTable sets    = new ConvertDataSet.SetDataTable();
            setAdap.Fill(sets);

            CopyData("CDSet", fieldsSet, sets);

            sql = string.Format("SET IDENTITY_INSERT [Set] ON");
            cmd = new SqlCeCommand(sql, sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            setAdap.Update(sets);

            sql = string.Format("SET IDENTITY_INSERT [Set] OFF");
            cmd = new SqlCeCommand(sql, sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            cmd = new SqlCeCommand("SELECT MAX(SetID) FROM [Set]", sdfDatabase.Connection);
            object maxSetID = cmd.ExecuteScalar();

            if (maxSetID is DBNull)
            {
                maxId = 1;
            }
            else
            {
                maxId = (int)maxSetID + 1;
            }

            cmd = new SqlCeCommand(string.Format("ALTER TABLE [Set] ALTER COLUMN SetID IDENTITY({0},1)", maxId), sdfDatabase.Connection);
            cmd.ExecuteNonQuery();
            #endregion

            #region Program
            formConvertProgress.CurrentTable = "Program";
            formConvertProgress.Value++;

            List <FieldConvert> fieldsProgram = new List <FieldConvert>();
            fieldsProgram.Add(new FieldConvert("IDCD", "CDID"));
            fieldsProgram.Add(new FieldConvert("szName", "Name"));
            fieldsProgram.Add(new FieldConvert("szLieder", "Tracks"));
            fieldsProgram.Add(new FieldConvert("bStandard", "IsStandard"));
            ProgramTableAdapter             programAdap = new ProgramTableAdapter(sdfDatabase);
            ConvertDataSet.ProgramDataTable programs    = new ConvertDataSet.ProgramDataTable();
            programAdap.Fill(programs);

            CopyData("Programme", fieldsProgram, programs);

            programAdap.Update(programs);
            #endregion

            #region Index
            formConvertProgress.CurrentTable = "Index";
            formConvertProgress.Value++;

            List <FieldConvert> fieldsIndex = new List <FieldConvert>();
            fieldsIndex.Add(new FieldConvert("IDCD", "CDID"));
            fieldsIndex.Add(new FieldConvert("szIndexName", "Name"));
            fieldsIndex.Add(new FieldConvert("dwPosition", "Position"));
            IndexTableAdapter             indexAdap = new IndexTableAdapter(sdfDatabase);
            ConvertDataSet.IndexDataTable indexes   = new ConvertDataSet.IndexDataTable();
            indexAdap.Fill(indexes);

            CopyData("Index", fieldsIndex, indexes);

            indexAdap.Update(indexes);
            #endregion

            #region Codes
            formConvertProgress.CurrentTable = "Codes";
            formConvertProgress.Value++;

            List <FieldConvert> fieldsCode = new List <FieldConvert>();
            fieldsCode.Add(new FieldConvert("cBuchstabe", "Letter"));
            fieldsCode.Add(new FieldConvert("szBedeutung", "Description"));
            CodeTableAdapter             codeAdap = new CodeTableAdapter(sdfDatabase);
            ConvertDataSet.CodeDataTable codes    = new ConvertDataSet.CodeDataTable();
            codeAdap.Fill(codes);

            CopyData("Kennzeichen", fieldsCode, codes);

            codeAdap.Update(codes);
            #endregion

            #region Queue
            formConvertProgress.CurrentTable = "Queue";
            formConvertProgress.Value++;

            List <FieldConvert> fieldsQueue = new List <FieldConvert>();
            fieldsQueue.Add(new FieldConvert("Q_lIDCD", "CDID"));
            fieldsQueue.Add(new FieldConvert("Q_lAction", "Action"));
            fieldsQueue.Add(new FieldConvert("Q_sIdentity", "Identity"));
            fieldsQueue.Add(new FieldConvert("Q_sIdentityCDDB", "IdentityCDDB"));
            QueueTableAdapter             queueAdap = new QueueTableAdapter(sdfDatabase);
            ConvertDataSet.QueueDataTable queues    = new ConvertDataSet.QueueDataTable();
            queueAdap.Fill(queues);

            CopyData("Queue", fieldsQueue, queues);

            queueAdap.Update(queues);
            #endregion

            #region LoanedCDs
            formConvertProgress.CurrentTable = "LoanedCDs";
            formConvertProgress.Value++;

            List <FieldConvert> fieldsLoanedCD = new List <FieldConvert>();
            fieldsLoanedCD.Add(new FieldConvert("IDCD", "CDID"));
            fieldsLoanedCD.Add(new FieldConvert("Kommentar", "Comment"));
            fieldsLoanedCD.Add(new FieldConvert("VerliehenAm", "LoanedDate"));
            fieldsLoanedCD.Add(new FieldConvert("VerliehenAn", "LoanedTo"));
            fieldsLoanedCD.Add(new FieldConvert("RueckgabeTermin", "ReturnDate"));
            LoanedCDTableAdapter             loanedCDAdap = new LoanedCDTableAdapter(sdfDatabase);
            ConvertDataSet.LoanedCDDataTable loanedCDs    = new ConvertDataSet.LoanedCDDataTable();
            loanedCDAdap.Fill(loanedCDs);

            CopyData("VerlieheneCDs", fieldsLoanedCD, loanedCDs);

            loanedCDAdap.Update(loanedCDs);
            #endregion

            #region Dialog
            formConvertProgress.CurrentTable = "Dialog";
            formConvertProgress.Value++;

            List <FieldConvert> fieldsDialog = new List <FieldConvert>();
            fieldsDialog.Add(new FieldConvert("D_IDDialog", "DialogID"));
            fieldsDialog.Add(new FieldConvert("D_IDCategory", "CategoryID"));
            fieldsDialog.Add(new FieldConvert("D_DialogXML", "DialogXML"));
            DialogTableAdapter             dialogAdap = new DialogTableAdapter(sdfDatabase);
            ConvertDataSet.DialogDataTable dialogs    = new ConvertDataSet.DialogDataTable();
            dialogAdap.Fill(dialogs);

            CopyData("Dialog", fieldsDialog, dialogs);

            sql = string.Format("SET IDENTITY_INSERT [Dialog] ON");
            cmd = new SqlCeCommand(sql, sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            dialogAdap.Update(dialogs);

            sql = string.Format("SET IDENTITY_INSERT [Dialog] OFF");
            cmd = new SqlCeCommand(sql, sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            cmd      = new SqlCeCommand("SELECT MAX(DialogID) FROM [Dialog]", sdfDatabase.Connection);
            maxSetID = cmd.ExecuteScalar();

            if (maxSetID is DBNull)
            {
                maxId = 1;
            }
            else
            {
                maxId = (int)maxSetID + 1;
            }

            cmd = new SqlCeCommand(string.Format("ALTER TABLE [Dialog] ALTER COLUMN DialogID IDENTITY({0},1)", maxId), sdfDatabase.Connection);
            cmd.ExecuteNonQuery();
            #endregion

            #region Role
            formConvertProgress.CurrentTable = "Role";
            formConvertProgress.Value++;

            List <FieldConvert> fieldsRole = new List <FieldConvert>();
            fieldsRole.Add(new FieldConvert("R_ID", "RoleID"));
            fieldsRole.Add(new FieldConvert("R_Role", "Name"));
            RoleTableAdapter             roleAdap = new RoleTableAdapter(sdfDatabase);
            ConvertDataSet.RoleDataTable roles    = new ConvertDataSet.RoleDataTable();
            roleAdap.Fill(roles);

            CopyData("Role", fieldsRole, roles);

            sql = string.Format("SET IDENTITY_INSERT [Role] ON");
            cmd = new SqlCeCommand(sql, sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            roleAdap.Update(roles);

            sql = string.Format("SET IDENTITY_INSERT [Role] OFF");
            cmd = new SqlCeCommand(sql, sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            cmd      = new SqlCeCommand("SELECT MAX(RoleID) FROM [Role]", sdfDatabase.Connection);
            maxSetID = cmd.ExecuteScalar();

            if (maxSetID is DBNull)
            {
                maxId = 1;
            }
            else
            {
                maxId = (int)maxSetID + 1;
            }

            cmd = new SqlCeCommand(string.Format("ALTER TABLE [Role] ALTER COLUMN RoleID IDENTITY({0},1)", maxId), sdfDatabase.Connection);
            cmd.ExecuteNonQuery();
            #endregion

            #region Participant
            formConvertProgress.CurrentTable = "Participant";
            formConvertProgress.Value++;

            List <FieldConvert> fieldsParticipant = new List <FieldConvert>();
            fieldsParticipant.Add(new FieldConvert("P_ID", "ParticipantID"));
            fieldsParticipant.Add(new FieldConvert("P_IDArtist", "PersonGroupID"));
            fieldsParticipant.Add(new FieldConvert("P_IDRole", "RoleID"));
            fieldsParticipant.Add(new FieldConvert("P_IDCD", "CDID"));
            fieldsParticipant.Add(new FieldConvert("P_TrackNumber", "TrackNumber"));
            fieldsParticipant.Add(new FieldConvert("P_Comment", "Comment"));
            ParticipantTableAdapter             participantAdap = new ParticipantTableAdapter(sdfDatabase);
            ConvertDataSet.ParticipantDataTable participants    = new ConvertDataSet.ParticipantDataTable();
            participantAdap.Fill(participants);

            CopyData("Participant", fieldsParticipant, participants);

            sql = string.Format("SET IDENTITY_INSERT [Participant] ON");
            cmd = new SqlCeCommand(sql, sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            participantAdap.Update(participants);

            sql = string.Format("SET IDENTITY_INSERT [Participant] OFF");
            cmd = new SqlCeCommand(sql, sdfDatabase.Connection);
            cmd.ExecuteNonQuery();

            cmd      = new SqlCeCommand("SELECT MAX(ParticipantID) FROM [Participant]", sdfDatabase.Connection);
            maxSetID = cmd.ExecuteScalar();

            if (maxSetID is DBNull)
            {
                maxId = 1;
            }
            else
            {
                maxId = (int)maxSetID + 1;
            }

            cmd = new SqlCeCommand(string.Format("ALTER TABLE [Participant] ALTER COLUMN ParticipantID IDENTITY({0},1)", maxId), sdfDatabase.Connection);
            cmd.ExecuteNonQuery();
            #endregion
        }
예제 #11
0
 public void Update(string categoryname, int categoryid)
 {
     _category.Update(categoryname, categoryid);
 }