zzr99
2021-11-24 4b1b93845c6ff19b60740ebe3b27353b5902711f
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
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebAPI.Models;
 
namespace WebAPI.Controllers.SBGL
{
    public class Sb_EquipMaintainRuleBillController : ApiController
    {
        private json objJsonResult = new json();
        public DataSet ds = new DataSet();
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更)
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        public DLL.ClsSb_EquipMaintainRuleBill BillNew = new DLL.ClsSb_EquipMaintainRuleBill();   //对应单据类
        public DLL.ClsSb_EquipMaintainRuleBill BillOld = new DLL.ClsSb_EquipMaintainRuleBill();   //对应单据类
 
        #region 设备保养规程单列表
        [Route("Sb_EquipMaintainRuleBill/GetEquipMaintainRuleList")]
        [HttpGet]
        public object GetEquipMaintainRuleList(string sWhere)
        {
            try
            {
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Sb_EquipMaintainRuleList " + sWhere + " order by hmainid desc", "h_v_Sb_EquipMaintainRuleList");
                }
                else
                {
                    string sql1 = "select * from h_v_Sb_EquipMaintainRuleList where 1 = 1";
                    string sql = sql1 + sWhere + " order by hmainid desc";
                    ds = oCN.RunProcReturn(sql, "h_v_Sb_EquipMaintainRuleList");
                }
                if (ds == null || 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 ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
 
        #region 设备保养规程记录删除功能
        [Route("Sb_EquipMaintainRuleBill/DeleteEquipMaintainRuleBillList")]
        [HttpGet]
        public object DeleteEquipMaintainRuleBillList(string HInterID)
        {
            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;
            }
            DLL.ClsSb_EquipMaintainRuleBill oBill = new DLL.ClsSb_EquipMaintainRuleBill();
            if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
            {
                if (oBill.omodel.HBillStatus > 1)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据当前处于不能删除状态,不能删除!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (oBill.omodel.HChecker != "")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据已经审核,不能删除!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
 
                bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                if (IsDete)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            else
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "单据未找到";
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
 
        # region 设备保养规程记录点击主表时获取表体数据新(保养项列表、配件项列表)
        [Route("Sb_EquipMaintainRuleBill/Sb_EquipMaintainRuleBillListProjectDetaiNew")]
        [HttpGet]
        public object Sb_EquipMaintainRuleBillListProjectDetaiNew(string HInterID)
        {
 
            DataSet ds, ds1;
            List<object> list = new List<object>();
            string Swhere = "";
            try
            {
                if (HInterID != "" || HInterID != null)
                {
                    Swhere = " and hmainid='" + HInterID + "'";
                }
                else
                {
                    Swhere = HInterID;
                }
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                //获取保养项目编辑数据
                string sql = "select 保养项目ID,保养项目,保养部位,具体要求,负责人ID,负责人代码,负责人名称,子备注2 from h_v_Sb_EquipMaintainRuleList where 1 = 1 " + Swhere + "";
                ds = oCN.RunProcReturn(sql, "h_v_Sb_EquipMaintainRuleList");
                //获取配件项目编辑数据
                string sql1 = "select 配件ID,配件代码,配件名称,单位ID,计量单位代码,计量单位名称,用量,标准用量,子备注1 from h_v_Sb_EquipMaintainRuleList where 1 = 1 " + Swhere + "";
                ds1 = oCN.RunProcReturn(sql1, "h_v_Sb_EquipMaintainRuleList");
 
                list.Add(ds.Tables[0]);
                list.Add(ds1.Tables[0]);
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "获取信息成功!";
                objJsonResult.list = list;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
            }
            return objJsonResult;
        }
        #endregion
    }
}