Exemplo n.º 1
0
        private void SurroundDescriptionTextWith(string leftChars, string rightChars, string tempText)
        {
            string part1;
            string part2;
            string part3;

            if (DescriptionTextBox.SelectionLength > 0)
            {
                var startIndex   = DescriptionTextBox.SelectionStart;
                var stringLength = DescriptionTextBox.SelectionLength;

                part1 = DescriptionTextBox.Text.Substring(0, startIndex);
                part2 = DescriptionTextBox.Text.Substring(startIndex, stringLength);
                part3 = DescriptionTextBox.Text.Substring(startIndex + stringLength);

                DescriptionTextBox.Text            = part1 + leftChars + part2 + rightChars + part3;
                DescriptionTextBox.SelectionStart  = startIndex + leftChars.Length;
                DescriptionTextBox.SelectionLength = stringLength;
            }
            else
            {
                var startIndex = DescriptionTextBox.CaretIndex;

                part1 = DescriptionTextBox.Text.Substring(0, startIndex);
                part2 = leftChars + tempText + rightChars;
                part3 = DescriptionTextBox.Text.Substring(startIndex);

                DescriptionTextBox.Text            = part1 + part2 + part3;
                DescriptionTextBox.SelectionStart  = startIndex + leftChars.Length;
                DescriptionTextBox.SelectionLength = tempText.Length;
            }
            DescriptionTextBox.Focus();
        }
Exemplo n.º 2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DescriptionTextBox.Focus();
            DescriptionTextBox.SelectAll();

            UpdateACFChart();
        }
Exemplo n.º 3
0
        private void OnAddTableClicked(object sender, RoutedEventArgs e)
        {
            var tableSizeVm = new TableMarkdownSizeViewModel("Enter table size:", "Enter table size");
            var view        = ViewFactory.CreateViewWithDataContext <TableMarkdownSizeView>(tableSizeVm);

            view.ShowDialog();

            if (tableSizeVm.UserCancelled)
            {
                return;
            }

            var tableVm = new TableMarkdownViewModel(tableSizeVm.NumCols, tableSizeVm.NumRows);

            view = ViewFactory.CreateViewWithDataContext <TableMarkdownView>(tableVm);
            view.ShowDialog();

            if (!tableVm.UserCancelled)
            {
                var startIndex = DescriptionTextBox.CaretIndex;

                var part1 = DescriptionTextBox.Text.Substring(0, startIndex);
                var part2 = $"\n{tableVm.SelectedValue}\n";
                var part3 = DescriptionTextBox.Text.Substring(startIndex);

                DescriptionTextBox.Text = part1 + part2 + part3;
                DescriptionTextBox.Focus();
            }
        }
Exemplo n.º 4
0
        private void OnCodeClicked(object sender, RoutedEventArgs e)
        {
            var textwrap = DescriptionTextBox.TextWrapping;

            if (textwrap == TextWrapping.Wrap)
            {
                DescriptionTextBox.TextWrapping = TextWrapping.NoWrap;
            }

            var startLineIndex = DescriptionTextBox.GetLineIndexFromCharacterIndex(DescriptionTextBox.SelectionStart);
            var endLineIndex   = DescriptionTextBox.GetLineIndexFromCharacterIndex(DescriptionTextBox.SelectionStart +
                                                                                   DescriptionTextBox.SelectionLength);

            if (startLineIndex != endLineIndex)
            {
                var collection = ColorCode.Languages.All.Select(l => l.Name).OrderBy(n => n).ToList();
                collection.Insert(0, "None");
                var vm = InputViewFactory.ShowComboBoxInput("Please choose a code language:", "Code Language", collection);

                var language = String.Empty;
                if (vm.UserCancelled)
                {
                    DescriptionTextBox.TextWrapping = textwrap;
                    return;
                }

                if (vm.SelectedValue != "None")
                {
                    language = vm.SelectedValue;
                }

                for (var index = startLineIndex; index <= endLineIndex; index++)
                {
                    var lineStartIndex = DescriptionTextBox.GetCharacterIndexFromLineIndex(index);
                    DescriptionTextBox.Text = DescriptionTextBox.Text.Insert(lineStartIndex, "    ");
                }

                if (language != String.Empty)
                {
                    DescriptionTextBox.Text =
                        DescriptionTextBox.Text.Insert(
                            DescriptionTextBox.GetCharacterIndexFromLineIndex(startLineIndex),
                            "    " + OmniTextRenderer.LangDefinitionText + language + Environment.NewLine);
                    endLineIndex++;
                }
                DescriptionTextBox.SelectionStart = DescriptionTextBox.GetCharacterIndexFromLineIndex(startLineIndex);
                var endOfLastLineIndex = DescriptionTextBox.GetCharacterIndexFromLineIndex(endLineIndex) +
                                         DescriptionTextBox.GetLineText(endLineIndex).Length;
                DescriptionTextBox.SelectionLength = endOfLastLineIndex - DescriptionTextBox.SelectionStart;

                DescriptionTextBox.Focus();
            }
            else
            {
                SurroundDescriptionTextWith("`", "code text");
            }

            DescriptionTextBox.TextWrapping = textwrap;
        }
Exemplo n.º 5
0
 private bool verifier()
 {
     if (DescriptionTextBox.Text.Trim() == string.Empty)
     {
         MessageBox.Show("Description de la fonction est Obligatoire", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
         DescriptionTextBox.Focus();
     }
     return(true);
 }
Exemplo n.º 6
0
        private bool DescriptionIsFilled()
        {
            bool filled = !string.IsNullOrEmpty(DescriptionTextBox.Text);

            if (!filled)
            {
                MessageBox.Show("Description cannot be empty");
                DescriptionTextBox.Focus();
            }
            return(filled);
        }
        private bool ValidateForm()
        {
            if (!Regex.Match(DescriptionTextBox.Text, @"^\D{1,150}$").Success)
            {
                MessageBox.Show("Description must consist of at least 6 character and not exceed 150 characters!");
                DescriptionTextBox.Focus();
                return(false);
            }

            return(true);
        }
        private bool ValidateForm()
        {
            if (!Regex.Match(TitleTextBox.Text, @"^\D{1,20}$").Success)
            {
                MessageBox.Show("Title must consist of at least 1 character and not exceed 20 characters!");
                TitleTextBox.Focus();
                return(false);
            }

            if (!Regex.Match(DescriptionTextBox.Text, @"^\D{1,200}$").Success)
            {
                MessageBox.Show("Description must consist of at least 1 character and not exceed 200 characters!");
                DescriptionTextBox.Focus();
                return(false);
            }

            if (CategoryComboBox.SelectedItem == null)
            {
                MessageBox.Show("Please select category");
                return(false);
            }

            if (ProducerComboBox.SelectedItem == null)
            {
                MessageBox.Show("Please select categoty");
                return(false);
            }

            if (!Regex.Match(WeightTextBox.Text, @"^[0-9]*(?:\,[0-9]*)?$").Success)
            {
                MessageBox.Show("Invalid weight! Check the data you've entered!");
                WeightTextBox.Focus();
                return(false);
            }

            if (!Regex.Match(ComponentsTextBox.Text, @"^\D{1,200}$").Success)
            {
                MessageBox.Show("Components must consist of at least 1 character and not exceed 200 characters!");
                ComponentsTextBox.Focus();
                return(false);
            }

            if (!Regex.Match(PriceTextBox.Text, @"^[0-9]*(?:\,[0-9]*)?$").Success)
            {
                MessageBox.Show("Invalid price! Check the data you've entered!");
                PriceTextBox.Focus();
                return(false);
            }

            return(true);
        }
Exemplo n.º 9
0
 /// <summary>
 /// ProjTextBoxのKeyDownイベント
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ProjTextBox_KeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.KeyCode == Keys.Enter)
         {
             DescriptionTextBox.Focus();
         }
     }
     catch (Exception ex)
     {
         throw Program.ThrowException(ex);
     }
 }
Exemplo n.º 10
0
        private void ApplicationBarIconButton_Save_Click(object sender, EventArgs e)
        {
            string term        = TermTextBox.Text.Trim();
            string description = DescriptionTextBox.Text.Trim();

            if (term.Length == 0)
            {
                TermTextBox.Focus();
                //ToastPromptHelper.ShowToastPrompt("Term shouldn't be empty.", 3000);
                MessageBox.Show("Term shouldn't be empty.");
                return;
            }

            if (description.Length == 0)
            {
                DescriptionTextBox.Focus();
                //ToastPromptHelper.ShowToastPrompt("Description shouldn't be empty.", 3000);
                MessageBox.Show("Description shouldn't be empty.");
                return;
            }

            if (detailAction == DetailAction.Add)
            {
                if (app.Glossary.CheckNewTermName(term))
                {
                    TermTextBox.SelectAll();
                    TermTextBox.Focus();
                    MessageBox.Show("Term name exists. Please input another term. Please notice Term name is case insensitive.");
                    return;
                }
                app.Glossary.Add(term, description);
                NavigationService.GoBack();
            }
            else if (detailAction == DetailAction.Edit)
            {
                editingTermItem.Term        = term;
                editingTermItem.Description = description;
                if (app.Glossary.CheckEditTermName(editingTermItem))
                {
                    TermTextBox.SelectAll();
                    TermTextBox.Focus();
                    MessageBox.Show("Term name exists. Please input another term. Please notice Term name is case insensitive.");
                    return;
                }
                app.Glossary.Edit(editingTermItem);
                NavigationService.GoBack();
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Event handler for when a problem radio button has been checked and the problem does require a description.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RadioButton_Click_TextboxFocus(object sender, RoutedEventArgs e)
        {
            //Set the problem to the text of the radio buttton
            if (Cougtech_CustomerLogger.Problem_SelectionChanged(((RadioButton)sender).Content.ToString()))
            {
                //If successfull
                SubmitButton.IsEnabled = false;                     //Disable the "Next" button

                DescriptionTextBox.Visibility = Visibility.Visible; //Make the red asterisk visible
                requiredLabel.Visibility      = Visibility.Visible; //Make the textbox visible

                DescriptionTextBox.Focus();                         //Focus on the textbox
                DescriptionTextBox.SelectAll();                     //Select the text within the textbox
            }
            else
            {
                MessageBox.Show("The ticketing system has not been initialized correctly./nPlease re-enter your student ID", "System Error");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (EmailTextBox.Text == String.Empty || EmailTextBox.Text.IndexOf("@") == -1 || EmailTextBox.Text.IndexOf(".") == -1)
            {
                MessageBox.Show("Please enter an email.");
                EmailTextBox.Focus();
                return;
            }
            if (DescriptionTextBox.Text == String.Empty || DescriptionTextBox.Text == descriptionText)
            {
                MessageBox.Show("Please enter a description.");
                DescriptionTextBox.Focus();
                return;
            }
            WebClient myClient = new WebClient();

            myClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            try
            {
                string subject          = "[SharePoint Outlook Connector] An error occured on Method:" + methodName;
                string email            = EmailTextBox.Text;
                string exceptionMessage = "Email:" + email + Environment.NewLine + "Description:" + DescriptionTextBox.Text + Environment.NewLine + GetSystemInformation() + Environment.NewLine + GetExceptionMessage(methodName, exception);

                NameValueCollection keyvaluepairs = new NameValueCollection();
                keyvaluepairs.Add("Subject", subject);
                keyvaluepairs.Add("Body", exceptionMessage);
                byte[] responseArray = myClient.UploadValues("http://www.sobiens.com/SendEmail.aspx", "POST", keyvaluepairs);
                string response      = Encoding.ASCII.GetString(responseArray);
                if (response == "Completed")
                {
                    MessageBox.Show("Your message has been sent completely.");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("An error occured while sending the message.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occcured while sending email. Error:" + ex.Message);
            }
        }
Exemplo n.º 13
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(UserTextBox.Text))
            {
                UserTextBox.Focus();
                UserTextBox.BackColor = Color.LightPink;
                return;
            }

            if (string.IsNullOrWhiteSpace(TitleTextBox.Text))
            {
                TitleTextBox.Focus();
                TitleTextBox.BackColor = Color.LightPink;
                return;
            }

            if (string.IsNullOrWhiteSpace(DescriptionTextBox.Text))
            {
                DescriptionTextBox.Focus();
                DescriptionTextBox.BackColor = Color.LightPink;
                return;
            }

            ReportData rd = new ReportData
            {
                Id          = ErrorIdTextBox.Text,
                User        = UserTextBox.Text,
                DateTime    = RegistrationDatePicker.Value,
                Title       = TitleTextBox.Text,
                Description = DescriptionTextBox.Text,
                Urgent      = UrgentCheckBox.Checked,
                Type        = BugRadioButton.Checked ? ReportType.BUG :
                              DocumentationIssueRadioButton.Checked ? ReportType.DOCUMENTATION :
                              PerformanceIssueRadioButton.Checked ? ReportType.PERFORMANCE : ReportType.NOTICE
            };

            Clear();

            DescriptionTextBox.Text = System.Text.Json.JsonSerializer.Serialize <ReportData>(rd);
        }
Exemplo n.º 14
0
        private void ConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            string name        = NameTextBox.Text;
            string description = DescriptionTextBox.Text;

            if (string.IsNullOrWhiteSpace(name))
            {
                NameTextBox.Focus();
                return;
            }
            if (string.IsNullOrWhiteSpace(description))
            {
                DescriptionTextBox.Focus();
                return;
            }
            if (!_edit)
            {
                Goal goal = new Goal
                {
                    Name      = name,
                    Text      = description,
                    Important = _importance,
                    Urgent    = _urgency,
                    Completed = false
                };
                _storage.AddGoal(_user, goal);
                _user.Goals.Add(goal);
                DialogResult = true;
            }
            else
            {
                _goal.Name      = name;
                _goal.Text      = description;
                _goal.Important = _importance;
                _goal.Urgent    = _urgency;
                _storage.EditGoal(_goal);
                DialogResult = true;
            }
        }
Exemplo n.º 15
0
        async Task <T> PopulateShowAndWaitAsync <T>(Secret secret, ClearAndPopulate clearAndPopulate, UpdateModelFromUiIfSaved <T> updateModelFromUiIfSaved)
        {
            var fields  = new Dictionary <string, string>();
            var secrets = new Dictionary <string, string>();

            clearAndPopulate(secret, fields, secrets);

            Visibility = Visibility.Visible;

            DescriptionTextBox.Focus();

            var completionSource = new TaskCompletionSource <bool>();

            FieldsListView.ItemsSource  = fields;
            SecretsListView.ItemsSource = secrets;

            var saveOnExit = await AddEvemtsAndWaitForUser(secrets, fields, completionSource);

            Visibility = Visibility.Collapsed;

            return(updateModelFromUiIfSaved(secret, saveOnExit, fields, secrets));
        }
 private void OnTextBoxKeyUp(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
 {
     if (e.Key != VirtualKey.Enter || !e.KeyStatus.WasKeyDown)
     {
         return;
     }
     if (sender == StreetNameTextBox)
     {
         DescriptionTextBox.Focus(Windows.UI.Xaml.FocusState.Keyboard);
     }
     else if (sender == RoomsTextBox)
     {
         LivingAreaTextBox.Focus(Windows.UI.Xaml.FocusState.Keyboard);
     }
     else if (sender == LivingAreaTextBox)
     {
         LotSizeTextBox.Focus(Windows.UI.Xaml.FocusState.Keyboard);
     }
     else if (sender == LotSizeTextBox)
     {
         OperatingCostsTextBox.Focus(Windows.UI.Xaml.FocusState.Keyboard);
     }
 }
Exemplo n.º 17
0
 // event. Click sur le boutton 'AjouterBtn'
 private void AjouterBtn_Click(object sender, EventArgs e)
 {
     try
     {
         // si la description est vide
         if (DescriptionTextBox.Text.Length == 0)
         {
             MessageBox.Show(ClassGlobal.resManager.GetString("MessageBox_Description_Obligatoire", ClassGlobal.cul), ClassGlobal.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, ClassGlobal.msgBoxOptions);
             DescriptionTextBox.Focus();
         }
         // si nn si travail en double
         else if (checkDoubleTravailDescription(DescriptionTextBox.Text))
         {
             MessageBox.Show(ClassGlobal.resManager.GetString("MessageBox_Description_Double", ClassGlobal.cul), ClassGlobal.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, ClassGlobal.msgBoxOptions);
             DescriptionTextBox.SelectAll(); // on séléctionne la description au cas l'utilisateur veut bien la supprimer
             DescriptionTextBox.Focus();
         }
         else // si nn, c'est bon
         {
             // ajout du travail
             ClassGlobal.ds.Tables["Travail"].Rows.Add(null, DescriptionTextBox.Text);
             ClassGlobal.appliquerChangement(ClassGlobal.daTravail, "Travail");
             if (showConfirmationMsg)
             {
                 MessageBox.Show(ClassGlobal.resManager.GetString("MessageBox_Travail_Ajouté", ClassGlobal.cul), ClassGlobal.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, ClassGlobal.msgBoxOptions);
             }
             // mise à jour de la dataTable Travail (pour avoir les bon ids)
             ClassGlobal.getTravail();
             // fermeture de la fenêtre
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, ClassGlobal.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, ClassGlobal.msgBoxOptions);
     }
 }
        private void ThreadSafeDisplayDefect(string caseId, string projectName, string areaName)
        {
            if (InvokeRequired)
            {
                ThreadSafeDisplayDefectInvoker invoker = ThreadSafeDisplayDefect;
                Invoke(invoker, new object[] { caseId, projectName, areaName });
            }
            else
            {
                try
                {
                    //now add these items to the project selection area.
                    ProjectSelection.Items.Clear();
                    ProjectSelection.DataSource = new List <string>(m_ProjectsAndAreas.Keys); //data source requires a list

                    int           lastMessageIndex = m_LogMessages.Count - 1;
                    StringBuilder builder          = new StringBuilder();

                    // Use compact formatting of all but the last message
                    for (int i = 0; i < lastMessageIndex; i++)
                    {
                        LogMessageFormatter preludeFormatter = new LogMessageFormatter(m_LogMessages[i]);
                        builder.Append(preludeFormatter.GetLogMessageSummary());
                    }

                    // Skip a line between last "prelude" message and the primary message
                    if (lastMessageIndex > 0)
                    {
                        builder.AppendLine();
                    }

                    // The primary message is the last of the selected messages
                    LogMessageFormatter formatter = new LogMessageFormatter(m_PrimaryMessage);
                    builder.Append(formatter.GetLogMessageDetails());

                    // Add session details after the primary message
                    builder.AppendLine();
                    builder.AppendFormat("Session Details:\r\n");
                    LogMessageFormatter.AppendDivider(builder);
                    builder.Append(formatter.GetSessionDetails());

                    // This will be applied later, after user editing is done
                    m_SessionIdMessage = formatter.GetSessionIdMessage();

                    // Check the fingerprint of the primary message to determine if
                    // a case for this error already exists in FogBugz
                    if (string.IsNullOrEmpty(caseId))
                    {
                        // If there is no existing case, check if this session has an
                        // affinity for a particular project (i.e. is there a
                        // MappingTarget associated with this MappingSource in the config?)
                        // If so, default the project selection accordingly.
                        Mapping target = m_Controller.FindTarget(m_PrimaryMessage.Session);
                        m_Context.Log.Verbose(LogCategory, "No existing case found, user will be able to select project", "The current mapping information for the message is:\r\n{0}", (target == null) ? "(No mapping found)" : target.Project);
                        ProjectSelection.SelectedItem = target == null ? null : target.Project;
                        ProjectSelection.Enabled      = true;
                        AreaSelection.Enabled         = true;
                        CaseLabel.Tag  = null;
                        CaseLabel.Text = "(New Case)";
                        Text           = "Create New Case";
                    }
                    else
                    {
                        // If a case already exists, get info about it from FogBugz
                        ProjectSelection.SelectedItem = projectName;
                        ProjectSelection.Enabled      = false;

                        AreaSelection.SelectedItem = areaName;
                        AreaSelection.Enabled      = false;
                        m_Context.Log.Verbose(LogCategory, "Existing case fond, user will not be able to change project / area", "The current case is in:\r\n {0} {1}", projectName, areaName);

                        CaseLabel.Tag  = caseId;
                        CaseLabel.Text = caseId;
                        Text           = "Edit Case " + caseId;
                    }

                    TitleTextBox.Text            = formatter.GetTitle();
                    TitleTextBox.SelectionStart  = 0;
                    TitleTextBox.SelectionLength = 0;
                    TitleTextBox.Enabled         = true;

                    DescriptionTextBox.Text            = builder.ToString();
                    DescriptionTextBox.SelectionStart  = 0;
                    DescriptionTextBox.SelectionLength = 0;
                    DescriptionTextBox.Enabled         = true;

                    DescriptionTextBox.Select();
                    DescriptionTextBox.Focus(); //this is what they should edit.

                    ValidateData();
                }
                finally
                {
                    //one way or the other, we're done so the user shouldn't be given the impression we're waiting around.
                    UseWaitCursor = false;
                }
            }
        }
        private async void ClockOutWindow_ContentRendered(object sender, EventArgs e)
        {
            try
            {
                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                this.IsEnabled       = false;

                var api = new Clockify(_client);

                _user = await api.GetGeneric <User>(_opts.APIKey, "user");

                if (_user == null)
                {
                    throw new ApplicationException("Failed to get the user for an unknown reason.");
                }
                UsernameTextBox.Text = _user.Email;

                _workspaces = await api.GetGeneric <List <Workspace> >(_opts.APIKey, "workspaces");

                if (_workspaces == null)
                {
                    throw new ApplicationException("Failed to get the workspaces for an unknown reason");
                }

                var workspace = _workspaces.FirstOrDefault(x => x.Id == _opts.Workspace);
                if (workspace == null)
                {
                    throw new ApplicationException("You do not have access to a workspace with that ID");
                }
                WorkspaceTextBox.Text = workspace.Name;

                var timeEntries = await api.GetGeneric <List <TimeEntry> >(_opts.APIKey, "workspaces/" + _opts.Workspace + "/user/" + _user.Id + "/time-entries?in-progress=true");

                if (timeEntries == null)
                {
                    throw new ApplicationException("Failed to get the time entries for an unknown reason");
                }
                if (timeEntries.Count == 0)
                {
                    throw new ApplicationException("You are not clocked in right now!");
                }
                else if (timeEntries.Count > 1)
                {
                    throw new ApplicationException("You are clocked in multiple times right now in the same workspace. I don\'t know how to handle that!");
                }
                _timeEntry = timeEntries.First();
                ClockStartedTextBox.Text = _timeEntry.TimeInterval.Start;

                _projects = await api.GetGeneric <List <Project> >(_opts.APIKey, "workspaces/" + _opts.Workspace + "/projects?archived=false");

                if (_projects == null)
                {
                    throw new ApplicationException("Failed to get the projects for an unknown reason");
                }
                _filteredProjects = new List <KeyValuePair <string, Project> >();
                foreach (var p in _projects)
                {
                    _filteredProjects.Add(new KeyValuePair <string, Project>(p.Name + " - " + p.ClientName, p));
                }
                _filteredProjects = _filteredProjects.OrderBy(x => x.Value.ClientName).ThenBy(x => x.Value.Name).ToList();
                ProjectResultsListBox.ItemsSource       = _filteredProjects;
                ProjectResultsListBox.DisplayMemberPath = "Key";
                ProjectResultsListBox.Items.Refresh();

                _tags = await api.GetGeneric <List <Tag> >(_opts.APIKey, "workspaces/" + _opts.Workspace + "/tags?archived=false");

                if (_tags == null)
                {
                    throw new ApplicationException("Failed to get the tags for any unknown reason");
                }
                _tags = _tags.OrderBy(x => x.Name).ToList();
                TagComboBox.ItemsSource       = _tags;
                TagComboBox.DisplayMemberPath = "Name";
                TagComboBox.Items.Refresh();
            }
            catch (Exception ex)
            {
                Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow;
                MessageBox.Show("ERROR: " + ex.Message);
                this.Close();
            }
            finally
            {
                Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow;
                this.IsEnabled       = true;
                DescriptionTextBox.Focus();
            }
        }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     DescriptionTextBox.Focus();
 }
Exemplo n.º 21
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            if (venta == null)
            {
                MessageBox.Show("Debe asignar un cliente");
                ClienteTextBox.Focus();
                return;
            }
            if (IdTextBox.Text == string.Empty)
            {
                MessageBox.Show("Debe ingresar un ID");
                IdTextBox.Focus();
                return;
            }

            int id = 0;

            if (!int.TryParse(IdTextBox.Text, out id))
            {
                MessageBox.Show("Debe ingresar un ID numerico entero");
                IdTextBox.Focus();
                return;
            }
            if (id <= 0)
            {
                MessageBox.Show("Debe ingresar un ID mayor a cero");
                IdTextBox.Focus();
                return;
            }

            if (DescriptionTextBox.Text == string.Empty)
            {
                MessageBox.Show("Debe ingresar una Descripcion");
                DescriptionTextBox.Focus();
                return;
            }
            decimal price = 0;

            if (!decimal.TryParse(PriceTextBox.Text, out price))
            {
                MessageBox.Show("Debe ingresar un Precio numerico entero");
                PriceTextBox.Focus();
                return;
            }
            if (price <= 0)
            {
                MessageBox.Show("Debe ingresar un Precio mayor a cero");
                PriceTextBox.Focus();
                return;
            }
            int amount = 0;

            if (!int.TryParse(AmountTextBox.Text, out amount))
            {
                MessageBox.Show("Debe ingresar una Cantidad numerico entero");
                AmountTextBox.Focus();
                return;
            }
            if (amount <= 0)
            {
                MessageBox.Show("Debe ingresar una Cantidad mayor a cero");
                AmountTextBox.Focus();
                return;
            }
            Article article = new Article();

            article.ID          = id;
            article.Description = DescriptionTextBox.Text;
            article.Price       = price;
            article.Amount      = amount;

            venta.AddProduct(article);
            DetailsDataGridView.DataSource = null;
            DetailsDataGridView.DataSource = venta.Products;

            IdTextBox.Text          = string.Empty;
            DescriptionTextBox.Text = string.Empty;
            PriceTextBox.Text       = string.Empty;
            AmountTextBox.Text      = string.Empty;
            IdTextBox.Focus();
        }