public void refreshGrid() { dataGridView1.Update(); dataGridView1.Refresh(); dataGridView1.AutoResizeColumns(); dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; ComboBoxItem selectedUser = cbo_employee.SelectedItem as ComboBoxItem; Users user = new Users(); user.id = selectedUser == null ? (long)0 : long.Parse(selectedUser.Value.ToString()); ComboBoxItem selectedWorkType = cbo_prodWorkType.SelectedItem as ComboBoxItem; model.WorkType workType = new model.WorkType(); workType.id = selectedWorkType == null ? (long)0 : long.Parse(selectedWorkType.Value.ToString());; ComboBoxItem selectedProject = cbo_prodProjType.SelectedItem as ComboBoxItem; model.Project project = new model.Project(); project.id = selectedProject == null ? (long)0 : long.Parse(selectedProject.Value.ToString());; ComboBoxItem selectedTask = cbo_prodTaskType.SelectedItem as ComboBoxItem; model.TaskType taskType = new model.TaskType(); taskType.id = selectedTask == null ? (long)0 : long.Parse(selectedTask.Value.ToString());; //Users user, WorkType workType, Project project, TaskType taskType DateTime start = dateTimePicker1.Value; DateTime end = dateTimePicker2.Value; dataGridView1.DataSource = getProductionController().getUserTasks(user, workType, project, taskType, start, end); lblTaskCount.Text = dataGridView1.DisplayedRowCount(false).ToString(); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == dataGridView1.Columns["Status"].Index && e.RowIndex >= 0) { DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex]; bool status = bool.Parse(row.Cells["Status"].Value.ToString()); String statusStr = status ? "deactivate" : "activate"; DialogResult dr = MessageBox.Show("Are you sure you want to " + statusStr + " this Work Type?", "Confirm", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information); if (dr == DialogResult.Yes) { model.WorkType workType = getLookupController().getWorkType(row.Cells["ID"].Value.ToString()); workType.activeFlag = !status; getLookupController().saveWorkType(workType, false, currentSessionUser); MessageBox.Show("Work Type successfully " + statusStr + "d"); } } else if (e.ColumnIndex == dataGridView1.Columns["Edit"].Index && e.RowIndex >= 0) { DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex]; isEditMode = true; model.WorkType workType = getLookupController().getWorkType(row.Cells["ID"].Value.ToString()); tempId = long.Parse(row.Cells["ID"].Value.ToString()); txt_code.Text = workType.code; txt_name.Text = workType.name; chkActive.Checked = workType.activeFlag; txt_code.ReadOnly = true; } refreshData(); }
private void button1_Click(object sender, EventArgs e) { model.WorkType workType = new model.WorkType(); if (isEditMode) { workType.id = tempId; } workType.code = txt_code.Text; workType.name = txt_name.Text; workType.activeFlag = chkActive.Checked; List <String> errMessages = getLookupController().validateWorkType(workType); if (errMessages.Count > 0) { MessageBox.Show(getStringUtility().arrayToStringMessages(errMessages)); return; } workType = getLookupController().saveWorkType(workType, (!isEditMode?true:false), currentSessionUser); if (workType != null && workType.id != 0) { refreshData(); txt_code.ReadOnly = false; txt_code.Text = String.Empty; txt_name.Text = String.Empty; MessageBox.Show("Work Type successfully saved"); tempId = 0L; isEditMode = false; } }
private void cbo_prodWorkType_SelectedIndexChanged(object sender, EventArgs e) { ComboBoxItem selectedItem = cbo_prodWorkType.SelectedItem as ComboBoxItem; model.WorkType workType = new model.WorkType(); workType.id = selectedItem == null ? (long)0 : long.Parse(selectedItem.Value.ToString()); cbo_prodProjType.Items.Clear(); foreach (Project project in getLookupController().getProjectsByWorkType(true, workType)) { ComboBoxItem item = new ComboBoxItem(); item.Text = project.name; item.Value = project.id.ToString(); cbo_prodProjType.Items.Add(item); } }