0

あなたの助けが必要です。

私はこの方法を持っています:

protected void btnDocumentType_Click(object sender, EventArgs e)
        {

            DocumentApplicationCategoryManager DACM = new DocumentApplicationCategoryManager();
            IkubInfo.NE.Domain.DocumentApplicationCategory DAC = new Domain.DocumentApplicationCategory();

            DAC.DocumentType = new DocumentTypeManager().GetById(new Guid(cboDocumentType.SelectedValue));
            DAC.ApplicationCategory = Entity;

            Entity.DocumentApplicationCategory.Add(DAC);

            DACM.Save(DAC);
            DACM.Session.CommitChanges();
            SetUIValues();
        }

これは、ユーザーがグリッドに値を追加できるようにする [ADD] ボタンのメソッドです。ユーザーが追加しようとしている値が 1 回保存されると、2 回保存できないことを確認する必要があります。検証してユーザーにエラー メッセージを表示する必要がありますが、その方法がわかりません。この行の前に「if」条件を付ける必要があると思います。

DAC.DocumentType = new DocumentTypeManager().GetById(new Guid(cboDocumentType.SelectedValue));

何か案が ?あなたの助けをいただければ幸いです。前もって感謝します :)

4

2 に答える 2

0

あなたがする必要があるのは、挿入された値が存在するかどうか、コンボボックス内のすべての値をチェックすることです。そのためには、タイプ HasNext または IsNull の条件でループを作成する必要があり、ループ内で ID の値を比較する If ステートメントを使用します (コードから理解したものから)。

于 2013-07-01T14:18:07.777 に答える
0
protected void btnDocumentType_Click(object sender, EventArgs e)
        {

            DocumentApplicationCategoryManager DACM = new DocumentApplicationCategoryManager();
            IkubInfo.NE.Domain.DocumentApplicationCategory DAC = new Domain.DocumentApplicationCategory();

            DAC.DocumentType = new DocumentTypeManager().GetById(new Guid(cboDocumentType.SelectedValue));
            DAC.ApplicationCategory = Entity;

//Check here from DocumentApplicationCategory, Whether DAC.DocumentType and Entity Exists or not, if does not exists then allow to come in 
        if(CHECK_HERE)
        {
                Entity.DocumentApplicationCategory.Add(DAC);

                DACM.Save(DAC);
                DACM.Session.CommitChanges();
        }
            SetUIValues();
        }

コメントを参照してください: CHECK_HERE の場所に、挿入しようとしているデータが既に存在するかどうかを確認する条件を入力します。

于 2013-07-01T14:22:43.807 に答える