예제 #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            Store1 storeSet = new Store1();

            storeSet.Id_Factory = Convert.ToInt32(comboBoxFactory.SelectedItem.ToString().Split('.')[0]);
            storeSet.Address    = textBoxAddress.Text;
            Program.wftDb.Store1.Add(storeSet);
            Program.wftDb.SaveChanges();
            ShowStore();
        }
예제 #2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewStore1.SelectedItems.Count == 1)
     {
         Store1 factory = listViewStore1.SelectedItems[0].Tag as Store1;
         factory.Id_Factory = Convert.ToInt32(comboBoxFactory.SelectedItem.ToString().Split('.')[0]);
         factory.Address    = textBoxAddress.Text;
         Program.wftDb.SaveChanges();
         ShowFactory();
     }
 }
예제 #3
0
        private void listViewStore1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if ((listViewStore1.SelectedItems.Count == 1))
            {
                Store1 realEstate = listViewStore1.SelectedItems[0].Tag as Store1;
                comboBoxFactory.SelectedIndex = comboBoxFactory.FindString(realEstate.Id_Factory.ToString());

                textBoxAddress.Text = realEstate.Address.ToString();
            }
            else
            {
                comboBoxFactory.SelectedItem = null;

                textBoxAddress.Text = "";
            }
        }
예제 #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewStore1.SelectedItems.Count == 1)
         {
             Store1 factory = listViewStore1.SelectedItems[0].Tag as Store1;
             Program.wftDb.Store1.Remove(factory);
             Program.wftDb.SaveChanges();
             ShowFactory();
         }
         comboBoxFactory.Text = "";
         textBoxAddress.Text  = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }