Ejemplo n.º 1
0
        /// <summary>
        /// 検索ボタン押下処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Btn_Search_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            if (_BlDivisionSearch == null)
            {
                _BlDivisionSearch = new BLDivisionSearch();
            }

            // 検索条件取得
            _BlDivisionSearch.SearchPrmDivision   = TxtDivision.Text;
            _BlDivisionSearch.SearchPrmDepartment = TxtDepartment.Text;

            // 検索処理(フィールドセット)
            _BlDivisionSearch.getDivisionInfo();
            _SearchResultList = _BlDivisionSearch.SearchResult;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 部署情報取得(検索条件指定)
        /// </summary>
        /// <param name="structure">Trueの場合、構造体のみ返却</param>
        /// <returns></returns>
        public DataTable getDivisionInfo(BLDivisionSearch parent)
        {
            StringBuilder sb      = new StringBuilder();
            StringBuilder sbwork  = new StringBuilder();
            StringBuilder sbwork2 = new StringBuilder();

            sb.AppendLine("SELECT ");
            sb.AppendLine("* ");
            sb.AppendLine("FROM ");
            sb.AppendLine("M_BUSYO_SEKKEI ");
            sb.AppendLine("WHERE ");

            if (parent.SearchPrmDivision != "")
            {
                sbwork.AppendLine("KA_CODE LIKE '@division%' ");
                sbwork = sbwork.Replace("@division", parent.SearchPrmDivision);
            }
            if (parent.SearchPrmDepartment != "")
            {
                if (sbwork.ToString() != "")
                {
                    sbwork.AppendLine("AND ");
                }
                sbwork.AppendLine("BU_CODE LIKE '@department%' ");
                sbwork = sbwork.Replace("@department", parent.SearchPrmDepartment);
            }

            sb.AppendLine(sbwork.ToString());

            sb.AppendLine("UNION ");
            sb.AppendLine("SELECT ");
            sb.AppendLine("* ");
            sb.AppendLine("FROM ");
            sb.AppendLine("M_BUSYO_HYOUKA ");
            sb.AppendLine("WHERE ");

            if (parent.SearchPrmDivision != "")
            {
                sbwork2.AppendLine("KA_CODE LIKE '@division%' ");
                sbwork2 = sbwork2.Replace("@division", parent.SearchPrmDivision);
            }
            if (parent.SearchPrmDepartment != "")
            {
                if (sbwork2.ToString() != "")
                {
                    sbwork2.AppendLine("AND ");
                }
                sbwork2.AppendLine("BU_CODE LIKE '@department%' ");
                sbwork2 = sbwork2.Replace("@department", parent.SearchPrmDepartment);
            }

            sb.AppendLine(sbwork2.ToString());

            // SQL実行
            DataTable dt = new SqlBridging().ExecuteReader(sb.ToString());

            DataColumn[] stringColumns =
                dt.Columns.Cast <DataColumn>()
                .Where(c => c.DataType == typeof(string))
                .ToArray();

            foreach (DataRow row in dt.Rows)
            {
                foreach (DataColumn col in stringColumns)
                {
                    if (row.Field <string>(col) == null)
                    {
                        continue;
                    }
                    row.SetField <string>(col, row.Field <string>(col).Trim());
                }
            }

            return(dt);
        }
Ejemplo n.º 3
0
 public frmDivisionSearch()
 {
     _BLCommon         = new CommonLogic();
     _BlDivisionSearch = new BLDivisionSearch();
     _DbDivisionSearch = new DADivisionSearch();
 }