Example #1
0
 //************************************************************
 //** 입력값의 정합성 Check
 //************************************************************
 private Boolean InputCheck()
 {
     if (myViewModel.Count <= 0)
     {
         MessageBox.Show("저장할 DATA가 없습니다.");
         return(false);
     }
     for (int i = 0; i <= myViewModel.Count - 1; i++)
     {
         UcSubC05ViewModel vm = (UcSubC05ViewModel)myViewModel.ElementAt(i);
         if (vm.DataStatus.Equals(""))
         {
             continue;                             //수정 및 신규입력 자료만 입력 Check
         }
         if (vm.HasError)
         {
             Utility.ShowValidationCheckMsg(vm.GetErrorMsg, i + 1);
             return(false);
         }
     }
     return(true);
 }
Example #2
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++;
            UcSubC05ViewModel data = new UcSubC05ViewModel();

            //----데이터 복제(Start)----------------------------------------------------------------------------------
            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";
            }
            //----데이터 복제(End)----------------------------------------------------------------------------------

            //---초기화 설정(2019.10.15)--------------
            data.Award_empno = award_empno.Text;
            myViewModel.Insert(rowIndex, data);
            SearchCount.Text = myViewModel.Count.ToString();
            //추가된 Row 선택 및 Focus 이동
            Utility.SelectingFocusingGridControl(dataGrid, tableView, rowIndex);
            //최초 입력 Control로 Focus 이동
            award_date.Focus();

            Utility.SetFuncBtn(MainBtn, "3");
        }
Example #3
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.BindByName  = true;
                cmd.Transaction = tran;
                for (int i = 0; i <= myViewModel.Count - 1; i++)
                {
                    UcSubC05ViewModel vm = (UcSubC05ViewModel)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("key1", OracleDbType.Varchar2).Value = vm.Key1;
                        cmd.Parameters.Add("key2", OracleDbType.Varchar2).Value = vm.Key2;
                    }
                    cmd.Parameters.Add("award_empno", OracleDbType.Varchar2).Value   = vm.Award_empno;
                    cmd.Parameters.Add("award_date", OracleDbType.Varchar2).Value    = Utility.FormatDateR(vm.Award_date);
                    cmd.Parameters.Add("award_type", OracleDbType.Varchar2).Value    = vm.Award_type_Cd;
                    cmd.Parameters.Add("award_no", OracleDbType.Varchar2).Value      = vm.Award_no;
                    cmd.Parameters.Add("award_kind", OracleDbType.Varchar2).Value    = vm.Award_kind;
                    cmd.Parameters.Add("award_organ", OracleDbType.Varchar2).Value   = vm.Award_organ;
                    cmd.Parameters.Add("award_content", OracleDbType.Varchar2).Value = vm.Award_content;
                    cmd.Parameters.Add("award_inout", OracleDbType.Varchar2).Value   = vm.Award_inout;
                    cmd.Parameters.Add("award_pos", OracleDbType.Varchar2).Value     = vm.Award_pos;
                    cmd.Parameters.Add("award_dept", OracleDbType.Varchar2).Value    = vm.Award_dept;
                    cmd.Parameters.Add("datasys3", OracleDbType.Varchar2).Value      = string.Concat(UserId, ":", UserNm);

                    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++)
            {
                UcSubC05ViewModel vm = (UcSubC05ViewModel)myViewModel.ElementAt(i);
                if (vm.DataStatus.Equals(""))
                {
                    continue;
                }
                vm.Key1       = vm.Award_empno;
                vm.Key2       = vm.Award_date;
                vm.DataStatus = "";
            }
            dataGrid.RefreshData();
            UserMessage.Text = "자료가 정상적으로 저장 되었습니다.";
            Utility.SetFuncBtn(MainBtn, "2");
        }
Example #4
0
        //************************************************************
        //** 삭제 버튼 Click (삭제는 DATA 1건씩 처리)
        //************************************************************
        public void BtnDelete_Click()
        {
            if (dataGrid.SelectedItems.Count < 1)
            {
                MessageBox.Show("삭제할 자료를 먼저 선택하세요.", "삭제확인", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            UcSubC05ViewModel vm = (UcSubC05ViewModel)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.Award_kind + " 자료를 삭제하시겠습니까?", "삭제확인", 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;
                cmd.Parameters.Add("key2", OracleDbType.Varchar2).Value = vm.Key2;
                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 #5
0
        //*-----------------------------------------------------------
        private void OnMouseDoubleClick()
        {
            if (dataGrid2.SelectedItems.Count <= 0)
            {
                return;
            }

            myViewModel?.Clear();
            DataRowView drv = (DataRowView)dataGrid2.SelectedItem;

            award_empno.Text = (string)drv.Row["bas_empno"];
            bas_name.Text    = (string)drv.Row["bas_name"];
            //--DB Handling(Start)-------------------------------------
            try
            {
                con = Utility.SetOracleConnection();
                OracleCommand cmd = con.CreateCommand();
                cmd.CommandText = SQLStatement.SelectSQL;
                cmd.Parameters.Add("award_empno", OracleDbType.Varchar2).Value = award_empno.Text;
                OracleDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    var data = new UcSubC05ViewModel
                    {
                        Award_empno   = dr.GetString(0),
                        Award_date    = dr.IsDBNull(1) ? "" : Utility.FormatDate(dr.GetString(1)),
                        Award_type    = dr.IsDBNull(2) ? "" : dr.GetString(2),
                        Award_no      = dr.IsDBNull(3) ? "" : dr.GetString(3),
                        Award_kind    = dr.IsDBNull(4) ? "" : dr.GetString(4),
                        Award_organ   = dr.IsDBNull(5) ? "" : dr.GetString(5),
                        Award_content = dr.IsDBNull(6) ? "" : dr.GetString(6),
                        Award_inout   = dr.IsDBNull(7) ? "" : dr.GetString(7),
                        Award_pos     = dr.IsDBNull(8) ? "" : dr.GetString(8),
                        Award_dept    = dr.IsDBNull(9) ? "" : dr.GetString(9),

                        Key1       = dr.GetString(0),
                        Key2       = dr.GetString(1),
                        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 = "자료가 정상적으로 조회 되었습니다.";
            Utility.SelectingFocusingGridControl(dataGrid, tableView, 0);
            Utility.SetFuncBtn(MainBtn, "2");
        }