Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            OrgSet orgSet = new OrgSet();

            orgSet.Name   = textBoxName.Text;
            orgSet.Adress = textBoxAdress.Text;
            orgSet.Phone  = textBoxPhone.Text;
            Program.dailyDB.OrgSet.Add(orgSet);
            Program.dailyDB.SaveChanges();
            ShowOrg();
        }
Example #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (listViewOrg.SelectedItems.Count == 1)
     {
         OrgSet orgSet = listViewOrg.SelectedItems[0].Tag as OrgSet;
         orgSet.Name   = textBoxName.Text;
         orgSet.Adress = textBoxAdress.Text;
         orgSet.Phone  = textBoxPhone.Text;
         Program.dailyDB.SaveChanges();
         ShowOrg();
     }
 }
Example #3
0
 private void listViewOrg_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewOrg.SelectedItems.Count == 1)
     {
         OrgSet orgSet = listViewOrg.SelectedItems[0].Tag as OrgSet;
         textBoxName.Text   = orgSet.Name;
         textBoxAdress.Text = orgSet.Adress;
         textBoxPhone.Text  = orgSet.Phone;
     }
     else
     {
         textBoxName.Text   = "";
         textBoxAdress.Text = "";
         textBoxPhone.Text  = "";
     }
 }
Example #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewOrg.SelectedItems.Count == 1)
         {
             OrgSet orgSet = listViewOrg.SelectedItems[0].Tag as OrgSet;
             Program.dailyDB.OrgSet.Remove(orgSet);
             Program.dailyDB.SaveChanges();
             ShowOrg();
         }
         textBoxName.Text   = "";
         textBoxAdress.Text = "";
         textBoxPhone.Text  = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }