public CollarDeploymentDetailsForm(CollarDeployment collarDeployment, bool lockCollar = false, bool lockAnimal = false)
 {
     InitializeComponent();
     CollarDeployment = collarDeployment;
     //TODO - remove locks when (if) CollarDeployments allows updates to collars or animals
     // ReSharper disable ConditionIsAlwaysTrueOrFalse
     LockCollar = lockCollar || true;
     LockAnimal = lockAnimal || true;
     // ReSharper restore ConditionIsAlwaysTrueOrFalse
     CurrentUser = Environment.UserDomainName + @"\" + Environment.UserName;
     LoadDataContext();
     LoadDefaultFormContents();  //Called before events are triggered
 }
 public CollarDeploymentDetailsForm(CollarDeployment collarDeployment, bool lockCollar = false, bool lockAnimal = false)
 {
     InitializeComponent();
     CollarDeployment = collarDeployment;
     //TODO - remove locks when (if) CollarDeployments allows updates to collars or animals
     // ReSharper disable ConditionIsAlwaysTrueOrFalse
     LockCollar = lockCollar || true;
     LockAnimal = lockAnimal || true;
     // ReSharper restore ConditionIsAlwaysTrueOrFalse
     CurrentUser = Environment.UserDomainName + @"\" + Environment.UserName;
     LoadDataContext();
     LoadDefaultFormContents();  //Called before events are triggered
 }
        private bool AddDeployment()
        {
            var deployment = new CollarDeployment
            {
                Collar         = CollarComboBox.SelectedItem as Collar,
                Animal         = AnimalComboBox.SelectedItem as Animal,
                DeploymentDate = StartDateTimePicker.Value.ToUniversalTime(),
                RetrievalDate  = EndDateTimePicker.Checked ? EndDateTimePicker.Value.ToUniversalTime() : (DateTime?)null
            };

            Database.CollarDeployments.InsertOnSubmit(deployment);
            if (SubmitChanges())
            {
                return(true);
            }
            // The collar now thinks it has a deployment, deleteOnSubmit does not clear it, reloading the context will reset the form
            LoadDataContext();
            return(false);
        }
 private bool AddDeployment()
 {
     var deployment = new CollarDeployment
     {
         Collar = CollarComboBox.SelectedItem as Collar,
         Animal = AnimalComboBox.SelectedItem as Animal,
         DeploymentDate = StartDateTimePicker.Value.ToUniversalTime(),
         RetrievalDate = EndDateTimePicker.Checked ? EndDateTimePicker.Value.ToUniversalTime() : (DateTime?)null
     };
     Database.CollarDeployments.InsertOnSubmit(deployment);
     if (SubmitChanges())
         return true;
     // The collar now thinks it has a deployment, deleteOnSubmit does not clear it, reloading the context will reset the form
     LoadDataContext();
     return false;
 }