private void button1_Click(object sender, EventArgs e) { try { string date = textBox1.Text; SkladDBEntities context = new SkladDBEntities(); Product_customer p_c = context.Product_customer .Where(o => o.ID_customer == currentCust && o.ID_product == currentProd).First(); if (date == "") { MessageBox.Show("Заполните поле дата"); return; } p_c.Order_date = date; context.Product_customer.Attach(p_c); context.Entry(p_c).Property(o => o.Order_date).IsModified = true; context.SaveChanges(); DialogResult = DialogResult.OK; } catch (FormatException) { MessageBox.Show("Заполните поле дата"); } catch (Exception) { throw; } }
private void button3_Click(object sender, EventArgs e) { try { int nCount = Convert.ToInt32(textBox2.Text); string adr = textBox1.Text; if (nCount < 0) { MessageBox.Show("Введите корректное число в поле \"Count\""); return; } SkladDBEntities context = new SkladDBEntities(); Storage_place stor = context.Storage_place .Where(o => o.Adress == addr) .First(); Product_Storage_place p_s = context.Product_Storage_place .Where(o => o.ID_product == currentProd && o.ID_storage_place == stor.ID_storage_place).First(); //.Find(currentProd, stor.ID_storage_place); stor.Adress = adr; p_s.C_Count = nCount; context.Storage_place.Attach(stor); context.Entry(stor).Property(o => o.Adress).IsModified = true; context.Product_Storage_place.Attach(p_s); context.Entry(p_s).Property(o => o.C_Count).IsModified = true; context.SaveChanges(); DialogResult = DialogResult.OK; } catch (FormatException) { MessageBox.Show("Заполните поля"); } catch (Exception) { throw; } }