예제 #1
0
        private void dgvMeasure_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            var measureid = clsCommon.CnvNullToInt(dgvMeasure.Rows[e.RowIndex].Cells[MeasureID.Index].Value);

            try
            {
                if (e.ColumnIndex == dgvMeasure.Columns[colDelete.Index].Index)
                {
                    // Delete
                    if (!ComfirmMsg(COMFIRM_MSG_DELETE))
                    {
                        ClearSelectionDgv(dgvMeasure);
                        return;
                    }

                    _objDB.DeleteMeasure(measureid);
                    LoadData();
                }
                else if (e.ColumnIndex == dgvMeasure.Columns[colEnable.Index].Index)
                {
                    // Enable
                    var      pathErrors = clsConfig.PathDataErrors + @"\" + measureid;
                    string[] files      = null;

                    if (Directory.Exists(pathErrors))
                    {
                        files = Directory.GetFiles(pathErrors);
                    }
                    else
                    {
                        using (var fbd = new FolderBrowserDialog())
                        {
                            DialogResult result = fbd.ShowDialog();

                            if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
                            {
                                files = Directory.GetFiles(fbd.SelectedPath);
                            }
                            else
                            {
                                ClearSelectionDgv(dgvMeasure);
                                return;
                            }
                        }
                    }

                    if (files == null || files.Length == 0)
                    {
                        ShowMsg(MessageBoxIcon.Warning, MSG_BLANK_FOLDER);
                    }

                    xExecuteNonQueryFromFile(files, measureid);
                }
                else
                {
                    // Load filter
                    var dtStartTime    = CnvDBToDateTimePickerValue(dgvMeasure.Rows[e.RowIndex].Cells[StartTime.Index].Value);
                    var dtEndTime      = CnvDBToDateTimePickerValue(dgvMeasure.Rows[e.RowIndex].Cells[EndTime.Index].Value);
                    var intMeasureType = clsCommon.CnvNullToInt(dgvMeasure.Rows[e.RowIndex].Cells[MeasureType.Index].Value);

                    ResultDetail.Visible = intMeasureType == (int)emMeasureType.AlarmTest;
                    pnlFilter.Enabled    = true;

                    dtpSubDateS.Value           = dtStartTime;
                    cboSubHourS.SelectedValue   = dtStartTime.Hour;
                    cboSubMimuteS.SelectedValue = dtStartTime.Minute;
                    cboSubSecondS.SelectedValue = dtStartTime.Second;

                    dtpSubDateE.Value           = dtEndTime;
                    cboSubHourE.SelectedValue   = dtEndTime.Hour;
                    cboSubMimuteE.SelectedValue = dtEndTime.Minute;
                    cboSubSecondE.SelectedValue = dtEndTime.Second;

                    LoadDataSub(measureid);
                }
            }
            catch (Exception ex)
            {
                ShowMsg(MessageBoxIcon.Error, MSG_ERR_PROCESS);
            }
        }