private void closeMenu_Click(object sender, EventArgs e) { exitButton.PerformClick(); humandb = null; open_dlg = null; closeMenu.Enabled = false; saveMenu.Enabled = false; panel1.Visible = false; panel2.Visible = false; }
public void Update(HumanDB humandb) { label5.Text = humandb.Clan_Name; label17.Text = humandb.Date_Create.ToShortDateString(); label18.Text = humandb.Date_Last_Edit.ToShortDateString(); if (humandb.dblist != null) { label6.Text = humandb.dblist.Count.ToString(); } else { label6.Text = "0"; } humanlist = humandb.dblist; UpdateAllHumanBox(humanlist); }
private void codeButton_Click(object sender, EventArgs e) { if (HumanDB.GetHashCode(codeBox.Text) == humandb.Code) { codeBox.Text = ""; label3.Visible = false; codeBox.Visible = false; codeButton.Visible = false; exitButton.Visible = true; addButton.Visible = true; RedButton.Visible = true; DeleteButton.Visible = true; label4.Text = "РЕДАКТИРОВАНИЕ РАЗРЕШЕНО"; label4.ForeColor = Color.Green; } else { MessageBox.Show(Properties.Resources.Error_Not_True_Code, "Ошибка"); } }
private void openMenu_Click(object sender, EventArgs e) { exitButton.PerformClick(); open_dlg = new OpenFileDialog(); open_dlg.FileName = ""; open_dlg.Filter = "Text |*.txt"; if (open_dlg.ShowDialog() == DialogResult.OK) { try { humandb = HumanDB.ReadFromTxt(open_dlg.FileName); } catch (FormatException ex) { MessageBox.Show(ex.Message, "Ошибка"); open_dlg = null; return; } Update(humandb); closeMenu.Enabled = true; saveMenu.Enabled = true; panel1.Visible = true; panel2.Visible = true; } else { open_dlg = null; } }
public static HumanDB ReadFromTxt(string path) { string[] data = File.ReadAllLines(path); HumanDB humandb; if (data.Length > 4 && data[4] == Validate_Code) { humandb = new HumanDB(data[0], data[1], data[2], data[3]); if (data.Length > 5 && (data.Length - 5) % 3 == 0) { for (int i = 5; i < data.Length; i += 3) { string data1 = data[i]; string data2 = data[i + 1]; string data3 = data[i + 2]; int j = 0, k = 0, l = 0; string[] temp0 = new string[8]; foreach (char value in data1) { switch (value) { case '{': { break; } case '}': { j++; break; } default: { temp0[j] += value; break; } } } int q = Int32.Parse(temp0[6]); string[] temp1 = new string[2]; foreach (char value in data2) { switch (value) { case '°': { break; } case '{': { break; } case '}': { k++; break; } default: { temp1[k] += value; break; } } } string[] temp2 = new string[q]; if (q > 0) { foreach (char value in data3) { switch (value) { case '°': { break; } case '{': { break; } case '}': { l++; break; } default: { temp2[l] += value; break; } } } } humandb.dblist.Add(new Human(temp0[0], temp0[1], temp0[2], StringToDate(temp0[3]), Boolean.Parse(temp0[4]), StringToDate(temp0[5]), temp1, q, temp2, temp0[7])); } if (humandb != null) { return(humandb); } else { throw new FormatException(Properties.Resources.Error_Validate_File_Gen); } } } else { throw new FormatException(Properties.Resources.Error_Validate_File); } return(humandb); }