private void p_BtnSetTimeClicked(object sender, EventArgs e) { LogPanel logPanel = sender as LogPanel; var log = db.DepartmentLog.FirstOrDefault(x => x.id == logPanel.id); var form = new DaysLimitForm(); if (form.ShowDialog() != DialogResult.OK) { return; } log.dueTime = form.dt; db.SubmitChanges(); logPanel.set_Due_text(log.dueTime); }