username@email.com
2025-05-15 6fe02a16e55f17e45a3997171e1b2284d45af25b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.BLL;
using CY.Model;
using CY.Infrastructure.Query;
using CY.Infrastructure.Common;
using CY.BLL.Sys;
using CY.BLL.OA;
namespace CY.WebForm.Pages.financial
{
    public partial class SubjectSetEdit : BasePage
    {
        Sys_DictionaryBLL _Sys_DictionaryBLL = null; //字典类业务逻辑操作对象
        OA_SubjectSetBLL _OA_SubjectSetBLL = null; // 科目类业务逻辑操作对象
        OA_SubjectSet subjectSet = null;       // 科目类对象
 
        public SubjectSetEdit()
        {
            _Sys_DictionaryBLL = new Sys_DictionaryBLL();
            _OA_SubjectSetBLL = new OA_SubjectSetBLL();
            subjectSet = new OA_SubjectSet();
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitialData();
                if (Request["Keyid"].ToInt32() > 0)  // 加载要修改的的数据
                {
                    InitialModifyData();
                }
            }
        }
 
        /// <summary>
        /// 初始化科目类别
        /// </summary>
        public void InitialData()
        {
            this.selGoodsStatus.DataSource = _Sys_DictionaryBLL.GetDataByType("科目类别");
            this.selGoodsStatus.DataBind();
        }
 
        /// <summary>
        /// 初始化要修改的数据
        /// </summary>
        public void InitialModifyData()
        {
            subjectSet = _OA_SubjectSetBLL.getSingleSubject(Request["Keyid"].ToInt32());
            if (subjectSet == null || subjectSet.FirmId != CurrentUser.MemberId)
            {
                JavaScript.MessageBox("数据错误", this, true, true);
                return;
            }
            this.selGoodsStatus.Value = subjectSet.SubjectType.ToString2();
            this.txtRemark.Value = subjectSet.Remark.ToString2();
            this.txtSubjectName.Value = subjectSet.SubjectName.ToString2();
            this.selStatus.Value = subjectSet.Status.ToString2();
        }
 
        /// <summary>
        /// 添加或修改科目
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Submit_Config(object sender, EventArgs e)
        {
            if (Request["Keyid"].ToInt32() > 0)    //如果keyid 大于0 则再加载一次对象,方便利用对象里面的不变属性
            {
                subjectSet = _OA_SubjectSetBLL.getSingleSubject(Request["Keyid"].ToInt32());
                if (subjectSet == null || subjectSet.FirmId != CurrentUser.MemberId)
                {
                    JavaScript.MessageBox("数据错误", this, true, true);
                    return;
                }
            }
 
            if (_OA_SubjectSetBLL.CheckTypeAndName(Request["Keyid"].ToInt32(), this.selGoodsStatus.Value.ToString2(), this.txtSubjectName.Value.ToString2(), CurrentUser.MemberId))
            {
                JavaScript.MessageBox("所选科目类别下面已存在此科目,请勿重复", this, " window.location = location;");
                return;
            }
 
 
            subjectSet.LastUpdateTime = System.DateTime.Now;
            subjectSet.Remark = this.txtRemark.Value.ToString2();
            subjectSet.SubjectType = this.selGoodsStatus.Value.ToString2();
            subjectSet.SubjectName = this.txtSubjectName.Value.ToString2();
            subjectSet.Operator = CurrentUser.ShortName;
            subjectSet.Status = Convert.ToBoolean(this.selStatus.Value);
 
            if (Request["Keyid"].ToInt32() > 0)
            {
                if (_OA_SubjectSetBLL.UpdateModel(subjectSet))
                    JavaScript.MessageBox("更新成功", this, true, true);
                else
                    JavaScript.MessageBox("更新失败", this);
            }
            else
            {
                subjectSet.FirmId = CurrentUser.MemberId;
                if (_OA_SubjectSetBLL.InserModel(subjectSet))
                    JavaScript.MessageBox("添加成功", this, true, true);
                else
                    JavaScript.MessageBox("添加失败", this);
            }
        }
    }
}