private void button_SaveToDB_Click(object sender, EventArgs e) { try { LabelTabInfo info = Tag as LabelTabInfo; if (info == null) { MessageBox.Show("Something went terribly wrong...but everything's OK!", "Unknown Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (info.IsNew) { using (InputNewNameWin newNameWin = new InputNewNameWin()) { if (newNameWin.ShowDialog() == DialogResult.OK) { if (MessageBox.Show(string.Format("Add template ({0}) to DB?\r\nAre you sure?", newNameWin.NewName), string.Format("Add new template to DB: {0}", newNameWin.NewName), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (MessageBox.Show(string.Format("Really, really sure?", newNameWin.NewName), string.Format("Add new template to DB: {0}...", newNameWin.NewName), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DB.AddBarcodLabelToDB(newNameWin.NewName, Label); } } } } } else { if (MessageBox.Show(string.Format("Save changes ({0}) to DB?\r\nAre you sure?", info.Title), string.Format("Save changes {0}...", info.Title), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (MessageBox.Show(string.Format("Really, really sure?", info.Title), string.Format("Save changes {0}...", info.Title), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DB.UpdateBarcodLabelByName(info.Title, Label); } } } } catch (Exception err) { MessageBox.Show(err.Message, err.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void button_ReloadFromDB_Click(object sender, EventArgs e) { LabelTabInfo info = Tag as LabelTabInfo; if (info == null) { MessageBox.Show("Something went terribly wrong...but everything's OK!", "Unknown Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (MessageBox.Show(string.Format("Reload ({0}) from DB?", info.Title), string.Format("Reload {0}...", info.Title), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { BarcodeLabel label; if (DB.GetBarcodLabelFromDB(info.Title, out label)) { Label = label; } else { MessageBox.Show(string.Format("Could not retrieve a label definition using the name:\r\n{0}", info.Title), "Label not found...", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }