Example #1
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (dataGridView.SelectedRows.Count != 1)
     {
         return;
     }
     using (AddEditSchedule f = new AddEditSchedule(this.AllowedScheduleTypes, this.Schedules.Where(t => t.ID == (dataGridView.SelectedRows[0].DataBoundItem as Schedule).ID).Single()))
     {
         if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             try
             {
                 Schedule originalSchedule = this.Schedules.Where(t => t.ID == (dataGridView.SelectedRows[0].DataBoundItem as Schedule).ID).Single();
                 Schedule newSchedule      = f.Tag as Schedule;
                 try
                 {
                     RemoveSystemSchedule(originalSchedule);
                 }
                 catch
                 {
                 }
                 Copy(originalSchedule, newSchedule);
                 SetSystemSchedule(originalSchedule);
             }
             catch (Exception ex)
             {
                 PersianMessageBox.Show(this, "خطا در ثبت برنامه زمانی" + "\r\n" + ex.Message);
             }
         }
     }
 }
Example #2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     using (AddEditSchedule f = new AddEditSchedule(this.AllowedScheduleTypes))
     {
         if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             try
             {
                 Schedule schedule = f.Tag as Schedule;
                 SetSystemSchedule(schedule);
                 scheduleBindingSource.Add(schedule);
             }
             catch (Exception ex)
             {
                 PersianMessageBox.Show(this, "خطا در ثبت برنامه زمانی" + "\r\n" + ex.Message);
             }
         }
     }
 }