YL
2022-02-21 a905b3df0d0c9ae045b51d1299fbb2f2dcbc2e2d
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
202
203
204
205
206
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Http;
using WebAPI.Models;
 
namespace WebAPI.Controllers.仓存管理.条码出入库记录
{
    public class Kf_ICStockInOutBillController : ApiController
    {
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更)
 
        private json objJsonResult = new json();
        public DataSet ds = new DataSet();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
 
        //存储过程 数据 类
        public class Data
        {
            public Data()
            {
                HStartDate = DateTime.Now.AddMonths(-1);
                HEndDate = DateTime.Now;
                BillType = "全部";
            }
            public DateTime HStartDate;//开始日期
            public DateTime HEndDate;//结束日期
            public string MaterialName;//物料
            public string sWH;//仓库
            public string sSP;//仓位
            public string sBatchNo;//批号
            public string HBarCode;//条形码
            public string BillType;//单据类型
            public string BillNo;//单据号
            public string SeOrderBillNo;//(销售订单号)
        }
 
        #region 出入库记录查询
        [Route("Kf_ICStockInOutBill/StockInOutBillList")]
        [HttpGet]
        public object StockInOutBillList(string sWhere)
        {
            List<object> columnNameList = new List<object>();
            try
            {
                var data = JsonConvert.DeserializeObject<Data>(sWhere);
 
                ds = oCN.RunProcReturn("exec h_p_Kf_BarCodeOutInReport '" +
                    data.HStartDate + "','" + data.HEndDate + "','" + data.MaterialName + "','" + data.sWH + "','" + data.sSP + "','" + data.sBatchNo + "','" + data.HBarCode + "','" + data.BillType + "','" + data.BillNo + "','" + data.SeOrderBillNo
                    + "'", "h_p_Kf_BarCodeOutInReport");
 
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
 
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
 
                //if (ds.Tables[0].Rows.Count > 0)
                //{
                objJsonResult.code = "1";
                objJsonResult.count = ds.Tables[0].Rows.Count;
                objJsonResult.Message = "获取资源绑定数据成功!";
                objJsonResult.data = JsonConvert.DeserializeObject<DataTable>(JsonConvert.SerializeObject(ds.Tables[0], new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" }));  //序列化DataSet中的时间格式,然后再反序列化回来
                objJsonResult.list = columnNameList;
                return objJsonResult;
                //}
                //else
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "暂无资源绑定!";
                //    objJsonResult.data = null;
                //    objJsonResult.list = columnNameList;
                //    return objJsonResult;
                //}
 
            }
            catch (Exception e)
            {
 
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.Message.ToString();
                objJsonResult.data = null;
                objJsonResult.list = columnNameList;
            }
            return objJsonResult;
        }
        #endregion
 
        #region 条码出入库缓存
        #region 条码出入库缓存列表
        [Route("Kf_ICStockInOutBill/GetPonderationBillMain_Temp")]
        [HttpGet]
        public object GetPonderationBillMain_Temp(string sWhere,string user)
        {
            try
            {
                //编辑权限
                if (!DBUtility.ClsPub.Security_Log_second("Gy_BarCodeBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                DataSet ds = new DataSet();
                string sql1 = string.Format(@"select * from h_v_KF_PonderationBillMain_Temp2 where 1=1 ");
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds= oCN.RunProcReturn(sql1 + "order by HInterID desc", "h_v_KF_PonderationBillMain_Temp2");
                }
                else
                {
                    ds = oCN.RunProcReturn(sql1 + sWhere + "order by HInterID desc", "h_v_KF_PonderationBillMain_Temp2");
                }
                if (ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "查询数据异常,请与管理员联系!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
 
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.Message.ToString();
                objJsonResult.data = null;
            }
            return objJsonResult;
        }
        #endregion
 
        #region 条码出入库缓存删除
        [Route("Kf_ICStockInOutBill/DelectPonderationBillMain_TempByID")]
        [HttpGet]
        public object DelectPonderationBillMain_TempByID(string HInterID, string user)
        {
            //编辑权限
            if (!DBUtility.ClsPub.Security_Log_second("Gy_BarCodeBillList_Delete", 1, false, user))
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "无删除权限!";
                objJsonResult.data = null;
                return objJsonResult;
            }
 
            string s = "";
            Int64 lngBillKey = 0;
            lngBillKey = DBUtility.ClsPub.isLong(HInterID);
            if (lngBillKey == 0)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "单据ID为空!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            DataSet ds = new DataSet();
            DataSet ds1 = new DataSet();
            ds = oCN.RunProcReturn("select * from KF_PonderationBillMain_Temp where HInterID="+ HInterID, "KF_PonderationBillMain_Temp");
            if (ds.Tables[0].Rows.Count!=0)
            {
                oCN.BeginTran();
                oCN.RunProc("delete from KF_PonderationBillMain_Temp where HInterID=" + HInterID);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "删除成功";
                objJsonResult.data = null;
                oCN.Commit();
                return objJsonResult;
            }
            else
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "单据未找到";
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
 
    }
}