Esempio n. 1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            ProviderSet providerSet = new ProviderSet();

            providerSet.idProduct   = Convert.ToInt32(comboBoxNameProduct.SelectedItem.ToString().Split('.')[0]);
            providerSet.NameProduct = comboBoxNameProduct.Text;
            providerSet.Company     = textBoxCompany.Text;
            providerSet.Phone       = textBoxPhone.Text;
            providerSet.Email       = textBoxEmail.Text;

            Program.master.ProviderSet.Add(providerSet);
            Program.master.SaveChanges();
            ShowProviderSet();
        }
Esempio n. 2
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listViewProvider.SelectedItems.Count == 1)
            {
                ProviderSet providerSet = listViewProvider.SelectedItems[0].Tag as ProviderSet;

                providerSet.idProduct   = Convert.ToInt32(comboBoxNameProduct.SelectedItem.ToString().Split('.')[0]);
                providerSet.NameProduct = comboBoxNameProduct.Text;
                providerSet.Company     = textBoxCompany.Text;
                providerSet.Phone       = textBoxPhone.Text;
                providerSet.Email       = textBoxEmail.Text;

                Program.master.SaveChanges();
                ShowProviderSet();
            }
        }
Esempio n. 3
0
        private void listViewProvider_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewProvider.SelectedItems.Count == 1)
            {
                ProviderSet providerSet = listViewProvider.SelectedItems[0].Tag as ProviderSet;

                textBoxCompany.Text      = providerSet.Company;
                textBoxPhone.Text        = providerSet.Phone;
                textBoxEmail.Text        = providerSet.Email;
                comboBoxNameProduct.Text = providerSet.NameProduct;
            }
            else
            {
                textBoxCompany.Text      = "";
                textBoxPhone.Text        = "";
                textBoxEmail.Text        = "";
                comboBoxNameProduct.Text = "";
            }
        }
Esempio n. 4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewProvider.SelectedItems.Count == 1)
         {
             ProviderSet providerSet = listViewProvider.SelectedItems[0].Tag as ProviderSet;
             Program.master.ProviderSet.Remove(providerSet);
             Program.master.SaveChanges();
             ShowProviderSet();
         }
         textBoxCompany.Text      = "";
         textBoxPhone.Text        = "";
         textBoxEmail.Text        = "";
         comboBoxNameProduct.Text = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }