示例#1
0
文件: FormOrg.cs 项目: RyabBusher/DB
        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();
        }
示例#2
0
文件: FormOrg.cs 项目: RyabBusher/DB
 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();
     }
 }
示例#3
0
文件: FormOrg.cs 项目: RyabBusher/DB
 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  = "";
     }
 }
示例#4
0
文件: FormOrg.cs 项目: RyabBusher/DB
 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);
     }
 }