private void buttonClear_Click(object sender, EventArgs e) { ProjectIdTextBox.Clear(); ProjectNameTextBox.Clear(); ProjectDescriptionTextBox.Clear(); NewClientTb.Clear(); PayPerHourTextBox.Clear(); ProjectStartDateDatePicker.Value = DateTime.Now; ProjectEndDatePicker.Value = DateTime.Now; }
internal void RefreshTabProject() { var customersOnProject = new List <CustomerInProject>(); var ProjectStatus = new List <string>(); int rowIndex = 0; customerIDList.Clear(); ProjectDataGridView.Rows.Clear(); foreach (Project.ProjestStatus status in Enum.GetValues(typeof(Project.ProjestStatus))) { ProjectStatus.Add(status.ToString()); } for (int i = 0; i < manager.Customers.Count; i++) { var customerProject = new CustomerInProject(manager.Customers[i].Name.ToString() + " " + manager.Customers[i].Surname.ToString(), manager.Customers[i].CustomerID); customersOnProject.Add(customerProject); } ProjectCustomerComboBox.DataSource = customersOnProject; ProjectCustomerComboBox.DisplayMember = "CustomerName"; ProjectCustomerComboBox.ValueMember = "CustomerID"; StatusComboBox.DataSource = ProjectStatus; for (int i = 0; i < manager.Projects.Count; i++) { ProjectDataGridView.Rows.Add(); ProjectDataGridView[ProjectIDColumn.Index, rowIndex].Value = manager.Projects[i].ProjectID.ToString(); ProjectDataGridView[ProjectNameColumn.Index, rowIndex].Value = manager.Projects[i].Name.ToString(); ProjectDataGridView[ProjectDataColumn.Index, rowIndex].Value = manager.Projects[i].DateAgreement.ToString(DateFomat).ToString(); ProjectDataGridView[ProjectCostColumn.Index, rowIndex].Value = manager.Projects[i].Cost.ToString(); ProjectStatusColumn.DataSource = ProjectStatus; ProjectDataGridView[ProjectStatusColumn.Index, rowIndex].Value = manager.Projects[i].Status.ToString(); ProjectCustomerColumn.DataSource = customersOnProject; ProjectCustomerColumn.DisplayMember = "CustomerName"; ProjectCustomerColumn.ValueMember = "CustomerID"; ProjectDataGridView[ProjectCustomerColumn.Index, rowIndex].Value = manager.Projects[i].CustomerID; ProjectDataGridView[EmployeeCountColumn.Index, rowIndex].Value = manager.Projects[i].EmployeesID.Count.ToString(); rowIndex++; } ProjectDateTimePicker.Value = DateTime.Now; ProjectNameTextBox.Clear(); ProjectCostTextBox.Clear(); ProjectCustomerComboBox.Text = ""; ProjectCustomerComboBox.SelectedText = "Choise..."; StatusComboBox.Text = ""; StatusComboBox.SelectedText = "Choise..."; }
private void SaveUser_Click(object sender, RoutedEventArgs e) { if (!update) { ProjectDescriptionTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource(); ProjectNameTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource(); clientsNameComboBox.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource(); projectStatusComboBox.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource(); if (Validation.GetHasError(ProjectNameTextBox) == true || ProjectNameTextBox.Text == String.Empty || clientsNameComboBox.SelectedItem == null) { MessageBox.Show("Есть не верно заполненные поля, запись не сохранится"); this.Close(); return; } else { context.projects.Local.Add(project); } } context.SaveChanges(); saveTrigger = true; this.Close(); }
private void Save(string action) { HttpClient client = new HttpClient(); client.Timeout = TimeSpan.FromMinutes(15); string URL = ""; string bodyString = ""; string projectJS = ""; string returnMessage = ""; Project project = new Project(); ResultProjects resultProjects = new ResultProjects(); project.CustomerID = Data.GlovalVariables.currentCustomerID; project.ProjectName = ProjectNameTextBox.Text; switch (Data.GlovalVariables.transactionType) { case "New": projectJS = JsonConvert.SerializeObject(project, Newtonsoft.Json.Formatting.Indented); URL = BaseURL + "Projects/NewProject"; bodyString = "'" + projectJS + "'"; HttpContent body_for_new = new StringContent(bodyString); body_for_new.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response_for_new = client.PostAsync(URL, body_for_new).Result; using (HttpContent content = response_for_new.Content) { Task <string> resultTemp = content.ReadAsStringAsync(); returnMessage = resultTemp.Result; // Reformating the result string //returnMessage = returnMessage.Replace(@"\n", "\n").Replace(@"\r", "\r").Replace("\\", ""); //returnMessage = returnMessage.Remove(returnMessage.Length - 1, 1).Substring(1); resultProjects = JsonConvert.DeserializeObject <ResultProjects>(returnMessage); } if (response_for_new.IsSuccessStatusCode) { // Set the value of the new project to a gloval variable if (resultProjects.ReturnCode == -1) { MessageBox.Show("Warning:" + "\r\n" + resultProjects.Message.Replace(". ", "\r\n"), "New Project Transaction ...", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Data.GlovalVariables.newProjectsList.Add(ProjectNameTextBox.Text); if (action == "SaveAndExit") { this.Close(); } else { ProjectNameTextBox.Text = ""; ProjectNameTextBox.Focus(); } } } else { MessageBox.Show("Error:" + "\r\n" + resultProjects.Message.Replace(". ", "\r\n") + resultProjects.Exception, "New Project Transaction ...", MessageBoxButtons.OK, MessageBoxIcon.Error); } break; case "Update": project.ProjectID = Data.GlovalVariables.currentProjectID; projectJS = JsonConvert.SerializeObject(project, Newtonsoft.Json.Formatting.Indented); URL = BaseURL + "Projects/UpdateProject"; bodyString = "'" + projectJS + "'"; HttpContent body_for_update = new StringContent(bodyString); body_for_update.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response_for_update = client.PostAsync(URL, body_for_update).Result; using (HttpContent content = response_for_update.Content) { Task <string> resultTemp = content.ReadAsStringAsync(); returnMessage = resultTemp.Result; // Reformating the result string returnMessage = returnMessage.Replace(@"\n", "\n").Replace(@"\r", "\r").Replace("\\", ""); returnMessage = returnMessage.Remove(returnMessage.Length - 1, 1).Substring(1); resultProjects = JsonConvert.DeserializeObject <ResultProjects>(returnMessage); } if (response_for_update.IsSuccessStatusCode) { // Set the value of the new project to a gloval variable if (resultProjects.ReturnCode == -1) { MessageBox.Show("Warning:" + "\r\n" + resultProjects.Message.Replace(". ", "\r\n"), "Update Projects Transaction ...", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Data.GlovalVariables.currentProjectName = ProjectNameTextBox.Text; if (action == "SaveAndExit") { this.Close(); } else { CustomerNameTextBox.Focus(); } } } else { MessageBox.Show("Error:" + "\r\n" + resultProjects.Message.Replace(". ", "\r\n"), "Update Project Transaction ...", MessageBoxButtons.OK, MessageBoxIcon.Error); } break; } }
private void OnWindowLoaded(object sender, RoutedEventArgs e) { ProjectNameTextBox.Focus(); ProjectNameTextBox.SelectAll(); }
private void buttonCreate_Click(object sender, EventArgs e) { if (!IsValidInput(ProjectIdTextBox) || !IsValidInput(PayPerHourTextBox) || !IsNotNull(ProjectNameTextBox) || !IsNotNull(ProjectDescriptionTextBox) || !IsValidSelection(ProjectClientComboBox) ) { // MessageBox.Show("Грешка"); return; } if (ProjectStartDateDatePicker.Value.Date < DateTime.Now.Date || ProjectEndDatePicker.Value.Date < DateTime.Now.Date || ProjectEndDatePicker.Value < ProjectStartDateDatePicker.Value) { MessageBox.Show("Невалидна дата!"); return; } if (RegisterNewClientBtn.Text == "Запази клиент") { MessageBox.Show("Моля запазете регистрирането на клиент!"); return; } var projectId = decimal.Parse(ProjectIdTextBox.Text); if (context.PROJECTS.Any(o => o.PROJECT_ID == projectId)) { MessageBox.Show("Вече съществува проект с този код!"); return; } if (context.PROJECTS.Any(o => o.PROJECT_NAME == ProjectNameTextBox.Text)) { MessageBox.Show("Вече съществува проект с това име!"); return; } var project = new PROJECT(); project.PROJECT_ID = projectId; project.PROJECT_NAME = ProjectNameTextBox.Text; project.PROJECT_DESCRIPTION = ProjectDescriptionTextBox.Text; project.CLIENT_ID = decimal.Parse(ProjectClientComboBox.SelectedValue.ToString()); //TODO: FIX project.PROJECT_BEGIN = ProjectStartDateDatePicker.Value; project.PROJECT_END = ProjectEndDatePicker.Value; project.PROJECT_STATUS = Constants.ProjectStatusNewId; project.PROJECT_PAY_PER_HOUR = decimal.Parse(PayPerHourTextBox.Text); context.PROJECTS.Add(project); context.SaveChanges(); MessageBox.Show("Проектът е създаден."); ProjectIdTextBox.Clear(); ProjectNameTextBox.Clear(); ProjectDescriptionTextBox.Clear(); ProjectClientComboBox.SelectedIndex = -1; ProjectStartDateDatePicker.Value = DateTime.Now.Date; ProjectEndDatePicker.Value = DateTime.Now.Date; PayPerHourTextBox.Clear(); }
void ProjectAdded(Project project) { ProjectNameTextBox.Focus(Windows.UI.Xaml.FocusState.Keyboard); }
private void Window_Loaded(object sender, RoutedEventArgs e) { ProjectNameTextBox.Focus(); }