private void button1_Click(object sender, EventArgs e) { if (dataGridView1.SelectedCells[0].Style.BackColor != System.Drawing.Color.LightPink && docid != 0 && dataGridView1.SelectedCells[0].ColumnIndex != 0) using (hc_dbEntities1 h = new hc_dbEntities1()) { healing heal = new healing(); heal.id_doctor = docid; heal.id_patient = patid; heal.comments = richTextBox1.Text; heal.healing_time = GetGridDate(); h.AddTohealing(heal); h.SaveChanges(); dataGridView1.SelectedCells[0].Style.BackColor = System.Drawing.Color.LightPink; FillHistory(); MessageBox.Show("Заявка подана"); } else MessageBox.Show("Ошибка записи!"); }
/// <summary> /// Создание нового объекта healing. /// </summary> /// <param name="id_healing">Исходное значение свойства id_healing.</param> /// <param name="id_doctor">Исходное значение свойства id_doctor.</param> /// <param name="id_patient">Исходное значение свойства id_patient.</param> /// <param name="healing_time">Исходное значение свойства healing_time.</param> public static healing Createhealing(global::System.Int32 id_healing, global::System.Int32 id_doctor, global::System.Int32 id_patient, global::System.DateTime healing_time) { healing healing = new healing(); healing.id_healing = id_healing; healing.id_doctor = id_doctor; healing.id_patient = id_patient; healing.healing_time = healing_time; return healing; }
/// <summary> /// Устаревший метод для добавления новых объектов в набор EntitySet healing. Взамен можно использовать метод .Add связанного свойства ObjectSet<T>. /// </summary> public void AddTohealing(healing healing) { base.AddObject("healing", healing); }