private void SaveBtn_Click(object sender, RoutedEventArgs e) { if (TitleTxt.Text == "") { l1.Foreground = new SolidColorBrush(Colors.Red); } else { l1.Foreground = new SolidColorBrush(Colors.Black); } if (MinTxt.Text == "") { l22.Foreground = new SolidColorBrush(Colors.Red); } else { l22.Foreground = new SolidColorBrush(Colors.Black); } if (Grid2.Items.Count == 0) { l4.Foreground = new SolidColorBrush(Colors.Red); } else { l4.Foreground = new SolidColorBrush(Colors.Black); } if (Grid4.Items.Count == 0) { l5.Foreground = new SolidColorBrush(Colors.Red); } else { l5.Foreground = new SolidColorBrush(Colors.Black); } if (HourTxt.Text == "" || MinuteTxt.Text == "") { l6.Foreground = new SolidColorBrush(Colors.Red); } else { l6.Foreground = new SolidColorBrush(Colors.Black); } if (HourTxt.Text == "" || MinuteTxt.Text == "" || TitleTxt.Text == "" || MinTxt.Text == "" || Grid2.Items.Count == 0 || Grid4.Items.Count == 0) { ErrorHandler.NotifyUser("برخی اطلاعات ضروری وارد نشده اند"); return; } else if (NextBtn.IsEnabled == true) { ErrorHandler.ShowErrorMessage("ثبت قبلا صورت گرفته است. لطفا به صفحه بعد بروید."); return; } else { List <User> l = new List <User>(); foreach (var item in Grid2.Items) { l.Add(item as User); } List <Contractor> l2 = new List <Contractor>(); foreach (var item in Grid4.Items) { l2.Add(item as Contractor); } try { var d = (DateTime)datePicker1.SelectedDate; DateTime date = new DateTime(d.Year, d.Month, d.Day, Int32.Parse(HourTxt.Text), Int32.Parse(MinuteTxt.Text), 0); currentEval = DataManagement.CreateEvaluationForm(Int32.Parse(MinTxt.Text), (DateTime)(datePicker1.SelectedDate), TitleTxt.Text, null, l, l2, true, false, null, false, false); ErrorHandler.NotifyUser("ثبت با موفقیت انجام شد به صفحه بعد بروید"); NextBtn.IsEnabled = true; } catch (System.Exception ex) { MessageBox.Show("مشکل در وارد کردن تاریخ و ساعت"); } } }