Esempio n. 1
0
        private void refreshList()
        {
            value = ITLogServices.GetAll();
            dataGridViewITLog.DataSource = value;
            dataGridViewITLog.ClearSelection();

            isByDate      = false;
            isByPersonnel = false;
        }
Esempio n. 2
0
        private void buttonSearchPersonnel_Click(object sender, EventArgs e)
        {
            int id = comboBoxPersonnel.SelectedIndex;

            value = ITLogServices.SearchByPersonnel(id);
            dataGridViewITLog.DataSource = value;
            dataGridViewITLog.ClearSelection();

            isByDate      = false;
            isByPersonnel = true;
        }
Esempio n. 3
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            var searchText = textBoxSearch.Text;

            value = ITLogServices.Search(searchText);
            dataGridViewITLog.DataSource = value;
            dataGridViewITLog.ClearSelection();

            isByDate      = false;
            isByPersonnel = false;
        }
Esempio n. 4
0
        private void buttonSearchDate_Click(object sender, EventArgs e)
        {
            DateTime from = dateTimePickerFromSearch.Value;
            DateTime to   = dateTimePickerToSearch.Value;

            value = ITLogServices.SearchByDate(from, to);
            dataGridViewITLog.DataSource = value;
            dataGridViewITLog.ClearSelection();

            isByDate      = true;
            isByPersonnel = false;
        }
Esempio n. 5
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to delete this?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (dataGridViewITLog.SelectedCells.Count > 0)
                {
                    int             selectedrowindex = dataGridViewITLog.SelectedCells[0].RowIndex;
                    DataGridViewRow selectedRow      = dataGridViewITLog.Rows[selectedrowindex];

                    int id = Convert.ToInt32(selectedRow.Cells[0].Value);
                    ITLogServices.Delete(id);

                    refreshList();
                    disableEditButton();
                }
            }
        }
Esempio n. 6
0
        public FormAddEdit(int?id)
        {
            InitializeComponent();

            if (id == null)
            {
                IsNew = true;
            }
            else
            {
                this.updateObj = ITLogServices.GetById((int)id);
                IsNew          = false;

                textBoxName.Text                  = updateObj.name;
                textBoxOffice.Text                = updateObj.office;
                dateTimePickerDate.Text           = Convert.ToDateTime(updateObj.date).ToString();
                dateTimePickerTime.Text           = updateObj.time.ToString();
                textBoxServiceRequest.Text        = updateObj.service_request;
                comboBoxITPersonnel.SelectedIndex = (int)updateObj.it_personnel_id;
            }
        }
Esempio n. 7
0
        private void FormAddEdit_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                if (string.IsNullOrEmpty(textBoxName.Text))
                {
                    MessageBox.Show("Please Enter Name!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBoxName.Focus();
                    e.Cancel = true;
                    return;
                }

                if (string.IsNullOrEmpty(textBoxOffice.Text))
                {
                    MessageBox.Show("Please Enter Office Name!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBoxOffice.Focus();
                    e.Cancel = true;
                    return;
                }

                if ((string.IsNullOrEmpty(dateTimePickerDate.Text)))
                {
                    MessageBox.Show("Please Enter the Date!");
                    dateTimePickerDate.Focus();
                    e.Cancel = true;
                    return;
                }

                if ((string.IsNullOrEmpty(dateTimePickerTime.Text)))
                {
                    MessageBox.Show("Please Enter the Date!");
                    dateTimePickerTime.Focus();
                    e.Cancel = true;
                    return;
                }

                if (string.IsNullOrEmpty(textBoxServiceRequest.Text))
                {
                    MessageBox.Show("Please Enter the Service Requested!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBoxServiceRequest.Focus();
                    e.Cancel = true;
                    return;
                }

                if (IsNew)
                {
                    var log = new it_log()
                    {
                        name            = textBoxName.Text.ToString(),
                        office          = textBoxOffice.Text.ToString(),
                        date            = Convert.ToDateTime(dateTimePickerDate.Text),
                        time            = TimeSpan.Parse(dateTimePickerTime.Text),
                        service_request = textBoxServiceRequest.Text.ToString(),
                        it_personnel_id = comboBoxITPersonnel.SelectedIndex
                    };

                    ITLogServices.Insert(log);
                    MessageBox.Show("Added!");
                }
                else
                {
                    updateObj.name            = textBoxName.Text.ToString();
                    updateObj.office          = textBoxOffice.Text.ToString();
                    updateObj.date            = Convert.ToDateTime(dateTimePickerDate.Text);
                    updateObj.time            = TimeSpan.Parse(dateTimePickerTime.Text);
                    updateObj.service_request = textBoxServiceRequest.Text.ToString();
                    updateObj.it_personnel_id = comboBoxITPersonnel.SelectedIndex;

                    ITLogServices.Update(updateObj);
                    MessageBox.Show("Saved!");
                }
            }
        }