/// <summary>
        /// DataGridViewForm - add selected track worker for client event
        /// </summary>
        /// <param name="clientEventForm"></param>
        /// <param name="clientsEvents_TrackWorkersList"></param>
        public DataGridViewForm(ClientEventForm clientEventForm, List <ClientEvents_TrackWorkersModel> clientsEvents_TrackWorkersList)
        {
            //TODO Need to Make is sticky for update
            InitializeComponent();
            List <TrackWorkerModel> appliedTrackWorkerIdList = new List <TrackWorkerModel>();

            foreach (ClientEvents_TrackWorkersModel clientsEvents_TrackWorkers in clientsEvents_TrackWorkersList)
            {
                appliedTrackWorkerIdList.Add(TrackWorkerDataAccess.LoadTrackWorker(clientsEvents_TrackWorkers.TrackWorkerID));
            }

            var dataTable = ToDataTable(appliedTrackWorkerIdList);

            dataTable.Columns.Add("Selected", typeof(bool)).SetOrdinal(0);
            dataTable.Columns.Add("Present", typeof(bool)).SetOrdinal(1);
            dgvData.DataSource        = dataTable;
            dgvData.CellContentClick += dgrvProductTemplate_CellContentClick;
            dgvData.MultiSelect       = false;
            dgvData.ReadOnly          = false;
            int dgv_width = dgvData.Columns.GetColumnsWidth(DataGridViewElementStates.Visible);

            this.Width = 365 + dgv_width;

            if (clientsEvents_TrackWorkersList != null)
            {
                foreach (DataGridViewRow row in dgvData.Rows)
                {
                    DataGridViewCheckBoxCell isSelectedCell = row.Cells["Selected"] as DataGridViewCheckBoxCell;
                    DataGridViewCheckBoxCell isPresentCell  = row.Cells["Present"] as DataGridViewCheckBoxCell;
                    isSelectedCell.Value = false;
                    isPresentCell.Value  = false;
                    foreach (ClientEvents_TrackWorkersModel trackWorkerId in clientsEvents_TrackWorkersList)
                    {
                        if (row.Cells["TrackWorkerID"].Value.ToString() == trackWorkerId.TrackWorkerID.ToString())
                        {
                            isSelectedCell.Value = trackWorkerId.IsSelected;
                            isPresentCell.Value  = trackWorkerId.IsPresent;
                        }
                    }
                }
            }

            foreach (DataGridViewColumn column in dgvData.Columns)
            {
                if (column.HeaderText == "Selected" || column.HeaderText == "Present")
                {
                    column.ReadOnly = false;
                }
                else
                {
                    column.ReadOnly = true;
                }
            }

            btnSelect.Click += btnSelectedTrackWorker_Click;
            _clientEventForm = clientEventForm;
        }
        /// <summary>
        /// DataGridViewForm - for adding track for client event
        /// </summary>
        /// <param name="clientEventForm"></param>
        /// <param name="list"></param>
        public DataGridViewForm(ClientEventForm clientEventForm, List <TrackModel> list)
        {
            InitializeComponent();
            dgvData.DataSource  = ToDataTable(list);
            dgvData.MultiSelect = false;
            dgvData.ReadOnly    = true;

            dgvData.AutoResizeColumns();
            int dgv_width = dgvData.Columns.GetColumnsWidth(DataGridViewElementStates.Visible);

            this.Width = 85 + dgv_width;

            btnSelect.Click += btnAddTrack_Click;
            _clientEventForm = clientEventForm;
        }
        /// <summary>
        /// DataGridViewForm - add apply track worker for client event
        /// </summary>
        /// <param name="clientEventForm"></param>
        /// <param name="list"></param>
        /// <param name="trackWorkerIdList"></param>
        public DataGridViewForm(ClientEventForm clientEventForm, List <TrackWorkerModel> list, List <ClientEvents_TrackWorkersModel> trackWorkerIdList)
        {
            InitializeComponent();
            var dataTable = ToDataTable(list);

            dataTable.Columns.Add("Applied", typeof(bool)).SetOrdinal(0);
            dgvData.DataSource  = dataTable;
            dgvData.MultiSelect = false;

            dgvData.AutoResizeColumns();
            int dgv_width = dgvData.Columns.GetColumnsWidth(DataGridViewElementStates.Visible);

            this.Width = 85 + dgv_width;

            if (trackWorkerIdList != null)
            {
                foreach (DataGridViewRow row in dgvData.Rows)
                {
                    DataGridViewCheckBoxCell cell = row.Cells[0] as DataGridViewCheckBoxCell;
                    cell.Value = false;
                    foreach (ClientEvents_TrackWorkersModel trackWorkerId in trackWorkerIdList)
                    {
                        if (row.Cells[1].Value.ToString() == trackWorkerId.TrackWorkerID.ToString())
                        {
                            cell.Value = true;
                        }
                    }
                }
            }
            foreach (DataGridViewColumn column in dgvData.Columns)
            {
                if (column.HeaderText == "Applied")
                {
                    column.ReadOnly = false;
                }
                else
                {
                    column.ReadOnly = true;
                }
            }
            btnSelect.Click += btnApplyTrackWorker_Click;
            _clientEventForm = clientEventForm;
        }
Exemplo n.º 4
0
        /// <summary>
        /// btnClientEventAddNew_Click - add new client event record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnClientEventAddNew_Click(object sender, EventArgs e)
        {
            ClientEventForm clientEventForm = new ClientEventForm(this);

            clientEventForm.ShowDialog();
        }
Exemplo n.º 5
0
        /// <summary>
        /// dgvClientEvent_CellClick - client event cell click event for updating
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvClientEvent_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                ClientEventModel clientEventModel = new ClientEventModel();
                clientEventModel.ClientEventID    = int.Parse(dgvClientEvent.Rows[e.RowIndex].Cells["ClientEventID"].Value.ToString());
                clientEventModel.ClientID         = int.Parse(dgvClientEvent.Rows[e.RowIndex].Cells["ClientID"].Value.ToString());
                clientEventModel.TrackID          = int.Parse(dgvClientEvent.Rows[e.RowIndex].Cells["TrackID"].Value.ToString());
                clientEventModel.Date             = dgvClientEvent.Rows[e.RowIndex].Cells["Date"].Value.ToString();
                clientEventModel.WorkersRequested = int.Parse(dgvClientEvent.Rows[e.RowIndex].Cells["WorkersRequested"].Value.ToString());

                if (dgvClientEvent.Rows[e.RowIndex].Cells["IsLunchProvided"].Value.ToString() == "True")
                {
                    clientEventModel.IsLunchProvided = true;
                }
                else
                {
                    clientEventModel.IsLunchProvided = false;
                }

                if (dgvClientEvent.Rows[e.RowIndex].Cells["IsUsingUpperPaddock"].Value.ToString() == "True")
                {
                    clientEventModel.IsUsingUpperPaddock = true;
                }
                else
                {
                    clientEventModel.IsUsingUpperPaddock = false;
                }

                if (dgvClientEvent.Rows[e.RowIndex].Cells["IsUsingMiddlePaddock"].Value.ToString() == "True")
                {
                    clientEventModel.IsUsingMiddlePaddock = true;
                }
                else
                {
                    clientEventModel.IsUsingMiddlePaddock = false;
                }

                if (dgvClientEvent.Rows[e.RowIndex].Cells["IsUsingLowerPaddock"].Value.ToString() == "True")
                {
                    clientEventModel.IsUsingLowerPaddock = true;
                }
                else
                {
                    clientEventModel.IsUsingLowerPaddock = false;
                }

                if (dgvClientEvent.Rows[e.RowIndex].Cells["WorkerCalloutSent"].Value.ToString() == "True")
                {
                    clientEventModel.WorkerCalloutSent = true;
                }
                else
                {
                    clientEventModel.WorkerCalloutSent = false;
                }

                if (dgvClientEvent.Rows[e.RowIndex].Cells["RequireSafetyDemo"].Value.ToString() == "True")
                {
                    clientEventModel.RequireSafetyDemo = true;
                }
                else
                {
                    clientEventModel.RequireSafetyDemo = false;
                }

                if (dgvClientEvent.Rows[e.RowIndex].Cells["IsDeleted"].Value.ToString() == "True")
                {
                    clientEventModel.IsDeleted = true;
                }
                else
                {
                    clientEventModel.IsDeleted = false;
                }
                ClientEventForm tracksForm = new ClientEventForm(this, clientEventModel);
                tracksForm.ShowDialog();
            }
        }