username@email.com
2 天以前 e4ee60ed94d24e394a7895daa9fb98df813e5953
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using CY.Model;
using CY.BLL;
using CY.Infrastructure.Common;
using CY.BLL.Sys;
using CY.BLL.EC;
using CY.Infrastructure.DESEncrypt;
using CY.Infrastructure.Query;
 
namespace CY.WebForm.Pages.work
{
    //吴辉
    //行政物品
    public partial class GongzuoneirongEdit : BasePage
    {
        OA_GongzuoneirongBLL bll_OA_GongzuoneirongBLL = null;
        OA_StaffBLL bll_OA_StaffBLL = null;
        OA_DepartmentBll bll_OA_DepartmentBll = null;
 
        public GongzuoneirongEdit()
        {
            bll_OA_GongzuoneirongBLL = new OA_GongzuoneirongBLL();
            bll_OA_StaffBLL = new OA_StaffBLL();
            bll_OA_DepartmentBll = new OA_DepartmentBll();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
 
            try
            {
                switch (Request["Target"])
                {
 
                    case "change":
                        Response.Write(reLoadAccountName(Request["TypeName"].ToString2()));
                        break;
 
 
                    default:
                        if (!IsPostBack)
                        {
 
                            this.selCateId.DataSource = bll_OA_GongzuoneirongBLL.GetDataByType(CurrentUser.MemberId);
                            this.selCateId.DataTextField = "Name";
                            this.selCateId.DataValueField = "Keyid";
                            this.selCateId.DataBind();
                            this.selCateId.Items.Insert(0, new ListItem("请选择", ""));
                            this.selCateId.Value = "";
 
                            this.selZerenren.DataSource = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, null, null);
                            this.selZerenren.DataTextField = "Name";
                            this.selZerenren.DataValueField = "Keyid";
                            this.selZerenren.DataBind();
                            //this.selZerenren.Items.Insert(0, new ListItem("全部", ""));
                            //this.selZerenren.Value = "";
 
                            Pagination pa = new Pagination();
                            pa.PageSize = 500;
                            pa.PageIndex = 1;
                            this.selBumen.DataSource = bll_OA_DepartmentBll.SelectModelPage(pa, CurrentUser.MemberId, "", "启用");
                            this.selBumen.DataTextField = "Name";
                            this.selBumen.DataValueField = "Keyid";
                            this.selBumen.DataBind();
                            this.selBumen.Items.Insert(0, new ListItem("全部", ""));
                            this.selBumen.Value = "";
 
                            InitData();
                        }
                        return;
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                Response.Clear();
                //Response.Write("-1");
                Response.Write(ex.Message);
            }
            Response.End();
 
 
           
        }
 
        //数据加载
        public void InitData()
        {
            OA_Gongzuoneirong m_OA_Gongzuoneirong = bll_OA_GongzuoneirongBLL.GetModelByKeyid(Request["keyid"].ToInt32());
            if (m_OA_Gongzuoneirong != null)
            {
                
                this.txtCarNumbera.Value = m_OA_Gongzuoneirong.Gongzuozhize;
                
                this.selZerenren.Value = m_OA_Gongzuoneirong.Zerenren.HasValue? m_OA_Gongzuoneirong.Zerenren.ToString():"";
            }
            
        }
 
        //表单提交
        protected void btn_submit_form(object sender, EventArgs e)
        {
            try
            {
                //if (string.IsNullOrEmpty(this.txtAllNum.Value) || string.IsNullOrEmpty(this.txtReceiveNum.Value))
                //{
                //    JavaScript.MessageBox("物品总数量和已领取数量均不能为空", this);
                //    return;
                //}
 
                //if (this.txtAllNum.Value.ToInt32() < this.txtReceiveNum.Value.ToInt32())
                //{
                //    JavaScript.MessageBox("已领取数量不能大于总数量",this);
                //    return;
                //}
 
                DateTime nowTime = DateTime.Now;
                OA_Gongzuoneirong m_OA_Gongzuoneirong = bll_OA_GongzuoneirongBLL.GetModelByKeyid(Request["keyid"].ToInt32());
                if (m_OA_Gongzuoneirong == null)
                {
                    m_OA_Gongzuoneirong = new OA_Gongzuoneirong();
                    m_OA_Gongzuoneirong.MemberId = CurrentUser.MemberId;
                  
                  
                }
               
                m_OA_Gongzuoneirong.Gongzuozhize = this.txtCarNumbera.Value;
               
 
                m_OA_Gongzuoneirong.Zerenren = this.selZerenren.Value.ToInt32();
                var a_Staff = bll_OA_StaffBLL.GetModelByKeyid(m_OA_Gongzuoneirong.Zerenren);
                if (a_Staff != null)
                {
                    m_OA_Gongzuoneirong.ZerenrenName = a_Staff.Name;
                }
                else
                {
                    m_OA_Gongzuoneirong.ZerenrenName = "";
                }
               
                m_OA_Gongzuoneirong.Updator = CurrentUser.ShortName;
                m_OA_Gongzuoneirong.LastUpdateTime = nowTime;
               
 
                if (Request["keyid"].ToInt32() > 0)
                {
                    if (bll_OA_GongzuoneirongBLL.UpdateModel(m_OA_Gongzuoneirong))
                    {
                        JavaScript.MessageBox("更新成功", this, true, true);
                    }
                       
                    else
                        JavaScript.MessageBox("更新失败", this);
                }
                else
                {
                    m_OA_Gongzuoneirong.Creator = CurrentUser.ShortName;
                    m_OA_Gongzuoneirong.CreateTime = nowTime;
                    if (bll_OA_GongzuoneirongBLL.InsertModel(m_OA_Gongzuoneirong))
                    {
                        this.txtCarNumbera.Value="";
                        this.selCateId.Value = "";
                        JavaScript.MessageBox("新增成功", this, false, true);
                    }
                       
                    else
                        JavaScript.MessageBox("操作失败", this);
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("操作失败", this);
            }
        }
 
 
        protected string reLoadAccountName(string selAcoountType)
        {
            
            if (!string.IsNullOrEmpty(selAcoountType))
            {
                return JsonHelper.GetJsonStringByObject(bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId,false,false).Where(x =>  x.DepartmentId == selAcoountType.ToInt32()));
            }
            else
            {
                return JsonHelper.GetJsonStringByObject(bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, false, false));
            }
 
 
        }
    }
}