private void btnSave_Click(object sender, EventArgs e) { string strErrMsg = ""; if (ValidateInPutControls(out strErrMsg)) { MasterEntry objMstrEntry = new MasterEntry(); objMstrEntry.Type = (string)cmbType.SelectedItem; objMstrEntry.Value = txtValue.Text; if (blEditMstrEntry) { UpdateMasterEntry(objMstrEntry, editRowIndxMstrEntry); } else { InsertMasterEntry(objMstrEntry); } //TODO. ResetMasterEntryControls(); } else { MessageBox.Show(strErrMsg, GlobalVariables.ProjectName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private bool ConnectTo(MasterEntry me, string username, string userpsw, bool secondtry = false) { var dbfilename = MyData.GetFileName(me); DoBackUpIfNeeded(dbfilename, false); return(MyData.ConnectTo(me, username, userpsw)); }
private void DeleteSelected() { if (dgvFiles.CurrentRow == null) { return; } int k = dgvFiles.CurrentRow.Index; if (k == -1 || k == dgvFiles.NewRowIndex) { return; } MasterEntry me = dgvFiles.CurrentRow.DataBoundItem as MasterEntry; if (MessageBox.Show("Dzēsīsim datubāzes ierakstu [" + me.Name + "]", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } if (MyData.Settings.MasterEntry.Name == me.Name) { MyData.Settings.MasterEntry = null; } bsFiles.RemoveCurrent(); MyData.SaveMasterList(); return; }
private void UpdateMasterEntry(MasterEntry objMstrEntry, int editRowIndxMstrEntry) { dgvMasterEntry.Rows[editRowIndxMstrEntry].Cells["ColType"].Value = objMstrEntry.Type; dgvMasterEntry.Rows[editRowIndxMstrEntry].Cells["ColValue"].Value = objMstrEntry.Value; editRowIndxMstrEntry = -1; blEditMstrEntry = false; MessageBox.Show("Updated successfully", GlobalVariables.ProjectName, MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void InsertMasterEntry(MasterEntry objMstrEntry) { dgvMasterEntry.Rows.Add(); int RowIndex = dgvMasterEntry.Rows.Count - 1; dgvMasterEntry.Rows[RowIndex].Cells["ColType"].Value = objMstrEntry.Type; dgvMasterEntry.Rows[RowIndex].Cells["ColValue"].Value = objMstrEntry.Value; MessageBox.Show("Inserted successfully", GlobalVariables.ProjectName, MessageBoxButtons.OK, MessageBoxIcon.Information); }
public static void Init() { Rom.Seek(Address); Entries = Rom.ReadUShort(); MasterEntries = Rom.ReadUShort(); Bgs = new GfxBattleBg[Entries]; Masters = new MasterEntry[MasterEntries]; for (int i = 0; i < Entries; i++) { var bg = new GfxBattleBg(); bg.index = i; bg.GfxEntry = Rom.ReadUShort(); bg.ArrEntry = Rom.ReadUShort(); bg.Palette = Rom.ReadPals(2); bg.PalDir = Rom.ReadUShort(); Rom.SeekAdd(2); bg.PalStart = Rom.ReadUShort(); bg.PalEnd = Rom.ReadUShort(); bg.PalDelay = Rom.ReadUShort(); Rom.SeekAdd(0x26); bg.DriftH = Rom.ReadShort(); bg.DriftV = Rom.ReadShort(); Rom.SeekAdd(4); bg.AmplH = Rom.ReadShort(); bg.AmplV = Rom.ReadShort(); bg.WavenumH = Rom.ReadShort(); bg.WavenumV = Rom.ReadShort(); bg.FreqH = Rom.ReadShort(); bg.FreqV = Rom.ReadShort(); Rom.SeekAdd(8); Bgs[i] = bg; } for (int i = 0; i < MasterEntries; i++) { Masters[i] = new MasterEntry(); Masters[i].index = i; Masters[i].Layer[0] = Rom.ReadUShort(); Masters[i].Layer[1] = Rom.ReadUShort(); Masters[i].Alpha[0] = Rom.ReadUShort(); Masters[i].Alpha[1] = Rom.ReadUShort(); Rom.SeekAdd(4); } }
private void dgvFiles_RowValidating(object sender, DataGridViewCellCancelEventArgs e) { if (dgvFiles.DataSource == null || dgvFiles.NewRowIndex == e.RowIndex || !dgvFiles.IsCurrentRowDirty) { return; } MasterEntry me = dgvFiles.GetDataItem(e.RowIndex) as MasterEntry; if (me == null) { return; } string s = me.Name; if (string.IsNullOrEmpty(s)) { dgvFiles.Rows[e.RowIndex].ErrorText = "Nepareizs kods"; e.Cancel = true; return; } for (int i = 0; i < dgvFiles.Rows.Count - 1; i++) { if (i == e.RowIndex) { continue; } if ((dgvFiles.Rows[i].DataBoundItem as MasterEntry).Name == s) { dgvFiles.Rows[e.RowIndex].ErrorText = "Nepareizs kods"; e.Cancel = true; return; } } if (string.IsNullOrEmpty(me.ConnStr) || string.IsNullOrEmpty(me.FileName)) { dgvFiles.Rows[e.RowIndex].ErrorText = "Jāaizpilda lauki pieslēgums un fails."; e.Cancel = true; return; } dgvFiles.Rows[e.RowIndex].ErrorText = null; }
private bool DoIt() { if (dgvFiles.CurrentRow == null) { return(false); } int k = dgvFiles.CurrentRow.Index; if (k == -1 || k == dgvFiles.NewRowIndex) { return(false); } MasterEntry me = dgvFiles.CurrentRow.DataBoundItem as MasterEntry; MyData.Settings.MasterEntry = me; return(true); }