Example #1
0
        private void ExecuteSearchCommand()
        {
            DataSet ds = MainDAO.GetCertainItembyCertainColumn(nowcolumnname, selectedcolumn);

            if (ds != null)
            {
                if (ds.Tables[0].Rows.Count > 1)
                {
                    MessageBox.Show("하나 이상의 행이 검색되었습니다. 검색하는데 쓰인 값이 기본키가 아닌 것 같습니다.\n첫 번째로 검색된 값만 사용합니다.");
                }
                else if (ds.Tables[0].Rows.Count < 1)
                {
                    MessageBox.Show("검색된 값이 없습니다.");
                    return;
                }
                ValueInject(ds.Tables[0].Rows[0]);
            }
            else
            {
                string res1 = nowcolumnname;
                string res2 = selectedcolumn;
                if (res1 == null)
                {
                    res1 = "(선택되지 않음)";
                }
                if (res2 == null)
                {
                    res2 = "(입력되지 않음)";
                }
                MessageBox.Show("컬럼 " + res1 + "의 값 " + res2 + "은 검색되지 않았습니다.");
            }
        }
Example #2
0
        private void ExecuteDeleteCommand()
        {
            DataSet ds = MainDAO.GetCertainItembyCertainColumn(nowcolumnname, selectedcolumn);

            if (ds != null)
            {
                if (ds.Tables[0].Rows.Count > 1)
                {
                    MessageBox.Show("복수의 행이 검색되었습니다. 검색하는데 쓰인 컬럼이 기본키가 아닌 것 같습니다.\n두 개 이상의 값이 검색되었을 경우엔 삭제할 수 없습니다.");
                    return;
                }
                else if (ds.Tables[0].Rows.Count < 1)
                {
                    MessageBox.Show("검색된 값이 없습니다.");
                    return;
                }
                foreach (DataColumn x in ds.Tables[0].Columns)
                {
                    Console.WriteLine("result Column:" + x.ColumnName);
                    Console.WriteLine("result Row:" + ds.Tables[0].Rows[0][x.ColumnName]);
                }
                MainDAO.DeleteItembyCertainColumn(nowcolumnname, selectedcolumn);
                MessageBox.Show("삭제 작업이 완료되었습니다.");
                Items = MainDAO.GetEveryItem().Tables[0];
            }
            else
            {
                string res1 = nowcolumnname;
                string res2 = selectedcolumn;
                if (res1 == null)
                {
                    res1 = "(선택되지 않음)";
                }
                if (res2 == null)
                {
                    res2 = "(입력되지 않음)";
                }
                MessageBox.Show("컬럼 " + res1 + "의 값 " + res2 + "은 검색되지 않았습니다.");
            }
        }