示例#1
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxClient.SelectedItem != null && comboBoxSotr.SelectedItem != null && textBoxPrice.Text != "")
     {
         SellsSet sell = new SellsSet();
         sell.IdClient    = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
         sell.IdSotrudnik = Convert.ToInt32(comboBoxSotr.SelectedItem.ToString().Split('.')[0]);
         sell.Price       = Convert.ToInt32(textBoxPrice.Text);
         if (comboBoxVidTovar.SelectedIndex == 0)
         {
             sell.TypeTovar   = 0;
             sell.Garant      = Convert.ToInt32(textBoxGarant.Text);
             sell.ModelMobile = Convert.ToString(textBoxModelMobile.Text);
         }
         else if (comboBoxVidTovar.SelectedIndex == 1)
         {
             sell.TypeTovar  = 1;
             sell.Garant     = Convert.ToInt32(textBoxGarant.Text);
             sell.NameAcsess = Convert.ToString(textBoxNameAcsess.Text);
         }
         else
         {
             sell.TypeTovar = 2;
             sell.NameOper  = Convert.ToString(textBoxNameOper);
         }
         Program.SpDb.SellsSet.Add(sell);
         Program.SpDb.SaveChanges();
         ShowSellsSet();
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
示例#2
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (comboBoxVidTovar.SelectedIndex == 0)
         {
             if (listViewMobile.SelectedItems.Count == 1)
             {
                 SellsSet sell = listViewMobile.SelectedItems[0].Tag as SellsSet;
                 Program.SpDb.SellsSet.Remove(sell);
                 Program.SpDb.SaveChanges();
                 ShowSellsSet();
             }
             comboBoxSotr.SelectedItem   = null;
             comboBoxClient.SelectedItem = null;
             textBoxPrice.Text           = "";
             textBoxGarant.Text          = "";
             textBoxModelMobile.Text     = "";
         }
         else if (comboBoxVidTovar.SelectedIndex == 1)
         {
             if (listViewAcsess.SelectedItems.Count == 1)
             {
                 SellsSet sell = listViewAcsess.SelectedItems[0].Tag as SellsSet;
                 Program.SpDb.SellsSet.Remove(sell);
                 Program.SpDb.SaveChanges();
                 ShowSellsSet();
             }
             comboBoxSotr.SelectedItem   = null;
             comboBoxClient.SelectedItem = null;
             textBoxPrice.Text           = "";
             textBoxGarant.Text          = "";
             textBoxNameAcsess.Text      = "";
         }
         else
         {
             if (listViewOper.SelectedItems.Count == 1)
             {
                 SellsSet sell = listViewOper.SelectedItems[0].Tag as SellsSet;
                 Program.SpDb.SellsSet.Remove(sell);
                 Program.SpDb.SaveChanges();
                 ShowSellsSet();
             }
             comboBoxSotr.SelectedItem   = null;
             comboBoxClient.SelectedItem = null;
             textBoxPrice.Text           = "";
             textBoxNameOper.Text        = "";
         }
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#3
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (comboBoxVidTovar.SelectedIndex == 0)
     {
         if (listViewMobile.SelectedItems.Count == 1)
         {
             SellsSet sell = listViewMobile.SelectedItems[0].Tag as SellsSet;
             sell.IdSotrudnik = Convert.ToInt32(comboBoxSotr.SelectedItem.ToString().Split('.')[0]);
             sell.IdClient    = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
             sell.Price       = Convert.ToInt32(textBoxPrice.Text);
             sell.Garant      = Convert.ToInt32(textBoxGarant.Text);
             sell.ModelMobile = Convert.ToString(textBoxModelMobile.Text);
             Program.SpDb.SaveChanges();
             ShowSellsSet();
         }
     }
     if (comboBoxVidTovar.SelectedIndex == 1)
     {
         if (listViewMobile.SelectedItems.Count == 1)
         {
             SellsSet sell = listViewMobile.SelectedItems[0].Tag as SellsSet;
             sell.IdSotrudnik = Convert.ToInt32(comboBoxSotr.SelectedItem.ToString().Split('.')[0]);
             sell.IdClient    = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
             sell.Price       = Convert.ToInt32(textBoxPrice.Text);
             sell.Garant      = Convert.ToInt32(textBoxGarant.Text);
             sell.NameAcsess  = Convert.ToString(textBoxNameAcsess.Text);
             Program.SpDb.SaveChanges();
             ShowSellsSet();
         }
     }
     else
     {
         if (listViewMobile.SelectedItems.Count == 1)
         {
             SellsSet sell = listViewMobile.SelectedItems[0].Tag as SellsSet;
             sell.IdSotrudnik = Convert.ToInt32(comboBoxSotr.SelectedItem.ToString().Split('.')[0]);
             sell.IdClient    = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]);
             sell.Price       = Convert.ToInt32(textBoxPrice.Text);
             sell.NameOper    = Convert.ToString(textBoxNameOper.Text);
             Program.SpDb.SaveChanges();
             ShowSellsSet();
         }
     }
 }
示例#4
0
 private void listViewOper_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewOper.SelectedItems.Count == 1)
     {
         SellsSet sell = listViewOper.SelectedItems[0].Tag as SellsSet;
         comboBoxClient.SelectedIndex = comboBoxClient.FindString(sell.IdClient.ToString());
         comboBoxSotr.SelectedIndex   = comboBoxClient.FindString(sell.IdSotrudnik.ToString());
         textBoxPrice.Text            = sell.Price.ToString();
         textBoxGarant.Text           = sell.Garant.ToString();
         textBoxNameOper.Text         = sell.NameOper.ToString();
     }
     else
     {
         comboBoxSotr.SelectedItem   = null;
         comboBoxClient.SelectedItem = null;
         textBoxPrice.Text           = "";
         textBoxGarant.Text          = "";
         textBoxNameOper.Text        = "";
     }
 }