2
schangxiang@126.com
2024-08-16 b47c50a2a514def7374b32d7194b2c599cba5625
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
using FineUIPro;
using iWareCommon.Common.Entity;
using iWareCommon.Common.EnumType;
using iWareDataCore.BASE.EnumType;
using iWareDataCore.BASE.Service;
using iWareDataCore.TASK.Service;
using iWareExcel.EXCEL.Service;
using iWareWms;
using iWareWms.Code.Excel.Service;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
 
namespace iWareWms.View.SL.PlaceMaterial
{
    public partial class PlaceMaterial :PageBase
    {
        protected override Grid GetGrid()
        {
            return PlaceGrid;
        }
 
        protected override DropDownList GetPageSizeDropDownList()
        {
            return ddlPageSize;
        }
 
        protected override List<object> GetDataSource(int pageIndex, int pageSize, out string msg, out int totalNum, out int currentPage)
        {
            var places = PlaceMaterialViewService.GetInstance().QueryByParam(new QueryParam
            {
                Search = new Dictionary<string, object> { { "Name", tbName.Text.Trim() }, { "MaterialCode", tbMaterialCode.Text.Trim() }, 
                                                        { "PlaceCode", tbPlaceCode.Text.Trim() } },
                PageIndex = pageIndex,
                PageSize = pageSize
            }, out msg, out totalNum, out currentPage);
 
            var res = new List<object>();
            places.ForEach(x => res.Add(x));
            return res;
        }
 
        /// <summary>
        /// 状态前台显示
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        protected string GetEYesOrNo(object type)
        {
            return ((EYesOrNo)Convert.ToInt32(type)).ToString();
        }
 
        protected string GetYesOrNo(object type)
        {
            return ((EYesOrNo)Convert.ToInt32(type)).ToString();
        }
 
        protected string GetStatus(object type)
        {
            return ((EPlaceStatus)Convert.ToInt32(type)).ToString();
        }
 
 
        //批量撤销
        protected override void Delete(List<int> ids, out string msg)
        {
 
            PlaceMaterialService.GetInstance().DeletePlaveMateial(ids, out msg);
            WriteLog("库位物料清除" + msg, "库存管理");
        }
 
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
 
                //ddlTypeName.Items.Add("全部", "");
                //foreach (var type in Enum.GetValues(typeof(EMaterialType)))
                //{
                //    ddlTypeName.Items.Add(type.ToString(), ((int)type).ToString());
                //}
 
 
                //var placeMaterials = PlaceMaterialViewService.GetInstance().QueryByParam(new QueryParam(), out msg);
                //ddlPlaceTypeName.Items.Add("全部", "");
                //placeMaterials.ForEach(x => ddlPlaceTypeName.Items.Add(x.PlaceTypeName, x.Id.ToString()));
                string name = GetIdentityName();
                if (name=="admin")
                {
                    btnClar.Hidden = false;
                }else
                {
                    btnClar.Hidden = true;
                }
                Query(1);
            }
        }
 
     
 
        protected override Window GetWindow()
        {
            return Window1;
        }
 
        protected override void GetPath(object userName)
        {
            string msg;
 
            var places = PlaceMaterialViewService.GetInstance().QueryByParam(new QueryParam
            {
                Search = new Dictionary<string, object> { { "Name", tbName.Text.Trim() }, { "MaterialCode", tbMaterialCode.Text.Trim() }, 
                                                        { "PlaceCode", tbPlaceCode.Text.Trim() } },
                //Filter = new Dictionary<string, object> { { "TypeName", ddlTypeName.SelectedValue }, 
                //{ "PlaceTypeName", ddlPlaceTypeName.SelectedValue } },
            }, out msg);
 
            var datas = new List<object>();
            places.ForEach(x => datas.Add(x));
 
 
            var workBooks = WorkBookService.GetInstance().QueryByParam(new QueryParam { Filter = new Dictionary<string, object> { { "Name", "库存管理" } } }, out msg);
 
            var path = ExcelService.GetInstance().ToExcelByEPPlus(workBooks[0], new Dictionary<string, List<object>> { { "库位物料信息", datas } }, out msg);
 
            Session["ExcelPath"] = path;
        }
 
        protected override FineUIPro.Timer GetTimer()
        {
            return timer1;
        }
 
        protected void btnOut_Click(object sender, EventArgs e)
        {
            string msg;
            List<int> ids = GetSelectedDataKeyIDs(PlaceGrid);
            if (ids.Count > 0)
            {
               int count=MainTaskService.GetInstance().SaveOutMainTask(ids, out msg);
               if (count>0)
                {
                    msg = "出库任务生成成功";
                }
               else if (count == 0)
               {
                   msg = "出库任务已在任务队列中";
               }
               else 
               {
                   msg = "出库任务生成失败!";
               }
            
            }
            else 
            {
                msg = "请选择要出库的物料";
            }
            Alert.Show(msg);
            WriteLog("库位物料出库" + msg, "库存管理");
        }
        
    }
}