三层架构

http://blog.csdn.net/hanxuemin12345/article/details/8544957 

1三层开发(软件项目开发)

三层结构为:
1.表示层(USL - User Show Layer):主要表示WEB方式,也可以表示成WINFORM方式。如果逻辑层相当强大和完善,无论表现层如何定义和更改,逻辑层都能完善地提供服务。
2.业务逻辑层(BLL-Business Logic Layer):主要是针对具体的问题的操作,也可以理解成对数据层的操作,对数据业务逻辑处理。如果说数据层是积木,那逻辑层就是对这些积木的搭建。
3.数据访问层(DAL - Data Access Layer):主要是对原始数据(数据库或者文本文件等存放数据的形式)的操作层,而不是指原始数据,也就是说,是对数据的操作,而不是数据库,具体为业务逻辑层或表示层提供数据服务。

2作用

业务逻辑层的作用:
业务逻辑层(Business Logic Layer)无疑是系统架构中体现核心价值的部分。它的关注点主要集中在业务规则的制定、业务流程的实现等与业务需求有关的系统设计,也即是说它是与系统所应对的领域(Domain)逻辑有关,很多时候,也将业务逻辑层称为领域层。例如Martin Fowler在《Patterns of Enterprise Application Architecture》一书中,将整个架构分为三个主要的层:表示层、领域层和数据源层。作为领域驱动设计的先驱Eric Evans,对业务逻辑层作了更细致地划分,细分为应用层与领域层,通过分层进一步将领域逻辑与领域逻辑的解决方案分离。
业务逻辑层在体系架构中的位置很关键,它处于数据访问层与表示层中间,起到了数据交换中承上启下的作用。由于层是一种弱耦合结构,层与层之间的依赖是向下的,底层对于上层而言是“无知”的,改变上层的设计对于其调用的底层而言没有任何影响。如果在分层设计时,遵循了面向接口设计的思想,那么这种向下的依赖也应该是一种弱依赖关系。因而在不改变接口定义的前提下,理想的分层式架构,应该是一个支持可抽取、可替换的“抽屉”式架构。正因为如此,业务逻辑层的设计对于一个支持可扩展的架构尤为关键,因为它扮演了两个不同的角色。对于数据访问层而言,它是调用者;对于表示层而言,它却是被调用者。依赖与被依赖的关系都纠结在业务逻辑层上,如何实现依赖关系的解耦,则是除了实现业务逻辑之外留给设计师的任务。
◆项目构成
 
◆表示层-USL
------------------------------------------
PageBase.cs
using System;
using System.Configuration;
using System.Collections.Generic;
using System.Data;
using System.Web.UI.WebControls;
using System.Text;
using Otsuka.Application.Common;
using Otsuka.Application.Common.Exception;
using Otsuka.Application.Bll;
using System.Diagnostics;
using System.IO;

/// <summary>
/// ページの基底クラス
/// </summary>
public class PageBase : System.Web.UI.Page
{
    private static string sendMailExePath = null;

    static PageBase()
    {
        sendMailExePath = ConfigurationManager.AppSettings["SendMailExePath"];
    }

    private string _displayName = null;
    //リダイレクト用セッション設定変数
    private Dictionary<string, object> _setParameters = new Dictionary<string, object>();
    //リダイレクト用セッション取得変数
    private Dictionary<string, object> _getParameters = null;

    //ポップアップブロック用セッション設定変数
    private Dictionary<string, object> _setPopUpBlockParameters = new Dictionary<string, object>();


    protected const string EVENT_TYPE_ON_BLUR = "ON_BLUR";
    protected const string EVENT_TYPE_ON_FOCUS = "ON_FOCUS";
    protected const string EVENT_TYPE_ON_CHANGE = "ON_CHANGE";
    protected const string EVENT_TYPE_ON_DBL_CLICK = "ON_DBL_CLICK";

    #region プロパティ

    /// <summary>
    /// 申請者情報
    /// </summary>
    public StaffInfo StaffInfo { set; get; }

    /// <summary>
    /// ログイン者情報
    /// </summary>
    public StaffInfo SysStaffInfo { set; get; }

    /// <summary>
    /// 画面名
    /// </summary>
    public string DisplayName
    {
        get
        {
            return _displayName;
        }
    }

    #endregion



    /// <summary>
    /// コンストラクタ
    /// </summary>
    public PageBase()
    {
        Load += new EventHandler(PageBase_Load);
    }

    /// <summary>
    /// ページロードイベント
    /// </summary>
    protected void PageBase_Load(object sender, EventArgs e)
    {
        WebLogUtility.WriteDebugLog("=====> PageBase_Load =====>");
        WebLogUtility.WriteDebugLog("----- Session -----");
        WebLogUtility.WriteDebugLogHttpSession(Session);

        // セッションの存在確認をする
        if (Session[ConstValue.SESSION_KEY_IS_AUTHENTICATED] == null)
        {
            throw new SessionTimeoutException();
        }

        this.StaffInfo = Session[ConstValue.SESSION_KEY_STAFF_INFO] as StaffInfo;

        _displayName = GetDisplayName();

        //画面アクセス権限チェック
        CheckDisplayAuth();

        //リダイレクト用セッションの設定
        SetRedirectSessionToPrivate();

        WebLogUtility.WriteDebugLog("----- Members -----");
        WebLogUtility.WriteDebugLog("LoginNtUserCd:[{0}]", StaffInfo.NtUserCd);
        WebLogUtility.WriteDebugLog("LoginUserIP:[{0}]", StaffInfo.Ip);
        WebLogUtility.WriteDebugLog("LoginUserStfCd:[{0}]", StaffInfo.StfCd);
        WebLogUtility.WriteDebugLog("LoginUserStfNm:[{0}]", StaffInfo.StfNm);
        WebLogUtility.WriteDebugLog("LoginUserCstCd:[{0}]", StaffInfo.CstCd);
        WebLogUtility.WriteDebugLog("LoginUserCstNm:[{0}]", StaffInfo.CstNm);
        WebLogUtility.WriteDebugLog("LoginUserScnNm:[{0}]", StaffInfo.ScnNm);
        WebLogUtility.WriteDebugLog("LoginUserSbrCd:[{0}]", StaffInfo.SbrCd);
        WebLogUtility.WriteDebugLog("LoginUserSbrNm:[{0}]", StaffInfo.SbrNm);
        WebLogUtility.WriteDebugLog("LoginUserBrnCd:[{0}]", StaffInfo.BrnCd);
        WebLogUtility.WriteDebugLog("LoginUserBrnNm:[{0}]", StaffInfo.BrnNm);
        WebLogUtility.WriteDebugLog("LoginUserDivOrgCd:[{0}]", StaffInfo.DivOrgCd);
        WebLogUtility.WriteDebugLog("LoginUserDivOrgNm:[{0}]", StaffInfo.DivOrgNm);
        WebLogUtility.WriteDebugLog("LoginUserManagedOrgLevel:[{0}]", StaffInfo.ManagedOrgLevel);
        WebLogUtility.WriteDebugLog("DisplayName:[{0}]", _displayName);

        WebLogUtility.WriteDebugLog("<===== PageBase_Load <=====");

    }

    /// <summary>
    /// BLLの実行処理
    /// </summary>
    /// <param name="bllClass">実行するBLLクラスの型</param>
    /// <param name="parameter">BLLに渡すパラメータ</param>
    /// <returns>BLLからの返却値</returns>
    protected virtual ResponseDataType InvokeBll(Type bllClass, Dictionary<string, object> parameter)
    {
        BllBase bllObject = (BllBase)bllClass.Assembly.CreateInstance(bllClass.FullName);

        bllObject.StaffInfo = StaffInfo;
        bllObject.DisplayName = _displayName;

        return bllObject.Execute(parameter);
    }

    /// <summary>
    /// BLL EXの実行処理
    /// </summary>
    /// <param name="bllClass">実行するBLL EXクラスの型</param>
    /// <param name="parameter">BLLに渡すパラメータ</param>
    /// <returns>BLLからの返却値</returns>
    protected virtual ResponseDataType InvokeBllEx(Type bllClass, Dictionary<string, object> parameter)
    {
        BllBaseEx bllObject = (BllBaseEx)bllClass.Assembly.CreateInstance(bllClass.FullName);

        bllObject.StaffInfo = StaffInfo;
        bllObject.DisplayName = _displayName;

        return bllObject.Execute(parameter);
    }

    /// <summary>
    /// BLLの実行処理
    /// </summary>
    /// <param name="bllClass">実行するBLLクラスの型</param>
    /// <returns>BLLからの返却値</returns>
    public ResponseDataType InvokeBll(Type bllClass)
    {
        return InvokeBll(bllClass, null);
    }

    /// <summary>
    /// BLLの実行処理
    /// </summary>
    /// <param name="bllClass">実行するBLLクラスの型</param>
    /// <returns>BLLからの返却値</returns>
    public ResponseDataType InvokeBllEx(Type bllClass)
    {
        return InvokeBllEx(bllClass, null);
    }

    /// <summary>
    /// パラメータに指定されたページへのリダイレクトを行なう
    /// </summary>
    /// <param name="page">リダイレクト先のローカルURL</param>
    protected void PageRedirect(string page)
    {
        // ページ履歴を格納する
        Stack<string> pageStack = (Stack<string>)Session[ConstValue.SESSION_KEY_PAGE_STACK];

        if (pageStack == null)
        {
            pageStack = new Stack<string>();
            Session[ConstValue.SESSION_KEY_PAGE_STACK] = pageStack;
        }

        pageStack.Push(Request.Url.LocalPath + Request.Url.Query);

        Response.Redirect(page, true);
    }

    /// <summary>
    /// パラメータに指定されたページへのリダイレクトを行なう
    /// 履歴には指定された値を設定する
    /// </summary>
    /// <param name="page">リダイレクト先のローカルURL</param>
    /// <param name="from">履歴に追加するローカルURL</param>
    protected void PageRedirect(string page, string from)
    {
        // ページ履歴を格納する
        Stack<string> pageStack = (Stack<string>)Session[ConstValue.SESSION_KEY_PAGE_STACK];

        if (pageStack == null)
        {
            pageStack = new Stack<string>();
            Session[ConstValue.SESSION_KEY_PAGE_STACK] = pageStack;
        }

        pageStack.Push(from);

        Response.Redirect(page, true);
    }

    /// <summary>
    /// 画面名を取得する
    /// </summary>
    /// <returns>画面名</returns>
    public string GetDisplayName()
    {
        string displayName = string.Empty;
        string[] splitValue = Request.FilePath.Split('/');
        displayName = splitValue[splitValue.Length - 1].Replace(".aspx", "");

        return displayName;
    }

    /// <summary>
    /// 変更検知フラグをOffにする
    /// </summary>
    protected void ChangeFlagOff()
    {
        HiddenField hiddenChangeFlg = (HiddenField)Master.FindControl("hiddenChangeFlg");
        hiddenChangeFlg.Value = "0";
    }

    /// <summary>
    /// 画面アクセス権限チェック
    /// </summary>
    private void CheckDisplayAuth()
    {
        // TODO 認証・アクセス制御
    }

    /// <summary>
    /// リダイレクト引渡しパラメータの設定
    /// </summary>
    /// <param name="key">キー</param>
    /// <param name="value"></param>
    public void SetRedirectParam(string key, object value)
    {
        _setParameters[key] = value;
        Session[ConstValue.SESSION_KEY_REDIRECT] = _setParameters;
    }

    /// <summary>
    /// リダイレクト引渡しパラメータの取得
    /// </summary>
    /// <param name="key">キー</param>
    /// <returns>リダイレクト引渡しパラメータ</returns>
    public object GetRedirectKeyParam(string key)
    {
        if (_getParameters == null)
        {
            return null;
        }

        if (!_getParameters.ContainsKey(key))
        {
            return null;
        }

        return _getParameters[key];
    }

    /// <summary>
    /// リダイレクト引渡しパラメータのオブジェクト取得
    /// </summary>
    /// <returns></returns>
    public Dictionary<string, object> GetRedirectDictionaryParam()
    {
        return _getParameters;
    }

    /// <summary>
    /// リダイレクト用セッションの設定
    /// </summary>
    private void SetRedirectSessionToPrivate()
    {
        _getParameters = (Dictionary<string, object>)Session[ConstValue.SESSION_KEY_REDIRECT];
        Session.Remove(ConstValue.SESSION_KEY_REDIRECT);
    }

    /// <summary>
    /// ポップアップブロック対策用パラメータの設定
    /// </summary>
    /// <param name="key">キー</param>
    /// <param name="value"></param>
    public void SetPopUpBlockParam(string key, object value)
    {
        _setPopUpBlockParameters[key] = value;
        Session[ConstValue.SESSION_KEY_POP_UP_BLOCK] = _setPopUpBlockParameters;
    }

    /// <summary>
    /// ポップアップブロック対策用パラメータの取得
    /// </summary>
    /// <param name="key">キー</param>
    /// <returns>リダイレクト引渡しパラメータ</returns>
    public object GetPopUpBlockKeyParam(string key)
    {
        if (Session[ConstValue.SESSION_KEY_POP_UP_BLOCK] == null)
        {
            return null;
        }

        if (!((Dictionary<string, object>)Session[ConstValue.SESSION_KEY_POP_UP_BLOCK]).ContainsKey(key))
        {
            return null;
        }

        Dictionary<string, object> sessionPopUpKey = (Dictionary<string, object>)Session[ConstValue.SESSION_KEY_POP_UP_BLOCK];
        return sessionPopUpKey[key];
    }


    /// <summary>
    /// ポップアップブロック用セッションの削除
    /// </summary>
    protected void RemovePopUpBlockSession()
    {
        Session.Remove(ConstValue.SESSION_KEY_POP_UP_BLOCK);
    }

    /// <summary>
    /// 文字列のエスケープ
    /// GridViewでの自動エスケープにより表示が乱れる箇所で利用する
    /// エスケープ一覧
    /// [&quot;] → ["]
    /// [&amp;] → [&]
    /// [&lt;] → [<]
    /// [&gt;] → [>]
    /// </summary>
    /// <param name="value"></param>
    /// <returns></returns>
    protected string EscapeForGridView(string value)
    {
        if (value == null)
        {
            return value;
        }
        else
        {
            return value.Replace("&quot;", """).Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");
        }
    }

    /// <summary>
    /// 文字列のエスケープ
    /// JavaScriptでエラーが発生する箇所で利用する
    /// [']→[\']
    /// </summary>
    /// <param name="value"></param>
    /// <returns></returns>
    protected string EscapeForJavaScript(string value)
    {
        if (value == null)
        {
            return value;
        }
        else
        {
            return value.Replace("'", "\'");
        }
    }

    /// <summary>
    /// ドロップリストボックスのコレクションの指定のコードが存在するかどうかを確認する
    /// </summary>
    /// <param name="targetCode">指定のコード</param>
    /// <param name="targetItems">ドロップリストボックスのアイテムコレクション</param>
    /// <returns>指定のコードが存在するときtrue、存在しないときfalse</returns>
    public bool ExistCodeInItems(string targetCode, ListItemCollection targetItems)
    {
        foreach (ListItem item in targetItems)
        {
            if (targetCode == item.Value)
            {
                return true;
            }
        }

        return false;
    }

    /// <summary>
    /// メッセージダイアログを表示する
    /// </summary>
    /// <param name="message">表示するメッセージ</param>
    protected void GenerateMessageJavaScript(string message)
    {
        StringBuilder script = new StringBuilder();
        script.Append("<script type=text/javascript>");
        script.Append("alert('");
        script.Append(message);
        script.Append("');");
        script.Append("</script>");
        Page.ClientScript.RegisterClientScriptBlock(typeof(string), "ErrorMessageScript", script.ToString());
    }

    /// <summary>
    /// メッセージを表示後にPostBackするJavaScriptを書き出す
    /// </summary>
    /// <param name="StrConfirmMsg">メッセージ文字列</param>
    /// <param name="strSetscriptName">スクリプト表示領域を表す文字列</param>
    /// <param name="strHiddenFieldUniqueId">HiddenField.UniqueId</param>
    /// <remarks>HiddenField.ValueChangedイベントを使ってPostBack後の処理を記載する。HiddenFieldの値は、そこで空文字列に戻すこと</remarks>
    protected void GenerateMessageAndPostBack(string strConfirmMsg , string strSetscriptName , string strHiddenFieldUniqueId )
    {
        if (! Page.ClientScript.IsStartupScriptRegistered(strSetscriptName) )
        {
            StringBuilder script = new StringBuilder();

            script.Append("alert('").Append(strConfirmMsg).AppendLine("');");
            script.Append("setTimeout(function(){").AppendLine();
            script.Append("    document.getElementById('").Append(strHiddenFieldUniqueId).AppendLine("').value = '1';");
            script.Append("    __doPostBack('").Append(strHiddenFieldUniqueId).AppendLine("','');");
            script.Append("},0);").AppendLine();

            Page.ClientScript.RegisterStartupScript(typeof(string), strSetscriptName, script.ToString(), true);
        }
    }

    /// <summary>
    /// 申請資材用のスクリプトを生成する
    /// </summary>
    protected void GenerateViewMaterials(string applicationNo)
    {
        string materialsPath = ConfigurationManager.AppSettings["MaterialsReferencePath"];

        StringBuilder script = new StringBuilder();
        //ADD:SCSK-KAIYO:20141031:2-4:START
        // 申請番号ディレクトリの作成
        DirectoryInfo applicationDirectory = new DirectoryInfo(materialsPath + "\" + applicationNo);
        if (applicationDirectory.Exists)
        {
            script.Append("<script type=text/javascript>");
            script.Append("function viewMaterials(){");
            script.Append("location.href = '");
            script.Append(materialsPath);
            script.Append("\\");
            script.Append(applicationNo);
            script.Append("';");
            script.Append("}");
            script.Append("</script>");
        }
        else
        {
            script.Append("<script type=text/javascript>");
            script.Append("function viewMaterials(){");
            script.Append("alert('");
            script.Append("指定したディリクトリが存在しません");
            script.Append("' + '\n\r' + '");
            script.Append(materialsPath + "\\" + applicationNo);
            script.Append("');");
            script.Append("}");
            script.Append("</script>");
        }
        //ADD:SCSK-KAIYO:20141031:2-4:END

        //DEL:SCSK-KAIYO:20141031:2-4:START
        //script.Append("<script type=text/javascript>");
        //script.Append("function viewMaterials(){");
        //script.Append("location.href = '");
        //script.Append(materialsPath);
        //script.Append("\\");
        //script.Append(applicationNo);
        //script.Append("';");
        //script.Append("}");
        //script.Append("</script>");
        //DEL:SCSK-KAIYO:20141031:2-4:END
        Page.ClientScript.RegisterClientScriptBlock(typeof(string), "ViewMaterialsScript", script.ToString());
    }
    //ADD:SCSK:20141113:2-4:START
    /// <summary>
    /// 申請資材用のスクリプトを生成する
    /// </summary>
    protected void GenerateViewMaterialsListVer(string materialsPath)
    {

        StringBuilder script = new StringBuilder();

            script.Append("<script type=text/javascript>");
            script.Append("function viewMaterialsList(applicationNo){");
            script.Append("location.href = '");
            script.Append(materialsPath);
            script.Append("\\'");
            script.Append(" + applicationNo");
            script.Append(";");
            script.Append("}");
            script.Append("</script>");
            script.Append("<script type=text/javascript>");
            script.Append("function viewMaterialsListNoDrect(applicationNo){");
            script.Append("alert('");
            script.Append("指定したディリクトリが存在しません");
            script.Append("' + '\n\r' + '");
            script.Append(materialsPath + "\\' + applicationNo");
            script.Append(");");
            script.Append("}");
            script.Append("</script>");

        Page.ClientScript.RegisterClientScriptBlock(typeof(string), "ViewMaterialsListScript", script.ToString());
        
    }
    //ADD:SCSK:20141113:2-4:END


    /// <summary>
    /// メール送信プログラムを起動する<br />
    /// トランザクションがコミットされた後に実行すること
    /// </summary>
    protected void RunSendMail()
    {
        // メール送信
        Process.Start(sendMailExePath);
    }

}
View Code

ApplicationMenu.master

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="ApplicationMenu.master.cs"
    Inherits="ApplicationMenu" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%-- 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
--%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Expires" content="Thu, 01 Dec 1994 16:00:00 GMT" />
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <link href="../App_Themes/Application/Application.css" rel="stylesheet" type="text/css" />
    <title>プロモーション用資材申請システム</title>

    <script type="text/javascript" src="../js/common.js"></script>

    <script type="text/javascript" src="../js/application.js"></script>

    <script type="text/javascript" src="../js/jquery-1.3.2.min.js"></script>

    <script type="text/javascript">
        /// --------------------------
        /// BackSpaceを無効にする
        /// --------------------------
        window.document.onkeydown = onKeyDown;
        function onKeyDown(e) {

            if (navigator.appName == "Microsoft Internet Explorer") {
                var t;
                var e = window.event.srcElement;
                t = window.event.srcElement.type;
                //テキストボックス、パスワードボックスは許す
                if (t == "text") {
                    if (e.readOnly == true) {
                        return false;
                    } else {
                        return true;
                    }
                }
                if (t == "password") return true;
                //テキストエリアは許す 
                if (t == "textarea") return true;

                if (event.keyCode == 8) {
                    return false;
                }
            } else
                if (navigator.appName == "Netscape") {
                if (e.which == 8) {
                    return false;
                }
            }
        }  
    </script>

    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body onload="setScroll()">
    <form id="form1" runat="server" defaultbutton="DummyButton">
    <table style="background-color: white;  100%" cellspacing="0" cellpadding="0"
        border="0">
        <tr>
            <td colspan="2" style=" 100%; height: 12px; text-align: right; background: #272727;
                font-family: Verdana; color: #5a5a5a; font-size: x-small">
                Powered by SCSK Corp.
            </td>
        </tr>
        <tr>
            <td style=" 80%; height: 57px; background-color: #393842; background-repeat: no-repeat;
                background-image: url('../img/ApplicationTitle.gif'); text-align:center; padding-left: 20px; padding-right: 10px; padding-bottom: 0px;
                color: White; font-weight: bold">          
            <asp:Label ID="lblEnvironment" runat="server" CssClass="environmentDisp"></asp:Label>
            
            </td>
            <td style=" 20%; height: 30px; background-color: #393842; background-repeat: no-repeat;
                text-align: center; padding-bottom: 0px;">
                <asp:LinkButton ID="linkMenu" CssClass="closeLink" runat="server" OnClientClick="return modifyCheck('登録');"
                    OnClick="linkMenu_Click">メニューにもどる</asp:LinkButton>
                 
                <asp:LinkButton ID="linkClose" CssClass="closeLink" runat="server" OnClientClick="return modifyCheck('登録');"
                    OnClick="linkClose_Click">閉じる</asp:LinkButton>
            </td>
        </tr>
        <tr>
            <td colspan="2" style=" 100%; height: 9px; background-image: url('../img/TtileShadow.gif');
                background-repeat: repeat; margin: 0px; padding: 0px;">
            </td>
        </tr>
    </table>
    <table border="0" cellspacing="0" width="100%">
        <tr>
            <td style=" 50%; padding-left: 10px; color: #393c42;" align="left">
                こんにちは、<strong><asp:Label ID="lblUserName" runat="server" Text="氏名"></asp:Label></strong>&nbsp;さん
                <asp:HiddenField ID="hiddenChangeFlg" runat="server" Value="0" />
                <asp:HiddenField ID="hiddenScrollVertical" runat="server" />
                <asp:HiddenField ID="hiddenScrollHorizon" runat="server" />
                <asp:Button ID="DummyButton" runat="server" OnClientClick="return false;" Text=""
                    Width="0px" Height="0px" />
                <strong>&nbsp;権限&nbsp;:&nbsp;<asp:Label ID="lblNowAuth" runat="server" Text="権限名"></asp:Label>&nbsp;</strong>&nbsp;
            </td>
            <td style=" 50%; padding-left: 10px; color: #393c42;" align="right">
            </td>
        </tr>
    </table>
    <div style="text-align: left">
        <asp:ContentPlaceHolder ID="contentPlaceHolder" runat="server">
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>
View Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using Otsuka.Application.Common;
using System.Configuration;

public partial class ApplicationMenu : System.Web.UI.MasterPage
{
    /// <summary>
    /// 変更破棄フラグ
    /// </summary>
    /// <value>変更有の場合True</value>
    public bool IsChanged
    {
        get
        {
            return hiddenChangeFlg.Value == "1";
        }
        set
        {
            if (value)
            {
                hiddenChangeFlg.Value = "1";

            }
            else
            {
                hiddenChangeFlg.Value = "0";
            }
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        //2014116:本番/検証環境接続先識別対応:START
        lblEnvironment.Text = ConfigurationManager.AppSettings["EnvironmentDisp"];
        //2014116:本番/検証環境接続先識別対応:END

        if (!IsPostBack)
        {
            PageBase page = (PageBase)this.Page;
            lblUserName.Text = page.StaffInfo.StfNm;
            lblNowAuth.Text = page.StaffInfo.RoleNm;
        }


        // JavaScriptを生成する
        StringBuilder script = new StringBuilder();
        script.Append("<script type=text/javascript>");

        // --------------------------------------------------
        // 入力項目変更フラグに'1'を設定する。
        // --------------------------------------------------
        script.Append("function ChangeFlagOn() {");
        // 変更フラグ項目を取得
        script.Append("    isChangedElement = window.document.getElementById('" + hiddenChangeFlg.ClientID + "');");
        script.Append("    if (isChangedElement == null) return;");
        script.Append("    isChangedElement.value = '1'");
        script.Append("} ");

        // --------------------------------------------------
        // 変更破棄確認処理
        // --------------------------------------------------
        script.Append("function modifyCheck(procName) {");
        script.Append("    var msg = "" + Messages.CONFIRM002 + "".replace('{0}', procName);");
        // 変更フラグ項目を取得
        script.Append("    isChangedElement = window.document.getElementById('" + hiddenChangeFlg.ClientID + "');");
        script.Append("    if (isChangedElement.value == '1') {");
        script.Append("            return confirm(msg);");
        script.Append("    }");
        script.Append("    return true;");
        script.Append("} ");

        // スクロール位置を反映する処理を追加
        script.Append("function setScroll(){");
        script.Append("setWindowScroll('" + hiddenScrollVertical.ClientID + "','" + hiddenScrollHorizon.ClientID + "');");
        script.Append("}");
        script.Append("function getScroll(){");
        script.Append("getWindowScroll('" + hiddenScrollVertical.ClientID + "','" + hiddenScrollHorizon.ClientID + "');");
        script.Append("}");

        // 変更フラグ取得
        script.Append("function isChanged() {");
        // 変更フラグ項目を取得
        script.Append("    isChangedElement = window.document.getElementById('" + hiddenChangeFlg.ClientID + "');");
        script.Append("    if (isChangedElement.value == '1') {");
        script.Append("            return true;");
        script.Append("    }");
        script.Append("    return false;");
        script.Append("} ");

        script.Append("</script>");
        Page.ClientScript.RegisterClientScriptBlock(typeof(string), "ApplicationPageScript", script.ToString());
    }

    /// <summary>
    /// 閉じるボタン押下時処理
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void linkClose_Click(object sender, EventArgs e)
    {
        Stack<string> pageStack = (Stack<string>)Session[ConstValue.SESSION_KEY_PAGE_STACK];

        if (pageStack != null && pageStack.Count != 0)
        {
            string previousPage = pageStack.Pop();

            if (!CheckUtility.IsEmpty(previousPage))
            {
                Response.Redirect(previousPage);
            }
        }
        else
        {
            // 画面を閉じる(IEの確認ダイアログを表示させない)
            Page.ClientScript.RegisterStartupScript(typeof(string), "CloseScript", "<script type=text/javascript>(window.open('','_self').opener=window).close();</script>");
        }
    }

    protected void linkMenu_Click(object sender, EventArgs e)
    {
        Stack<string> pageStack = (Stack<string>)Session[ConstValue.SESSION_KEY_PAGE_STACK];

        if (pageStack != null && pageStack.Count != 0)
        {
            pageStack.Clear();
        }

        Response.Redirect("Menu.aspx");
    }
}
View Code

 ApplicationList.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Form/ApplicationMenu.master" AutoEventWireup="true"
    CodeFile="ApplicationList.aspx.cs" Inherits="Form_ApplicationList" %>

<%@ Import Namespace="Otsuka.Application.Common" %>
<%@ Register Assembly="Otsuka.Application.Control" Namespace="Otsuka.Application.Control"
    TagPrefix="ac" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<%--ADD:SCSK-KAIYO:20141022:2-1:START --%>
 <%--<script type="text/javascript" language="javascript">
        // 提示メッセージ出力
     function alertMessage(path) {
         return alert("指定したディリクトリが存在しません
" + path);
        }
    </script>--%>
<%--ADD:SCSK-KAIYO:20141022:2-1:END--%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="contentPlaceHolder" runat="Server">
    <asp:HiddenField ID="hdnApplicantStaff" runat="server" />
    <asp:HiddenField ID="hdnApplicantDivision" runat="server" />
    <asp:HiddenField ID="hdnApplicantStaffName" runat="server" />
    <asp:HiddenField ID="hdnApplicantDivisionName" runat="server" />
    <asp:HiddenField ID="hdnDrug" runat="server" />
    <asp:HiddenField ID="hdnProduct" runat="server" />
    <asp:HiddenField ID="hdnDrugName" runat="server" />
    <asp:HiddenField ID="hdnProductName" runat="server" />

    <table width="100%" class="ScreenTable">
        <tr>
            <td class="menuTitle" style=" 20%">
                <asp:Label ID="lblTitle" runat="server" Text="申請検索"></asp:Label>
            </td>
            <td class="menuTitle" style=" 80%; text-align: right">
                <asp:Button CssClass="button fontSizeSmaller" ID="btnSearch" runat="server" Text="検索"
                    Visible="true" OnClick="btnSearch_Click" />
                <asp:Button CssClass="button fontSizeSmaller" ID="btnOutputResult" runat="server"
                    Text="検索結果出力" Visible="true" OnClick="btnOutputResult_Click" />
            </td>
        </tr>
    </table>
    <br />
    <table class="borderedTable" style=" 99%;">
        <tr>
            <td class="TDTitle" style=" 15%">
                申請番号
            </td>
            <td class="TDValueNoBorder" style=" 15%">
                <asp:TextBox runat="server" ID="txtApplicationNo" CssClass="textboxImeDisabled" MaxLength="11" />
            </td>
            <td class="TDTitleHeader" style=" 15%">
                資材媒体
            </td>
            <td class="TDValueNoBorder" style=" 15%">
                <ac:ApplicationDropDownList ID="ddlMaterialsInfo" runat="server" Editable="True"
                    Width="99%" DataSourceID="MaterialsInfoLinqDataSource" DataTextField="MATERIALS_NM_KNJ"
                    DataValueField="MATERIALS_CODE" IsScriptExec="false"  AppendDataBoundItems="true" OnDataBound ="ddlMaterialsInfo_DataBound">
                    <asp:ListItem Value="" Text="" />
                </ac:ApplicationDropDownList>
                <asp:LinqDataSource ID="MaterialsInfoLinqDataSource" runat="server" ContextTypeName="Otsuka.Application.Dal.ApplicationDataContext"
                    OrderBy="MATERIALS_DIV_DISP_ORDER" Select="new (MATERIALS_CODE, MATERIALS_NM_KNJ)"
                    TableName="MATERIALS_INFO" Where="DEL_FLG != @DEL_FLG">
                    <WhereParameters>
                        <asp:Parameter DefaultValue="1" Name="DEL_FLG" Type="Char" />
                    </WhereParameters>
                </asp:LinqDataSource>
            </td>
            <td class="TDTitleHeader" style=" 15%">
                資材分類
            </td>
            <td class="TDValueNoBorder" style=" 25%">
                <ac:ApplicationDropDownList ID="ddlMaterialsClassInfo" runat="server" Editable="True"
                    Width="99%" DataSourceID="MaterialsClassInfoLinqDataSource" DataTextField="MATERIALS_CLASS_NM_KNJ"
                    DataValueField="MATERIALS_CLASS_CODE" IsScriptExec="false" AppendDataBoundItems="true" OnDataBound ="ddlMaterialsClassInfo_DataBound">
                    <asp:ListItem Value="" Text="" />
                </ac:ApplicationDropDownList>
                <asp:LinqDataSource ID="MaterialsClassInfoLinqDataSource" runat="server" ContextTypeName="Otsuka.Application.Dal.ApplicationDataContext"
                    OrderBy="MATERIALS_CLASS_DISP_ORDER" Select="new (MATERIALS_CLASS_CODE, MATERIALS_CLASS_NM_KNJ)"
                    TableName="MATERIALS_CLASS_INFO" Where="DEL_FLG != @DEL_FLG">
                    <WhereParameters>
                        <asp:Parameter DefaultValue="1" Name="DEL_FLG" Type="Char" />
                    </WhereParameters>
                </asp:LinqDataSource>
            </td>
        </tr>
        <tr>
            <td class="TDTitle" style=" 15%">
                統一コード
            </td>
            <td class="TDValueNoBorder" style=" 15%">
                <asp:TextBox runat="server" ID="txtUniformCode" CssClass="textboxImeDisabled" MaxLength="10" />
            </td>
            <td class="TDTitleHeader" style=" 15%">
                資材名称
            </td>
            <td class="TDValueNoBorder" style=" 55%" colspan="3">
                <asp:TextBox runat="server" ID="txtmaterialsNameKnj" CssClass="textboxImeOn" MaxLength="255"
                    Style=" 100%;" />
            </td>
        </tr>
        <tr>
            <td class="TDTitle" style=" 15%">
                発注品番
            </td>
            <td class="TDValueNoBorder" style=" 15%">
                <asp:TextBox runat="server" ID="txtOrderPart" CssClass="textboxImeDisabled" MaxLength="5"
                    Style=" 40px;" />
            </td>
            <td class="TDTitleHeader" style=" 15%">
                申請部署/申請者
            </td>
            <td class="TDValueNoBorder" style=" 15%">
                <asp:TextBox runat="server" ID="txtApplicantDivision" ReadOnly="true" Style=" 100%;" />
            </td>
            <td class="TDValueNoBorder" style=" 15%">
                <asp:TextBox runat="server" ID="txtApplicantStaff" ReadOnly="true" Style=" 100%;" />
            </td>
            <td class="TDValueNoBorder" style=" 25%">
                <asp:Button runat="server" ID="btnStaffFind" Text="申請者選択" CssClass="button fontSizeSmaller" OnClientClick ="selectApplicant();return false;"/>
                <asp:Button runat="server" ID="btnStaffClear" Text="クリア" CssClass="button fontSizeSmaller" OnClientClick ="clearApplicant();return false;"/>
            </td>
        </tr>
        <tr>
            <td class="TDTitle" style=" 15%">
                資材管理番号
            </td>
            <td class="TDValueNoBorder" style=" 15%">
                <asp:TextBox runat="server" ID="txtMaterialsNo" CssClass="textboxImeDisabled " MaxLength="16" />
            </td>
            <td class="TDTitleHeader" style=" 15%">
                薬剤/製品
            </td>
            <td class="TDValueNoBorder" style=" 15%">
                <asp:TextBox runat="server" ID="txtDrug" ReadOnly="true" Style=" 100%;" />
            </td>
            <td class="TDValueNoBorder" style=" 15%">
                <asp:TextBox runat="server" ID="txtProduct" ReadOnly="true" Style=" 100%;" />
            </td>
            <td class="TDValueNoBorder" style=" 25%">
                <asp:Button runat="server" ID="btnDrugProductFind" Text="薬剤/製品選択" CssClass="button fontSizeSmaller" OnClientClick ="selectDrugAndProd();return false;"/>
                <asp:Button runat="server" ID="btnDrugProductClear" Text="クリア" CssClass="button fontSizeSmaller" OnClientClick ="clearDrugAndProd();return false;"/>
            </td>
        </tr>
        <tr>
            <td class="TDTitleHeader" style=" 15%">
                申請
            </td>
            <td class="TDValueNoBorder" style=" 30%" colspan="3">
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkApplicantSave" Text="作成中" Checked="true" />
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkApplicantApply" Text="上長提出中" Checked="true"/>
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkSuperiorApprove" Text="上長承認済" Checked="true"/>
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkSuperiorSendBack" Text="差し戻し" Checked="true"/>
                <%--ADD:SCSK-KAIYO:20141028:2-4:START--%>
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkApplicantSubmit" Text="再提出中" Checked="true"/>
                <%--ADD:SCSK-KAIYO:20141028:2-4:END--%>
            </td>
            <td class="TDTitleHeader" style=" 15%;clear:left;">
                申請年月
            </td>
            <td class="TDValueNoBorder" style=" 25%">
                <asp:TextBox runat="server" ID="txtApplicationStartDate" CssClass="textboxImeDisabled"
                    MaxLength="7" Style=" 55px;" />
                &nbsp;&nbsp;&nbsp;&nbsp;
                <asp:TextBox runat="server" ID="txtApplicationEndDate" CssClass="textboxImeDisabled"
                    MaxLength="7" Style=" 55px;" />
            </td>
        </tr>
        <tr>
            <td class="TDTitleHeader" style=" 15%">
                事務局判定
            </td>
            <td class="TDValueNoBorder" style=" 45%" colspan="2">
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkSecretariatAccept" Text="受理" Checked="true"/>
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkSecretariatSendBack" Text="差し戻し" Checked="true"/>
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkSecretariatNoJudge" Text="対象外" />
            </td>
            <td class="TDValueNoBorder" style=" 15%">
                <asp:Button CssClass="button fontSizeSmaller" ID="btnSelectAllStatus" runat="server" Text="全選択"
                    Visible="true" OnClientClick="selectAllStatus(true);return false;" style="50%;position:relative;float:left;"/>
                <asp:Button CssClass="button fontSizeSmaller" ID="btnClearAllStatus" runat="server"
                    Text="全解除" Visible="true" OnClientClick="selectAllStatus(false);return false;" style="50%;position:relative ;float:left;"/>
            </td>
            <td class="TDTitleHeader" style=" 15%">
                許可年月
            </td>
            <td class="TDValueNoBorder" style=" 25%">
                <asp:TextBox runat="server" ID="txtPermissionStartDate" CssClass="textboxImeDisabled"
                    MaxLength="7" Style=" 55px;" />
                &nbsp;&nbsp;&nbsp;&nbsp;
                <asp:TextBox runat="server" ID="txtPermissionEndDate" CssClass="textboxImeDisabled"
                    MaxLength="7" Style=" 55px;" />
            </td>
        </tr>
        <tr>
            <td class="TDTitleHeader" style=" 15%">
                審議結果
            </td>
            <td class="TDValueNoBorder" style=" 45%" colspan="3">
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkCommitteePermit" Text="許可" Checked="true"/>
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkCommitteeConditionalPermit" Text="条件付許可" Checked="true"/>
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkCommitteeReserve" Text="留保" Checked="true"/>
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkCommitteeNoPermit" Text="不許可" />
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkCommitteeSendBack" Text="差し戻し" />
            </td>
            <td class="TDTitleHeader" style=" 15%">
                委員会
            </td>
            <td class="TDValueNoBorder" style=" 25%">
                <ac:ApplicationDropDownList ID="ddlCommittee" runat="server" Width="50%" DataSourceID="CommitteeLinqDataSource"
                    DataTextField="COMMITTEE_NO" DataValueField="COMMITTEE_NO" Editable="True" IsScriptExec="false"
                    AppendDataBoundItems="true" TextStyle=" 50%" OnDataBound ="ddlCommittee_DataBound">
                    <asp:ListItem Value="" Text="" />
                </ac:ApplicationDropDownList>
                <asp:LinqDataSource ID="CommitteeLinqDataSource" runat="server" ContextTypeName="Otsuka.Application.Dal.ApplicationDataContext"
                    Select="new (COMMITTEE_NO)" TableName="TBAAMS_COMMITTEE" Where="DEL_FLG != @DEL_FLG">
                    <WhereParameters>
                        <asp:Parameter DefaultValue="1" Name="DEL_FLG" Type="Char" />
                    </WhereParameters>
                </asp:LinqDataSource></td>
        </tr>
        <tr>
            <td class="TDTitleHeader" style=" 15%">
                委員長判定
            </td>
            <td class="TDValueNoBorder" style=" 15%">
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkChairpersonPermit" Text="許可" Checked="true"/>
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkChairpersonSendBack" Text="差し戻し" Checked="true"/>
            </td>
            <td class="TDTitleHeader" style=" 15%">
                完成品判定
            </td>
            <td class="TDValueNoBorder" style=" 15%" >
             <%--MOD:SCSK-KAIYO:20141028:2-4:START--%>
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkApplicantRequestPublic" Text="依頼中" Checked="true"/>
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkSecretariatPermitPublic" Text="公開許可" /><br />
                <asp:CheckBox runat="server" CssClass="checkStatus" ID="chkSecretariatSendBackPublic" Text="差し戻し" Checked="true"/> 
             <%--MOD:SCSK-KAIYO:20141028:2-4:END--%>
            </td>
            <td class="TDTitleHeader" style=" 15%">
                表示順
            </td>
            <td class="TDValueNoBorder" style=" 25%">
                <asp:RadioButtonList runat="server"  ID="rdoOrder" RepeatDirection ="Horizontal" >
                    <asp:ListItem Text ="申請番号" Value ="1" Selected ="True" />
                    <asp:ListItem Text ="薬剤&nbsp;&nbsp;&nbsp;&nbsp;" Value ="2" />
                    <asp:ListItem Text ="申請部署" Value ="3" />
                </asp:RadioButtonList>
            </td>
        </tr>
    </table>
    <hr />
    <div style="height: 300px;100%;overflow: scroll;">
        <asp:GridView ID="gvSearchResult" CssClass="borderedTable" runat="server" AutoGenerateColumns="False"
            Style=" 1800px;" HeaderStyle-CssClass="freezingRow">
            <Columns>
                <asp:TemplateField HeaderText="複写" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResultCenter"
                    HeaderStyle-Width="30px">
                    <ItemTemplate>
                        <asp:Button ID="btnCopy" runat="server" Text="★" Style=" 100%;" OnClick ="btnCopy_Click" CommandArgument ='<%# Eval("APPLI_NO") %>'/>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="申請番号" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResult"
                    HeaderStyle-Width="60px">
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkApplication" runat="server" Text='<%# Eval("APPLI_NO") %>'
                            OnClick="lnkApplication_Click" />
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:BoundField HeaderText="回数" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResultCenter"
                    HeaderStyle-Width="30px" DataField="REVISION_NO" />
                <%--DEL:SCSK-KAIYO:20141028:2-4:START--%>
                    <%--<asp:BoundField HeaderText="ステータス" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResult"
                    HeaderStyle-Width="140px" DataField="APPLI_STATUS_NM"/>--%>
                <%--ADD:SCSK-KAIYO:20141028:2-4:END--%>
                <%--ADD:SCSK-KAIYO:20141028:2-4:START--%>
                <asp:TemplateField HeaderText="ステータス" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResult"
                    HeaderStyle-Width="140px">
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkStatusHistory" runat="server" Text='<%# Eval("APPLI_STATUS_NM") %>'
                        CommandArgument='<%#Eval("APPLI_NO") %>' OnClick="lnkStatusHistory_Click" />
                    </ItemTemplate>
                </asp:TemplateField>
                <%--ADD:SCSK-KAIYO:20141028:2-4:END--%>
                <asp:BoundField HeaderText="申請日" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResult"
                    HeaderStyle-Width="60px" DataField="APPLICATION_DATE" />
                <asp:BoundField HeaderText="申請部署" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResult"
                    HeaderStyle-Width="125px" DataField="SCN_NM_KNJ" />
                <asp:BoundField HeaderText="申請者" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResult"
                    HeaderStyle-Width="90px" DataField="STF_NM_KNJ" />
                <asp:BoundField HeaderText="薬剤" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResult"
                    HeaderStyle-Width="105px" DataField="DRUG_NM_KNJ" />                    
                <%--DEL:SCSK-KAIYO:20141028:2-4:START--%>
                    <%--<asp:BoundField HeaderText="資材名称" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResult"
                    HeaderStyle-Width="300px" ItemStyle-Width="340px" DataField="MATERIALS_NM_KNJ" />--%>
                <%--DEL:SCSK-KAIYO:20141028:2-4:END--%>                
                <%--ADD:SCSK-KAIYO:20141028:2-4:START--%>
                <%--<asp:TemplateField HeaderText="資材名称" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResult"
                    HeaderStyle-Width="300px">
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkViewMaterials" runat="server" Text='<%# Eval("MATERIALS_NM_KNJ") %>'
                             CommandArgument='<%#Eval("APPLI_NO") %>' OnClick="lnkViewMaterials_Click" />
                    </ItemTemplate>
                </asp:TemplateField>--%>
                <asp:TemplateField HeaderText="資材名称" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResult"
                    HeaderStyle-Width="300px">
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkViewMaterials" runat="server" Text='<%# Eval("MATERIALS_NM_KNJ") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <%--ADD:SCSK-KAIYO:20141028:2-4:END--%>
                <asp:BoundField HeaderText="資材媒体" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResult"
                    HeaderStyle-Width="80px" DataField="MATERIALS_CODE_NM_KNJ" />
                <asp:BoundField HeaderText="資材分類" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResult"
                    HeaderStyle-Width="80px" DataField="MATERIALS_CLASS_NM_KNJ" />
                <asp:BoundField HeaderText="委員会" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResultCenter"
                    HeaderStyle-Width="50px" DataField="COMMITTEE_NO" />
                <asp:BoundField HeaderText="審議結果" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResultCenter"
                    HeaderStyle-Width="80px" DataField="DISCUSSION_RESULT_STATUS_NM" />
                <asp:BoundField HeaderText="統一コード" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResult"
                    HeaderStyle-Width="80px" DataField="UNIFORM_CODE" />
                <asp:BoundField HeaderText="元統一コード" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResult"
                    ItemStyle-Width="80px" DataField="OLD_UNIFORM_CODE" />
                <asp:BoundField HeaderText="発注品番" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResult"
                    HeaderStyle-Width="80px" DataField="ORDER_PART_CODE" />
                <asp:BoundField HeaderText="資材管理番号" HeaderStyle-CssClass="TDTitle" ItemStyle-CssClass="TDResult"
                    HeaderStyle-Width="80px" DataField="MATERIALS_NO" />
            </Columns>
            <EmptyDataTemplate>
                <tr class="freezingRow">
                    <th class="TDTitle" style=" 30px;">
                        複写
                    </th>
                    <th class="TDTitle" style=" 60px;">
                        申請番号
                    </th>
                    <th class="TDTitle" style=" 30px;">
                        回数
                    </th>
                    <th class="TDTitle" style=" 140px;">
                        ステータス
                    </th>
                    <th class="TDTitle" style=" 60px;">
                        申請日
                    </th>
                    <th class="TDTitle" style=" 125px;">
                        申請部署
                    </th>
                    <th class="TDTitle" style=" 90px;">
                        申請者
                    </th>
                    <th class="TDTitle" style=" 105px;">
                        薬剤
                    </th>
                    <th class="TDTitle" style=" 200px;">
                        資材名称
                    </th>
                    <th class="TDTitle" style=" 80px;">
                        資材媒体
                    </th>
                    <th class="TDTitle" style=" 80px;">
                        資材分類
                    </th>
                    <th class="TDTitle" style=" 50px;">
                        委員会
                    </th>
                    <th class="TDTitle" style=" 80px;">
                        審議結果
                    </th>
                    <th class="TDTitle" style=" 80px;">
                        統一コード
                    </th>
                    <th class="TDTitle" style=" 80px;">
                        元統一コード
                    </th>
                    <th class="TDTitle" style=" 80px;">
                        発注品番
                    </th>
                    <th class="TDTitle" style=" 80px;">
                        資材管理番号
                    </th>
                </tr>
            </EmptyDataTemplate>
        </asp:GridView>
    </div>
</asp:Content>
View Code

ApplicationList.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Otsuka.Application.Bll;
using Otsuka.Application.Bll.ApplicationInput;
using Otsuka.Application.Dal;
using Otsuka.Application.Bll.Common;
using Otsuka.Application.Common;
using Otsuka.Application.Control;
using System.Web.UI.HtmlControls;
using System.Diagnostics;
using System.Data;

public partial class Form_ApplicationInput : PageBase
{
    private string displayName = "ApplicationInput.aspx";

    private const string SESSION_KEY_IS_HISTORY = "IS_HISTORY";

    #region 画面コントロールイベント群

    protected void Page_Load(object sender, EventArgs e)
    {
        WebLogUtility.WriteDebugLog("時間計測 : Page_Load 開始[" + DateTime.Now.ToString("yyyy:MM:dd HH:mm:ss.ffff") + "]");

        if (!IsPostBack)
        {
            string applicationNo = Request[ConstValue.QUERY_STRING_KEY_APPLICATION_NO];
            string mode = Request[ConstValue.QUERY_STRING_KEY_MODE];
            string completeRegister = Request[ConstValue.QUERY_STRING_KEY_COMPLETE_REGISTER];
            string openFolder = Request[ConstValue.QUERY_STRING_KEY_OPEN_FOLDER];

            hdnApplicationNo.Value = applicationNo;

            if (mode == ConstValue.APPLICATION_INPUT_MODE_NEW)
            {
                // 新規作成のとき
                hdnStatusNo.Value = ((int)Status.ApplicantNew).ToString();
                this.Initialize();
            }
            else if (mode == ConstValue.APPLICATION_INPUT_MODE_EDIT)
            {
                // 編集のとき
                this.Initialize(applicationNo, false);
            }
            else if (mode == ConstValue.APPLICATION_INPUT_MODE_COPY)
            {
                // 複製のとき
                this.Initialize(applicationNo, true);
            }
            else if (mode == ConstValue.APPLICATION_INPUT_MODE_HISTORY)
            {
                // 履歴のとき
                string historyNo = Request[ConstValue.QUERY_STRING_KEY_HISTORY_NO];
                Session[SESSION_KEY_IS_HISTORY] = true;
                hdnIsHistory.Value = "1";
                this.Initialize(applicationNo, historyNo);
            }
            else
            {
                hdnIsHistory.Value = "0";
            }

            if (completeRegister == "1" || completeRegister == "2")
            {
                if (openFolder == "1")
                {
                    //StartUpScriptでメッセージを表示し、OKボタン押下後、フォルダを開く
                    this.GenerateMessageAndOpenFolderJavaScript();
                }
                else
                {
                    this.GenerateMessageJavaScript(Messages.INFO002);
                }
            }
        }

        WebLogUtility.WriteDebugLog("時間計測 : Page_Load 終了[" + DateTime.Now.ToString("yyyy:MM:dd HH:mm:ss.ffff") + "]");

    }

    protected void chkDistributionObject_DataBound(object sender, EventArgs e)
    {
        if (Session[ConstValue.SESSION_KEY_APPLICATION_INFO] == null)
        {
            return;
        }

        // 配布対象情報取得
        List<string> distributionObjects = ((ApplicationInfo)Session[ConstValue.SESSION_KEY_APPLICATION_INFO]).DistributionObjects;

        if (distributionObjects == null)
        {
            return;
        }

        foreach (ListItem item in chkDistributionObject.Items)
        {
            foreach (string distrobutionObject in distributionObjects)
            {
                if (item.Value == distrobutionObject)
                {
                    item.Selected = true;
                }
            }
        }
    }

    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        bool isHistory = false;
        if (Session[SESSION_KEY_IS_HISTORY] != null)
        {
            isHistory = (bool)Session[SESSION_KEY_IS_HISTORY];
            Session[SESSION_KEY_IS_HISTORY] = false;
        }

        this.ViewMenuButton(new StatusManager(hdnStatusNo.Value), isHistory);
        this.ViewControl(new StatusManager(hdnStatusNo.Value), isHistory);

        //MOD:SCSK:20141028:2-3:START
        //this.GenerateDrugAndProdJavaScript();
        this.GenerateDrugAndProdJavaScript(new StatusManager(hdnStatusNo.Value));
        //MOD:SCSK:20141028:2-3:END
        this.GenerateApplicantJavaScript();
        this.GenerateSuperiorJavaScript();
        this.GenerateOldApplicationJavaScript();
        this.GenerateViewMaterials(hdnApplicationNo.Value);
        this.GenerateReportJavaScript();

        this.SetReadOnlyValue();
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        ApplicationInfo application = this.GetApplicationInfo(Status.ApplicantSave);

        ResponseDataType response = this.InvokeUpdateApplication(application);

        if (!response.IsSuccess)
        {
            this.GenerateMessageJavaScript(StringUtility.GetFormatMessageForJavaScript(response.Messages));
            return;
        }

        string applicationNo = response[UpdateApplicationBll.RESPONSE_KEY_APPLICATION_NO] as string;

        Response.Redirect(this.displayName + "?MODE=EDIT&APPLICATION_NO=" + applicationNo + "&" + ConstValue.QUERY_STRING_KEY_COMPLETE_REGISTER + "=1");
    }

    protected void btnApply_Click(object sender, EventArgs e)
    {
        WebLogUtility.WriteDebugLog("時間計測 : btnApply_Click 開始[" + DateTime.Now.ToString("yyyy:MM:dd HH:mm:ss.ffff") + "]");

        ApplicationInfo application = this.GetApplicationInfo(Status.ApplicantApply);

        // 申請日の設定
        application.APPLICATION_DATE = DateTime.Now.ToString("yyyyMMdd");

        // 上長ステータス、上長コメントの削除
        application.SUPERIOR_STATUS_NO = null;
        application.SUPERIOR_COMMENT = null;

        WebLogUtility.WriteDebugLog("時間計測 : InvokeUpdateApplication 呼び出し開始[" + DateTime.Now.ToString("yyyy:MM:dd HH:mm:ss.ffff") + "]");

        ResponseDataType response = this.InvokeUpdateApplication(application);

        WebLogUtility.WriteDebugLog("時間計測 : InvokeUpdateApplication 呼び出し終了[" + DateTime.Now.ToString("yyyy:MM:dd HH:mm:ss.ffff") + "]");

        if (!response.IsSuccess)
        {
            this.GenerateMessageJavaScript(StringUtility.GetFormatMessageForJavaScript(response.Messages));
            return;
        }

        string applicationNo = response[UpdateApplicationBll.RESPONSE_KEY_APPLICATION_NO] as string;

        WebLogUtility.WriteDebugLog("時間計測 : SendMail 呼び出し開始[" + DateTime.Now.ToString("yyyy:MM:dd HH:mm:ss.ffff") + "]");

        // メール送信
        this.SendMail(response, new StatusManager(application.Status));

        WebLogUtility.WriteDebugLog("時間計測 : SendMail 呼び出し終了[" + DateTime.Now.ToString("yyyy:MM:dd HH:mm:ss.ffff") + "]");

        WebLogUtility.WriteDebugLog("時間計測 : btnApply_Click 終了[" + DateTime.Now.ToString("yyyy:MM:dd HH:mm:ss.ffff") + "]");

        // 直前複写可
        // 資材フォルダを開く
        Response.Redirect(this.displayName + "?MODE=EDIT&APPLICATION_NO=" + applicationNo + "&" + ConstValue.QUERY_STRING_KEY_COMPLETE_REGISTER + "=2&" + ConstValue.QUERY_STRING_KEY_OPEN_FOLDER + "=1");
    }

    protected void btnReApply_Click(object sender, EventArgs e)
    {
        ApplicationInfo application = this.GetApplicationInfo(Status.ApplicantReApply);

        // 上長ステータス、上長コメントの削除
        application.SUPERIOR_STATUS_NO = null;
        application.SUPERIOR_COMMENT = null;

        ResponseDataType response = this.InvokeUpdateApplication(application);

        if (!response.IsSuccess)
        {
            this.GenerateMessageJavaScript(StringUtility.GetFormatMessageForJavaScript(response.Messages));
            return;
        }

        string applicationNo = response[UpdateApplicationBll.RESPONSE_KEY_APPLICATION_NO] as string;

        // メール送信
        this.SendMail(response, new StatusManager(application.Status));

        // 資材フォルダを開く
        Response.Redirect(this.displayName + "?MODE=EDIT&APPLICATION_NO=" + applicationNo + "&" + ConstValue.QUERY_STRING_KEY_COMPLETE_REGISTER + "=1&" + ConstValue.QUERY_STRING_KEY_OPEN_FOLDER + "=1");
    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ApplicationInfo application = this.GetApplicationInfo(Status.ApplicantSubmit);


        ResponseDataType response = this.InvokeUpdateApplication(application);

        if (!response.IsSuccess)
        {
            this.GenerateMessageJavaScript(StringUtility.GetFormatMessageForJavaScript(response.Messages));
            return;
        }

        string applicationNo = response[UpdateApplicationBll.RESPONSE_KEY_APPLICATION_NO] as string;

        // メール送信
        this.SendMail(response, new StatusManager(application.Status));

        Response.Redirect(this.displayName + "?MODE=EDIT&APPLICATION_NO=" + applicationNo + "&" + ConstValue.QUERY_STRING_KEY_COMPLETE_REGISTER + "=1");
    }

    protected void btnRequestConfirmartion_Click(object sender, EventArgs e)
    {
        ApplicationInfo application = this.GetApplicationInfo(Status.ApplicantRequestPublic);

        ResponseDataType response = this.InvokeUpdateApplication(application);

        if (!response.IsSuccess)
        {
            this.GenerateMessageJavaScript(StringUtility.GetFormatMessageForJavaScript(response.Messages));
            return;
        }

        string applicationNo = response[UpdateApplicationBll.RESPONSE_KEY_APPLICATION_NO] as string;

        // メール送信
        this.SendMail(response, new StatusManager(application.Status));


        Response.Redirect(this.displayName + "?MODE=EDIT&APPLICATION_NO=" + applicationNo + "&" + ConstValue.QUERY_STRING_KEY_COMPLETE_REGISTER + "=1");
    }

    protected void btnSuperiorApprove_Click(object sender, EventArgs e)
    {
        ApplicationInfo application = this.GetApplicationInfo(Status.SuperiorApprove);

        application.SUPERIOR_STATUS_NO = ((int)Status.SuperiorApprove).ToString();

        // 上長承認日の設定
        application.SUPERIOR_APPROVE_DATE = DateTime.Now.ToString("yyyyMMdd");

        ResponseDataType response = this.InvokeUpdateApplication(application);

        if (!response.IsSuccess)
        {
            this.GenerateMessageJavaScript(StringUtility.GetFormatMessageForJavaScript(response.Messages));
            return;
        }

        string applicationNo = response[UpdateApplicationBll.RESPONSE_KEY_APPLICATION_NO] as string;

        // メール送信
        this.SendMail(response, new StatusManager(application.Status));

        Response.Redirect(this.displayName + "?MODE=EDIT&APPLICATION_NO=" + applicationNo + "&" + ConstValue.QUERY_STRING_KEY_COMPLETE_REGISTER + "=1");
    }

    protected void btnSuperiorSendBack_Click(object sender, EventArgs e)
    {
        ApplicationInfo application = this.GetApplicationInfo(Status.SuperiorSendBack);

        application.SUPERIOR_STATUS_NO = ((int)Status.SuperiorSendBack).ToString();

        ResponseDataType response = this.InvokeUpdateApplication(application);

        if (!response.IsSuccess)
        {
            this.GenerateMessageJavaScript(StringUtility.GetFormatMessageForJavaScript(response.Messages));
            return;
        }

        string applicationNo = response[UpdateApplicationBll.RESPONSE_KEY_APPLICATION_NO] as string;

        // メール送信
        this.SendMail(response, new StatusManager(application.Status));

        Response.Redirect(this.displayName + "?MODE=EDIT&APPLICATION_NO=" + applicationNo + "&" + ConstValue.QUERY_STRING_KEY_COMPLETE_REGISTER + "=1");
    }

    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        ApplicationInfo application = null;

        //MOD:SCSK:20141028:2-3:START
        //if (rdbDiscussionClass.SelectedValue == "1" || rdbDiscussionClass.SelectedValue == "2")
        //{
        //    application = this.GetApplicationInfo(Status.SecretariatAcceptDiscuss);
        //    application.SECRETARIAT_STATUS_NO = ((int)Status.SecretariatAcceptDiscuss).ToString();
        //}
        //else if (rdbDiscussionClass.SelectedValue == "3")
        //{
        //    application = this.GetApplicationInfo(Status.SecretariatAcceptNoDiscuss);
        //    application.SECRETARIAT_STATUS_NO = ((int)Status.SecretariatAcceptNoDiscuss).ToString();
        //}
        //else
        //{
        //    application = this.GetApplicationInfo(Status.SecretariatAccept);
        //    application.SECRETARIAT_STATUS_NO = ((int)Status.SecretariatAccept).ToString();
        //}

        // 上長承認、事務局受理(未判定)、事務局受理(審議Ⅰ、Ⅱ)、事務局受理(事前審議)の場合、ステータス更新
        bool isUpdateStatus = false;
        if (hdnStatusNo.Value == ((int)Status.SuperiorApprove).ToString() ||
            hdnStatusNo.Value == ((int)Status.SecretariatAccept).ToString() ||
            hdnStatusNo.Value == ((int)Status.SecretariatAcceptDiscuss).ToString() ||
            hdnStatusNo.Value == ((int)Status.SecretariatAcceptNoDiscuss).ToString())
        {
            isUpdateStatus = true;
        }

        // ステータスを更新する場合
        if (isUpdateStatus)
        {
            // 審議種別で対象外を選択している場合、対象外ボタンクリック処理を実行し、処理を終了
            if (rdbDiscussionClass.SelectedValue == "4")
            {
                btnNoJudge_Click(sender, e);
                return;
            }

            if (rdbDiscussionClass.SelectedValue == "1" || rdbDiscussionClass.SelectedValue == "2")
            {
                application = this.GetApplicationInfo(Status.SecretariatAcceptDiscuss);
                application.SECRETARIAT_STATUS_NO = ((int)Status.SecretariatAcceptDiscuss).ToString();
            }
            else if (rdbDiscussionClass.SelectedValue == "3")
            {
                application = this.GetApplicationInfo(Status.SecretariatAcceptNoDiscuss);
                application.SECRETARIAT_STATUS_NO = ((int)Status.SecretariatAcceptNoDiscuss).ToString();
            }
            else
            {
                application = this.GetApplicationInfo(Status.SecretariatAccept);
                application.SECRETARIAT_STATUS_NO = ((int)Status.SecretariatAccept).ToString();
            }
        }
        else
        {
            StatusManager statusManager = new StatusManager(hdnStatusNo.Value);
            application = this.GetApplicationInfo(statusManager.GetStatus());
        }
        //MOD:SCSK:20141028:2-3:END

        ResponseDataType response = this.InvokeUpdateApplication(application);

        if (!response.IsSuccess)
        {
            this.GenerateMessageJavaScript(StringUtility.GetFormatMessageForJavaScript(response.Messages));
            return;
        }

        string applicationNo = response[UpdateApplicationBll.RESPONSE_KEY_APPLICATION_NO] as string;

        Response.Redirect(this.displayName + "?MODE=EDIT&APPLICATION_NO=" + applicationNo + "&" + ConstValue.QUERY_STRING_KEY_COMPLETE_REGISTER + "=1");
    }

    protected void btnOrderUpdate_Click(object sender, EventArgs e)
    {
        ApplicationInfo application = this.GetApplicationInfo(Status.SecretariatPermitPublic);

        ResponseDataType response = this.InvokeUpdateApplication(application);

        if (!response.IsSuccess)
        {
            this.GenerateMessageJavaScript(StringUtility.GetFormatMessageForJavaScript(response.Messages));
            return;
        }

        string applicationNo = response[UpdateApplicationBll.RESPONSE_KEY_APPLICATION_NO] as string;

        Response.Redirect(this.displayName + "?MODE=EDIT&APPLICATION_NO=" + applicationNo + "&" + ConstValue.QUERY_STRING_KEY_COMPLETE_REGISTER + "=1");
    }

    protected void btnAccept_Click(object sender, EventArgs e)
    {
        //ADD:SCSK:20141028:2-3:START
        // 審議種別で対象外を選択している場合、対象外ボタンクリック処理を実行し、処理を終了
        if (rdbDiscussionClass.SelectedValue == "4")
        {
            btnNoJudge_Click(sender, e);
            return;
        }
        //ADD:SCSK:20141028:2-3:END

        ApplicationInfo application = null;

        if (hdnStatusNo.Value == ((int)Status.ApplicantSubmit).ToString())
        {
            // 修正資材提出のとき、事務局受理(提出)
            application = this.GetApplicationInfo(Status.SecretariatAcceptSubmission);
            application.SECRETARIAT_STATUS_NO = ((int)Status.SecretariatAcceptSubmission).ToString();
        }
        else if (rdbDiscussionClass.SelectedValue == "1" || rdbDiscussionClass.SelectedValue == "2")
        {
            // 修正資材提出以外で、審議種別Ⅰ、Ⅱのとき、事務局受理(審議)
            application = this.GetApplicationInfo(Status.SecretariatAcceptDiscuss);
            application.SECRETARIAT_STATUS_NO = ((int)Status.SecretariatAcceptDiscuss).ToString();
        }
        else if (rdbDiscussionClass.SelectedValue == "3")
        {
            // 修正資材提出以外で、事前審議のとき、事務局受理(事前審議)
            application = this.GetApplicationInfo(Status.SecretariatAcceptNoDiscuss);
            application.SECRETARIAT_STATUS_NO = ((int)Status.SecretariatAcceptNoDiscuss).ToString();
        }
        else
        {
            // 修正資材提出以外で、未設定のとき、事務局受理(未判定)
            application = this.GetApplicationInfo(Status.SecretariatAccept);
            application.SECRETARIAT_STATUS_NO = ((int)Status.SecretariatAccept).ToString();
        }

        // 事務局受理日の設定
        application.SECRETARIAT_ACCEPT_DATE = DateTime.Now.ToString("yyyyMMdd");

        ResponseDataType response = this.InvokeUpdateApplication(application);

        if (!response.IsSuccess)
        {
            this.GenerateMessageJavaScript(StringUtility.GetFormatMessageForJavaScript(response.Messages));
            return;
        }

        string applicationNo = response[UpdateApplicationBll.RESPONSE_KEY_APPLICATION_NO] as string;

        // メール送信
        this.SendMail(response, new StatusManager(application.Status));

        Response.Redirect(this.displayName + "?MODE=EDIT&APPLICATION_NO=" + applicationNo + "&" + ConstValue.QUERY_STRING_KEY_COMPLETE_REGISTER + "=1");
    }

    protected void btnSendBack_Click(object sender, EventArgs e)
    {
        // 事務局差し戻しの時には委員会をクリアする
        ddlCommittee.SelectedValue = string.Empty;

        ApplicationInfo application = this.GetApplicationInfo(Status.SecretariatSendBack);

        application.SECRETARIAT_STATUS_NO = ((int)Status.SecretariatSendBack).ToString();

        ResponseDataType response = this.InvokeUpdateApplication(application);

        if (!response.IsSuccess)
        {
            this.GenerateMessageJavaScript(StringUtility.GetFormatMessageForJavaScript(response.Messages));
            return;
        }

        string applicationNo = response[UpdateApplicationBll.RESPONSE_KEY_APPLICATION_NO] as string;

        // メール送信
        this.SendMail(response, new StatusManager(application.Status));

        Response.Redirect(this.displayName + "?MODE=EDIT&APPLICATION_NO=" + applicationNo + "&" + ConstValue.QUERY_STRING_KEY_COMPLETE_REGISTER + "=1");
    }

    protected void btnNoJudge_Click(object sender, EventArgs e)
    {
        // 事務局差し戻しの時には委員会をクリアする
        ddlCommittee.SelectedValue = string.Empty;

        ApplicationInfo application = this.GetApplicationInfo(Status.SecretariatNoJudge);

        application.SECRETARIAT_STATUS_NO = ((int)Status.SecretariatNoJudge).ToString();

        ResponseDataType response = this.InvokeUpdateApplication(application);

        if (!response.IsSuccess)
        {
            this.GenerateMessageJavaScript(StringUtility.GetFormatMessageForJavaScript(response.Messages));
            return;
        }

        string applicationNo = response[UpdateApplicationBll.RESPONSE_KEY_APPLICATION_NO] as string;

        // メール送信
        this.SendMail(response, new StatusManager(application.Status));

        Response.Redirect(this.displayName + "?MODE=EDIT&APPLICATION_NO=" + applicationNo + "&" + ConstValue.QUERY_STRING_KEY_COMPLETE_REGISTER + "=1");
    }

    protected void btnCopy_Click(object sender, EventArgs e)
    {
        Response.Redirect(this.displayName + "?MODE=COPY&APPLICATION_NO=" + txtApplicationNo.Text);
    }

    protected void btnNew_Click(object sender, EventArgs e)
    {
        Response.Redirect(this.displayName + "?MODE=NEW");
    }

    protected void btnApplicationHistory_Click(object sender, EventArgs e)
    {
        // 登録完了フラグを履歴に含めないため、URLパラメータから登録完了フラグを削除
        StringBuilder savedHistory = new StringBuilder(Request.Url.LocalPath);
        savedHistory.Append("?");
        savedHistory.Append(ConstValue.QUERY_STRING_KEY_APPLICATION_NO);
        savedHistory.Append("=");
        savedHistory.Append(Request.QueryString[ConstValue.QUERY_STRING_KEY_APPLICATION_NO]);
        savedHistory.Append("&");
        savedHistory.Append(ConstValue.QUERY_STRING_KEY_MODE);
        savedHistory.Append("=");
        savedHistory.Append(Request.QueryString[ConstValue.QUERY_STRING_KEY_MODE]);

        if (Request.QueryString[ConstValue.QUERY_STRING_KEY_HISTORY_NO] != null)
        {
            savedHistory.Append("&");
            savedHistory.Append(ConstValue.QUERY_STRING_KEY_HISTORY_NO);
            savedHistory.Append("=");
            savedHistory.Append(Request.QueryString[ConstValue.QUERY_STRING_KEY_HISTORY_NO]);
        }

        this.PageRedirect("StatusHistory.aspx?" + ConstValue.QUERY_STRING_KEY_APPLICATION_NO + "=" + txtApplicationNo.Text, savedHistory.ToString());
    }

    protected void btnDiscussionResult_Click(object sender, EventArgs e)
    {
        // 登録完了フラグを履歴に含めないため、URLパラメータから登録完了フラグを削除
        StringBuilder savedHistory = new StringBuilder(Request.Url.LocalPath);
        savedHistory.Append("?");
        savedHistory.Append(ConstValue.QUERY_STRING_KEY_APPLICATION_NO);
        savedHistory.Append("=");
        savedHistory.Append(Request.QueryString[ConstValue.QUERY_STRING_KEY_APPLICATION_NO]);
        savedHistory.Append("&");
        savedHistory.Append(ConstValue.QUERY_STRING_KEY_MODE);
        savedHistory.Append("=");
        savedHistory.Append(Request.QueryString[ConstValue.QUERY_STRING_KEY_MODE]);

        if (Request.QueryString[ConstValue.QUERY_STRING_KEY_HISTORY_NO] != null)
        {
            savedHistory.Append("&");
            savedHistory.Append(ConstValue.QUERY_STRING_KEY_HISTORY_NO);
            savedHistory.Append("=");
            savedHistory.Append(Request.QueryString[ConstValue.QUERY_STRING_KEY_HISTORY_NO]);
        }

        StringBuilder url = new StringBuilder();
        url.Append("InspectionResult.aspx?");
        url.Append(ConstValue.QUERY_STRING_KEY_MODE);
        url.Append("=");

        if (hdnIsHistory.Value == "1")
        {
            url.Append(ConstValue.APPLICATION_INPUT_MODE_HISTORY);
        }
        else
        {
            url.Append(ConstValue.INSPECTION_RESULT_MODE_SINGLE);
        }
        url.Append("&");
        url.Append(ConstValue.QUERY_STRING_KEY_APPLICATION_NO);
        url.Append("=");
        url.Append(txtApplicationNo.Text);
        url.Append("&");
        url.Append(ConstValue.QUERY_STRING_KEY_REVISION_NO);
        url.Append("=");
        url.Append(txtRevisionNo.Text);

        //画面遷移制御対応:SCSK:20141107:START

        Stack<string> pageStack = (Stack<string>)Session[ConstValue.SESSION_KEY_PAGE_STACK];

        if (pageStack != null && pageStack.Count != 0)
        {
            string previousPage = pageStack.Peek();

            if (!CheckUtility.IsEmpty(previousPage))
            {
                if (previousPage.IndexOf("InspectionResult.aspx?" + ConstValue.QUERY_STRING_KEY_MODE + "=" + ConstValue.INSPECTION_RESULT_MODE_CONTINUE) > 0)
                {
                    //previousPage = pageStack.Pop();
                    //Response.Redirect(previousPage);
                    url.Length = 0;
                    url.Append("InspectionResult.aspx?");
                    url.Append(ConstValue.QUERY_STRING_KEY_MODE);
                    url.Append("=");
                    url.Append(ConstValue.INSPECTION_RESULT_MODE_CONTINUE);
                    url.Append("&");
                    url.Append(ConstValue.QUERY_STRING_KEY_APPLICATION_NO);
                    url.Append("=");
                    url.Append(txtApplicationNo.Text);
                    url.Append("&");
                    url.Append(ConstValue.QUERY_STRING_KEY_REVISION_NO);
                    url.Append("=");
                    url.Append(txtRevisionNo.Text);

                    this.PageRedirect(url.ToString(), savedHistory.ToString());
                }
            }
        }

        this.PageRedirect(url.ToString(), savedHistory.ToString());

        //this.PageRedirect(url.ToString(), savedHistory.ToString());
        //画面遷移制御対応:SCSK:20141107:END



    }

    protected void btnDelete_Click(object sender, EventArgs e)
    {
        ApplicationInfo application = this.GetApplicationInfo(Status.ApplicantDelete);

        ResponseDataType response = this.InvokeUpdateApplication(application);

        if (!response.IsSuccess)
        {
            this.GenerateMessageJavaScript(StringUtility.GetFormatMessageForJavaScript(response.Messages));
            return;
        }

        Response.Redirect(this.displayName + "?MODE=EDIT&APPLICATION_NO=" + application.APPLI_NO + "&" + ConstValue.QUERY_STRING_KEY_COMPLETE_REGISTER + "=1");
    }

    protected void rdbNewOrRevision_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (rdbNewOrRevision.SelectedValue == "0")
        {
            // 新規のとき
            btnSelectOldMaterials.Enabled = false;
            txtOldUniformCode.Text = string.Empty;
            txtOldOrderPartCode.Text = string.Empty;
            hdnOldUniformCode.Value = string.Empty;
            hdnOldOrderPartCode.Value = string.Empty;
        }
        else if (rdbNewOrRevision.SelectedValue == "1")
        {
            // 改訂のとき
            btnSelectOldMaterials.Enabled = true;
        }
    }

    protected void rdbQuotation_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (rdbQuotation.SelectedValue == "0")
        {
            // 無のとき
            rdbLicenseAgreement.Enabled = false;
            rdbLicenseAgreement.SelectedIndex = -1;     //未選択に戻す
        }
        else if (rdbQuotation.SelectedValue == "1")
        {
            // 有のとき
            rdbLicenseAgreement.Enabled = true;
        }
    }

    protected void btnSelectApplicant_Click(object sender, EventArgs e)
    {
        // 申請者に設定された値を元に、デフォルト上長を取得する
        StaffInfo superior = GetDefaultSuperior(hdnApplicantDivision.Value, hdnApplicantStaff.Value);

        if (superior != null)
        {
            hdnSuperiorDivision.Value = superior.CstCd;
            hdnSuperiorStaff.Value = superior.StfCd;

            txtSuperiorDivision.Text = superior.ScnNm;
            hdnSuperiorDivisionName.Value = superior.ScnNm;
            txtSuperiorStaff.Text = superior.StfNm;
            hdnSuperiorStaffName.Value = superior.StfNm;
        }
        else
        {
            hdnSuperiorDivision.Value = string.Empty;
            hdnSuperiorStaff.Value = string.Empty;

            txtSuperiorDivision.Text = string.Empty;
            hdnSuperiorDivisionName.Value = string.Empty;
            txtSuperiorStaff.Text = string.Empty;
            hdnSuperiorStaffName.Value = string.Empty;
        }
    }

    #endregion

    #region ロジックメソッド群

    /// <summary>
    /// 申請情報を取得し、画面表示する
    /// </summary>
    /// <param name="applicationNo"></param>
    private void Initialize(string applicationNo, bool isCopy)
    {
        // パラメータ生成
        Dictionary<string, object> parameter = new Dictionary<string, object>();
        parameter.Add(SearchApplicationBll.REQUEST_KEY_APPLICATION_NO, applicationNo);

        // 申請情報取得
        ResponseDataType response = InvokeBllEx(typeof(SearchApplicationBll), parameter);

        // 申請
        ApplicationInfo application = (ApplicationInfo)response[SearchApplicationBll.RESPONSE_KEY_APPLICATION_INFO];

        Session[ConstValue.SESSION_KEY_APPLICATION_INFO] = application;

        // 直近開催の委員会番号
        string recentCommitteeNo = response[SearchApplicationBll.RESPONSE_KEY_RECENT_COMMITTEE_NO] as string;

        if (isCopy)
        {
            application.APPLI_NO = null;
            application.REVISION_NO = null;

            // 統一コード、発注品番
            application.UNIFORM_CODE = null;
            application.ORDER_PART_CODE = null;
            application.OLD_UNIFORM_CODE = null;
            application.OLD_ORDER_PART_CODE = null;

            // 委員会、審議結果
            application.COMMITTEE_NO = null;
            application.DISCUSSION_RESULT_STATUS_NO = null;

            // 資材分類
            application.MATERIALS_CLASS_CODE = null;
            application.MATERIALS_CLASS_INFO_NM = null;

            // 審議種別
            application.DISCUSSION_CLASS = null;

            // 申請者
            application.APPLICANT_DIV_REG_DATE = null;
            application.APPLICANT_DIVISION = this.StaffInfo.CstCd;
            application.APPLICANT_STF_CODE = this.StaffInfo.StfCd;
            application.Applicant = new ApplicationInfo.Staff() { CostName = this.StaffInfo.ScnNm, StaffName = this.StaffInfo.StfNm };

            // 登録者
            application.REGISTRANT_DIV_DATE = null;
            application.REGISTRANT_DIVISION = this.StaffInfo.CstCd;
            application.REGISTRANT_STF_CODE = this.StaffInfo.StfCd;
            application.Registrant = new ApplicationInfo.Staff() { CostName = this.StaffInfo.ScnNm, StaffName = this.StaffInfo.StfNm };

            // 上長
            this.SetDefaultSuperior(application);

            // 上長判定/上長コメント
            application.SUPERIOR_APPROVE_DATE = null;
            application.SUPERIOR_STATUS_NO = null;
            application.SUPERIOR_COMMENT = null;

            // 事務局判定/コメント
            application.SECRETARIAT_STATUS_NO = null;
            application.SECRETARIAT_ACCEPT_DATE = null;
            application.SecretariatComments = null;

            // 申請日
            application.APPLICATION_DATE = null;

            application.STATUS_NO = ((int)Status.ApplicantNew).ToString();
        }

        if (response.Items.ContainsKey(SearchApplicationBll.RESPONSE_KEY_APPLICATION_HISTORY_INFO) && !isCopy)
        {
            // 履歴が存在し、複写時ではないとき
            ApplicationInfo applicationHistory = (ApplicationInfo)response[SearchApplicationBll.RESPONSE_KEY_APPLICATION_HISTORY_INFO];

            this.ApplyUpdatedStyle(application, applicationHistory);
        }

        // 画面表示
        this.DisplayApplication(application, recentCommitteeNo);
    }

    /// <summary>
    /// 申請履歴情報を取得し、画面表示する
    /// </summary>
    /// <param name="applicationNo"></param>
    /// <param name="historyNo"></param>
    private void Initialize(string applicationNo, string historyNo)
    {
        // パラメータ生成
        Dictionary<string, object> parameter = new Dictionary<string, object>();
        parameter.Add(SearchApplicationBll.REQUEST_KEY_APPLICATION_NO, applicationNo);
        parameter.Add(SearchApplicationBll.REQUEST_KEY_HISTORY_NO, historyNo);
        parameter.Add(SearchApplicationBll.REQUEST_KEY_IS_HISTORY, true);

        // 申請情報取得
        ResponseDataType response = InvokeBllEx(typeof(SearchApplicationBll), parameter);

        // 申請
        ApplicationInfo application = (ApplicationInfo)response[SearchApplicationBll.RESPONSE_KEY_APPLICATION_INFO];

        Session[ConstValue.SESSION_KEY_APPLICATION_INFO] = application;

        // 直近開催の委員会
        string recentCommitteeNo = response[SearchApplicationBll.RESPONSE_KEY_RECENT_COMMITTEE_NO] as string;

        // 画面表示
        this.DisplayApplication(application, recentCommitteeNo);
    }

    /// <summary>
    /// 新規作成
    /// </summary>
    private void Initialize()
    {
        ApplicationInfo application = new ApplicationInfo(false);

        application.APPLICANT_DIVISION = this.StaffInfo.CstCd;
        application.APPLICANT_STF_CODE = this.StaffInfo.StfCd;
        application.Applicant = new ApplicationInfo.Staff() { CostName = this.StaffInfo.ScnNm, StaffName = this.StaffInfo.StfNm };

        application.REGISTRANT_DIVISION = this.StaffInfo.CstCd;
        application.REGISTRANT_STF_CODE = this.StaffInfo.StfCd;
        application.Registrant = new ApplicationInfo.Staff() { CostName = this.StaffInfo.ScnNm, StaffName = this.StaffInfo.StfNm };

        application.STATUS_NO = ((int)Status.ApplicantNew).ToString();

        // SesionClear
        Session[ConstValue.SESSION_KEY_APPLICATION_INFO] = null;

        // 上長を設定する
        application = this.SetDefaultSuperior(application);

        this.DisplayApplication(application, null);
    }

    /// <summary>
    /// 画面コントロールから申請情報を取得する
    /// </summary>
    /// <param name="status">設定するステータス</param>
    /// <returns></returns>
    private ApplicationInfo GetApplicationInfo(Status status)
    {
        ApplicationInfo application = new ApplicationInfo(false);

        application.STATUS_NO = ((int)status).ToString();

        // 申請
        application.APPLI_NO = txtApplicationNo.Text;
        application.REVISION_NO = CommonUtility.ParseIntOrNull(txtRevisionNo.Text);
        application.APPLICATION_DATE = txtApplicationDate.Text.Replace("/", "");
        application.REVISE_FLG = CommonUtility.GetCharAt(rdbNewOrRevision.SelectedValue, 0);
        application.ORDER_FLG = CommonUtility.GetCharAt(rdbOrder.SelectedValue, 0);
        application.UNIFORM_CODE = txtUniformCode.Text;
        application.ORDER_PART_CODE = txtOrderPartCode.Text;
        application.OLD_UNIFORM_CODE = hdnOldUniformCode.Value;
        application.OLD_ORDER_PART_CODE = hdnOldOrderPartCode.Value;
        application.MATERIALS_NM_KNJ = txtMaterialsName.Text;
        application.PURPOSE_BACKGROUND = txtPurposeAndContent.Text;
        application.DRUG = hdnDrug.Value;
        application.MATERIALS_CODE = CommonUtility.GetCharAt(ddlMaterialsInfo.SelectedValue, 0);
        application.MATERIALS_CLASS_CODE = ddlMaterialsClassInfo.SelectedValue;
        application.QUOTATION_FLG = CommonUtility.GetCharAt(rdbQuotation.SelectedValue, 0);
        application.PRODUCTION_CODE = ddlProduction.SelectedValue;
        application.PRINTED_DATE = txtPrintedDate.Value;
        application.USE_START_DATE = txtUseStartDate.Value;
        application.DISTRIBUTION_TERM = CommonUtility.ParseIntOrNull(txtDistributionTerm.Text);
        application.FIRST_PRINT_COPIES = CommonUtility.ParseIntOrNull(txtFirstPrintCopies.Text);
        application.LICENSE_AGREEMENT = rdbLicenseAgreement.SelectedValue;
        application.LICENSE_CONDITIONS = txtLicenseConditions.Text;
        application.SUPERIOR_STATUS_NO = hdnSuperiorStatusNo.Value;
        application.SUPERIOR_COMMENT = txtSuperiorComment.Text;
        application.SECRETARIAT_STATUS_NO = hdnSecretariatStatusNo.Value;
        application.DISCUSSION_CLASS = CommonUtility.GetCharAt(rdbDiscussionClass.SelectedValue, 0);
        application.SUPERIOR_DIV_REG_DATE = hdnSuperiorDivRegDate.Value;
        application.SUPERIOR_DIVISION = hdnSuperiorDivision.Value;
        application.SUPERIOR_STF_CODE = hdnSuperiorStaff.Value;
        application.APPLICANT_DIV_REG_DATE = hdnApplicantDivRegDate.Value;
        application.APPLICANT_DIVISION = hdnApplicantDivision.Value;
        application.APPLICANT_STF_CODE = hdnApplicantStaff.Value;
        application.REGISTRANT_DIV_DATE = hdnRegistrantDivRegDate.Value;
        application.REGISTRANT_DIVISION = hdnRegistrantDivision.Value;
        application.REGISTRANT_STF_CODE = hdnRegistrantStaff.Value;

        // 登録日
        string yyyymmdd = DateTime.Now.ToString("yyyyMMdd");
        if (CheckUtility.IsEmpty(application.SUPERIOR_DIV_REG_DATE))
        {
            application.SUPERIOR_DIV_REG_DATE = yyyymmdd;
        }

        if (CheckUtility.IsEmpty(application.APPLICANT_DIV_REG_DATE))
        {
            application.APPLICANT_DIV_REG_DATE = yyyymmdd;
        }

        if (CheckUtility.IsEmpty(application.REGISTRANT_DIV_DATE))
        {
            application.REGISTRANT_DIV_DATE = yyyymmdd;
        }

        // 委員会
        application.COMMITTEE_NO = CommonUtility.ParseIntOrNull(ddlCommittee.SelectedValue);

        // 配布対象
        application.DistributionObjects = new List<string>();
        foreach (ListItem item in chkDistributionObject.Items)
        {
            if (item.Selected)
            {
                application.DistributionObjects.Add(item.Value);
            }
        }

        // 事務局コメント
        application.SecretariatComments = new List<ApplicationInfo.SecretariatComment>();

        //MOD:SCSK:20141028:2-3:START
        //foreach (GridViewRow gvRow in gvSecretariatComment.Rows)
        //{
        //    ApplicationInfo.SecretariatComment comment = new ApplicationInfo.SecretariatComment();
        //    TextBox txtSecretariatCommentDate = (TextBox)gvRow.FindControl("txtSecretariatCommentDate");
        //    TextBox txtSecretariatComment = (TextBox)gvRow.FindControl("txtSecretariatComment");

        //    if (CheckUtility.IsEmpty(txtSecretariatComment.Text))
        //    {
        //        continue;
        //    }

        //    if (CheckUtility.IsEmpty(txtSecretariatCommentDate.Text))
        //    {
        //        comment.SECRETARIAT_COMMENT_DATE = DateTime.Now;
        //    }
        //    else
        //    {
        //        comment.SECRETARIAT_COMMENT_DATE = DateTime.Parse(txtSecretariatCommentDate.Text);
        //    }

        //    comment.SECRETARIAT_COMMENT = txtSecretariatComment.Text;

        //    application.SecretariatComments.Add(comment);
        //}

        ApplicationInfo.SecretariatComment comment = new ApplicationInfo.SecretariatComment();
        if (!CheckUtility.IsEmpty(txtSecretariatComment.Text))
        {
            comment.SECRETARIAT_COMMENT_DATE = null;
            comment.SECRETARIAT_COMMENT = txtSecretariatComment.Text;
            application.SecretariatComments.Add(comment);
        }
        //MOD:SCSK:20141028:2-3:END

        // 申請製品
        string[] productCodes = hdnProduct.Value.Split(',');
        string[] productNames = hdnProductName.Value.Split(',');
        application.Products = new List<ApplicationInfo.Product>();

        for (int i = 0; i < productCodes.Length; i++)
        {
            if (productCodes[i].Trim().Length == 0)
            {
                continue;
            }

            application.Products.Add(new ApplicationInfo.Product() { PROD_GRP_CODE = productCodes[i], PROD_GRP_NM_KNJ = productNames[i] });
        }

        return application;
    }

    private ResponseDataType InvokeUpdateApplication(ApplicationInfo application)
    {
        // 排他制御項目の設定
        ApplicationInfo originalApplication = (ApplicationInfo)Session[ConstValue.SESSION_KEY_APPLICATION_INFO];
        if (originalApplication != null)
        {
            application.UPD_USERID = originalApplication.UPD_USERID;
            application.UPD_DATE = originalApplication.UPD_DATE;
            application.UPD_IP = originalApplication.UPD_IP;
        }

        Dictionary<string, object> parameter = new Dictionary<string, object>();
        parameter.Add(UpdateApplicationBll.REQUEST_KEY_APPLICATION_INFO, application);

        return this.InvokeBllEx(typeof(UpdateApplicationBll), parameter);
    }

    private StaffInfo GetDefaultSuperior(string costCode, string staffCode)
    {
        // 事業企画申請上長取得
        Dictionary<string, object> parameter = new Dictionary<string, object>();
        parameter = new Dictionary<string, object>();
        parameter.Add(SearchApproverBll.REQUEST_KEY_CST_CODE, costCode);
        parameter.Add(SearchApproverBll.REQUEST_KEY_STF_CODE, staffCode);

        ResponseDataType response = InvokeBll(typeof(SearchApproverBll), parameter);

        if (!response.Items.ContainsKey(SearchApproverBll.RESPONSE_KEY_SUPERIOR))
        {
            return null;
        }

        DataTable superior = (DataTable)response[SearchApproverBll.RESPONSE_KEY_SUPERIOR];

        string superiorStaffCode = string.Empty;
        if (!CheckUtility.HaveRows(superior))
        {
            return null;
        }
        else
        {
            superiorStaffCode = superior.Rows[0]["stf_code"] as string;
        }

        // 上長の詳細情報取得
        parameter = new Dictionary<string, object>();
        parameter.Add(SimpleStaffInfoBll.REQUEST_KEY_STAFF_CODE, superiorStaffCode);

        response = InvokeBllEx(typeof(SimpleStaffInfoBll), parameter);
        StaffInfo superiorInfo = response[SimpleStaffInfoBll.RESPONSE_KEY_STAFF_INFO] as StaffInfo;

        return superiorInfo;
    }

    #endregion

    #region 画面に値を表示するためのメソッド群(DisplayXxx)

    /// <summary>
    /// 申請情報を元に画面コントロールに値を表示する
    /// </summary>
    /// <param name="application"></param>
    private void DisplayApplication(ApplicationInfo application, string recentCommitteeNo)
    {
        // ヘッダ情報を表示する
        this.DisplayHeader(application, recentCommitteeNo);

        // 資材情報を表示する
        this.DisplayMaterialsMainInfo(application);

        // 配布情報を表示する
        this.DisplayDistributionInfo(application);

        // 上長判定/コメントを表示する
        this.DisplaySuperiorInfo(application);

        // 事務局判定/コメントを表示する
        this.DisplaySecretariatInfo(application);
    }

    /// <summary>
    /// ヘッダ情報を表示する
    /// このメソッドでは次の情報を画面に表示します
    /// ・申請番号
    /// ・申請回数
    /// ・申請日
    /// ・ステータス
    /// ・委員会
    /// ・申請者
    /// ・審議結果
    /// ・登録者
    /// </summary>
    /// <param name="application"></param>
    private void DisplayHeader(ApplicationInfo application, string recentCommitteeNo)
    {
        txtApplicationNo.Text = application.APPLI_NO;
        if (application.REVISION_NO.HasValue)
        {
            txtRevisionNo.Text = application.REVISION_NO.Value.ToString();
        }
        txtApplicationDate.Text = StringUtility.ToDateFormat(application.APPLICATION_DATE);
        if (!CheckUtility.IsEmpty(application.STATUS_NO))
        {
            hdnStatusNo.Value = application.STATUS_NO;
            txtStatus.Text = new StatusManager(application.STATUS_NO).GetStatusName1();
        }

        if (application.COMMITTEE_NO.HasValue)
        {
            ddlCommittee.SelectedValue = application.COMMITTEE_NO.Value.ToString();
        }
        else
        {
            // 委員会が未設定の時
            if (application.Status == Status.SuperiorApprove
                && this.StaffInfo.Role == Role.Secretariat
                && !CheckUtility.IsEmpty(recentCommitteeNo))
            {
                // ステータスが上長承認のとき
                ddlCommittee.SelectedValue = recentCommitteeNo;
            }
        }
        hdnApplicantDivision.Value = application.APPLICANT_DIVISION;
        hdnApplicantDivRegDate.Value = application.APPLICANT_DIV_REG_DATE;
        hdnApplicantStaff.Value = application.APPLICANT_STF_CODE;
        txtApplicantDivision.Text = application.Applicant.CostName;
        hdnApplicantDivisionName.Value = application.Applicant.CostName;
        txtApplicantStaff.Text = application.Applicant.StaffName;
        hdnApplicantStaffName.Value = application.Applicant.StaffName;
        if (!CheckUtility.IsEmpty(application.DISCUSSION_RESULT_STATUS_NO))
        {
            txtDiscussionResult.Text = new StatusManager(application.DISCUSSION_RESULT_STATUS_NO).GetStatusName1();
        }
        hdnRegistrantDivision.Value = application.REGISTRANT_DIVISION;
        hdnRegistrantDivRegDate.Value = application.REGISTRANT_DIV_DATE;
        hdnRegistrantStaff.Value = application.REGISTRANT_STF_CODE;
        txtRegistrantDivision.Text = application.Registrant.CostName;
        txtRegistrantStaff.Text = application.Registrant.StaffName;

        //ADD:SCSK:20141028:2-3:START
        // ステータスが新規作成以外の場合、最終更新者を設定
        if (application.STATUS_NO != ((int)Status.ApplicantNew).ToString())
        {
            application.UpdateUser = GetUpdateUserName(application);
            txtLastUpdateUser.Text = application.UpdateUser.StaffName;
        }
        else
        {
            txtLastUpdateUser.Text = string.Empty;
        }
        //ADD:SCSK:20141028:2-3:END
    }

    /// <summary>
    /// 更新者ユーザー名を取得する
    /// </summary>
    /// <param name="application">申請情報</param>
    /// <returns>更新者情報</returns>
    private ApplicationInfo.Staff GetUpdateUserName(ApplicationInfo application)
    {
        ApplicationInfo.Staff stf = new ApplicationInfo.Staff();

        Dictionary<string, object> paramUser = new Dictionary<string, object>();
        paramUser.Add(SimpleStaffInfoBll.REQUEST_KEY_STAFF_CODE, application.UPD_USERID);
        paramUser.Add(SimpleStaffInfoBll.REQUEST_KEY_BASE_DATE, application.UPD_DATE.ToString("yyyyMMdd"));

        ResponseDataType responseUser = InvokeBllEx(typeof(SimpleStaffInfoBll), paramUser);
        if (!responseUser.IsSuccess)
        {
            this.GenerateMessageJavaScript(StringUtility.GetFormatMessageForJavaScript(responseUser.Messages));
            return stf;
        }

        StaffInfo UpdateStaffInfo = responseUser[SimpleStaffInfoBll.RESPONSE_KEY_STAFF_INFO] as StaffInfo;
        if (UpdateStaffInfo != null)
        {
            stf.StaffName = UpdateStaffInfo.StfNm;
            stf.CostName = UpdateStaffInfo.ScnNm;
        }
        return stf;
    }

    /// <summary>
    /// 資材の主情報を表示する
    /// このメソッドでは次の情報を画面に表示します
    /// ・新規/改訂
    /// ・発注有無
    /// ・改訂元統一コード
    /// ・改訂元発注品番
    /// ・統一コード
    /// ・発注品番
    /// ・資材名称
    /// ・作成目的/資材内容
    /// ・薬剤
    /// ・製品
    /// ・資材媒体
    /// ・資材分類
    /// </summary>
    /// <param name="application"></param>
    private void DisplayMaterialsMainInfo(ApplicationInfo application)
    {
        if (application.REVISE_FLG.HasValue)
        {
            rdbNewOrRevision.SelectedValue = application.REVISE_FLG.Value.ToString();
        }
        if (application.ORDER_FLG.HasValue)
        {
            rdbOrder.SelectedValue = application.ORDER_FLG.Value.ToString();
        }
        hdnOldUniformCode.Value = application.OLD_UNIFORM_CODE;
        txtOldUniformCode.Text = application.OLD_UNIFORM_CODE;
        hdnOldOrderPartCode.Value = application.OLD_ORDER_PART_CODE;
        txtOldOrderPartCode.Text = application.OLD_ORDER_PART_CODE;

        txtUniformCode.Text = application.UNIFORM_CODE;
        txtOrderPartCode.Text = application.ORDER_PART_CODE;

        txtMaterialsName.Text = application.MATERIALS_NM_KNJ;

        txtPurposeAndContent.Text = application.PURPOSE_BACKGROUND;

        hdnDrug.Value = application.DRUG;
        hdnDrugName.Value = application.DRUG_NM_KNJ;
        txtDrug.Text = application.DRUG_NM_KNJ;

        StringBuilder productCodes = new StringBuilder();
        StringBuilder productNames = new StringBuilder();

        if (application.Products != null)
        {
            foreach (var product in application.Products)
            {
                if (productCodes.Length != 0)
                {
                    productCodes.Append(",");
                    productNames.Append(",");
                }

                productCodes.Append(product.PROD_GRP_CODE);
                productNames.Append(product.PROD_GRP_NM_KNJ);
            }
        }

        hdnProduct.Value = productCodes.ToString();
        hdnProductName.Value = productNames.ToString();
        txtProduct.Text = hdnProductName.Value;

        if (application.MATERIALS_CODE.HasValue)
        {
            ddlMaterialsInfo.SelectedValue = application.MATERIALS_CODE.Value.ToString();
        }
        if (application.MATERIALS_CLASS_CODE != null)
        {
            ddlMaterialsClassInfo.SelectedValue = application.MATERIALS_CLASS_CODE;
        }
    }

    /// <summary>
    /// 配布情報を表示する
    /// このメソッドでは次の情報を画面に表示します
    /// ・配布対象
    /// ・制作/印刷業者
    /// ・入稿期限/印刷予定日
    /// ・配布/配信予定日
    /// ・配布/配信期間
    /// ・初回印刷部数
    /// ・引用文献
    /// ・著作権に係る利用許諾
    /// ・著作権に関する状況
    /// </summary>
    /// <param name="application"></param>
    private void DisplayDistributionInfo(ApplicationInfo application)
    {
        //ADD:SCSK:20141201:結合テスト指摘事項一覧管理No.17対応:START
        ApplicationDataContext dataContext = new ApplicationDataContext();
        var productions = from row in dataContext.TBAAMS_PRODUCTION
                          where row.DEL_FLG == '0' 
                          || row.PRODUCTION_CODE == application.PRODUCTION_CODE
                          orderby row.PRODUCTION_CODE
                          select new { PRODUCTION_NAME = row.PRODUCTION_CODE + ":" + row.PRODUCTION_NAME, PRODUCTION_CODE = row.PRODUCTION_CODE, DEL_FLG = row.DEL_FLG, PRODUCTION_DISP_ORDER = row.PRODUCTION_DISP_ORDER } ;
       
        ddlProduction.DataSource = productions;
        ddlProduction.DataTextField = "PRODUCTION_NAME";
        ddlProduction.DataValueField = "PRODUCTION_CODE";
        ddlProduction.DataBind();
        ddlProduction.Items.Insert(0, string.Empty);
        //END:SCSK:20141201:結合テスト指摘事項一覧管理No.17対応:START

        ddlProduction.SelectedValue = application.PRODUCTION_CODE;

        txtPrintedDate.Text = StringUtility.ToDateFormat(application.PRINTED_DATE);

        txtUseStartDate.Text = StringUtility.ToDateFormat(application.USE_START_DATE);
        if (application.DISTRIBUTION_TERM.HasValue)
        {
            txtDistributionTerm.Text = application.DISTRIBUTION_TERM.Value.ToString();
        }
        if (application.FIRST_PRINT_COPIES.HasValue)
        {
            txtFirstPrintCopies.Text = application.FIRST_PRINT_COPIES.Value.ToString();
        }
        if (application.QUOTATION_FLG.HasValue)
        {
            rdbQuotation.SelectedValue = application.QUOTATION_FLG.Value.ToString();
        }
        rdbLicenseAgreement.SelectedValue = application.LICENSE_AGREEMENT;

        txtLicenseConditions.Text = application.LICENSE_CONDITIONS;
    }

    /// <summary>
    /// 上長判定/コメントを表示する
    /// このメソッドでは次の情報を画面に表示します
    /// ・上長判定
    /// ・上長
    /// ・上長コメント
    /// </summary>
    /// <param name="application"></param>
    private void DisplaySuperiorInfo(ApplicationInfo application)
    {
        if (!CheckUtility.IsEmpty(application.SUPERIOR_STATUS_NO))
        {
            txtSuperiorStatus.Text = new StatusManager(application.SUPERIOR_STATUS_NO).GetStatusName1();
            hdnSuperiorStatusNo.Value = application.SUPERIOR_STATUS_NO;
            txtSuperiorComment.Text = application.SUPERIOR_COMMENT;

            //上長差し戻しの場合、コメントを赤字にする
            if (new StatusManager(application.SUPERIOR_STATUS_NO).GetStatus() == Status.SuperiorSendBack)
            {
                txtSuperiorComment.Style.Add("color", "#FF0000");
                txtSuperiorComment.ReadOnlyStyle = txtSuperiorComment.ReadOnlyStyle + "color:#FF0000";
            }

        }
        //ADD:SCSK:20141120:IT指摘事項No.9:START
        else if (!CheckUtility.IsEmpty(application.SUPERIOR_COMMENT))
        {
            txtSuperiorComment.Text = application.SUPERIOR_COMMENT;
        }
        //ADD:SCSK:20141120:IT指摘事項No.9:START

        if (application.Superior != null)
        {
            hdnSuperiorDivision.Value = application.SUPERIOR_DIVISION;
            hdnSuperiorStaff.Value = application.SUPERIOR_STF_CODE;
            hdnSuperiorDivRegDate.Value = application.SUPERIOR_DIV_REG_DATE;

            txtSuperiorDivision.Text = application.Superior.CostName;
            hdnSuperiorDivisionName.Value = application.Superior.CostName;
            txtSuperiorStaff.Text = application.Superior.StaffName;
            hdnSuperiorStaffName.Value = application.Superior.StaffName;
        }
    }

    /// <summary>
    /// 事務局判定/コメントを表示する
    /// このメソッドでは次の情報を画面に表示します
    /// ・事務局判定
    /// ・審議種別
    /// ・事務局コメント
    /// </summary>
    /// <param name="application"></param>
    private void DisplaySecretariatInfo(ApplicationInfo application)
    {
        if (!CheckUtility.IsEmpty(application.SECRETARIAT_STATUS_NO))
        {
            txtSecretariatStatus.Text = new StatusManager(application.SECRETARIAT_STATUS_NO).GetStatusName1();
            hdnSecretariatStatusNo.Value = application.SECRETARIAT_STATUS_NO;
            if (application.DISCUSSION_CLASS.HasValue)
            {
                rdbDiscussionClass.SelectedValue = application.DISCUSSION_CLASS.Value.ToString();
            }
        }

        if (application.SecretariatComments == null)
        {
            application.SecretariatComments = new List<ApplicationInfo.SecretariatComment>();
        }

        application.SecretariatComments.Insert(0, (new ApplicationInfo.SecretariatComment() { SECRETARIAT_COMMENT_DATE = null, SECRETARIAT_COMMENT = null }));

        //MOD:SCSK:20141028:2-3:START
        //gvSecretariatComment.DataSource = application.SecretariatComments;
        //gvSecretariatComment.DataBind();

        ////事務局差し戻しor対象外で、2行目が存在する場合、2行目の文字を赤くする
        //for (int i = 0; i < gvSecretariatComment.Rows.Count; i++)
        //{
        //    if (i == 1
        //        && (new StatusManager(application.SECRETARIAT_STATUS_NO).GetStatus() == Status.SecretariatSendBack
        //        || new StatusManager(application.SECRETARIAT_STATUS_NO).GetStatus() == Status.SecretariatNoJudge))
        //    {
        //        ApplicationTextBox txtSecretariatComment = (ApplicationTextBox)gvSecretariatComment.Rows[i].FindControl("txtSecretariatComment");

        //        if (txtSecretariatComment != null)
        //        {
        //            txtSecretariatComment.Style.Add("color", "#FF0000");
        //            txtSecretariatComment.ReadOnlyStyle = txtSecretariatComment.ReadOnlyStyle + "color:#FF0000";
        //        }
        //    }
        //}

        foreach (var secretariatComment in application.SecretariatComments)
        {
            txtSecretariatComment.Text = secretariatComment.SECRETARIAT_COMMENT;
        }

        //事務局差し戻しor対象外で事務局コメントの文字を赤くする
        if (!string.IsNullOrEmpty(application.SECRETARIAT_STATUS_NO))
        {
            if (new StatusManager(application.SECRETARIAT_STATUS_NO).GetStatus() == Status.SecretariatSendBack ||
                new StatusManager(application.SECRETARIAT_STATUS_NO).GetStatus() == Status.SecretariatNoJudge)
            {
                txtSecretariatComment.Style.Add("color", "#FF0000");
                txtSecretariatComment.ReadOnlyStyle = txtSecretariatComment.ReadOnlyStyle + "color:#FF0000";
            }
        }
        //MOD:SCSK:20141028:2-3:END
    }

    #endregion

    #region ボタン制御メソッド群(ViewMenuButtonXXX/HideXXX)

    /// <summary>
    /// ボタンの表示/非表示制御
    /// </summary>
    /// <param name="statusManager">現在のステータス</param>
    private void ViewMenuButton(StatusManager statusManager, bool isHistory)
    {
        // すべてのメニューボタンを無効化する
        this.HideAllMenuButton();

        // 審議結果ボタン制御(審議結果は履歴表示の時にも表示する)
        switch (statusManager.GetStatus())
        {
            case Status.ApplicantNew:
            case Status.ApplicantSave:
            case Status.ApplicantApply:
            case Status.ApplicantReApply:
            case Status.SuperiorApprove:
            case Status.SuperiorSendBack:
            case Status.SecretariatAccept:
            case Status.SecretariatNoJudge:
                break;
            default:
                btnDiscussionResult.Visible = true;
                break;

        }

        if (statusManager.GetStatus() != Status.ApplicantNew)
        {
            // ステータスが新規作成以外のとき(一度でもデータベース登録が行われたときには有効)
            // 申請資材、申請内容出力、ステータス履歴
            btnViewMaterials.Visible = true;
            btnExportApplication.Visible = true;
            btnApplicationHistory.Visible = true;
        }

        if (isHistory)
        {
            return;
        }

        if (hdnSuperiorStaff.Value == this.StaffInfo.StfCd && (statusManager.GetStatus() == Status.ApplicantApply || statusManager.GetStatus() == Status.ApplicantReApply))
        {
            // 上長かつステータスが上長承認待ちのとき
            this.ViewMenuButtonSuperior(statusManager);
        }
        else if (this.StaffInfo.Role == Role.Applicant)
        {
            // 申請者のとき
            this.ViewMenuButtonApplicant(statusManager);
        }
        else if (this.StaffInfo.Role == Role.Secretariat || this.StaffInfo.Role == Role.SystemAdministrator)
        {
            // 事務局のとき
            this.ViewMenuButtonSecretariat(statusManager);
        }

        // 元資材選択は改訂のときのみ
        if (rdbNewOrRevision.SelectedValue == "0")
        {
            btnSelectOldMaterials.Enabled = false;
        }

        // 利用許諾取得の状況は利用許諾を要する転載が有のときのみ
        if (rdbQuotation.SelectedValue == "0")
        {
            rdbLicenseAgreement.Enabled = false;
            rdbLicenseAgreement.SelectedIndex = -1;
        }

    }

    /// <summary>
    /// ログイン者が申請者のときのボタン制御
    /// </summary>
    /// <param name="statusManager"></param>
    private void ViewMenuButtonApplicant(StatusManager statusManager)
    {
        lblTitle.Text = "申請入力";

        string completeRegister = Request[ConstValue.QUERY_STRING_KEY_COMPLETE_REGISTER];

        if (completeRegister != null && completeRegister == "2")
        {
            // 上長申請直後のとき
            btnCopy.Visible = true;
            btnNew.Visible = true;
        }

        if (statusManager.GetActiveRole() != Role.Applicant)
        {
            if (statusManager.GetStatus() == Status.SecretariatPermitPublic)
            {
                //MOD:SCSK:20141028:2-3:START
                //// 公開許可かつ発注品番要否が否のとき
                //if (rdbOrder.SelectedValue == "0")
                //{
                //    btnOrderUpdate.Visible = true;
                //}
                btnOrderUpdate.Visible = true;
                //MOD:SCSK:20141028:2-3:END
            }
            return;
        }

        // アクティブな役割が申請者のときには有効
        //btnSelectApplicant.Visible = true;    //申請者は変更不可
        btnSelectDrug.Visible = true;
        btnSelectOldMaterials.Visible = true;
        btnSelectSuperior.Visible = true;

        switch (statusManager.GetStatus())
        {
            case Status.ApplicantNew:
                btnSave.Visible = true;
                btnApply.Visible = true;
                break;
            case Status.ApplicantSave:
                btnSave.Visible = true;
                btnApply.Visible = true;
                btnDelete.Visible = true;
                break;
            case Status.SuperiorSendBack:
                btnApply.Visible = true;
                btnDelete.Visible = true;
                break;
            case Status.SecretariatSendBack:
            case Status.CommitteeReserve:
                btnReApply.Visible = true;
                btnDelete.Visible = true; ;
                break;
            case Status.CommitteeConditionalPermit:
                btnSubmit.Visible = true;
                break;
            case Status.SecretariatSendBackSubmission:
            case Status.ChairpersonSendBack:
                btnSubmit.Visible = true;
                break;
            case Status.CommitteePermit:
            case Status.ChairpersonPermit:
            case Status.SecretariatSendBackPublic:
                btnRequestConfirmartion.Visible = true;
                break;
        }
    }

    /// <summary>
    /// ログイン者の上長のときの表示/非表示制御
    /// </summary>
    /// <param name="statusManager"></param>
    private void ViewMenuButtonSuperior(StatusManager statusManager)
    {
        lblTitle.Text = "申請入力(上長判定)";

        if (statusManager.GetActiveRole() != Role.Superior)
        {
            if (hdnApplicantStaff.Value == this.StaffInfo.StfCd)
            {
                // 申請者が自分であり、かつ次の役割が上長でないとき、申請者として振舞う
                this.ViewMenuButtonApplicant(statusManager);
            }
            return;
        }

        // アクティブな役割が上長のときには有効
        btnSelectApplicant.Visible = true;
        btnSelectDrug.Visible = true;
        btnSelectOldMaterials.Visible = true;
        btnSelectSuperior.Visible = true;

        switch (statusManager.GetStatus())
        {
            case Status.ApplicantApply:
            case Status.ApplicantReApply:
                btnSuperiorApprove.Visible = true;
                btnSuperiorSendBack.Visible = true;
                break;
        }
    }

    /// <summary>
    /// ログイン者が事務局の時のボタン制御
    /// </summary>
    /// <param name="statusManager"></param>
    private void ViewMenuButtonSecretariat(StatusManager statusManager)
    {
        if (statusManager.GetActiveRole() == Role.Secretariat)
        {
            lblTitle.Text = "事務局判定";
            // アクティブな役割が事務局のときには有効
            btnSelectApplicant.Visible = true;
            btnSelectDrug.Visible = true;
            btnSelectOldMaterials.Visible = true;
            btnSelectSuperior.Visible = true;

            switch (statusManager.GetStatus())
            {
                case Status.SuperiorApprove:
                    btnUpdate.Visible = true;
                    btnAccept.Visible = true;
                    btnSendBack.Visible = true;
                    btnNoJudge.Visible = true;
                    break;
                case Status.SecretariatAccept:
                case Status.SecretariatAcceptDiscuss:
                case Status.SecretariatAcceptNoDiscuss:
                    btnUpdate.Visible = true;
                    break;
            }
        }
        else if (statusManager.GetActiveRole() == Role.Applicant)
        {
            lblTitle.Text = "申請入力";
            // アクティブな役割が申請者のときには有効
            btnSelectApplicant.Visible = true;
            btnSelectDrug.Visible = true;
            btnSelectOldMaterials.Visible = true;
            btnSelectSuperior.Visible = true;

            switch (statusManager.GetStatus())
            {
                case Status.ApplicantNew:
                    btnSave.Visible = true;
                    btnApply.Visible = true;
                    break;
                case Status.ApplicantSave:
                    btnSave.Visible = true;
                    btnApply.Visible = true;
                    //ADD:SCSK:20141028:2-3:START
                    btnDelete.Visible = true;
                    //ADD:SCSK:20141028:2-3:END
                    break;
                case Status.SuperiorSendBack:
                    btnApply.Visible = true;
                    break;
                case Status.SecretariatSendBack:
                    btnReApply.Visible = true;
                    break;
                case Status.CommitteeConditionalPermit:
                    btnSubmit.Visible = true;
                    break;
                case Status.SecretariatSendBackSubmission:
                case Status.ChairpersonSendBack:
                    btnSubmit.Visible = true;
                    break;
                case Status.CommitteePermit:
                case Status.ChairpersonPermit:
                case Status.SecretariatSendBackPublic:
                    btnRequestConfirmartion.Visible = true;
                    break;
            }
        }
        else if (statusManager.GetActiveRole() == Role.Superior)
        {

            lblTitle.Text = "申請入力(上長判定)";

            // アクティブな役割が上長のときには有効
            btnSelectApplicant.Visible = true;
            btnSelectDrug.Visible = true;
            btnSelectOldMaterials.Visible = true;
            btnSelectSuperior.Visible = true;

            switch (statusManager.GetStatus())
            {
                case Status.ApplicantApply:
                case Status.ApplicantReApply:
                    btnSuperiorApprove.Visible = true;
                    btnSuperiorSendBack.Visible = true;
                    break;
            }
        }
        else
        {
            if (statusManager.GetStatus() == Status.SecretariatPermitPublic)
            {
                //MOD:SCSK:20141028:2-3:START
                //// 公開許可かつ発注品番要否が否のとき
                //if (rdbOrder.SelectedValue == "0")
                //{
                //    btnOrderUpdate.Visible = true;
                //}
                btnOrderUpdate.Visible = true;
                //MOD:SCSK:20141028:2-3:END
            }
        }
    }

    private void HideAllMenuButton()
    {
        // 申請者向けボタン
        btnSave.Visible = false;
        btnApply.Visible = false;
        btnDelete.Visible = false;
        btnCopy.Visible = false;
        btnReApply.Visible = false;
        btnSubmit.Visible = false;
        btnRequestConfirmartion.Visible = false;

        // 上長向けボタン
        btnSuperiorApprove.Visible = false;
        btnSuperiorSendBack.Visible = false;


        // 事務局向けボタン
        btnUpdate.Visible = false;
        btnAccept.Visible = false;
        btnSendBack.Visible = false;
        btnNoJudge.Visible = false;

        // 申請者、事務局向けボタン
        btnDiscussionResult.Visible = false;
        btnOrderUpdate.Visible = false;

        // 共通ボタン
        btnViewMaterials.Visible = false;
        btnExportApplication.Visible = false;
        btnApplicationHistory.Visible = false;

        // 画面内ボタン

        btnSelectApplicant.Visible = false;
        btnSelectDrug.Visible = false;
        btnSelectOldMaterials.Visible = false;
        btnSelectSuperior.Visible = false;
    }

    #endregion

    #region コントロールの表示非表示制御のためのメソッド群(ViewControlXxx)

    private void ViewControl(StatusManager statusManager, bool isHistory)
    {
        if (isHistory)
        {
            this.ViewControlNoEditable();
            return;
        }

        if (hdnSuperiorStaff.Value == this.StaffInfo.StfCd && (statusManager.GetStatus() == Status.ApplicantApply || statusManager.GetStatus() == Status.ApplicantReApply))
        {
            // 上長かつステータスが上長承認待ちのとき
            this.ViewControlSuperior(statusManager);
        }
        else if (this.StaffInfo.Role == Role.Applicant)
        {
            // 申請者のとき
            this.ViewControlApplicant(statusManager);
        }
        else if (this.StaffInfo.Role == Role.Secretariat || this.StaffInfo.Role == Role.SystemAdministrator)
        {
            // 事務局のとき
            this.ViewControlSecretariat(statusManager);
        }

        if (btnOrderUpdate.Visible == true)
        {
            rdbOrder.Enabled = true;
        }

        //ADD:SCSK:20141028:2-3:START
        ViewControlsCommon(statusManager, this.StaffInfo.Role);
        //ADD:SCSK:20141028:2-3:END
    }

    private void ViewControlApplicant(StatusManager statusManager)
    {
        // 上長、事務局の入力項目は常に入力不可
        ddlCommittee.Editable = false;
        txtSuperiorComment.Editable = false;
        rdbDiscussionClass.Enabled = false;
        ddlMaterialsClassInfo.Editable = false;

        //MOD:SCSK:20141028:2-3:START
        //foreach (GridViewRow gvRow in gvSecretariatComment.Rows)
        //{
        //    ApplicationTextBox txtSecretariatComment = (ApplicationTextBox)gvRow.FindControl("txtSecretariatComment");
        //    txtSecretariatComment.Editable = false;
        //}
        txtSecretariatComment.Editable = false;
        //MOD:SCSK:20141028:2-3:END

        if (statusManager.GetActiveRole() == Role.Applicant)
        {
            // アクティブな役割が申請者のとき
            return;
        }

        // アクティブな役割が申請者でないとき
        rdbNewOrRevision.Enabled = false;
        rdbOrder.Enabled = false;
        txtMaterialsName.Editable = false;
        txtPurposeAndContent.Editable = false;
        ddlMaterialsInfo.Editable = false;
        chkDistributionObject.Enabled = false;
        ddlProduction.Editable = false;
        txtPrintedDate.Editable = false;
        txtUseStartDate.Editable = false;
        txtDistributionTerm.Editable = false;
        txtFirstPrintCopies.Editable = false;
        rdbQuotation.Enabled = false;
        rdbLicenseAgreement.Enabled = false;
        txtLicenseConditions.Editable = false;
    }

    private void ViewControlSuperior(StatusManager statusManager)
    {
        // 事務局の入力項目は常に入力不可
        ddlCommittee.Editable = false;
        rdbDiscussionClass.Enabled = false;
        ddlMaterialsClassInfo.Editable = false;

        //MOD:SCSK:20141028:2-3:START
        //foreach (GridViewRow gvRow in gvSecretariatComment.Rows)
        //{
        //    ApplicationTextBox txtSecretariatComment = (ApplicationTextBox)gvRow.FindControl("txtSecretariatComment");
        //    txtSecretariatComment.Editable = false;
        //}
        txtSecretariatComment.Editable = false;
        //MOD:SCSK:20141028:2-3:END

        if (statusManager.GetActiveRole() == Role.Superior)
        {
            // アクティブな役割が上長のとき
            return;
        }
        else
        {
            // アクティブな役割が上長でないとき
            if (hdnApplicantStaff.Value == this.StaffInfo.StfCd)
            {
                // 申請者が自分であり、かつ次の役割が上長でないとき、申請者として振舞う
                this.ViewControlApplicant(statusManager);
                return;
            }
        }

        // アクティブな役割が申請者でないとき
        rdbNewOrRevision.Enabled = false;
        rdbOrder.Enabled = false;
        txtMaterialsName.Editable = false;
        txtPurposeAndContent.Editable = false;
        ddlMaterialsInfo.Editable = false;
        chkDistributionObject.Enabled = false;
        ddlProduction.Editable = false;
        txtPrintedDate.Editable = false;
        txtUseStartDate.Editable = false;
        txtDistributionTerm.Editable = false;
        txtFirstPrintCopies.Editable = false;
        rdbQuotation.Enabled = false;
        rdbLicenseAgreement.Enabled = false;
        txtLicenseConditions.Editable = false;

        txtSuperiorComment.Editable = false;

    }

    private void ViewControlSecretariat(StatusManager statusManager)
    {
        if (!CheckUtility.IsEmpty(txtDiscussionResult.Text)
            || (statusManager.GetActiveRole() != Role.Secretariat && (statusManager.GetActiveRole() == Role.Applicant || statusManager.GetActiveRole() == Role.Superior)))
        {
            // 審議結果が出ているとき
            ddlCommittee.Editable = false;
        }

        if (statusManager.GetActiveRole() == Role.Applicant)
        {
            // アクティブな役割が申請者のとき
            // 申請者として振舞う
            this.ViewControlApplicant(statusManager);

            return;
        }
        else if (statusManager.GetActiveRole() == Role.Superior)
        {
            // アクティブな役割が上長のとき
            // 上長として振舞う
            this.ViewControlSuperior(statusManager);

            return;
        }
        else if (statusManager.GetActiveRole() == null)
        {
            // 次の役割がない今後変更されない申請は変更不可
            ddlCommittee.Editable = false;
            rdbNewOrRevision.Enabled = false;
            rdbOrder.Enabled = false;
            txtMaterialsName.Editable = false;
            txtPurposeAndContent.Editable = false;
            ddlMaterialsInfo.Editable = false;
            ddlMaterialsClassInfo.Editable = false;
            chkDistributionObject.Enabled = false;
            ddlProduction.Editable = false;
            txtPrintedDate.Editable = false;
            txtUseStartDate.Editable = false;
            txtDistributionTerm.Editable = false;
            txtFirstPrintCopies.Editable = false;
            rdbQuotation.Enabled = false;
            rdbLicenseAgreement.Enabled = false;
            txtLicenseConditions.Editable = false;

            txtSuperiorComment.Editable = false;

            rdbDiscussionClass.Enabled = false;

            //MOD:SCSK:20141028:2-3:START
            //foreach (GridViewRow gvRow in gvSecretariatComment.Rows)
            //{
            //    ApplicationTextBox txtSecretariatComment = (ApplicationTextBox)gvRow.FindControl("txtSecretariatComment");
            //    txtSecretariatComment.Editable = false;
            //}
            txtSecretariatComment.Editable = false;
            //MOD:SCSK:20141028:2-3:END
        }
    }

    private void ViewControlNoEditable()
    {
        // すべてのコントロールを変更不可にする
        ddlCommittee.Editable = false;
        rdbNewOrRevision.Enabled = false;
        rdbOrder.Enabled = false;
        txtMaterialsName.Editable = false;
        txtPurposeAndContent.Editable = false;
        ddlMaterialsInfo.Editable = false;
        ddlMaterialsClassInfo.Editable = false;
        chkDistributionObject.Enabled = false;
        ddlProduction.Editable = false;
        txtPrintedDate.Editable = false;
        txtUseStartDate.Editable = false;
        txtDistributionTerm.Editable = false;
        txtFirstPrintCopies.Editable = false;
        rdbQuotation.Enabled = false;
        rdbLicenseAgreement.Enabled = false;
        txtLicenseConditions.Editable = false;

        txtSuperiorComment.Editable = false;

        rdbDiscussionClass.Enabled = false;

        //MOD:SCSK:20141028:2-3:START
        //foreach (GridViewRow gvRow in gvSecretariatComment.Rows)
        //{
        //    ApplicationTextBox txtSecretariatComment = (ApplicationTextBox)gvRow.FindControl("txtSecretariatComment");
        //    txtSecretariatComment.Editable = false;
        //}
        txtSecretariatComment.Editable = false;
        //MOD:SCSK:20141028:2-3:END
    }

    //ADD:SCSK:20141028:2-3:START
    /// <summary>
    /// コントロールの表示、編集制御
    /// </summary>
    /// <param name="isVisibleBtnUpdate">更新ボタンを表示するか(true:Yes/false:No)</param>
    /// <param name="isControlRdbOrder">発注品番の要否コントロールの表示制御をするか(true:Yes/false:No)</param>
    private void ViewControlVisibleAndEdiable(bool isVisibleBtnUpdate)
    {
        // コントロールを表示 かつ 変更可にする
        btnSelectApplicant.Visible = true;
        btnSelectDrug.Visible = true;
        btnSelectOldMaterials.Visible = true;
        btnSelectSuperior.Visible = true;
        if (isVisibleBtnUpdate)
        {
            btnUpdate.Visible = true;
        }
        rdbNewOrRevision.Enabled = true;
        rdbOrder.Enabled = true;

        txtMaterialsName.Editable = true;
        txtPurposeAndContent.Editable = true;
        ddlMaterialsInfo.Editable = true;
        ddlMaterialsClassInfo.Editable = true;
        chkDistributionObject.Enabled = true;
        ddlProduction.Editable = true;
        txtPrintedDate.Editable = true;
        txtFirstPrintCopies.Editable = true;
        txtUseStartDate.Editable = true;
        txtDistributionTerm.Editable = true;
        rdbQuotation.Enabled = true;
        txtLicenseConditions.Editable = true;
        txtSuperiorComment.Editable = true;
        txtSecretariatComment.Editable = true;

        // 新規の場合、元資材選択ボタンは非活性
        if (rdbNewOrRevision.SelectedValue == "0")
        {
            btnSelectOldMaterials.Enabled = false;
        }

        // 利用許諾取得の状況は利用許諾を要する転載が有のときのみ
        if (rdbQuotation.SelectedValue == "0")
        {
            rdbLicenseAgreement.Enabled = false;
            rdbLicenseAgreement.SelectedIndex = -1;
        }
        else
        {
            rdbLicenseAgreement.Enabled = true;
        }
    }

    /// <summary>
    /// 共通画面項目の表示制御
    /// </summary>
    /// <param name="statusManager">ステータス管理クラス</param>
    /// <param name="staffInfoRole">申請者の権限</param>
    private void ViewControlsCommon(StatusManager statusManager, Role staffInfoRole)
    {
        bool isControlRdbOrder = false; // 発注品番の要否rdbを表示制御するか(true:Yes/false:No)
        bool isControlEditable = false; // 事務局権限(システム管理者権限)時にコントロールを編集可にするか(true:Yes/false:No)

        // 事務局権限またはシステム管理者権限の場合
        if (staffInfoRole == Role.Secretariat || this.StaffInfo.Role == Role.SystemAdministrator)
        {
            switch (statusManager.GetStatus())
            {
                case Status.ApplicantNew:                   // 新規作成
                case Status.ApplicantSave:                  // 一時保存
                    break;
                case Status.ApplicantApply:                 // 申請
                case Status.ApplicantReApply:               // 再申請
                    ddlMaterialsClassInfo.Editable = true;
                    btnUpdate.Visible = true;
                    break;
                case Status.CommitteePermit:                // 審議結果:許可
                case Status.CommitteeConditionalPermit:     // 審議結果:条件付許可
                case Status.SecretariatSendBackSubmission:  // 事務局差し戻し(提出)
                case Status.ChairpersonSendBack:            // 委員長差し戻し
                case Status.ChairpersonPermit:              // 委員長許可
                case Status.SecretariatSendBackPublic:      // 差し戻し(公開NG)
                    btnUpdate.Visible = true;
                    isControlEditable = true;
                    if (statusManager.GetStatus() != Status.CommitteeConditionalPermit &&
                        statusManager.GetStatus() != Status.ChairpersonSendBack &&
                        statusManager.GetStatus() != Status.SecretariatSendBackSubmission)
                    { 
                        isControlRdbOrder = true; 
                    }
                    break;
                case Status.CommitteeNoPermit:              // 審議結果:不許可
                case Status.CommitteeSendBack:              // 審議結果:差し戻し
                    ViewControlVisibleAndEdiable(true);
                    break;
                case Status.SuperiorSendBack:               // 上長差し戻し
                case Status.SecretariatSendBack:            // 事務局差し戻し
                case Status.CommitteeReserve:               // 審議結果:留保
                    if (statusManager.GetStatus() == Status.SuperiorSendBack)
                    {
                        ddlMaterialsClassInfo.Editable = true;
                    }
                    else
                    {
                        isControlEditable = true;
                    }
                    btnDelete.Visible = true;
                    btnUpdate.Visible = true;
                    if (statusManager.GetStatus() == Status.CommitteeReserve) 
                    {
                        btnReApply.Visible = true;
                    }
                    break;
                case Status.ApplicantSubmit:                // 修正資材提出
                case Status.SecretariatAcceptSubmission:    // 事務局受理(提出)
                case Status.ApplicantRequestPublic:         // 完成品確認依頼
                    rdbDiscussionClass.Enabled = false;
                    btnUpdate.Visible = true;
                    if (statusManager.GetStatus() == Status.ApplicantRequestPublic) { isControlRdbOrder = true; }
                    break;
                case Status.SecretariatPermitPublic:        // 許可(公開OK)
                    ViewControlVisibleAndEdiable(false);
                    isControlRdbOrder = true;
                    break;
                case Status.SecretariatNoJudge:             // 事務局未判定
                case Status.ApplicantDelete:                // 申請削除
                    btnSelectDrug.Visible = true;
                    btnSelectSuperior.Visible = true;
                    btnSelectDrug.Enabled = false;
                    btnSelectSuperior.Enabled = false;
                    break;
                default:
                    isControlEditable = true;
                    break;
            }
        }
        else
        {
            switch (statusManager.GetStatus())
            {
                case Status.SecretariatAcceptDiscuss:       // 事務局受理(審議Ⅰ、Ⅱ)
                    btnDiscussionResult.Visible = false;
                    break;
                case Status.CommitteePermit:                // 審議結果:許可
                case Status.ChairpersonPermit:              // 委員長許可
                case Status.SecretariatSendBackPublic:      // 差し戻し(公開NG)
                    btnSelectDrug.Enabled = false;
                    isControlRdbOrder = true;
                    break;
                case Status.SecretariatNoJudge:             // 事務局未判定(対象外)
                case Status.ApplicantDelete:                // 申請削除
                    btnSelectDrug.Visible = true;
                    btnSelectDrug.Enabled = false;
                    btnSelectSuperior.Visible = true;
                    btnSelectSuperior.Enabled = false;
                    break;
                case Status.ApplicantRequestPublic:         // 完成品確認依頼
                case Status.SecretariatPermitPublic:        // 許可(公開OK)
                    btnOrderUpdate.Visible = false;
                    //MOD:SCSK:20141125:IT指摘事項No.14:START
                    //rdbNewOrRevision.Visible = false;
                    //rdbOrder.Visible = false;
                    rdbOrder.Enabled = false;
                    //MOD:SCSK:20141125:IT指摘事項No.14:END
                    break;
            }
        }

        ApplicationInfo originalApplication = (ApplicationInfo)Session[ConstValue.SESSION_KEY_APPLICATION_INFO];

        // 発注品番の要否rdbの表示制御をする場合
        if ((isControlRdbOrder) && (originalApplication.ORDER_FLG == '1'))
        {
            if (rdbOrder.SelectedValue == "1")
            {
                rdbNewOrRevision.Enabled = false;
                rdbOrder.Enabled = false;
                btnSelectOldMaterials.Enabled = false;
            }
        }

        // コントロールを編集可にする場合
        if (isControlEditable)
        {
            ddlMaterialsClassInfo.Editable = true;
            txtSuperiorComment.Editable = true;
            txtSecretariatComment.Editable = true;
        }
    }
    //ADD:SCSK:20141028:2-3:END
    #endregion

    /// <summary>
    /// 履歴と比較して資材情報が更新された項目のスタイルを変更する
    /// </summary>
    /// <param name="application"></param>
    /// <param name="applicationHistory"></param>
    private void ApplyUpdatedStyle(ApplicationInfo application, ApplicationInfo applicationHistory)
    {
        if (application.DRUG != applicationHistory.DRUG)
        {
            this.ChangeStyleUpdated(tdDrug);
        }

        if (application.REVISE_FLG != applicationHistory.REVISE_FLG)
        {
            this.ChangeStyleUpdated(tdNewOrRevision);
        }

        if (application.ORDER_FLG != applicationHistory.ORDER_FLG)
        {
            this.ChangeStyleUpdated(tdOrder);
        }

        if (application.OLD_UNIFORM_CODE != applicationHistory.OLD_UNIFORM_CODE)
        {
            this.ChangeStyleUpdated(tdOldUniformCode);
        }

        if (application.OLD_ORDER_PART_CODE != applicationHistory.OLD_ORDER_PART_CODE)
        {
            this.ChangeStyleUpdated(tdOldUniformCode);
        }

        if (application.MATERIALS_NM_KNJ != applicationHistory.MATERIALS_NM_KNJ)
        {
            this.ChangeStyleUpdated(tdMaterialsName);
        }

        if (application.PURPOSE_BACKGROUND != applicationHistory.PURPOSE_BACKGROUND)
        {
            this.ChangeStyleUpdated(tdPurposeAndContent);
        }

        if (application.MATERIALS_CODE != applicationHistory.MATERIALS_CODE)
        {
            this.ChangeStyleUpdated(tdMaterialsInfo);
        }

        if (application.MATERIALS_CLASS_CODE != applicationHistory.MATERIALS_CLASS_CODE)
        {
            this.ChangeStyleUpdated(tdMaterialsClassInfo);
        }

        bool isUpdatedDistributionObjects = false;

        if ((application.DistributionObjects == null && applicationHistory.DistributionObjects != null)
            || application.DistributionObjects != null && applicationHistory.DistributionObjects == null)
        {
            isUpdatedDistributionObjects = true;
        }

        if (application.DistributionObjects != null && applicationHistory.DistributionObjects != null)
        {
            if (application.DistributionObjects.Count != applicationHistory.DistributionObjects.Count)
            {
                isUpdatedDistributionObjects = true;
            }
            else
            {
                for (int i = 0; i < application.DistributionObjects.Count; i++)
                {
                    if (application.DistributionObjects[i] != applicationHistory.DistributionObjects[i])
                    {
                        isUpdatedDistributionObjects = true;
                    }
                }
            }
        }

        if (isUpdatedDistributionObjects)
        {
            this.ChangeStyleUpdated(tdDistributionObject);
        }

        bool isUpdatedProducts = false;

        if ((application.Products == null && applicationHistory.Products != null) || application.Products != null && applicationHistory.Products == null)
        {
            isUpdatedProducts = true;
        }

        if (application.Products != null && applicationHistory.Products != null)
        {
            if (application.Products.Count != applicationHistory.Products.Count)
            {
                isUpdatedProducts = true;
            }
            else
            {
                for (int i = 0; i < application.Products.Count; i++)
                {
                    if (application.Products[i].PROD_GRP_CODE != applicationHistory.Products[i].PROD_GRP_CODE)
                    {
                        isUpdatedProducts = true;
                    }
                }
            }
        }

        if (isUpdatedProducts)
        {
            this.ChangeStyleUpdated(tdProduct);
        }

        if (application.PRODUCTION_CODE != applicationHistory.PRODUCTION_CODE)
        {
            this.ChangeStyleUpdated(tdProduction);
        }

        if (application.PRINTED_DATE != applicationHistory.PRINTED_DATE)
        {
            this.ChangeStyleUpdated(tdPrintedDate);
        }

        if (application.USE_START_DATE != applicationHistory.USE_START_DATE)
        {
            this.ChangeStyleUpdated(tdUseStartDate);
        }

        if (application.DISTRIBUTION_TERM != applicationHistory.DISTRIBUTION_TERM)
        {
            this.ChangeStyleUpdated(tdDistributionTerm);
        }

        if (application.FIRST_PRINT_COPIES != applicationHistory.FIRST_PRINT_COPIES)
        {
            this.ChangeStyleUpdated(tdFirstPrintCopies);
        }

        if (application.QUOTATION_FLG != applicationHistory.QUOTATION_FLG)
        {
            this.ChangeStyleUpdated(tdQuotation);
        }

        if (application.LICENSE_AGREEMENT != applicationHistory.LICENSE_AGREEMENT)
        {
            this.ChangeStyleUpdated(tdLicenseAgreement);
        }

        if (application.LICENSE_CONDITIONS != applicationHistory.LICENSE_CONDITIONS)
        {
            this.ChangeStyleUpdated(tdLicenseConditions);
        }
    }

    /// <summary>
    /// TDタグのスタイルを更新有りスタイルに変更する
    /// </summary>
    /// <param name="tdTag"></param>
    private void ChangeStyleUpdated(HtmlTableCell tdTag)
    {
        tdTag.Style[HtmlTextWriterStyle.Color] = "red";
        tdTag.Style[HtmlTextWriterStyle.TextDecoration] = "underline";
    }

    /// <summary>
    /// ReadOnly項目の値の復帰を行なう
    /// </summary>
    private void SetReadOnlyValue()
    {
        if (!CheckUtility.IsEmpty(hdnApplicantStaffName))
        {
            txtApplicantDivision.Text = hdnApplicantDivisionName.Value;
            txtApplicantStaff.Text = hdnApplicantStaffName.Value;
        }

        if (!CheckUtility.IsEmpty(hdnSuperiorStaffName))
        {
            txtSuperiorDivision.Text = hdnSuperiorDivisionName.Value;
            txtSuperiorStaff.Text = hdnSuperiorStaffName.Value;
        }

        if (!CheckUtility.IsEmpty(hdnDrugName))
        {
            txtDrug.Text = hdnDrugName.Value;
            txtProduct.Text = hdnProductName.Value;
        }

        if (!CheckUtility.IsEmpty(hdnOldApplicationNo))
        {
            txtOldUniformCode.Text = hdnOldUniformCode.Value;
            txtOldOrderPartCode.Text = hdnOldOrderPartCode.Value;
        }
    }

    /// <summary>
    /// 申請者に結びつくデフォルトの上長を設定する
    /// </summary>
    /// <param name="application"></param>
    /// <returns></returns>
    private ApplicationInfo SetDefaultSuperior(ApplicationInfo application)
    {
        WebLogUtility.WriteDebugLog("時間計測 : SetDefaultSuperior 開始[" + DateTime.Now.ToString("yyyy:MM:dd HH:mm:ss.ffff") + "]");

        // 事業企画申請上長取得
        StaffInfo superiorInfo = this.GetDefaultSuperior(this.StaffInfo.CstCd, this.StaffInfo.StfCd);

        if (superiorInfo == null)
        {
            return application;
        }

        application.Superior = new ApplicationInfo.Staff() { StaffName = superiorInfo.StfNm, CostName = superiorInfo.ScnNm };
        application.SUPERIOR_DIV_REG_DATE = DateTime.Now.ToString("yyyyMMdd");
        application.SUPERIOR_DIVISION = superiorInfo.CstCd;
        application.SUPERIOR_STF_CODE = superiorInfo.StfCd;

        WebLogUtility.WriteDebugLog("時間計測 : SetDefaultSuperior 終了[" + DateTime.Now.ToString("yyyy:MM:dd HH:mm:ss.ffff") + "]");

        return application;
    }

    private void SendMail(ResponseDataType response, StatusManager statusManager)
    {
        bool isRequiredSendMail = (bool)response[UpdateApplicationBll.RESPONSE_KEY_IS_REQUIRED_SEND_MAIL];

        if (!isRequiredSendMail)
        {
            return;
        }

        string applicationNo = response[UpdateApplicationBll.RESPONSE_KEY_APPLICATION_NO] as string;

        Dictionary<string, object> parameter = new Dictionary<string, object>();
        parameter.Add(SendMailBll.REQUEST_KEY_APPLICATION_NO, applicationNo);
        parameter.Add(SendMailBll.REQUEST_KEY_MAIL_TYPE, statusManager.GetMailType());

        InvokeBllEx(typeof(SendMailBll), parameter);

        this.RunSendMail();
    }

    #region JavaScript生成メソッド群(GenerateXXX)

    //MOD:SCSK:20141028:2-3:START
    //private void GenerateDrugAndProdJavaScript()
    //{
    //    StringBuilder script = new StringBuilder();
    //    script.Append("<script type=text/javascript>");
    //    script.Append("function selectDrugAndProd(){");
    //    script.Append("var drug = document.getElementById('" + hdnDrug.ClientID + "').value;");
    //    script.Append("var productList = document.getElementById('" + hdnProduct.ClientID + "').value;");
    //    script.Append("result = showModalDialogDisplay('../Dialog/DrugProdSelect.aspx?" + ConstValue.QUERY_STRING_KEY_SELECTED_DRUG_CODE + "=' + drug + '" + "&" + ConstValue.QUERY_STRING_KEY_SELECTED_PRODUCT_CODES + "=' + productList" + ", null, 650, 400);");
    //    script.Append("if(result != null && typeof(result) == 'object') {");
    //    script.Append("document.getElementById('" + hdnDrug.ClientID + "').value = result[0];");
    //    script.Append("document.getElementById('" + txtDrug.ClientID + "').value = result[1];");
    //    script.Append("document.getElementById('" + hdnDrugName.ClientID + "').value = result[1];");
    //    script.Append("document.getElementById('" + hdnProduct.ClientID + "').value = result[3];");
    //    script.Append("document.getElementById('" + txtProduct.ClientID + "').value = result[4];");
    //    script.Append("document.getElementById('" + hdnProductName.ClientID + "').value = result[4];");
    //    script.Append("}");
    //    script.Append("}");
    //    script.Append("</script>");
    //    Page.ClientScript.RegisterClientScriptBlock(typeof(string), "DrugAndProdJavaScript", script.ToString());
    //}

    private void GenerateDrugAndProdJavaScript(StatusManager statusManager)
    {
        // 統一コードが採番されたか判定
        string uniformCodeFlg = string.Empty;
        switch (statusManager.GetStatus())
        {
            //ADD:SCSK:20141119:IT指摘事項No.5:START
            case Status.CommitteePermit:
            case Status.ChairpersonPermit:
            //ADD:SCSK:20141119:IT指摘事項No.5:END
            case Status.ApplicantRequestPublic:
            case Status.SecretariatPermitPublic:
            case Status.SecretariatSendBackPublic:
                uniformCodeFlg = ConstValue.UNIFORM_CODE_NUMBERING;
                break;
            default:
                uniformCodeFlg = ConstValue.UNIFORM_CODE_NO_NUMBERING;
                break;
        }

        StringBuilder script = new StringBuilder();
        script.Append("<script type=text/javascript>");
        script.Append("function selectDrugAndProd(){");
        script.Append("var drug = document.getElementById('" + hdnDrug.ClientID + "').value;");
        script.Append("var productList = document.getElementById('" + hdnProduct.ClientID + "').value;");
        script.Append("var uniformCodeFlg = " + uniformCodeFlg + ";");
        script.Append("result = showModalDialogDisplay('../Dialog/DrugProdSelect.aspx?" + ConstValue.QUERY_STRING_KEY_SELECTED_DRUG_CODE + "=' + drug + '" + 
                                                       "&" + ConstValue.QUERY_STRING_KEY_SELECTED_PRODUCT_CODES + "=' + productList + '" +
                                                       "&" + ConstValue.QUERY_STRING_KEY_UNIFORM_CODE_FLG + "=' + uniformCodeFlg" + ", null, 650, 400);");
        script.Append("if(result != null && typeof(result) == 'object') {");
        script.Append("document.getElementById('" + hdnDrug.ClientID + "').value = result[0];");
        script.Append("document.getElementById('" + txtDrug.ClientID + "').value = result[1];");
        script.Append("document.getElementById('" + hdnDrugName.ClientID + "').value = result[1];");
        script.Append("document.getElementById('" + hdnProduct.ClientID + "').value = result[3];");
        script.Append("document.getElementById('" + txtProduct.ClientID + "').value = result[4];");
        script.Append("document.getElementById('" + hdnProductName.ClientID + "').value = result[4];");
        script.Append("}");
        script.Append("}");
        script.Append("</script>");
        Page.ClientScript.RegisterClientScriptBlock(typeof(string), "DrugAndProdJavaScript", script.ToString());
    }
    //MOD:SCSK:20141028:2-3:END

    private void GenerateApplicantJavaScript()
    {
        StringBuilder script = new StringBuilder();
        script.Append("<script type=text/javascript>");
        script.Append("function selectApplicant(){");
        script.Append("result = showModalDialogDisplay('../Dialog/Staff.aspx', null, 800, 550);");
        script.Append("if(result != null && typeof(result) == 'object') {");
        script.Append("document.getElementById('" + hdnApplicantStaff.ClientID + "').value = result[0];");
        script.Append("document.getElementById('" + txtApplicantStaff.ClientID + "').value = result[1];");
        script.Append("document.getElementById('" + hdnApplicantStaffName.ClientID + "').value = result[1];");
        script.Append("document.getElementById('" + hdnApplicantDivision.ClientID + "').value = result[5];");
        script.Append("document.getElementById('" + txtApplicantDivision.ClientID + "').value = result[6];");
        script.Append("document.getElementById('" + hdnApplicantDivisionName.ClientID + "').value = result[6];");
        //        script.Append("__doPostBack('" + btnSelectApplicant.ClientID + "','')");
        script.Append("}");
        script.Append("}");
        script.Append("</script>");
        Page.ClientScript.RegisterClientScriptBlock(typeof(string), "ApplicantJavaScript", script.ToString());
    }

    private void GenerateSuperiorJavaScript()
    {
        StringBuilder script = new StringBuilder();
        script.Append("<script type=text/javascript>");
        script.Append("function selectSuperior(){");
        script.Append("result = showModalDialogDisplay('../Dialog/Staff.aspx', null, 800, 550);");
        script.Append("if(result != null && typeof(result) == 'object') {");
        script.Append("document.getElementById('" + hdnSuperiorStaff.ClientID + "').value = result[0];");
        script.Append("document.getElementById('" + txtSuperiorStaff.ClientID + "').value = result[1];");
        script.Append("document.getElementById('" + hdnSuperiorStaffName.ClientID + "').value = result[1];");
        script.Append("document.getElementById('" + hdnSuperiorDivision.ClientID + "').value = result[5];");
        script.Append("document.getElementById('" + txtSuperiorDivision.ClientID + "').value = result[6];");
        script.Append("document.getElementById('" + hdnSuperiorDivisionName.ClientID + "').value = result[6];");
        script.Append("}");
        script.Append("}");
        script.Append("</script>");
        Page.ClientScript.RegisterClientScriptBlock(typeof(string), "SuperiorJavaScript", script.ToString());
    }

    private void GenerateOldApplicationJavaScript()
    {
        StringBuilder script = new StringBuilder();
        script.Append("<script type=text/javascript>");
        script.Append("function selectApplication(){");
        script.Append("result = showModalDialogDisplay('../Dialog/ApplicationFind.aspx?MODE=APPLICATION', null, 1024, 550);");
        script.Append("if(result != null && typeof(result) == 'object') {");
        script.Append("document.getElementById('" + hdnOldApplicationNo.ClientID + "').value = result[0];");
        script.Append("document.getElementById('" + txtOldUniformCode.ClientID + "').value = result[1];");
        script.Append("document.getElementById('" + hdnOldUniformCode.ClientID + "').value = result[1];");
        script.Append("document.getElementById('" + txtOldOrderPartCode.ClientID + "').value = result[2];");
        script.Append("document.getElementById('" + hdnOldOrderPartCode.ClientID + "').value = result[2];");
        //ADD:SCSK:20141028:2-3:START
        script.Append("if (!document.getElementById('" + txtMaterialsName.ClientID + "').value){");
        script.Append("document.getElementById('" + txtMaterialsName.ClientID + "').value = result[3];}");
        script.Append("if (!document.getElementById('" + txtPurposeAndContent.ClientID + "').value){");
        script.Append("document.getElementById('" + txtPurposeAndContent.ClientID + "').value = result[4];}");
        //ADD:SCSK:20141028:2-3:END
        //ADD:20131030:ISHIKAWA:START
        script.Append("document.getElementById('" + hdnApplicationFind.ClientID + "').value = '1';");
        script.Append("document.forms[0].submit();");
        //ADD:20131030:ISHIKAWA:END    
        script.Append("}");
        script.Append("}");
        script.Append("</script>");
        Page.ClientScript.RegisterClientScriptBlock(typeof(string), "ApplicationJavaScript", script.ToString());
    }

    private void GenerateReportJavaScript()
    {
        StringBuilder url = new StringBuilder();
        url.Append("../Dialog/Report.aspx?");
        url.Append(ConstValue.QUERY_STRING_KEY_REPORT_ID);
        url.Append("=");
        url.Append(ConstValue.REPORT_ID_APPLICATION_FORM);
        url.Append("&");
        url.Append(ConstValue.QUERY_STRING_KEY_APPLICATION_NO);
        url.Append("=");
        url.Append(txtApplicationNo.Text);

        btnExportApplication.OnClientClick = "window.open('" + url.ToString() + "');return false;";
    }

    private void GenerateMessageAndOpenFolderJavaScript()
    {
        StringBuilder script = new StringBuilder();

        script.Append("alert('").Append(Messages.INFO002).Append("' + '\n\r' + '").Append(Messages.INFO101).AppendLine("');");
        script.Append("setTimeout(function(){").AppendLine();
        script.Append("    viewMaterials();return false;");
        script.Append("},0);").AppendLine();

        Page.ClientScript.RegisterStartupScript(typeof(string), "GenerateMessageAndOpenFolderJavaScript", script.ToString(), true);
    }

    #endregion

    //DEL:SCSK:20141201:結合テスト指摘事項一覧管理No.17対応:START
    //protected void ProductionLinqDataSource_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    //{
    //    ApplicationDataContext dataContext = new ApplicationDataContext();

    //    var productions = from row in dataContext.TBAAMS_PRODUCTION
    //                      select new { PRODUCTION_NAME = row.PRODUCTION_CODE + ":" + row.PRODUCTION_NAME, PRODUCTION_CODE = row.PRODUCTION_CODE, DEL_FLG = row.DEL_FLG, PRODUCTION_DISP_ORDER = row.PRODUCTION_DISP_ORDER };

    //    e.Result = productions;
    //}
    //DEL:SCSK:20141201:結合テスト指摘事項一覧管理No.17対応:END

    //ADD:20131030:ISHIKAWA:START
    protected void hdnApplicationFind_TextChanged(object sender, EventArgs e)
    {
        //改訂にチェック設定
        rdbNewOrRevision.SelectedIndex = 1;

        //発注品番が存在しない場合、不要を設定、以外は必要
        string OldOrderPartCode = hdnOldOrderPartCode.Value;
        if (string.IsNullOrEmpty(OldOrderPartCode)) 
        {
            rdbOrder.SelectedIndex = 1;
        }
        else
        {
            rdbOrder.SelectedIndex = 0;
        }
        Char ApplicationFind = '0';
        hdnApplicationFind.Value = ApplicationFind.ToString();
    }
    //ADD:20131030:ISHIKAWA:END
 
}
View Code

◆业务逻辑层-BLL

------------------------------------------
BllBase.cs类
using System;
using System.Configuration;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using Otsuka.Application.Common;
using Otsuka.Application.Common.Exception;
using System.Data.Linq;

namespace Otsuka.Application.Bll
{
    /// <summary>
    /// BLL基底クラス。
    /// </summary>
    public abstract class BllBase
    {
        private string _connectionString = null;
        private string _displayName = null;
        private SqlTransaction _transaction = null;
        private Dictionary<string, object> _request = null;

        #region プロパティ

        public StaffInfo StaffInfo { set; get; }

        /// <summary>
        /// DBへの接続文字列を取得する。
        /// </summary>
        protected string ConnectionString
        {
            get
            {
                return _connectionString;
            }
        }

        /// <summary>
        /// 画面名
        /// </summary>
        public string DisplayName
        {
            set
            {
                _displayName = value;
            }
            get
            {
                return _displayName;
            }
        }

        /// <summary>
        /// BLLリクエスト
        /// </summary>
        protected Dictionary<string, object> Request
        {
            get
            {
                return _request;
            }
        }

        /// <summary>
        /// SQLトランザクション
        /// </summary>
        protected SqlTransaction Transaction
        {
            get
            {
                return _transaction;
            }
        }


        #endregion

        #region コンストラクタ
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public BllBase()
        {
            _connectionString = ConfigurationManager.ConnectionStrings["Otsuka.Application.Dal.Properties.Settings.APPLICATIONConnectionString"].ConnectionString;
        }

        /// <summary>
        /// BLLが所属するコネクションを指定できるコンストラクタ
        /// </summary>
        /// <param name="connectionString">BLLが所属するコネクション接続文字列</param>
        public BllBase(string connectionString)
        {
            _connectionString = connectionString;
        }

        #endregion

        #region リクエストパラメータのTrim
        /// <summary>
        /// 内容が文字列のものにTrimをかける。
        /// </summary>
        /// <param name="request">リクエストパラメータ</param>
        /// <returns>Trim後のリクエストパラメータ</returns>
        protected Dictionary<string, object> TrimRequestString(Dictionary<string, object> request)
        {
            // リクエストがnullの場合はnullを返却する
            if (request == null) return null;

            Dictionary<string, object> returnValue = new Dictionary<string, object>();

            foreach (string key in request.Keys)
            {
                object val = request[key];
                if (val is string)
                {
                    val = StringUtility.Trim((string)val);
                }

                returnValue.Add(key, val);
            }

            return returnValue;
        }
        #endregion

        #region Executeメソッド(BLLのエントリポイント)
        /// <summary>
        /// BLLのエントリポイント。
        /// </summary>
        /// プレゼンテーションへの返却値。
        /// 処理成功の場合、返却値.IsSuccessがtrueとなり、
        /// 返却値.Messagesはnullとなる。
        /// 処理失敗(業務エラー)の場合、返却値.IsSuccessがfalseとなり、
        /// 返却値.Messagesにエラーメッセージが入る。
        /// </returns>
        public ResponseDataType Execute()
        {
            return Execute(null);
        }

        /// <summary>
        /// BLLのエントリポイント。
        /// </summary>
        /// <param name="request">プレゼンテーションからのリクエストパラメータ</param>
        /// <returns>
        /// プレゼンテーションへの返却値。
        /// 処理成功の場合、返却値.IsSuccessがtrueとなり、
        /// 返却値.Messagesはnullとなる。
        /// 処理失敗(業務エラー)の場合、返却値.IsSuccessがfalseとなり、
        /// 返却値.Messagesにエラーメッセージが入る。
        /// </returns>
        public virtual ResponseDataType Execute(Dictionary<string, object> request)
        {
            int startTime = Environment.TickCount;

            ///TODO 他システム接続不可エラーを表示する。
            ///★他システム接続不可エラーを表示する。

            BllLogUtility.WriteDebugLog("=====> {0}.Execute() =====>", GetType().FullName);

            // リクエスト情報にTrimをかける
            _request = TrimRequestString(request);

            // レスポンス情報
            ResponseDataType response = new ResponseDataType();

            // DB接続
            SqlConnection connection = new SqlConnection(ConnectionString);
            
            try
            {
                // DBオープン
                connection.Open();

                // トランザクションの開始
                _transaction = connection.BeginTransaction();

                // 入力チェック処理
                Validate();

                // BLL本体の実行
                Dictionary<string, object> bllResponse = this.Perform();

                // レスポンス情報設定
                response.SetParameters(bllResponse);

                // トランザクションのコミット
                Transaction.Commit();
            }
            catch (MessageException ex)
            {
                _transaction.Rollback();

                // 入力チェックエラー発生
                response.IsSuccess = false;
                response.Messages = ex.Messages;
            }
            //catch (SqlException ex)
            //{
            //    if (_transaction != null) _transaction.Rollback();

            //    BLLLogUtility.WriteFatalLog("=====> 例外発生:{0}.Execute() =====>", GetType().FullName);
            //    BLLLogUtility.WriteException(ex);
            //    BLLLogUtility.WriteFatalLogLoginUserInfo(this);
            //    BLLLogUtility.WriteFatalLogBLLRequest(request);
            //    BLLLogUtility.WriteFatalLog("<===== 例外発生:{0}.Execute() <=====", GetType().FullName);

            //    if (!CheckUtility.IsEmpty(RefOtherDbName))
            //    {
            //        throw new DbConnectionException(OtherDbDisableMessage,DisplayName,LoginUserStfCd,LoginNtUserCd);
            //    }
            //    throw;
            //}
            catch (Exception ex)
            {
                if (_transaction != null) _transaction.Rollback();

                BllLogUtility.WriteFatalLog("=====> 例外発生:{0}.Execute() =====>", GetType().FullName);
                BllLogUtility.WriteException(ex);
                BllLogUtility.WriteFatalLogLoginUserInfo(this);
                BllLogUtility.WriteFatalLogBLLRequest(request);
                BllLogUtility.WriteFatalLog("<===== 例外発生:{0}.Execute() <=====", GetType().FullName);

                throw new ApplException(Messages.SYSERR001, _displayName, ex.Message, StaffInfo.StfCd, null);
            }
            finally
            {
                // 後処理
                if (_transaction != null)
                {
                    _transaction.Dispose();
                }

                if (connection != null)
                {
                    if (connection.State == ConnectionState.Open)
                    {
                        connection.Close();
                    }

                    connection.Dispose();
                }
            }

            int endTime = Environment.TickCount;
            BllLogUtility.WriteDebugLogBLLResponse(response);
            BllLogUtility.WriteDebugLog("<===== {0}.Execute() elaps:[{1}] <=====", GetType().FullName, endTime - startTime);

            return response;
        }
        #endregion

        /// <summary>
        /// リクエスト情報の入力値チェック処理。
        /// 規定の実装はなにもしない。
        /// エラーが発生した場合はMessageExceptionをthrowすること。
        /// </summary>
        protected virtual void Validate()
        {
        }

        /// <summary>
        /// BLLの実装部。
        /// ここへBLLの処理本体を記述する。
        /// </summary>
        /// <returns>プレゼンテーションへの返却値</returns>
        protected abstract Dictionary<string, object> Perform();

    }
}
View Code

BllBaseEx.cs

using System;
using System.Configuration;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using Otsuka.Application.Common;
using Otsuka.Application.Common.Exception;
using System.Data.Linq;
using Otsuka.Application.Dal;

namespace Otsuka.Application.Bll
{
    /// <summary>
    /// データアクセスにDataContextを利用するBll基底クラス
    /// </summary>
    public abstract class BllBaseEx
    {

        #region プロパティ

        /// <summary>
        /// 担当者情報
        /// </summary>
        public StaffInfo StaffInfo { set; get; }

        /// <summary>
        /// データアクセス
        /// </summary>
        protected string ConnectionString { get; private set; }
        protected ApplicationDataContext DataContext { set; get; }

        /// <summary>
        /// 画面名
        /// </summary>
        public string DisplayName { set; get; }

        /// <summary>
        /// BLLリクエスト
        /// </summary>
        protected Dictionary<string, object> Request { get; private set; }

        #endregion

        #region コンストラクタ
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public BllBaseEx()
        {
            ConnectionString = ConfigurationManager.ConnectionStrings["Otsuka.Application.Dal.Properties.Settings.APPLICATIONConnectionString"].ConnectionString;
        }

        /// <summary>
        /// BLLが所属するコネクションを指定できるコンストラクタ
        /// </summary>
        /// <param name="connectionString">BLLが所属するコネクション接続文字列</param>
        public BllBaseEx(string connectionString)
        {
            ConnectionString = connectionString;
        }

        #endregion

        #region リクエストパラメータのTrim

        /// <summary>
        /// 内容が文字列のものにTrimをかける。
        /// </summary>
        /// <param name="request">リクエストパラメータ</param>
        /// <returns>Trim後のリクエストパラメータ</returns>
        protected Dictionary<string, object> TrimRequestString(Dictionary<string, object> request)
        {
            // リクエストがnullの場合はnullを返却する
            if (request == null) return null;

            Dictionary<string, object> returnValue = new Dictionary<string, object>();

            foreach (string key in request.Keys)
            {
                object val = request[key];
                if (val is string)
                {
                    val = StringUtility.Trim((string)val);
                }

                returnValue.Add(key, val);
            }

            return returnValue;
        }

        #endregion

        #region Executeメソッド(BLLのエントリポイント)
        /// <summary>
        /// BLLのエントリポイント。
        /// </summary>
        /// プレゼンテーションへの返却値。
        /// 処理成功の場合、返却値.IsSuccessがtrueとなり、
        /// 返却値.Messagesはnullとなる。
        /// 処理失敗(業務エラー)の場合、返却値.IsSuccessがfalseとなり、
        /// 返却値.Messagesにエラーメッセージが入る。
        /// </returns>
        public ResponseDataType Execute()
        {
            return Execute(null);
        }

        /// <summary>
        /// BLLのエントリポイント。
        /// </summary>
        /// <param name="request">プレゼンテーションからのリクエストパラメータ</param>
        /// <returns>
        /// プレゼンテーションへの返却値。
        /// 処理成功の場合、返却値.IsSuccessがtrueとなり、
        /// 返却値.Messagesはnullとなる。
        /// 処理失敗(業務エラー)の場合、返却値.IsSuccessがfalseとなり、
        /// 返却値.Messagesにエラーメッセージが入る。
        /// </returns>
        public virtual ResponseDataType Execute(Dictionary<string, object> request)
        {
            int startTime = Environment.TickCount;

            ///TODO 他システム接続不可エラーを表示する。
            ///★他システム接続不可エラーを表示する。

            BllLogUtility.WriteDebugLog("=====> {0}.Execute() =====>", GetType().FullName);

            // リクエスト情報にTrimをかける
            Request = TrimRequestString(request);

            // レスポンス情報
            ResponseDataType response = new ResponseDataType();

            // DB接続
            this.DataContext = new ApplicationDataContext(ConnectionString);
            this.DataContext.CommandTimeout = 60;

            try
            {
                // 入力チェック処理
                Validate();

                // BLL本体の実行
                Dictionary<string, object> bllResponse = this.Perform();

                // レスポンス情報設定
                response.SetParameters(bllResponse);

                // トランザクションのコミット
                this.DataContext.SubmitChanges();
            }
            catch (MessageException ex)
            {
                // 入力チェックエラー発生
                response.IsSuccess = false;
                response.Messages = ex.Messages;
            }
            catch (SqlException ex)
            {
                BllLogUtility.WriteFatalLog("=====> 例外発生:{0}.Execute() =====>", GetType().FullName);
                BllLogUtility.WriteException(ex);
                BllLogUtility.WriteFatalLogLoginUserInfo(this);
                BllLogUtility.WriteFatalLogBLLRequest(request);
                BllLogUtility.WriteFatalLog("<===== 例外発生:{0}.Execute() <=====", GetType().FullName);

                throw;
            }
            catch (Exception ex)
            {
                BllLogUtility.WriteFatalLog("=====> 例外発生:{0}.Execute() =====>", GetType().FullName);
                BllLogUtility.WriteException(ex);
                BllLogUtility.WriteFatalLogLoginUserInfo(this);
                BllLogUtility.WriteFatalLogBLLRequest(request);
                BllLogUtility.WriteFatalLog("<===== 例外発生:{0}.Execute() <=====", GetType().FullName);

                throw new ApplException(Messages.SYSERR001, DisplayName, ex.Message, StaffInfo.StfCd, null);
            }
            finally
            {
                // 後処理
                // DataContext には明示的なクローズ処理は不要
            }

            int endTime = Environment.TickCount;
            BllLogUtility.WriteDebugLogBLLResponse(response);
            BllLogUtility.WriteDebugLog("<===== {0}.Execute() elaps:[{1}] <=====", GetType().FullName, endTime - startTime);

            return response;
        }
        #endregion

        /// <summary>
        /// リクエスト情報の入力値チェック処理。
        /// 規定の実装はなにもしない。
        /// エラーが発生した場合はMessageExceptionをthrowすること。
        /// </summary>
        protected virtual void Validate()
        {
        }

        /// <summary>
        /// BLLの実装部。
        /// ここへBLLの処理本体を記述する。
        /// </summary>
        /// <returns>プレゼンテーションへの返却値</returns>
        protected abstract Dictionary<string, object> Perform();

    }
}
View Code

ResponseDataType.cs

//$Id: ResponseDataType.cs 583 2011-11-10 11:48:21Z ichikawa $
using System;
using System.Collections.Generic;
using System.Text;

namespace Otsuka.Application.Bll
{
    /// <summary>
    /// BLLからの返却値を格納するクラス。
    /// </summary>
    public class ResponseDataType
    {
        private bool _isSuccess = true;
        private List<string> _messages = null;
        private Dictionary<string, object> _parameters = null;

        /// <summary>
        /// レスポンスの内容
        /// </summary>
        public Dictionary<string, object> Items
        {
            get
            {
                return _parameters;
            }
        }

        /// <summary>
        /// 実行結果
        /// </summary>
        public bool IsSuccess
        {
            get
            {
                return _isSuccess;
            }
            set
            {
                _isSuccess = value;
            }
        }

        /// <summary>
        /// エラーメッセージの一覧
        /// </summary>
        public List<string> Messages
        {
            get
            {
                return _messages;
            }
            set
            {
                _messages = value;
            }
        }

        /// <summary>
        /// インデクサ
        /// </summary>
        public object this[string key]
        {
            get
            {
                return _parameters[key];
            }
        }

        public ResponseDataType()
        {
        }

        /// <summary>
        /// パラメータをこのオブジェクトに設定する。
        /// </summary>
        /// <param name="parameters">パラメータ</param>
        public void SetParameters(Dictionary<string, object> parameters)
        {
            _parameters = parameters;
        }
    }
}
View Code

 SearchApplicationListBll.cs类

namespace Otsuka.Application.Bll.ApplicationList
{
    public class SearchApplicationListBll : BllBaseEx
    {

        /// <summary>
        /// 要求キー-申請者の担当者コード(事務局の場合、セットしない)
        /// </summary>
        public const string REQUEST_KEY_STAFF_CODE = "APPLICATION_LIST_STAFF_CODE";

        /// <summary>
        /// 要求キー-申請No
        /// </summary>
        public const string REQUEST_KEY_APPLI_NO = "APPLICATION_LIST_APPLI_NO";

        /// <summary>
        /// 要求キー-資材媒体コード
        /// </summary>
        public const string REQUEST_KEY_MATERIALS_CODE = "APPLICATION_LIST_MATERIALS_CODE";

        /// <summary>
        /// 要求キー-資材分類コード
        /// </summary>
        public const string REQUEST_KEY_MATERIALS_CLASS_CODE = "APPLICATION_LIST_MATERIALS_CLASS_CODE";

        /// <summary>
        /// 要求キー-統一コード
        /// </summary>
        public const string REQUEST_KEY_UNIFORM_CODE = "APPLICATION_LIST_UNIFORM_CODE";

        /// <summary>
        /// 要求キー-発注品番
        /// </summary>
        public const string REQUEST_KEY_ORDER_PART_CODE = "APPLICATION_LIST_ORDER_PART_CODE";

        /// <summary>
        /// 要求キー-資材管理番号
        /// </summary>
        public const string REQUEST_KEY_MATERIALS_NO = "APPLICATION_LIST_MATERIALS_NO";

        /// <summary>
        /// 要求キー-申請年月開始(yyyy/MM)
        /// </summary>
        public const string REQUEST_KEY_APPLICATION_DATE_START = "APPLICATION_LIST_APPLICATION_DATE_START";

        /// <summary>
        /// 要求キー-申請年月終了(yyyy/MM)
        /// </summary>
        public const string REQUEST_KEY_APPLICATION_DATE_END = "APPLICATION_LIST_APPLICATION_DATE_END";

        /// <summary>
        /// 要求キー-許可年月開始(yyyy/MM)
        /// </summary>
        public const string REQUEST_KEY_PERMISSION_DATE_START = "APPLICATION_LIST_PERMISSION_DATE_START";

        /// <summary>
        /// 要求キー-許可年月終了(yyyy/MM)
        /// </summary>
        public const string REQUEST_KEY_PERMISSION_DATE_END = "APPLICATION_LIST_PERMISSION_DATE_END";

        /// <summary>
        /// 要求キー-資材名称
        /// </summary>
        public const string REQUEST_KEY_MATERIALS_NM_KNJ = "APPLICATION_LIST_MATERIALS_NM_KNJ";

        /// <summary>
        /// 要求キー-申請部署コード
        /// </summary>
        public const string REQUEST_KEY_APPLICANT_DIVISION = "APPLICATION_LIST_APPLICANT_DIVISION";

        /// <summary>
        /// 要求キー-申請者コード
        /// </summary>
        public const string REQUEST_KEY_APPLICANT_STF_CODE = "APPLICATION_LIST_APPLICANT_STF_CODE";

        /// <summary>
        /// 要求キー-薬剤コード
        /// </summary>
        public const string REQUEST_KEY_DRUG = "APPLICATION_LIST_DRUG";

        /// <summary>
        /// 要求キー-製品コード
        /// </summary>
        public const string REQUEST_KEY_PRODUCT = "APPLICATION_LIST_PRODUCT";

        /// <summary>
        /// 要求キー-申請ステータス(カンマ区切り文字列)
        /// </summary>
        public const string REQUEST_KEY_STATUS = "APPLICATION_LIST_STATUS";

        /// <summary>
        /// 要求キー-委員会
        /// </summary>
        public const string REQUEST_KEY_COMMITTEE_NO = "APPLICATION_LIST_COMMITTEE_NO";

        /// <summary>
        /// 要求キー-表示順(申請番号:"1"、薬剤:"2"、申請部署:"3")
        /// </summary>
        public const string REQUEST_KEY_ORDER = "APPLICATION_LIST_ORDER";

        /// <summary>
        /// 返却キー-検索結果リスト
        /// </summary>
        public const string RESPONSE_KEY_SEARCH_RESULT_LIST = "APPLICATION_LIST_SEARCH_RESULT";

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        protected override Dictionary<string, object> Perform()
        {
            // 検索条件の設定
            string strAppliNo = Request[REQUEST_KEY_APPLI_NO] as string;
            Char strMaterialsCode = new Char();
            if (!String.IsNullOrEmpty (Request[REQUEST_KEY_MATERIALS_CODE ].ToString ()))
            {
                strMaterialsCode = Request[REQUEST_KEY_MATERIALS_CODE].ToString().ToCharArray()[0];
            }
            string strMaterialsClassCode = Request[REQUEST_KEY_MATERIALS_CLASS_CODE] as string;
            string strUniformCode = Request[REQUEST_KEY_UNIFORM_CODE] as string;
            string strOrderPartCode = Request[REQUEST_KEY_ORDER_PART_CODE ] as string;
            string strMaterialsNo = Request[REQUEST_KEY_MATERIALS_NO] as string;
            string strApplicationDateStart = Request[REQUEST_KEY_APPLICATION_DATE_START ] as string;
            string strApplicationDateEnd = Request[REQUEST_KEY_APPLICATION_DATE_END] as string;
            string strPermissionDateStart = Request[REQUEST_KEY_PERMISSION_DATE_START ] as string;
            string strPermissionDateEnd = Request[REQUEST_KEY_PERMISSION_DATE_END] as string;
            string strMaterialsNmKnj = Request[REQUEST_KEY_MATERIALS_NM_KNJ] as string;
            string strApplicantDivision = Request[REQUEST_KEY_APPLICANT_DIVISION ] as string;
            string strApplicantStfCode = Request[REQUEST_KEY_APPLICANT_STF_CODE ] as string;
            string strDrug = Request[REQUEST_KEY_DRUG] as string;
            string strProduct = Request[REQUEST_KEY_PRODUCT] as string;
            string strStatusNo = Request[REQUEST_KEY_STATUS] as string;
            string strCommitteeNo = Request[REQUEST_KEY_COMMITTEE_NO] as string;
            string strStfCode = Request[REQUEST_KEY_STAFF_CODE] as string;

            // SP実行
            var lstResult = DataContext.SPAA_APPLICATION_LIST_SEL(strAppliNo, strMaterialsCode, strMaterialsClassCode, strUniformCode
                , strOrderPartCode,strMaterialsNo,strApplicationDateStart,strApplicationDateEnd,strPermissionDateStart,strPermissionDateEnd
                , strMaterialsNmKnj, strApplicantDivision, strApplicantStfCode, strDrug, strProduct, strStatusNo, strCommitteeNo, strStfCode
                ).ToList();

            //ソートを行う
            string strOrder = Request[REQUEST_KEY_ORDER ] as string;

            if (lstResult == null)
            {
                return new Dictionary<string, object>();
            }

            switch (strOrder) {
                case "1":
                    //申請番号
                    lstResult = (from row in lstResult select row).OrderByDescending(row => row.APPLI_NO).ToList();
                    
                    break;
                case "2":
                    //薬剤
                    lstResult = (from row in lstResult select row).OrderBy(row => row.DRUG_SORT_1 ).ToList();

                    break;
                case "3":
                    //申請部署
                    lstResult = (from row in lstResult select row).OrderBy(row => row.ORG_DSP_SORT ).ToList();

                    break;
            }

            Dictionary<string, object> response = new Dictionary<string, object>();
            response.Add(RESPONSE_KEY_SEARCH_RESULT_LIST, lstResult);

            return response;
        }
    }
}
View Code

◆数据访问层-DAL

------------------------------------------
 
DalBase.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Configuration;

namespace Otsuka.Application.Dal
{
    /// <summary>
    /// DAL基底クラス
    /// </summary>
    public abstract class DalBase
    {

        /// <summary>
        /// 要求キー-検索結果の件数
        /// Type:int
        /// </summary>
        public const string REQUEST_KEY_APPLICATION_COUNT = "APPLICATION_COUNT";

        /// <summary>
        /// 要求キー-検索結果先頭レコード番号
        /// Type:int
        /// </summary>
        public const string REQUEST_KEY_START_RECORD_NO = "START_RECORD_NO";

        private SqlTransaction _transaction = null;
        private Dictionary<string, object> _request = null;
        private List<SqlParameter> _sqlParameters = new List<SqlParameter>();

        #region プロパティ
        /// <summary>
        /// BLLより渡されたパラメータ
        /// </summary>
        protected Dictionary<string, object> RequestParameters
        {
            get
            {
                return _request;
            }
        }

        /// <summary>
        /// 各DALにて生成されるSqlParameter
        /// </summary>
        protected List<SqlParameter> SqlParameters
        {
            get
            {
                return _sqlParameters;
            }
        }

        #endregion

        #region コンストラクタ
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="connection">DBトランザクション</param>
        public DalBase(SqlTransaction transaction)
            : this(transaction, null)
        {
        }

        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="connection">DBトランザクション</param>
        /// <param name="request">リクエストパラメータ</param>
        public DalBase(SqlTransaction transaction, Dictionary<string, object> request)
        {
            _transaction = transaction;
            _request = request;
        }
        #endregion

        public SqlTransaction Transaction
        {
            get
            {
                return _transaction;
            }
        }

        #region SQLパラメータの追加
        /// <summary>
        /// このオブジェクトにSQLパラメータを追加する。
        /// </summary>
        /// <param name="name">SQLパラメータ名</param>
        /// <param name="sqlDbType">パラメータの型</param>
        /// <param name="val">セットする値</param>
        protected void AppendSqlParameter(string name, SqlDbType sqlDbType, object val)
        {
            SqlParameter parameter = new SqlParameter(name, sqlDbType);
            parameter.Value = val;
            _sqlParameters.Add(parameter);
        }

        /// <summary>
        /// このオブジェクトにSQLパラメータを追加する。
        /// </summary>
        /// <param name="name">SQLパラメータ名</param>
        /// <param name="sqlDbType">パラメータの型</param>
        /// <param name="val">セットする値</param>
        /// <param name="direction">パラメータの方向</param>
        protected void AppendSqlParameter(string name, SqlDbType sqlDbType, object val, ParameterDirection direction)
        {
            SqlParameter parameter = new SqlParameter(name, sqlDbType);
            parameter.Direction = direction;
            parameter.Value = val;
            _sqlParameters.Add(parameter);
        }

        /// <summary>
        /// このオブジェクトにSQLパラメータを追加する。
        /// </summary>
        /// <param name="name">SQLパラメータ名</param>
        /// <param name="sqlDbType">パラメータの型</param>
        /// <param name="val">セットする値</param>
        /// <param name="scale">スケール</param>
        protected void AppendSqlParameter(string name, SqlDbType sqlDbType, object val, byte precision, byte scale)
        {
            SqlParameter parameter = new SqlParameter(name, sqlDbType);
            parameter.Value = val;
            parameter.Precision = precision;
            parameter.Scale = scale;
            _sqlParameters.Add(parameter);
        }

        #endregion

        #region SQLコマンドの生成
        /// <summary>
        /// SQLコマンドを生成する。
        /// </summary>
        /// <param name="connection">DB接続</param>
        /// <returns>生成されたSqlCommand</returns>
        protected virtual SqlCommand CreateSqlCommand()
        {
            string sql = CreateSqlAndParameters();

            SqlCommand command = new SqlCommand(sql, _transaction.Connection, _transaction);

            command.CommandTimeout = int.Parse(ConfigurationManager.AppSettings["CommandTimeout"].ToString());

            foreach (SqlParameter parameter in SqlParameters)
            {
                command.Parameters.Add(parameter);
            }

            return command;
        }
        #endregion

        #region SQLの実行
        #region SQLの実行⇒戻り値:DataTable(参照処理)
        /// <summary>
        /// SQLを実行する。(参照処理)
        /// </summary>
        /// <returns>取得したデータ</returns>
        public DataTable ExecuteQuery()
        {
            DalLogUtility.WriteDebugLog("=====> {0}.ExecuteQuery() =====>", GetType().FullName);

            int startTime = Environment.TickCount;

            DataSet data = null;
            SqlCommand command = null;
            SqlDataAdapter adapter = null;

            try
            {
                command = CreateSqlCommand();

                DalLogUtility.WriteDebugLogDALRequest(RequestParameters);
                DalLogUtility.WriteDebugLogSql(command.CommandText);
                DalLogUtility.WriteDebugLogSqlParameter(SqlParameters);

                adapter = new SqlDataAdapter(command);
                data = new DataSet();

                if (this.RequestParameters != null &&
                    this.RequestParameters.ContainsKey(REQUEST_KEY_START_RECORD_NO) &&
                    this.RequestParameters.ContainsKey(REQUEST_KEY_APPLICATION_COUNT))
                    adapter.Fill(data, int.Parse(this.RequestParameters[REQUEST_KEY_START_RECORD_NO].ToString()) - 1,
                                       int.Parse(this.RequestParameters[REQUEST_KEY_APPLICATION_COUNT].ToString()), "result");
                else
                    adapter.Fill(data, "result");
            }
            catch (SqlException ex)
            {
                DalLogUtility.WriteFatalLog("=====> 例外発生:{0}.ExecuteQuery() =====>", GetType().FullName);
                DalLogUtility.WriteException(ex);
                DalLogUtility.WriteFatalLogDALRequest(RequestParameters);
                DalLogUtility.WriteFatalLogSql(command.CommandText);
                DalLogUtility.WriteFatalLogSqlParameter(SqlParameters);
                DalLogUtility.WriteFatalLog("<===== 例外発生:{0}.ExecuteQuery() <=====", GetType().FullName);
                throw;
            }
            catch (Exception ex)
            {
                DalLogUtility.WriteFatalLog("=====> 例外発生:{0}.ExecuteQuery() =====>", GetType().FullName);
                DalLogUtility.WriteException(ex);
                DalLogUtility.WriteFatalLogDALRequest(RequestParameters);
                DalLogUtility.WriteFatalLog("<===== 例外発生:{0}.ExecuteQuery() <=====", GetType().FullName);
                throw;
            }
            finally
            {
                if (command != null) command.Dispose();
                if (adapter != null) adapter.Dispose();
            }

            int endTime = Environment.TickCount;

            DalLogUtility.WriteDebugLogDALResponse(data.Tables["result"]);
            DalLogUtility.WriteDebugLog("<===== {0}.ExecuteQuery() elaps:[{1}] <=====", GetType().FullName, endTime - startTime);

            return data.Tables["result"];
        }
        #endregion

        #region SQLの実行⇒戻り値object(単一値取得)
        /// <summary>
        /// SQLを実行する。(単一値取得)
        /// </summary>
        /// <returns>取得したデータ</returns>
        public object ExecuteScalar()
        {
            DalLogUtility.WriteDebugLog("=====> {0}.ExecuteScalar() =====>", GetType().FullName);
            int startTime = Environment.TickCount;

            object returnValue = null;
            SqlCommand command = null;

            try
            {
                command = CreateSqlCommand();

                DalLogUtility.WriteDebugLogDALRequest(RequestParameters);
                DalLogUtility.WriteDebugLogSql(command.CommandText);
                DalLogUtility.WriteDebugLogSqlParameter(SqlParameters);

                returnValue = command.ExecuteScalar();
            }
            catch (SqlException ex)
            {
                DalLogUtility.WriteFatalLog("=====> 例外発生:{0}.ExecuteScalar() =====>", GetType().FullName);
                DalLogUtility.WriteException(ex);
                DalLogUtility.WriteFatalLogDALRequest(RequestParameters);
                DalLogUtility.WriteFatalLogSql(command.CommandText);
                DalLogUtility.WriteFatalLogSqlParameter(SqlParameters);
                DalLogUtility.WriteFatalLog("<===== 例外発生:{0}.ExecuteScalar() <=====", GetType().FullName);
                throw;
            }
            catch (Exception ex)
            {
                DalLogUtility.WriteFatalLog("=====> 例外発生:{0}.ExecuteScalar() =====>", GetType().FullName);
                DalLogUtility.WriteException(ex);
                DalLogUtility.WriteFatalLogDALRequest(RequestParameters);
                DalLogUtility.WriteFatalLog("<===== 例外発生:{0}.ExecuteScalar() <=====", GetType().FullName);
                throw;
            }
            finally
            {
                if (command != null) command.Dispose();
            }

            int endTime = Environment.TickCount;

            DalLogUtility.WriteDebugLog("----- DAL Response -----");
            if (returnValue == null)
            {
                DalLogUtility.WriteDebugLog("Response is null.");
            }
            else
            {
                DalLogUtility.WriteDebugLog("type:[{0}] value:[{1}]", returnValue.GetType().Name, returnValue);
            }
            DalLogUtility.WriteDebugLog("<===== {0}.ExecuteScalar() elaps:[{1}] <=====", GetType().FullName, endTime - startTime);

            return returnValue;
        }
        #endregion

        #region SQLの実行(更新処理)
        /// <summary>
        /// SQLを実行する。(更新処理)
        /// </summary>
        /// <returns>更新対象件数</returns>
        public int ExecuteNonQuery()
        {
            DalLogUtility.WriteDebugLog("=====> {0}.ExecuteNonQuery() =====>", GetType().FullName);
            int startTime = Environment.TickCount;

            int returnValue = 0;

            SqlCommand command = null;

            try
            {
                command = CreateSqlCommand();

                DalLogUtility.WriteDebugLogDALRequest(RequestParameters);
                DalLogUtility.WriteDebugLogSql(command.CommandText);
                DalLogUtility.WriteDebugLogSqlParameter(SqlParameters);

                returnValue = command.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                DalLogUtility.WriteFatalLog("=====> 例外発生:{0}.ExecuteNonQuery() =====>", GetType().FullName);
                DalLogUtility.WriteException(ex);
                DalLogUtility.WriteFatalLogDALRequest(RequestParameters);
                DalLogUtility.WriteFatalLogSql(command.CommandText);
                DalLogUtility.WriteFatalLogSqlParameter(SqlParameters);
                DalLogUtility.WriteFatalLog("<===== 例外発生:{0}.ExecuteNonQuery() <=====", GetType().FullName);
                throw;
            }
            catch (Exception ex)
            {
                DalLogUtility.WriteFatalLog("=====> 例外発生:{0}.ExecuteNonQuery() =====>", GetType().FullName);
                DalLogUtility.WriteException(ex);
                DalLogUtility.WriteFatalLogDALRequest(RequestParameters);
                DalLogUtility.WriteFatalLog("<===== 例外発生:{0}.ExecuteNonQuery() <=====", GetType().FullName);
                throw;
            }
            finally
            {
                if (command != null) command.Dispose();
            }

            int endTime = Environment.TickCount;

            DalLogUtility.WriteDebugLog("----- DAL Response -----");
            DalLogUtility.WriteDebugLog("[{0}] row updated.", returnValue);
            DalLogUtility.WriteDebugLog("<===== {0}.ExecuteNonQuery() elaps:[{1}] <=====", GetType().FullName, endTime - startTime);

            return returnValue;
        }
        #endregion

        #region ストプロの実行(更新処理)
        /// <summary>
        /// ストアドプロシージャを実行する。(更新処理)
        /// </summary>
        /// <returns>更新対象件数</returns>
        public int ExecuteSPNonQuery()
        {
            DalLogUtility.WriteDebugLog("=====> {0}.ExecuteSPNonQuery() =====>", GetType().FullName);
            int startTime = Environment.TickCount;

            int returnValue = 0;
            SqlCommand command = null;

            try
            {
                command = CreateSqlCommand();
                command.CommandType = CommandType.StoredProcedure;  // この部分のみExecuteNonQueryと異なる

                DalLogUtility.WriteDebugLogDALRequest(RequestParameters);
                DalLogUtility.WriteDebugLogSql(command.CommandText);
                DalLogUtility.WriteDebugLogSqlParameter(SqlParameters);

                returnValue = command.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                DalLogUtility.WriteFatalLog("=====> 例外発生:{0}.ExecuteSPNonQuery() =====>", GetType().FullName);
                DalLogUtility.WriteException(ex);
                DalLogUtility.WriteFatalLogDALRequest(RequestParameters);
                DalLogUtility.WriteFatalLogSql(command.CommandText);
                DalLogUtility.WriteFatalLogSqlParameter(SqlParameters);
                DalLogUtility.WriteFatalLog("<===== 例外発生:{0}.ExecuteSPNonQuery() <=====", GetType().FullName);
                throw;
            }
            catch (Exception ex)
            {
                DalLogUtility.WriteFatalLog("=====> 例外発生:{0}.ExecuteSPNonQuery() =====>", GetType().FullName);
                DalLogUtility.WriteException(ex);
                DalLogUtility.WriteFatalLogDALRequest(RequestParameters);
                DalLogUtility.WriteFatalLog("<===== 例外発生:{0}.ExecuteSPNonQuery() <=====", GetType().FullName);
                throw;
            }
            finally
            {
                if (command != null) command.Dispose();
            }

            int endTime = Environment.TickCount;

            DalLogUtility.WriteDebugLog("----- DAL Response -----");
            DalLogUtility.WriteDebugLog("[{0}] row updated.", returnValue);
            DalLogUtility.WriteDebugLog("<===== {0}.ExecuteSPNonQuery() elaps:[{1}] <=====", GetType().FullName, endTime - startTime);

            return returnValue;
        }



        public Dictionary<string,object> ExecuteSPNonQueryEx()
        {
            DalLogUtility.WriteDebugLog("=====> {0}.ExecuteSPNonQuery() =====>", GetType().FullName);
            int startTime = Environment.TickCount;

            int returnValue;
            Dictionary<string,object > result = new Dictionary<string,object>();
            SqlCommand command = null;

            try
            {
                command = CreateSqlCommand();
                command.CommandType = CommandType.StoredProcedure;  // この部分のみExecuteNonQueryと異なる

                DalLogUtility.WriteDebugLogDALRequest(RequestParameters);
                DalLogUtility.WriteDebugLogSql(command.CommandText);
                DalLogUtility.WriteDebugLogSqlParameter(SqlParameters);
            
                returnValue = command.ExecuteNonQuery();

                foreach (SqlParameter parameter in command.Parameters)
                {
                    result.Add(parameter.ParameterName, parameter.Value);
                }
            }
            catch (SqlException ex)
            {
                DalLogUtility.WriteFatalLog("=====> 例外発生:{0}.ExecuteSPNonQuery() =====>", GetType().FullName);
                DalLogUtility.WriteException(ex);
                DalLogUtility.WriteFatalLogDALRequest(RequestParameters);
                DalLogUtility.WriteFatalLogSql(command.CommandText);
                DalLogUtility.WriteFatalLogSqlParameter(SqlParameters);
                DalLogUtility.WriteFatalLog("<===== 例外発生:{0}.ExecuteSPNonQuery() <=====", GetType().FullName);
                throw;
            }
            catch (Exception ex)
            {
                DalLogUtility.WriteFatalLog("=====> 例外発生:{0}.ExecuteSPNonQuery() =====>", GetType().FullName);
                DalLogUtility.WriteException(ex);
                DalLogUtility.WriteFatalLogDALRequest(RequestParameters);
                DalLogUtility.WriteFatalLog("<===== 例外発生:{0}.ExecuteSPNonQuery() <=====", GetType().FullName);
                throw;
            }
            finally
            {
                if (command != null) command.Dispose();
            }

            int endTime = Environment.TickCount;

            DalLogUtility.WriteDebugLog("----- DAL Response -----");
            DalLogUtility.WriteDebugLog("[{0}] row updated.", returnValue);
            DalLogUtility.WriteDebugLog("<===== {0}.ExecuteSPNonQuery() elaps:[{1}] <=====", GetType().FullName, endTime - startTime);

            return result;
        }
 
        #endregion
        #endregion

        /// <summary>
        /// SQLとパラメータを生成する。
        /// </summary>
        /// <returns>SQL文字列</returns>
        protected abstract string CreateSqlAndParameters();
    }
}
View Code
 
原文地址:https://www.cnblogs.com/haiy/p/4142862.html