示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            model.TaskType taskType = new model.TaskType();
            if (isEditMode)
            {
                taskType.id = tempId;
            }
            taskType.code       = txtTaskTypeCode.Text;
            taskType.name       = txtTaskTypeName.Text;
            taskType.activeFlag = chkActive.Checked;

            List <String> errMessages = getLookupController().validateTaskType(taskType);

            if (errMessages.Count > 0)
            {
                MessageBox.Show(getStringUtility().arrayToStringMessages(errMessages));
                return;
            }
            taskType = getLookupController().saveTaskType(taskType, (!isEditMode ? true : false), currentSessionUser);
            if (taskType != null && taskType.id != 0)
            {
                refreshData();
                txtTaskTypeCode.ReadOnly = false;
                txtTaskTypeCode.Text     = String.Empty;
                txtTaskTypeName.Text     = String.Empty;
                MessageBox.Show("Task Type successfully saved");
                tempId     = 0L;
                isEditMode = false;
            }
        }
        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();
        }
示例#3
0
 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 Task Type?", "Confirm", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
         if (dr == DialogResult.Yes)
         {
             model.TaskType taskType = getLookupController().getTaskType(row.Cells["ID"].Value.ToString());
             taskType.activeFlag = !status;
             getLookupController().saveTaskType(taskType, false, currentSessionUser);
             MessageBox.Show("Task 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.TaskType taskType = getLookupController().getTaskType(row.Cells["ID"].Value.ToString());
         tempId = taskType.id;
         txtTaskTypeCode.Text     = taskType.code;
         txtTaskTypeName.Text     = taskType.name;
         chkActive.Checked        = taskType.activeFlag;
         txtTaskTypeCode.ReadOnly = true;
     }
     refreshData();
 }