| 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 | 
|     } | 
| } |