コード例 #1
0
 public Reports()
 {
     InitializeComponent();
     FillClientCombo();
     baseDt = new DataTable();
     baseDt.Columns.Add(columnDateName, typeof(string));
     baseDt.Columns.Add(columnTaskName, typeof(string));
     baseDt.Columns.Add(columnDescriptionName, typeof(string));
     baseDt.Columns.Add(columnDurationName, typeof(int));
     FormatDataGrid();
     allTasks   = coreOperations.GetAllTasksFromFile();
     allClients = coreOperations.GetAllClientsFromFile();
 }
コード例 #2
0
        private void FillCombo()
        {
            try
            {
                List <Task> allTasksForCombo = coreOperations.GetAllTasksFromFile();
                allTasksForCombo.Insert(0, new Task()
                {
                    Id = 0, Name = "Add New Task"
                });

                cmbTasks.DataSource = allTasksForCombo;

                cmbTasks.DisplayMember = "Name";
                cmbTasks.ValueMember   = "Id";

                txtName.Text        = "";
                txtDescription.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                coreOperations.WriteLog("AddTask", "FillCombo", ex.Message);
            }
        }
コード例 #3
0
        private void FormatDataGrid()
        {
            try
            {
                dataGridViewDailyTaks.AutoGenerateColumns = false;

                DataGridViewComboBoxCell dccbTasks = new DataGridViewComboBoxCell();
                dccbTasks.DataSource    = coreOperations.GetAllTasksFromFile();
                dccbTasks.DisplayMember = "Name";
                dccbTasks.ValueMember   = "Id";

                DataGridViewColumn dcTask = new DataGridViewColumn
                {
                    ValueType        = typeof(string),
                    DataPropertyName = columnTaskName,
                    CellTemplate     = dccbTasks,
                    Name             = columnTaskHeader,
                    DisplayIndex     = 0
                };
                dataGridViewDailyTaks.Columns.Add(dcTask);


                DataGridViewComboBoxCell dccbClients = new DataGridViewComboBoxCell();
                dccbClients.DataSource    = coreOperations.GetAllClientsFromFile();
                dccbClients.DisplayMember = "Name";
                dccbClients.ValueMember   = "Id";

                DataGridViewColumn dcClient = new DataGridViewColumn
                {
                    ValueType        = typeof(string),
                    DataPropertyName = columnClientName,
                    CellTemplate     = dccbClients,
                    Name             = columnClientHeader,
                    DisplayIndex     = 1,
                };
                dataGridViewDailyTaks.Columns.Add(dcClient);

                DataGridViewCell   dct           = new DataGridViewTextBoxCell();
                DataGridViewColumn dcDescription = new DataGridViewColumn
                {
                    ValueType        = typeof(string),
                    Name             = columnDescriptionHeader,
                    DataPropertyName = columnDescriptionName,
                    CellTemplate     = dct,
                    DisplayIndex     = 2,
                    MinimumWidth     = 200
                };
                dataGridViewDailyTaks.Columns.Add(dcDescription);

                DataGridViewColumn dcDuration = new DataGridViewColumn
                {
                    ValueType        = typeof(int),
                    Name             = columnDurationHeader,
                    CellTemplate     = dct,
                    DataPropertyName = columnDurationName,
                    DisplayIndex     = 3
                };
                dataGridViewDailyTaks.Columns.Add(dcDuration);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                coreOperations.WriteLog("Main", "FormatDataGrid", ex.Message);
            }
        }