Esempio n. 1
0
        /// <summary>
        /// 행 선택 변경시 동작합니다.
        /// </summary>
        /// <param name="sender">이벤트 발생자 입니다.</param>
        /// <param name="e">이벤트 인자 입니다.</param>
        private void subGridView_SelectionChanged(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in this.subGridView.SelectedRows)
            {
                SubModel focusItem = row.DataBoundItem as SubModel;

                UpdateSubControlData(focusItem);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 서브 컨트롤 데이터를 업데이트 합니다.
 /// </summary>
 /// <param name="source">소스 입니다.</param>
 private void UpdateSubControlData(SubModel source)
 {
     if (source == null)
     {
         ClearSubControlData();
     }
     else if (source != null)
     {
         SetSubControlData(source);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 취소 버튼 클릭시 동작합니다.
        /// </summary>
        /// <param name="sender">이벤트 발생자 입니다.</param>
        /// <param name="e">이벤트 인자 입니다.</param>
        private void subCancelButton_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in this.subGridView.SelectedRows)
            {
                SubModel item = row.DataBoundItem as SubModel;

                UpdateSubControlData(item);
            }

            SetMainEditMode(EditMode.Search);
        }
Esempio n. 4
0
        /// <summary>
        /// 메인 컨트롤에서 값을 가져옵니다.
        /// </summary>
        /// <returns></returns>
        private SubModel GetSubControlData()
        {
            SubModel item = new SubModel();

            item.Subject    = this.subSubjectTextBox.Text;
            item.Content    = this.subContentTextBox.Text;
            item.CreateDate = DateTime.Now;
            item.UpdateDate = DateTime.Now;
            item.FilePath   = this.attachFileTextBox.Text;

            return(item);
        }
Esempio n. 5
0
        /// <summary>
        /// 삭제 버튼 클릭시 동작합니다.
        /// </summary>
        /// <param name="sender">이벤트 발생자 입니다.</param>
        /// <param name="e">이벤트 인자 입니다.</param>
        private void subDeleteButton_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in this.subGridView.SelectedRows)
            {
                SubModel focusItem = row.DataBoundItem as SubModel;

                if (focusItem == null)
                {
                    MessageBox.Show("삭제할 항목이 없습니다.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (MessageBox.Show("해당 항목을 삭제하시겠습니까?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
                {
                    return;
                }

                try
                {
                    if (!string.IsNullOrEmpty(focusItem.FilePath))
                    {
                        DirectoryInfo directory = new DirectoryInfo(Path.GetDirectoryName(focusItem.FilePath));
                        if (directory.Exists)
                        {
                            directory.Delete(true);
                            QueryHelper.DeleteSubData(focusItem);
                        }
                        else if (!directory.Exists)
                        {
                            QueryHelper.DeleteSubData(focusItem);
                        }
                    }
                    this.subSearchButton.PerformClick();
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.ToString());
                }
                finally
                {
                    SetSubEditMode(EditMode.Search);

                    UpdateSubControlData(focusItem);
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 그리드 뷰의 셀 클릭시 동작합니다.
        /// </summary>
        /// <param name="sender">이벤트 발생자 입니다.</param>
        /// <param name="e"></param>
        private void subGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 1)
            {
                foreach (DataGridViewRow row in this.subGridView.SelectedRows)
                {
                    SubModel focusItem = row.DataBoundItem as SubModel;

                    if (string.IsNullOrEmpty(focusItem.FilePath))
                    {
                        return;
                    }
                    else
                    {
                        Process.Start(focusItem.FilePath);
                    }
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 확인 버튼 클릭시 동작합니다.
        /// </summary>
        /// <param name="sender">이벤트 발생자 입니다.</param>
        /// <param name="e">이벤트 인자 입니다.</param>
        private void subOKButton_Click(object sender, EventArgs e)
        {
            string targetPath = @"D:\TEST2\";

            if (this.subEditMode == EditMode.Add)
            {
                #region 추가 모드일 때 처리합니다.
                try
                {
                    SubModel inputItem = GetSubControlData();

                    inputItem.MainID = this.mainIDTextBox.Text;
                    inputItem.ID     = Guid.NewGuid().ToString();

                    if (!string.IsNullOrEmpty(this.attachFileTextBox.Text))
                    {
                        inputItem.FilePath = targetPath + inputItem.ID + @"\" + Path.GetFileName(this.attachFileTextBox.Text);
                    }
                    else
                    {
                        inputItem.FilePath = null;
                    }

                    QueryHelper.InsertSubData(inputItem);

                    if (!string.IsNullOrEmpty(inputItem.FilePath))
                    {
                        CopyFile(inputItem.FilePath);
                    }

                    this.subGridView.Update();
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.ToString());
                }
                finally
                {
                    SetSubEditMode(EditMode.Search);
                    this.subSearchButton.PerformClick();
                    foreach (DataGridViewRow row in this.subGridView.SelectedRows)
                    {
                        SubModel focusItem = row.DataBoundItem as SubModel;

                        UpdateSubControlData(focusItem);

                        this.subSearchButton.PerformClick();

                        this.subGridView.ClearSelection();

                        List <SubModel> newItem = this.subGridView.DataSource as List <SubModel>;
                        this.subGridView.Rows[newItem.Count - 1].Selected = true;
                        this.subGridView.FirstDisplayedScrollingRowIndex  = this.subGridView.Rows.Count - 1;
                    }
                }
                #endregion
            }

            else if (this.subEditMode == EditMode.Update)
            {
                #region 수정 모드일 때 처리합니다.

                foreach (DataGridViewRow row in this.subGridView.SelectedRows)
                {
                    SubModel focusItem = row.DataBoundItem as SubModel;

                    focusItem.Subject = this.subSubjectTextBox.Text;
                    focusItem.Content = this.subContentTextBox.Text;

                    if (!string.IsNullOrEmpty(this.attachFileTextBox.Text))
                    {
                        focusItem.FilePath = targetPath + focusItem.ID + @"\" + Path.GetFileName(this.attachFileTextBox.Text);
                    }
                    else
                    {
                        focusItem.FilePath = null;
                    }

                    try
                    {
                        QueryHelper.UpdateSubData(focusItem);

                        if (!string.IsNullOrEmpty(focusItem.FilePath))
                        {
                            CopyFile(focusItem.FilePath);
                        }

                        this.mainSearchButton.PerformClick();
                        this.subSearchButton.PerformClick();

                        this.subGridView.Update();
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.ToString());
                    }
                    finally
                    {
                        SetSubEditMode(EditMode.Search);
                        UpdateSubControlData(focusItem);
                    }
                }

                #endregion
            }
        }
Esempio n. 8
0
 /// <summary>
 /// 메인 컨트롤 데이터를 설정합니다.
 /// </summary>
 /// <param name="source"></param>
 private void SetSubControlData(SubModel source)
 {
     this.subSubjectTextBox.Text = source.Subject;
     this.subContentTextBox.Text = source.Content;
     this.attachFileTextBox.Text = source.FilePath;
 }