Exemple #1
0
        private void Dgv부서_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            var    list = DB.부서.GetAll();
            string startDay, endDay;

            //if (e.ColumnIndex == 6 || e.ColumnIndex == 7)
            //{
            for (int i = 0; i < list.Count; i++)
            {
                startDay = dgv부서.Rows[i].Cells[6].Value.ToString();

                if (dgv부서.Rows[i].Cells[7].Value != null)
                {
                    endDay = dgv부서.Rows[i].Cells[7].Value.ToString();

                    if (
                        list[i].부서코드 != dgv부서.Rows[i].Cells[0].Value.ToString() || list[i].부서명 != dgv부서.Rows[i].Cells[1].Value.ToString() ||
                        list[i].사업장코드 != dgv부서.Rows[i].Cells[2].Value.ToString() || list[i].부문코드 != dgv부서.Rows[i].Cells[4].Value.ToString() ||
                        list[i].사용시작기간.ToString() != DateTime.Parse(startDay)
                        .ToShortDateString() ||
                        list[i].사용종료기간.ToString() != DateTime.Parse(endDay).
                        ToShortDateString()
                        )
                    {
                        DB.부서.Update(FillInDepartment(i));
                    }
                }
                else
                {
                    if (
                        list[i].부서코드 != dgv부서.Rows[i].Cells[0].Value.ToString() || list[i].부서명 != dgv부서.Rows[i].Cells[1].Value.ToString() ||
                        list[i].사업장코드 != dgv부서.Rows[i].Cells[2].Value.ToString() || list[i].부문코드 != dgv부서.Rows[i].Cells[4].Value.ToString() ||
                        list[i].사용시작기간.ToString() != DateTime.Parse(startDay)
                        .ToShortDateString()
                        )
                    {
                        DB.부서.Update(FillInDepartment(i));
                    }
                }
            }

            for (int i = list.Count; i < dgv부서.RowCount - 1; i++)
            {
                if (dgv부서.Rows[i].Cells[0].Value != null && dgv부서.Rows[i].Cells[1].Value != null && dgv부서.Rows[i].Cells[2].Value != null && dgv부서.Rows[i].Cells[4].Value != null && dgv부서.Rows[i].Cells[6].Value != null)
                {
                    ClassLibrary.부서등록 부서 = FillInDepartment(i);

                    DB.부서.Insert(부서);
                }
            }
            //}
        }
Exemple #2
0
        /// <summary>
        /// 부서 데이터 담음
        /// </summary>
        /// <param name="i">인덱스 번호</param>
        /// <returns></returns>
        private ClassLibrary.부서등록 FillInDepartment(int i)
        {
            ClassLibrary.부서등록 부서 = new ClassLibrary.부서등록();

            부서.부서코드   = dgv부서.Rows[i].Cells[0].Value.ToString();
            부서.부서명    = dgv부서.Rows[i].Cells[1].Value.ToString();
            부서.사업장코드  = dgv부서.Rows[i].Cells[2].Value.ToString();
            부서.부문코드   = dgv부서.Rows[i].Cells[4].Value.ToString();
            부서.사용시작기간 = DateTime.Parse(dgv부서.Rows[i].Cells[6].Value.ToString());
            if (dgv부서.Rows[i].Cells[7].Value != null)
            {
                부서.사용종료기간 = DateTime.Parse(dgv부서.Rows[i].Cells[7].Value.ToString());
            }

            return(부서);
        }