Exemple #1
0
 private void GetData(string selectCommand)
 {
     try
     {
         dataAdapterbindingsource1 = new MySqlDataAdapter();
         // Create a new data adapter based on the specified query.
         dataAdapterbindingsource1 = new MySqlDataAdapter(selectCommand, Util.Connection);
         // Create a command builder to generate SQL update, insert, and
         // delete commands based on selectCommand. These are used to
         // update the database.
         commandBuilder = new MySqlCommandBuilder(dataAdapterbindingsource1);
         StyleDataTable.Clear();
         // Populate a new data table and bind it to the BindingSource.
         StyleDataTable.Locale = System.Globalization.CultureInfo.InvariantCulture;
         dataAdapterbindingsource1.Fill(StyleDataTable);
         bindingSource1.DataSource = StyleDataTable;
     }
     catch (MySqlException ex)
     {
         MessageBox.Show("Error " + ex.Message);
     }
 }
Exemple #2
0
        private void SaveNewStyle_Click(object sender, EventArgs e)
        {
            if (!ValidStyleData())
            {
                return;
            }

            if (MessageBox.Show("Save this new style?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                long i = 1;
                foreach (byte b in Guid.NewGuid().ToByteArray())
                {
                    i *= ((int)b + 1);
                }
                i -= DateTime.Now.Ticks;
                string str = "Dol_Server_Editor_" + i.ToString();

                DataRow datarow = StyleDataTable.NewRow();

                datarow["Style_ID"]                = str;
                datarow["ID"]                      = StyleIDtextBox.Text;
                datarow["ClassId"]                 = Util.ClassNameToID(this.ClassIDcomboBox.Text);
                datarow["Name"]                    = StyleNametextBox.Text;
                datarow["SpecKeyName"]             = SpecKeyNamecomboBox.Text;
                datarow["SpecLevelRequirement"]    = SpecLevelRequirementtextBox.Text;
                datarow["Icon"]                    = IcontextBox.Text;
                datarow["EnduranceCost"]           = EnduranceCosttextBox.Text;
                datarow["StealthRequirement"]      = Util.Find_Bool_Value(StealthRequirementcomboBox.Text);
                datarow["OpeningRequirementType"]  = OpeningRequirementTypecomboBox.SelectedIndex;
                datarow["OpeningRequirementValue"] = OpeningRequirementValuecomboBox.SelectedValue;
                datarow["AttackResultRequirement"] = AttackResultRequirementcomboBox.SelectedIndex;

                datarow["WeaponTypeRequirement"] = Util.ObjectNameToID(WeaponTypeRequirementcomboBox.Text);
                datarow["GrowthRate"]            = GrowthratetextBox.Text;
                datarow["BonusToHit"]            = BonustoHittextBox.Text;
                datarow["BonusToDefense"]        = BonustoDefensetextBox.Text;
                datarow["TwoHandAnimation"]      = TwoHandAnimtextBox.Text;
                datarow["RandomProc"]            = Util.Find_Bool_Value(RandomProccomboBox.Text);
                datarow["ArmorHitLocation"]      = ArmorHitLoctextBox.Text;

                if (DolEditor.Properties.Settings.Default.OriginsSettings)
                {
                    datarow["TranslationId"] = TranslationIDtextBox.Text;
                }

                StyleDataTable.Rows.Add(datarow);

                this.Validate();
                this.bindingSource1.EndEdit();

                try
                {
                    dataAdapterbindingsource1.Update(StyleDataTable);
                }
                catch (MySqlException s)
                {
                    MessageBox.Show(s.Message);
                }

                this.EditStyleControl.Hide();
                this.dataGridStyle.Show();
                this.ControlMenu.Visible        = true;
                this.StyleAddButton.Visible     = true;
                this.StyleListingButton.Visible = false;
                this.SaveNewbutton.Hide();
            }
        }