schangxiang@126.com
2025-09-23 ea04aef49691444ed8ac1e7e7b94feabcbb5326f
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
using FineUIPro;
using iWareCommon.Common.Entity;
using iWareDataCore.BASE.Service;
using iWareDataCore.Check.Service;
using iWareExcel.EXCEL.Service;
using iWareWms.Code.Excel.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace iWareWms.View.CHECK.Plan
{
    public partial class Plan : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //设置时间
            dpBeginTime.SelectedDate = DateTime.Now.AddDays(-10);
            dpEndTime.SelectedDate = DateTime.Now.AddDays(20);
            Query(1);
        }
 
 
        /// <summary>
        /// 查询未完成盘点的计划,状态 “0”或“1”(0,未盘点,1,未核对,2,已核对)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSerch_Click(object sender, EventArgs e)
        {
            string msg;
            var plans = PlanService.GetInstance().QueryByParam(new QueryParam
            {
                //Geqd = new Dictionary<string, object> { { "BeginTime", dpBeginTime.SelectedDate }, { "EndTime", dpEndTime.SelectedDate } },
                Search = new Dictionary<string, object> { { "PlanNo", tbPlanNo.Text } },
                Lt = new Dictionary<string, object> { { "Status", 2 } }
            }, out msg);
 
            var res = new List<object>();
 
            plans.ForEach(x => res.Add(x));
            PlanGrid.DataSource = res;
            PlanGrid.DataBind();
 
        }
 
        /// <summary>
        /// 保存计划单,状态改为已经盘点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string planno = lbPlano.Text;
 
            int count = PlanViewService.GetInstance().UpdateByPlanNo(planno);
            if (count >= 0)
            {
                Alert.ShowInTop("计划单盘点已完成");
            }
            PlanPlaceMaterialGrid.DataSource = null;
            PlanPlaceMaterialGrid.DataBind();
            PlanGrid.DataSource = null;
            PlanGrid.DataBind();
        }
 
 
        /// <summary>
        /// 绑定查看物料
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void GridRowCommand(object sender, GridCommandEventArgs e)
        {
            btnSubmit.Enabled = true;
 
            
            var grid = PlanGrid;
 
            if (e.CommandName == "Confirm")
            {
                var pno = grid.Rows[e.RowIndex].DataKeys[1].ToString();
                string msg;
                var placematerials = PlanViewService.GetInstance().GetPlaceMaterialByPlanNo(pno, out msg);
 
                List<string> planno = new List<string>();
 
                placematerials.ForEach(x => planno.Add(x.PlanNo));
                lbPlano.Text = planno[0];
 
                PlanPlaceMaterialGrid.DataSource = placematerials;
                PlanPlaceMaterialGrid.DataBind();
                //Tab2.Title = grid.Rows[e.RowIndex].DataKeys[3].ToString() + "的库位明细";
            }
        }
 
 
        protected override void GetPath(object userName)
        {
            string msg;
 
            string planno = lbPlano.Text;
            
            var placematerial = PlanViewService.GetInstance().QueryByParam(new QueryParam 
                {
                    Filter = new Dictionary<string,object> { {"PlanNo",planno} }
                },out msg);
            var placematerials = new List<object>();
            placematerial.ForEach(x => placematerials.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>> { { "盘点库存明细", placematerials } }, out msg);
 
            Session["ExcelPath"] = path;
        }
 
        protected override Window GetWindow()
        {
            if (string.IsNullOrEmpty(lbPlano.Text))
            {
                return null;
            }
            return Window2;
        }
 
        protected override FineUIPro.Timer GetTimer()
        {
            return timer1;
        }
 
        
    }
}