Example #1
0
        //************************************************************
        //** 삭제 버튼 Click (삭제는 DATA 1건씩 처리)
        //************************************************************
        public void BtnDelete_Click()
        {
            if (dataGrid.SelectedItems.Count < 1)
            {
                MessageBox.Show("삭제할 자료를 먼저 선택하세요.", "삭제확인", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            UcSubC19ViewModel vm = (UcSubC19ViewModel)dataGrid.SelectedItem;

            //신규 입력중인 자료는 단순하게 Grid에서 제거만 한다.
            if (vm.DataStatus.Equals("A"))
            {
                myViewModel.Remove(vm);
                SearchCount.Text = myViewModel.Count.ToString();
                return;
            }
            //----------------------------------------------------------------
            if (authority.Delete.Equals("0"))
            {
                Utility.MsgAuthorityViolation("삭제");
                return;
            }

            if (MessageBox.Show(vm.Papr_appno + " 자료를 삭제하시겠습니까?", "삭제확인", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
            {
                return;
            }
            //--DB Handling(Start)-------------------------------------
            try
            {
                con = Utility.SetOracleConnection();
                OracleCommand cmd = con.CreateCommand();
                cmd.CommandText = SQLStatement.DeleteSQL;
                cmd.Parameters.Add("key1", OracleDbType.Varchar2).Value = vm.Key1;
                if (cmd.ExecuteNonQuery() > 0)
                {
                    myViewModel.Remove(vm);
                    SearchCount.Text = myViewModel.Count.ToString();
                    UserMessage.Text = "자료가 정상적으로 삭제 되었습니다.";
                }
                else
                {
                    UserMessage.Text = "자료삭제에 문제가 있습니다. 시스템 담당자에게 문의하세요.";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
            //--DB Handling(End)-------------------------------------
        }
Example #2
0
 //************************************************************
 //** 입력값의 정합성 Check
 //************************************************************
 private Boolean InputCheck()
 {
     if (myViewModel.Count <= 0)
     {
         MessageBox.Show("저장할 DATA가 없습니다.");
         return(false);
     }
     for (int i = 0; i <= myViewModel.Count - 1; i++)
     {
         UcSubC19ViewModel vm = (UcSubC19ViewModel)myViewModel.ElementAt(i);
         if (vm.DataStatus.Equals(""))
         {
             continue;                             //수정 및 신규입력 자료만 입력 Check
         }
         if (vm.HasError)
         {
             Utility.ShowValidationCheckMsg(vm.GetErrorMsg, i + 1);
             return(false);
         }
     }
     return(true);
 }
Example #3
0
        //************************************************************
        //** 입력 버튼 Click
        //************************************************************
        public void BtnInsert_Click(int type)
        {
            if (authority.Insert.Equals("0"))
            {
                Utility.MsgAuthorityViolation("입력");
                return;
            }
            int rowIndex = tableView.FocusedRowHandle;

            if (dataGrid.SelectedItems.Count < 1)
            {
                rowIndex = -1;
            }
            rowIndex++;
            UcSubC19ViewModel data = new UcSubC19ViewModel();

            myViewModel.Insert(rowIndex, data);
            //----데이터 복제----------------------------------------------------------------------------------
            if ((type == 2) && (dataGrid.SelectedItem != null))
            {
                for (int i = 0; i <= dataGrid.Columns.Count - 1; i++)
                {
                    tableView.Grid.SetCellValue(rowIndex, dataGrid.Columns[i],
                                                tableView.Grid.GetCellValue(rowIndex - 1, dataGrid.Columns[i]));
                }
                data.DataStatus = "A";
            }
            //----데이터 복제----------------------------------------------------------------------------------
            SearchCount.Text = myViewModel.Count.ToString();
            //추가된 Row 선택 및 Focus 이동
            Utility.SelectingFocusingGridControl(dataGrid, tableView, rowIndex);
            //최초 입력 Control로 Focus 이동
            searchText.Focus();

            Utility.SetFuncBtn(MainBtn, "3");
        }
Example #4
0
        //************************************************************
        //** 조회 버튼 Click
        //************************************************************
        public void BtnSearch_Click()
        {
            if (authority.Read.Equals("0"))
            {
                Utility.MsgAuthorityViolation("조회");
                return;
            }

            myViewModel?.Clear();
            //--DB Handling(Start)-------------------------------------
            try
            {
                con = Utility.SetOracleConnection();
                OracleCommand cmd = con.CreateCommand();
                cmd.CommandText = SQLStatement.SelectSQL;
                cmd.Parameters.Add("papr_appno", OracleDbType.Varchar2).Value = searchText.Text + "%";
                OracleDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    var data = new UcSubC19ViewModel
                    {
                        Papr_appno   = dr.GetString(0),
                        Papr_content = dr.GetString(1),
                        Papr_num     = Convert.ToInt32(dr.GetString(2)),
                        Papr_date    = dr.IsDBNull(3) ? "" : Utility.FormatDate(dr.GetString(3)),
                        Key1         = dr.GetString(0),
                        DataStatus   = ""
                    };
                    myViewModel.Add(data);
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
            //--DB Handling(End)-------------------------------------
            SearchCount.Text = myViewModel.Count.ToString();
            if (myViewModel.Count == 0)
            {
                UserMessage.Text = "조건을 만족하는 자료가 없습니다.";
                Utility.SetFuncBtn(MainBtn, "1");
                return;
            }
            {
                UserMessage.Text = "자료가 정상적으로 조회 되었습니다.";
                //**-개인정보 조회 Loging----------------------------
                if (PersonalInfo.Equals("1"))
                {
                    Utility.PersonalInfo_Logging(UserId, UserNm, MyIpAddress, ProgramName, "조회", myViewModel.Count);
                }
                Utility.SelectingFocusingGridControl(dataGrid, tableView, 0);
                Utility.SetFuncBtn(MainBtn, "2");
            }
        }
Example #5
0
        //************************************************************
        //** 저장 버튼 Click (여러 건의 DATA 추가입력/수정 후 저장)
        //************************************************************
        public void BtnSave_Click()
        {
            if (MessageBox.Show("입력 및 수정중인 자료를 저장합니다.", "저장확인", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
            {
                return;
            }

            if (!InputCheck())
            {
                return;
            }

            OracleTransaction tran = null;

            try
            {
                con  = Utility.SetOracleConnection();
                tran = con.BeginTransaction(IsolationLevel.ReadCommitted);
                OracleCommand cmd = con.CreateCommand();
                cmd.Transaction = tran;
                for (int i = 0; i <= myViewModel.Count - 1; i++)
                {
                    UcSubC19ViewModel vm = (UcSubC19ViewModel)myViewModel.ElementAt(i);
                    if (vm.DataStatus.Equals(""))
                    {
                        continue;
                    }
                    if (vm.DataStatus.Equals("A"))
                    {
                        cmd.CommandText = SQLStatement.InsertSQL;
                    }
                    if (vm.DataStatus.Equals("U"))
                    {
                        cmd.CommandText = SQLStatement.UpdateSQL;
                    }

                    cmd.Parameters.Add("papr_appno", OracleDbType.Varchar2).Value   = vm.Papr_appno;
                    cmd.Parameters.Add("papr_content", OracleDbType.Varchar2).Value = vm.Papr_content;
                    cmd.Parameters.Add("papr_num", OracleDbType.Int32).Value        = vm.Papr_num;
                    cmd.Parameters.Add("papr_date", OracleDbType.Varchar2).Value    = Utility.FormatDateR(vm.Papr_date);


                    if (vm.DataStatus.Equals("U"))
                    {
                        cmd.Parameters.Add("key1", OracleDbType.Varchar2).Value = vm.Key1;
                    }
                    cmd.ExecuteNonQuery();
                    cmd.Parameters.Clear();  //*----반드시 포함
                }
                tran.Commit();
            }
            catch (Exception ex)
            {
                tran.Rollback();
                MessageBox.Show(ex.Message);
                return;
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
            //**정상 저장 후 초기화*******************************************************
            for (int i = 0; i <= myViewModel.Count - 1; i++)
            {
                UcSubC19ViewModel vm = (UcSubC19ViewModel)myViewModel.ElementAt(i);
                if (vm.DataStatus.Equals(""))
                {
                    continue;
                }
                vm.Key1       = vm.Papr_appno;
                vm.DataStatus = "";
            }
            dataGrid.RefreshData();
            UserMessage.Text = "자료가 정상적으로 저장 되었습니다.";
            Utility.SetFuncBtn(MainBtn, "2");
        }