示例#1
0
 public Plan(PlanDS plan)
 {
     InitializeComponent();
     this.plan          = plan;
     this.TextPath.Text = plan.path;
     this.TextTime.Text = PlanDS.getTimeStringFormat(plan.time);
 }
示例#2
0
        private void ButtonAddDate_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            bool pickerIsEmpty = this.DatePicker.Value.ToString().Length == 0;
            bool pathIsEmpty   = this.scanPath.Length == 0;

            if (pickerIsEmpty || pathIsEmpty)
            {
                MessageBox.Show("Заполните все поля");
                return;
            }

            ServiceClient client = ServiceClientCreate.createClient();
            DateTime      picker = (DateTime)this.DatePicker.Value;

            string[] date = picker.ToString().Split(' ')[0].Split('.');
            string[] time = picker.ToString().Split(' ')[1].Split(':');

            string day   = date[0];
            string month = date[1];
            string year  = date[2];
            string hour  = time[0];
            string min   = time[1];

            string   currentStringFormat = $"{year}-{month}-{day}|{hour}:{min}";
            DateTime currentTime         = PlanDS.getTimeFromStringFormat(currentStringFormat);
            DateTime now = DateTime.Now;

            now.AddSeconds(-now.Second);
            now.AddMilliseconds(-now.Millisecond);

            if (now > currentTime)
            {
                MessageBox.Show($"Неверная дата. Введите дату, не ранее {DateTime.Now.ToString()}");
                return;
            }

            PlanDS plan       = new PlanDS(this.scanPath, currentTime);
            bool   successAdd = client.addPlan(plan);

            if (!successAdd)
            {
                MessageBox.Show("Аналогичный план уже имеется в списке");
            }
            client.Close();
        }