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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.Model;
using CY.BLL.OA;
using CY.Infrastructure.Common;
using CY.Infrastructure.Query;
using CY.BLL.Sys;
using System.Data;
 
namespace CY.WebForm.Pages.financial
{
    //吴辉
    //采购付款
    public partial class PurchasePayments : BasePage
    {
        Sys_DictionaryBLL _Sys_DictionaryBLL = null;
        OA_SuppliersBLL _OA_SuppliersBLL = null;
        OA_CommodityBLL _OA_CommodityBLL = null;
        OA_GoodsInfoBLL _OA_GoodsInfoBLL = null;
        OA_ProcurementBLL _OA_ProcurementBLL = null;
        OA_Procurement Procuremet = null;
 
        //初始化
        public PurchasePayments()
        {
            Procuremet = new OA_Procurement();
            _OA_CommodityBLL = new OA_CommodityBLL();
            _Sys_DictionaryBLL = new Sys_DictionaryBLL();
            _OA_SuppliersBLL = new OA_SuppliersBLL();
            _OA_GoodsInfoBLL = new OA_GoodsInfoBLL();
            _OA_ProcurementBLL = new OA_ProcurementBLL();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
 
            UCPager1.AspNetPager.PageChanged += AspNetPager1_PageChanged;
            if (!IsPostBack)
            {
            }
 
            if (!IsPostBack)
            {
 
                if (Request["Keyid"].ToInt32() > 0) //如果keyid>0 则删除对应对象
                {
                    Procuremet = _OA_ProcurementBLL.SelectSingleModel(Request["Keyid"].ToString2());
                    if (_OA_ProcurementBLL.DeleteModel(Procuremet))
                    {
                        JavaScript.MessageBox("删除成功", this);
                        BindList();
                    }
                    else
                    {
                        JavaScript.MessageBox("删除失败", this);
                        BindList();
                    }
                }
                else
                {
 
                    BindList();
                    InitialData();
                }
            }
 
        }
 
        //加载收入list数据
        protected void BindList()
        {
            DateTime? beginTime = null;
            DateTime? endTime = null;
            Pagination pa = new Pagination();
            pa.PageIndex = UCPager1.AspNetPager.CurrentPageIndex;
            pa.PageSize = UCPager1.AspNetPager.PageSize;
            ReProcurentList.DataSource = _OA_ProcurementBLL.getModelList(pa, CurrentUser.MemberId, "", this.selPurchaseStatus.Value, this.selClearingStatus.Value, this.selSuppliers.Value, this.selGoodsName.Value, this.dwCommity.SelectedValue, string.IsNullOrEmpty(this.txtRegTimeStart.Value) ? beginTime : Convert.ToDateTime(this.txtRegTimeStart.Value), string.IsNullOrEmpty(this.txtRegTimeEnd.Value) ? endTime : MyConvert.GetDateTime(this.txtRegTimeEnd.Value), this.txtBrandName.Value, this.txtPaperWeight.Value);
            ReProcurentList.DataBind();
            UCPager1.AspNetPager.RecordCount = pa.RecordCount;
 
            OA_Procurement m_OA_Procurement = _OA_ProcurementBLL.SumMoney(pa, CurrentUser.MemberId, "", this.selPurchaseStatus.Value, this.selClearingStatus.Value, this.selSuppliers.Value, this.selGoodsName.Value, this.dwCommity.SelectedValue, string.IsNullOrEmpty(this.txtRegTimeStart.Value) ? beginTime : Convert.ToDateTime(this.txtRegTimeStart.Value), string.IsNullOrEmpty(this.txtRegTimeEnd.Value) ? endTime : MyConvert.GetDateTime(this.txtRegTimeEnd.Value), this.txtBrandName.Value, this.txtPaperWeight.Value);
            if (m_OA_Procurement != null && m_OA_Procurement.AllMoney > 0)
            {
                this.AllMoney.InnerHtml = m_OA_Procurement.AllMoney.Value.ToString("0.00");
                this.PayMoney.InnerHtml = m_OA_Procurement.ReceiveMoney.Value.ToString("0.00");
                this.OweMoney.InnerHtml = (m_OA_Procurement.AllMoney - m_OA_Procurement.ReceiveMoney).Value.ToString("0.00");
            }
        }
 
        //加载查询条件
        protected void InitialData()
        {
            //采购状态
            this.selPurchaseStatus.DataSource = _Sys_DictionaryBLL.GetDataByType("采购状态");
            this.selPurchaseStatus.DataBind();
            this.selPurchaseStatus.Items.Insert(0, new ListItem("全部", ""));
 
            //结账状态
            this.selClearingStatus.DataSource = _Sys_DictionaryBLL.GetDataByType("结账状态");
            this.selClearingStatus.DataBind();
            this.selClearingStatus.Items.Insert(0, new ListItem("全部", ""));
 
            //供应商
            this.selSuppliers.DataSource = _OA_SuppliersBLL.getSupplierTable(CurrentUser.MemberId);
            this.selSuppliers.DataBind();
            this.selSuppliers.Items.Insert(0, new ListItem("全部", ""));
            
            //货品名称
            this.selGoodsName.DataSource = _OA_GoodsInfoBLL.SelectTableList(CurrentUser.MemberId);
            this.selGoodsName.DataBind();
            this.selGoodsName.Items.Insert(0, new ListItem("全部", ""));
            
            //产品类别
            DataTable ds = _OA_CommodityBLL.SelectModelPage(CurrentUser.MemberId, "", "true");
            GetDataByLevel(this.dwCommity, ds, 0, 0);
            this.dwCommity.Items.Insert(0, new ListItem("全部", ""));
        }
 
        //产品类别
        public static void GetDataByLevel(System.Web.UI.WebControls.DropDownList dwCommity, DataTable data, int parentId, int level)
        {
 
            if (data == null || data.Rows.Count == 0)
                return;
            DataRow[] result = data.Select(string.Format("ParentId={0}", parentId));
            int i = -1;
            while (++i < result.Length)
            {
                dwCommity.Items.Add(new ListItem(GetSplitChar(level) + result[i]["CommodityName"].ToString2(), result[i]["Keyid"].ToString2()));
                GetDataByLevel(dwCommity, data, result[i]["Keyid"].ToInt32().Value, level + 1);
 
            }
        }
 
        //隔位符
        public static string GetSplitChar(int level)
        {
            string splitchar = "";
            int i = -1;
            while (++i < level)
            {
                splitchar += ".";
            }
            return splitchar;
        }
 
        //分页事件
        protected void AspNetPager1_PageChanged(object src, EventArgs e)
        {
            BindList();
        }
 
        //查询事件
        protected void btn_Register_Click(object sender, EventArgs e)
        {
            BindList();
        }
    }
}